Crystal 10
Microsoft SQL 2000 database
Here is my SQL Query
I will remove the "PATIENT"."PAT_ID" LIKE '21003360' from the WHERE clause after my initial testing.
Here is sample output from the above:
Here is what I would like to see:
Is there a way that I can filter the "PAT_ENC_CURR_MEDS"."CURRENT_MED_ID" to show only the most recent date for each ORDER_MED_ID?
I know that I can create groups in Crystal and use formulas to get to the most recent information for each line, but would prefer to have SQL do as much as possible.
I have little experience with SQL, so I do appreciate your assistance.
Steve
Microsoft SQL 2000 database
Here is my SQL Query
Code:
SELECT "PATIENT"."PAT_ID" as "PATIENT_PAT_ID", "AH_ASTHMA_PTS"."PAT_ID" as "AH_ASTHMA_PAT_ID", "PATIENT"."EPI_ID_TYPE_0", "PATIENT"."PAT_NAME", "PAT_ENC_CURR_MEDS"."LINE", "PAT_ENC_CURR_MEDS"."PAT_ENC_CSN_ID", "PAT_ENC_CURR_MEDS"."CONTACT_DATE", "PAT_ENC_CURR_MEDS"."IS_ACTIVE_YN", "RX_MED_TWO"."MEDICATION_NAME", "RX_MED_TWO"."MEDICATION_ID", "ORDER_MED"."START_DATE", "ORDER_MED"."END_DATE", "ORDER_MED"."ORDERING_DATE", "ORDER_MED"."ORDER_MED_ID", "PAT_ENC_CURR_MEDS"."CURRENT_MED_ID"
FROM ((("Clarity"."dbo"."AH_ASTHMA_PTS" "AH_ASTHMA_PTS" LEFT OUTER JOIN "Clarity"."dbo"."PATIENT" "PATIENT" ON "AH_ASTHMA_PTS"."PAT_ID"="PATIENT"."PAT_ID") LEFT OUTER JOIN "Clarity"."dbo"."PAT_ENC_CURR_MEDS" "PAT_ENC_CURR_MEDS" ON "PATIENT"."PAT_ID"="PAT_ENC_CURR_MEDS"."PAT_ID") LEFT OUTER JOIN "Clarity"."dbo"."RX_MED_TWO" "RX_MED_TWO" ON "PAT_ENC_CURR_MEDS"."MEDICATION_ID"="RX_MED_TWO"."MEDICATION_ID") LEFT OUTER JOIN "Clarity"."dbo"."ORDER_MED" "ORDER_MED" ON "PAT_ENC_CURR_MEDS"."CURRENT_MED_ID"="ORDER_MED"."ORDER_MED_ID"
WHERE "PATIENT"."PAT_ID" LIKE '21003360' AND "PAT_ENC_CURR_MEDS"."CONTACT_DATE" <= {?Contact_Date}
ORDER BY "AH_ASTHMA_PAT_ID","PAT_ENC_CURR_MEDS"."CURRENT_MED_ID", "PAT_ENC_CURR_MEDS"."CONTACT_DATE"
I will remove the "PATIENT"."PAT_ID" LIKE '21003360' from the WHERE clause after my initial testing.
Here is sample output from the above:
Code:
PAT_ID ORDER_MED_ID CONTACT_DATE IS_ACTIVE_YN
1231 99213 6/1/2004 Y
1231 99213 8/1/2004 N
1231 99213 1/15/2005 Y
1231 99902 6/15/2004 Y
1231 99902 6/30/2004 N
Here is what I would like to see:
Code:
PAT_ID ORDER_MED_ID CONTACT_DATE IS_ACTIVE_YN
1231 99213 1/15/2005 Y
1231 99902 6/30/2004 N
Is there a way that I can filter the "PAT_ENC_CURR_MEDS"."CURRENT_MED_ID" to show only the most recent date for each ORDER_MED_ID?
I know that I can create groups in Crystal and use formulas to get to the most recent information for each line, but would prefer to have SQL do as much as possible.
I have little experience with SQL, so I do appreciate your assistance.
Steve