In a subquery I only want the line 1 from a list of null, 1,2 and 3, but I keep getting line 1 and null. How can I get only line 1? - (select HOSPICE_DX.PAT_ENC_CSN_ID
-
, edg.DX_NAME
-
, HOSPICE_DX.LINE
-
from HOSPICE_DX
-
inner join EDG on HOSPICE_DX.HOSPICE_DX_CODED_ID=edg.DX_ID
-
-
) hospice on PAT_ENC.PAT_ENC_CSN_ID=hospice.PAT_ENC_CSN_ID and hospice.LINE=1
thanks!
3 1562 Rabbit 12,516
Recognized Expert Moderator MVP
We need to see the rest of the SQL.
- select PATIENT.PAT_MRN_ID as MRN
-
, PATIENT.PAT_NAME as Patient
-
, convert(date,HH_EPSD_EVNT_DATES.DATE_OF_EVENT,101) as SOC
-
, CASE when ZC_ACCT_CLASS_HA.NAME='Home Health' then diagnosis.DX_NAME else hospice.DX_NAME end as 'PRIMARY DX'
-
, ZC_TEAM_ASSIGNMENT.NAME as TEAM
-
, ZC_ACCT_CLASS_HA.NAME AS PROGRAM
-
, hospice.LINE
-
-
-
-
from HSP_ACCOUNT
-
inner join ZC_ACCT_CLASS_HA on HSP_ACCOUNT.ACCT_CLASS_HA_C=ZC_ACCT_CLASS_HA.ACCT_CLASS_HA_C
-
inner join HSP_ACCOUNT_3 on HSP_ACCOUNT.HSP_ACCOUNT_ID=HSP_ACCOUNT_3.HSP_ACCOUNT_ID
-
inner join HSP_TRANSACTIONS on HSP_ACCOUNT.HSP_ACCOUNT_ID=HSP_TRANSACTIONS.HSP_ACCOUNT_ID
-
inner join PATIENT on HSP_ACCOUNT.PAT_ID=PATIENT.PAT_ID
-
inner join PAT_ENC on HSP_ACCOUNT.HSP_ACCOUNT_ID=PAT_ENC.HSP_ACCOUNT_ID
-
inner join EPISODE on HSP_ACCOUNT_3.HH_HSB_ID=EPISODE.EPISODE_ID
-
inner join HH_EPSD_INFO on EPISODE.EPISODE_ID=HH_EPSD_INFO.SUMMARY_BLOCK_ID
-
left join ZC_TEAM_ASSIGNMENT on HH_EPSD_INFO.TEAM_ASSIGNMENT_C=ZC_TEAM_ASSIGNMENT.TEAM_ASSIGNMENT_C
-
inner join HH_EPSD_EVNT_DATES on HH_EPSD_INFO.SUMMARY_BLOCK_ID=HH_EPSD_EVNT_DATES.SUMMARY_BLOCK_ID
-
inner join ZC_DATE_EVENT on HH_EPSD_EVNT_DATES.DATE_EVENT_C=ZC_DATE_EVENT.DATE_EVENT_C
-
inner join HH_EPSD_EVNT_DATES as ed on HH_EPSD_INFO.SUMMARY_BLOCK_ID=ed.SUMMARY_BLOCK_ID
-
inner join ZC_MC_PAT_STATUS on HH_EPSD_INFO.HC_DC_DISPOSITION_C=ZC_MC_PAT_STATUS.PAT_STATUS_C
-
inner join CLARITY_DEP on HSP_TRANSACTIONS.DEPARTMENT=CLARITY_DEP.DEPARTMENT_ID
-
left join (select HH_PAT_ENC.PAT_ID
-
, ROW_NUMBER() over(partition by hh_pat_enc.pat_id order by hh_pat_enc.prim_dx_start_date desc)enc_rank
-
, CLARITY_EDG.DX_NAME
-
from HH_PAT_ENC
-
inner join CLARITY_EDG on HH_PAT_ENC.PRIMARY_DX_ID=CLARITY_EDG.DX_ID
-
) diagnosis on PATIENT.PAT_ID=diagnosis.PAT_ID and diagnosis.enc_rank='1'
-
left join (select HOSPICE_DX.PAT_ENC_CSN_ID
-
, HOSPICE_DX.CONTACT_DATE
-
, edg.DX_NAME
-
, HOSPICE_DX.LINE
-
from HOSPICE_DX
-
inner join CLARITY_EDG as edg on HOSPICE_DX.HOSPICE_DX_CODED_ID=edg.DX_ID
-
-
) hospice on PAT_ENC.PAT_ENC_CSN_ID=hospice.PAT_ENC_CSN_ID and hospice.LINE=1
-
-
-
where ZC_DATE_EVENT.NAME in ('Start of Care Date (M0030,CMS 485.2)', 'Hospice Admission')
-
and ZC_MC_PAT_STATUS.NAME <> 'Left Against Medical Advice or Discontinued Care'
-
and EPISODE.STATUS_C<>'3'
-
-
-
-
-
-
group by EPISODE.EPISODE_ID
-
, PATIENT.PAT_MRN_ID
-
, PATIENT.PAT_NAME
-
, HH_EPSD_EVNT_DATES.DATE_OF_EVENT
-
, ZC_TEAM_ASSIGNMENT.NAME
-
, ZC_ACCT_CLASS_HA.NAME
-
, hospice.DX_NAME
-
, hospice.LINE
-
, diagnosis.DX_NAME
-
-
-
order by 1
Rabbit 12,516
Recognized Expert Moderator MVP
It's because you did a left join. A left join returns any rows in the left table that match the right table in addition to any rows in the left table that don't match any rows in the right table.
Sign in to post your reply or Sign up for a free account.
Similar topics
by: Vernon |
last post by:
Hi anyone,
This is my code.
int num
num = 0;
for(int a=0; a<count; ++a){
if(current->transID==aNo)
++num;
current = current->next;
|
by: Chefry |
last post by:
I'm trying to set up an off the shelf script and keep getting an error.
My host set up the mysql on my site and I changed the variables I had to in the
settings.php file but I keep getting the...
|
by: iainw |
last post by:
HI All,
1st post here, i wonder if you can help. We are about to upload CMS t
a windows server and keep getting 2 errors below. We need to go LIVE an
it's delaying us.
An error occured when...
|
by: George W. |
last post by:
Okay, I'm a C#/XML newbie, and I've been wrestling with this for a while
now, checked dotnet sites, articles, MSDN Library, etc. and haven't been
able to determine why this is happening.
I have...
|
by: nfr |
last post by:
I keep getting the following warning in my compile:
Warning: The dependency 'WBWebServices, Version=1.0.1289.13943,
Culture=neutral' in project 'WBWin' cannot be copied to the run directory...
|
by: partybob99 |
last post by:
I am trying to call SP_Password from some vb.net code. This should be
very straight forward but no matter what I do, I keep getting errors.
Here is the code
strConnectString = "Data Source=" +...
|
by: lawrence k |
last post by:
I've installed Apache 1.3.36 on my Redhat EL 3 machine. Now I'm trying
to install PHP 5.1.4. I can not get the ./configure command to work. I
keep getting this error:
configure: error: Invalid...
|
by: sangram |
last post by:
how to delete last node of a Linked list if you only know the address
of last node.
thanks
sangram
|
by: Daniel |
last post by:
is there some per-process-limit on memory in .net processes? is there any
way to increase it? i keep getting System.OutOfMemoryException when my box
has 8 gigs of unused memory.
|
by: Hystou |
last post by:
There are some requirements for setting up RAID:
1. The motherboard and BIOS support RAID configuration.
2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
|
by: marktang |
last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
|
by: tracyyun |
last post by:
Dear forum friends,
With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
|
by: agi2029 |
last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...
|
by: isladogs |
last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM).
In this session, we are pleased to welcome a new...
|
by: conductexam |
last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and...
|
by: adsilva |
last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
|
by: 6302768590 |
last post by:
Hai team
i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated ...
|
by: muto222 |
last post by:
How can i add a mobile payment intergratation into php mysql website.
| | |