Report about certain medical conditions (adjustable)
The report generates an Excel file with the information about certain medical conditions in MER for the described time frame. It can be adjusted accordingly. The 1st sheet is specific extract, the 2nd sheet is raw data for all medical conditions.
Here is an example with fictitious data:
Here is the query:
-- PBI 177970. Report regarding certain medical conditions in MER for the period Apr-1-2021 to Mar-31-2022
-- Supplies an Excel with two sheets - one selected data, another - raw data
-- N.Melnik May-11-2022
WITH MEDICAL_ASSESSMENTS_CONDITIONS
AS (
SELECT ua006.MEDICAL_EXAMINATION_ID, ta004.MEDICAL_CATEGORY_ABBR_ETXT, ta025.MEDICAL_CONDITION_CD, ta025.MEDICAL_CONDITION_ETXT
FROM camis.UA007_MEDICAL_EXAM_ASSESSMENT UA007,
camis.UA006_MEDICAL_EXAMINATION UA006,
camis.UA046_MEDICAL_CAT_ASSESSED UA046,
camis.TA004_MEDICAL_CATEGORY ta004,
CAMIS.UA020_SYS_REVIEW_CHECKLIST ua020,
camis.TA025_MEDICAL_CONDITION ta025
WHERE UA007.MEDICAL_EXAMINATION_ID =
UA046.MEDICAL_EXAMINATION_ID
AND UA006.MEDICAL_EXAMINATION_ID(+) =
UA007.MEDICAL_EXAMINATION_ID
AND UA007.MEDICAL_EXAM_ASSESS_SEQ_NUM =
UA046.MEDICAL_EXAM_ASSESS_SEQ_NUM
AND UA046.MEDICAL_CATEGORY_CD = ta004.MEDICAL_CATEGORY_CD
AND ua006.MEDICAL_EXAMINATION_ID = ua020.MEDICAL_EXAMINATION_ID
AND ua020.MEDICAL_CONDITION_CD = ta025.MEDICAL_CONDITION_CD
AND ua020.MEDICAL_CONDITION_IND = 'Y'
AND UA007.DATE_DELETED_DTE IS NULL
AND UA006.DATE_DELETED_DTE IS NULL
AND UA046.DATE_DELETED_DTE IS NULL
AND UA007.ASSESSMENT_DTE >=
TO_DATE ('1/04/2021 00:00:00',
'DD/MM/YYYY HH24:MI:SS')
AND UA007.ASSESSMENT_DTE <=
TO_DATE ('31/03/2022 23:59:59',
'DD/MM/YYYY HH24:MI:SS')
ORDER BY ua006.MEDICAL_EXAMINATION_ID
)
SELECT MEDICAL_CONDITION_ETXT AS "CONDITION", COUNT(MEDICAL_CONDITION_ETXT) AS "COUNT"
FROM MEDICAL_ASSESSMENTS_CONDITIONS
WHERE MEDICAL_CONDITION_CD IN (1,2,6,7,8,10,13,17,20,23,24)
GROUP BY MEDICAL_CONDITION_ETXT, MEDICAL_CONDITION_CD
ORDER BY MEDICAL_CONDITION_ETXT;
WITH MEDICAL_ASSESSMENTS_CONDITIONS
AS (
SELECT ua006.MEDICAL_EXAMINATION_ID, ta004.MEDICAL_CATEGORY_ABBR_ETXT, ta025.MEDICAL_CONDITION_CD, ta025.MEDICAL_CONDITION_ETXT
FROM camis.UA007_MEDICAL_EXAM_ASSESSMENT UA007,
camis.UA006_MEDICAL_EXAMINATION UA006,
camis.UA046_MEDICAL_CAT_ASSESSED UA046,
camis.TA004_MEDICAL_CATEGORY ta004,
CAMIS.UA020_SYS_REVIEW_CHECKLIST ua020,
camis.TA025_MEDICAL_CONDITION ta025
WHERE UA007.MEDICAL_EXAMINATION_ID =
UA046.MEDICAL_EXAMINATION_ID
AND UA006.MEDICAL_EXAMINATION_ID(+) =
UA007.MEDICAL_EXAMINATION_ID
AND UA007.MEDICAL_EXAM_ASSESS_SEQ_NUM =
UA046.MEDICAL_EXAM_ASSESS_SEQ_NUM
AND UA046.MEDICAL_CATEGORY_CD = ta004.MEDICAL_CATEGORY_CD
AND ua006.MEDICAL_EXAMINATION_ID = ua020.MEDICAL_EXAMINATION_ID
AND ua020.MEDICAL_CONDITION_CD = ta025.MEDICAL_CONDITION_CD
AND ua020.MEDICAL_CONDITION_IND = 'Y'
AND UA007.DATE_DELETED_DTE IS NULL
AND UA006.DATE_DELETED_DTE IS NULL
AND UA046.DATE_DELETED_DTE IS NULL
AND UA007.ASSESSMENT_DTE >=
TO_DATE ('1/04/2021 00:00:00',
'DD/MM/YYYY HH24:MI:SS')
AND UA007.ASSESSMENT_DTE <=
TO_DATE ('31/03/2022 23:59:59',
'DD/MM/YYYY HH24:MI:SS')
ORDER BY ua006.MEDICAL_EXAMINATION_ID
)
SELECT MEDICAL_CONDITION_ETXT AS "CONDITION", COUNT(MEDICAL_CONDITION_ETXT) AS "COUNT"
FROM MEDICAL_ASSESSMENTS_CONDITIONS
-- WHERE MEDICAL_CONDITION_CD IN (1,2,6,7,8,10,13,17,20,23,24)
GROUP BY MEDICAL_CONDITION_ETXT, MEDICAL_CONDITION_CD
ORDER BY MEDICAL_CONDITION_ETXT;