Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view

Large diffs are not rendered by default.

60 changes: 60 additions & 0 deletions api/src/main/resources/messages.properties
Original file line number Diff line number Diff line change
Expand Up @@ -360,6 +360,66 @@ ${project.parent.artifactId}.report.drc.ptStartedOnArtWithVLGT12MonthsLessEqual5
${project.parent.artifactId}.report.drc.ptStartedOnArtWithVLGT12MonthsGreater50LessEqual1000=PLHIV on ARV who received biological monitoring of viral load at > 12 months > 50 and ≤ 1000 copies/ML
${project.parent.artifactId}.report.drc.ptStartedOnArtWithVLGT12MonthsGreaterthan1000=PLHIV on ARV who received biological monitoring of viral load at > 12 months > 1000 copies/ML

${project.parent.artifactId}.report.drc.txCurr.reportName=DRC TX_CURR Report
${project.parent.artifactId}.report.drc.txCurr.reportDescription=DRC TX_CURR Report

${project.parent.artifactId}.report.drc.total.label=Total

${project.parent.artifactId}.report.drc.belowOneYrMales.label=Below 1 year (Males)
${project.parent.artifactId}.report.drc.belowOneYrFemales.label=Below 1 year (Females)

${project.parent.artifactId}.report.drc.oneToFourYrsMales.label=1-4 years (Males)
${project.parent.artifactId}.report.drc.oneToFourYrsFemales.label=1-4 years (Females)

${project.parent.artifactId}.report.drc.fiveToNineYrsMales.label=5-9 years (Males)
${project.parent.artifactId}.report.drc.fiveToNineYrsFemales.label=5-9 years (Females)

${project.parent.artifactId}.report.drc.tenToFourteenYrsMales.label=10-14 years (Males)
${project.parent.artifactId}.report.drc.tenToFourteenYrsFemales.label=10-14 years (Females)

${project.parent.artifactId}.report.drc.fifteenToNineteenYrsMales.label=15-19 years (Males)
${project.parent.artifactId}.report.drc.fifteenToNineteenYrsFemales.label=15-19 years (Females)

${project.parent.artifactId}.report.drc.twentyToTwentyFourYrsMales.label=20-24 years (Males)
${project.parent.artifactId}.report.drc.twentyToTwentyFourYrsFemales.label=20-24 years (Females)

${project.parent.artifactId}.report.drc.twentyFiveToTwentyNineYrsMales.label=25-29 years (Males)
${project.parent.artifactId}.report.drc.twentyFiveToTwentyNineYrsFemales.label=25-29 years (Females)

${project.parent.artifactId}.report.drc.thirtyToThirtyFourYrsMales.label=30-34 years (Males)
${project.parent.artifactId}.report.drc.thirtyToThirtyFourYrsFemales.label=30-34 years (Females)

${project.parent.artifactId}.report.drc.thirtyFiveToThirtyNineYrsMales.label=35-39 years (Males)
${project.parent.artifactId}.report.drc.thirtyFiveToThirtyNineYrsFemales.label=35-39 years (Females)

${project.parent.artifactId}.report.drc.fortyToFortyFourYrsMales.label=40-44 years (Males)
${project.parent.artifactId}.report.drc.fortyToFortyFourYrsFemales.label=40-44 years (Females)

${project.parent.artifactId}.report.drc.fortyFiveToFortyNineYrsMales.label=45-49 years (Males)
${project.parent.artifactId}.report.drc.fortyFiveToFortyNineYrsFemales.label=45-49 years (Females)

${project.parent.artifactId}.report.drc.fiftyToFiftyFourYrsMales.label=50-54 years (Males)
${project.parent.artifactId}.report.drc.fiftyToFiftyFourYrsFemales.label=50-54 years (Females)

${project.parent.artifactId}.report.drc.fiftyFiveToFiftyNineYrsMales.label=55-59 years (Males)
${project.parent.artifactId}.report.drc.fiftyFiveToFiftyNineYrsFemales.label=55-59 years (Females)

${project.parent.artifactId}.report.drc.sixtyToSixtyFourYrsMales.label=60-64 years (Males)
${project.parent.artifactId}.report.drc.sixtyToSixtyFourYrsFemales.label=60-64 years (Females)

${project.parent.artifactId}.report.drc.sixtyFiveAndAboveMales.label=65+ years (Males)
${project.parent.artifactId}.report.drc.sixtyFiveAndAboveFemales.label=65+ years (Females)

${project.parent.artifactId}.report.drc.belowFifteenYrsMales.label=Below 15 years (Males)
${project.parent.artifactId}.report.drc.belowFifteenYrsFemales.label=Below 15 years (Females)

${project.parent.artifactId}.report.drc.fifteenYrsAndAboveMales.label=15+ years (Males)
${project.parent.artifactId}.report.drc.fifteenYrsAndAboveFemales.label=15+ years (Females)

${project.parent.artifactId}.report.drc.lessThanThreeMonthsDrugsGiven.label=< 3 months drugs
${project.parent.artifactId}.report.drc.threeToFiveMonthsDrugsGiven.label=3-5 months drugs
${project.parent.artifactId}.report.drc.sixPlusMonthsDrugsGiven.label=6+ months drugs

${project.parent.artifactId}.report.visits.reportName=Visits Report
${project.parent.artifactId}.report.visits.reportDescription=
${project.parent.artifactId}.report.visits.datasetName=Visits SQL Dataset
Expand Down
60 changes: 60 additions & 0 deletions api/src/main/resources/messages_fr.properties
Original file line number Diff line number Diff line change
Expand Up @@ -350,6 +350,66 @@ ${project.parent.artifactId}.report.drc.ptStartedOnArtWithVLGT12MonthsGreatertha
${project.parent.artifactId}.report.drc.artAbandonment.reportName=Patients de la RDC ayant abandonné ou refusé le traitement antirétroviral
${project.parent.artifactId}.report.drc.artAbandonment.datasetName=Patients de la RDC ayant abandonné ou refusé le traitement antirétroviral

${project.parent.artifactId}.report.drc.txCurr.reportName=Rapport TX_CURR RDC
${project.parent.artifactId}.report.drc.txCurr.reportDescription=Rapport TX_CURR RDC

${project.parent.artifactId}.report.drc.total.label=Total

${project.parent.artifactId}.report.drc.belowOneYrMales.label=Moins d’1 an (Hommes)
${project.parent.artifactId}.report.drc.belowOneYrFemales.label=Moins d’1 an (Femmes)

${project.parent.artifactId}.report.drc.oneToFourYrsMales.label=1-4 ans (Hommes)
${project.parent.artifactId}.report.drc.oneToFourYrsFemales.label=1-4 ans (Femmes)

${project.parent.artifactId}.report.drc.fiveToNineYrsMales.label=5-9 ans (Hommes)
${project.parent.artifactId}.report.drc.fiveToNineYrsFemales.label=5-9 ans (Femmes)

${project.parent.artifactId}.report.drc.tenToFourteenYrsMales.label=10-14 ans (Hommes)
${project.parent.artifactId}.report.drc.tenToFourteenYrsFemales.label=10-14 ans (Femmes)

${project.parent.artifactId}.report.drc.fifteenToNineteenYrsMales.label=15-19 ans (Hommes)
${project.parent.artifactId}.report.drc.fifteenToNineteenYrsFemales.label=15-19 ans (Femmes)

${project.parent.artifactId}.report.drc.twentyToTwentyFourYrsMales.label=20-24 ans (Hommes)
${project.parent.artifactId}.report.drc.twentyToTwentyFourYrsFemales.label=20-24 ans (Femmes)

${project.parent.artifactId}.report.drc.twentyFiveToTwentyNineYrsMales.label=25-29 ans (Hommes)
${project.parent.artifactId}.report.drc.twentyFiveToTwentyNineYrsFemales.label=25-29 ans (Femmes)

${project.parent.artifactId}.report.drc.thirtyToThirtyFourYrsMales.label=30-34 ans (Hommes)
${project.parent.artifactId}.report.drc.thirtyToThirtyFourYrsFemales.label=30-34 ans (Femmes)

${project.parent.artifactId}.report.drc.thirtyFiveToThirtyNineYrsMales.label=35-39 ans (Hommes)
${project.parent.artifactId}.report.drc.thirtyFiveToThirtyNineYrsFemales.label=35-39 ans (Femmes)

${project.parent.artifactId}.report.drc.fortyToFortyFourYrsMales.label=40-44 ans (Hommes)
${project.parent.artifactId}.report.drc.fortyToFortyFourYrsFemales.label=40-44 ans (Femmes)

${project.parent.artifactId}.report.drc.fortyFiveToFortyNineYrsMales.label=45-49 ans (Hommes)
${project.parent.artifactId}.report.drc.fortyFiveToFortyNineYrsFemales.label=45-49 ans (Femmes)

${project.parent.artifactId}.report.drc.fiftyToFiftyFourYrsMales.label=50-54 ans (Hommes)
${project.parent.artifactId}.report.drc.fiftyToFiftyFourYrsFemales.label=50-54 ans (Femmes)

${project.parent.artifactId}.report.drc.fiftyFiveToFiftyNineYrsMales.label=55-59 ans (Hommes)
${project.parent.artifactId}.report.drc.fiftyFiveToFiftyNineYrsFemales.label=55-59 ans (Femmes)

${project.parent.artifactId}.report.drc.sixtyToSixtyFourYrsMales.label=60-64 ans (Hommes)
${project.parent.artifactId}.report.drc.sixtyToSixtyFourYrsFemales.label=60-64 ans (Femmes)

${project.parent.artifactId}.report.drc.sixtyFiveAndAboveMales.label=65 ans et plus (Hommes)
${project.parent.artifactId}.report.drc.sixtyFiveAndAboveFemales.label=65 ans et plus (Femmes)

${project.parent.artifactId}.report.drc.belowFifteenYrsMales.label=Moins de 15 ans (Hommes)
${project.parent.artifactId}.report.drc.belowFifteenYrsFemales.label=Moins de 15 ans (Femmes)

${project.parent.artifactId}.report.drc.fifteenYrsAndAboveMales.label=15 ans et plus (Hommes)
${project.parent.artifactId}.report.drc.fifteenYrsAndAboveFemales.label=15 ans et plus (Femmes)

${project.parent.artifactId}.report.drc.lessThanThreeMonthsDrugsGiven.label=Devrait \u00EAtre inf\u00E9rieur \u00E0 3 mois
${project.parent.artifactId}.report.drc.threeToFiveMonthsDrugsGiven.label=M\u00E9dicaments pour 3 \u00E0 5 mois
${project.parent.artifactId}.report.drc.sixPlusMonthsDrugsGiven.label=M\u00E9dicaments pour 6 mois et plus

${project.parent.artifactId}.report.visits.reportName=Rapport de la Table des Visites
${project.parent.artifactId}.report.visits.reportDescription=Rapport de la Table des Visites
${project.parent.artifactId}.report.visits.datasetName=Jeu de Données SQL des Visites
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
SELECT DISTINCT p.patient_id
FROM patient p
INNER JOIN person pe ON p.patient_id = pe.person_id
WHERE pe.voided = 0
AND p.voided = 0
AND EXISTS (
SELECT 1
FROM obs o
INNER JOIN concept c ON o.concept_id = c.concept_id
WHERE o.person_id = p.patient_id
AND o.voided = 0
AND c.uuid = '3a0709e9-d7a8-44b9-9512-111db5ce3989'
AND o.value_numeric < 90
AND o.obs_datetime = (
SELECT MAX(o2.obs_datetime)
FROM obs o2
INNER JOIN concept c2 ON o2.concept_id = c2.concept_id
WHERE o2.person_id = o.person_id
AND o2.voided = 0
AND c2.uuid = '3a0709e9-d7a8-44b9-9512-111db5ce3989'
AND o2.value_numeric IS NOT NULL
)
)
ORDER BY p.patient_id;
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
SELECT DISTINCT p.patient_id
FROM patient p
INNER JOIN person pe ON p.patient_id = pe.person_id
WHERE pe.voided = 0
AND p.voided = 0
AND EXISTS (
SELECT 1
FROM obs o
INNER JOIN concept c ON o.concept_id = c.concept_id
WHERE o.person_id = p.patient_id
AND o.voided = 0
AND c.uuid = '3a0709e9-d7a8-44b9-9512-111db5ce3989'
AND o.value_numeric >= 180
AND o.obs_datetime = (
SELECT MAX(o2.obs_datetime)
FROM obs o2
INNER JOIN concept c2 ON o2.concept_id = c2.concept_id
WHERE o2.person_id = o.person_id
AND o2.voided = 0
AND c2.uuid = '3a0709e9-d7a8-44b9-9512-111db5ce3989'
AND o2.value_numeric IS NOT NULL
)
)
ORDER BY p.patient_id;
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
SELECT DISTINCT p.patient_id
FROM patient p
INNER JOIN person pe ON p.patient_id = pe.person_id
WHERE pe.voided = 0
AND p.voided = 0
AND EXISTS (
SELECT 1
FROM obs o
INNER JOIN concept c ON o.concept_id = c.concept_id
WHERE o.person_id = p.patient_id
AND o.voided = 0
AND c.uuid = '3a0709e9-d7a8-44b9-9512-111db5ce3989'
AND o.value_numeric IS NOT NULL
AND o.value_numeric >= 90
AND o.value_numeric <= 179
AND o.obs_datetime = (
SELECT MAX(o2.obs_datetime)
FROM obs o2
INNER JOIN concept c2 ON o2.concept_id = c2.concept_id
WHERE o2.person_id = o.person_id
AND o2.voided = 0
AND c2.uuid = '3a0709e9-d7a8-44b9-9512-111db5ce3989'
AND o2.value_numeric IS NOT NULL
)
)
ORDER BY p.patient_id;
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
SELECT DISTINCT p.patient_id
FROM patient p
INNER JOIN person pe ON p.patient_id = pe.person_id
WHERE pe.voided = 0
AND p.voided = 0
AND NOT EXISTS (
-- Check that patient does NOT have death date observation
SELECT 1
FROM obs o
INNER JOIN concept c ON o.concept_id = c.concept_id
WHERE o.person_id = p.patient_id
AND o.voided = 0
AND c.uuid = '1543AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA'
)
ORDER BY p.patient_id;
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
SELECT DISTINCT p.patient_id
FROM patient p
INNER JOIN person pe ON p.patient_id = pe.person_id
WHERE pe.voided = 0
AND p.voided = 0
AND EXISTS (
SELECT 1
FROM obs o
INNER JOIN concept c_question ON o.concept_id = c_question.concept_id
INNER JOIN concept c_answer ON o.value_coded = c_answer.concept_id
WHERE o.person_id = p.patient_id
AND o.voided = 0
AND c_question.uuid = '1255AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA' -- ART initiation during this visit
AND c_answer.uuid = '1256AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA' -- Start ART
AND DATE(o.obs_datetime) BETWEEN :onOrAfter AND :onOrBefore
)
AND EXISTS (
-- Check for initiation date concept within date range
SELECT 1
FROM obs o_init_date
INNER JOIN concept c_init_date ON o_init_date.concept_id = c_init_date.concept_id
WHERE o_init_date.person_id = p.patient_id
AND o_init_date.voided = 0
AND c_init_date.uuid = '159599AAAAAAAAAAAAAAAAAAAAAAAAAAAAAA' -- Initiation date concept
AND DATE(o_init_date.value_datetime) BETWEEN :onOrAfter AND :onOrBefore
)
ORDER BY p.patient_id;
Original file line number Diff line number Diff line change
@@ -0,0 +1,64 @@
SELECT DISTINCT p.patient_id
FROM patient p
INNER JOIN person pe ON p.patient_id = pe.person_id
WHERE pe.voided = 0
AND p.voided = 0
AND EXISTS (
-- Filter for patients who have refill dates in the reporting period
SELECT 1
FROM obs o_appt
INNER JOIN concept c_appt ON o_appt.concept_id = c_appt.concept_id
WHERE o_appt.person_id = p.patient_id
AND o_appt.voided = 0
AND c_appt.uuid = '162549AAAAAAAAAAAAAAAAAAAAAAAAAAAAAA' -- Next Refill Date concept
AND DATE(o_appt.value_datetime) >= :onOrAfter
AND DATE(o_appt.value_datetime) <= :onOrBefore
)
AND NOT EXISTS (
-- Exclude patients who meet the compliance criteria based on their latest refill date
SELECT 1
FROM obs o_appt
INNER JOIN concept c_appt ON o_appt.concept_id = c_appt.concept_id
WHERE o_appt.person_id = p.patient_id
AND o_appt.voided = 0
AND c_appt.uuid = '162549AAAAAAAAAAAAAAAAAAAAAAAAAAAAAA' -- Next Refill Date concept
AND DATE(o_appt.value_datetime) >= :onOrAfter
AND DATE(o_appt.value_datetime) <= :onOrBefore
-- Ensure this is the latest refill date for this patient in the date range
AND o_appt.value_datetime = (
SELECT MAX(o_latest.value_datetime)
FROM obs o_latest
INNER JOIN concept c_latest ON o_latest.concept_id = c_latest.concept_id
WHERE o_latest.person_id = p.patient_id
AND o_latest.voided = 0
AND c_latest.uuid = '162549AAAAAAAAAAAAAAAAAAAAAAAAAAAAAA'
AND DATE(o_latest.value_datetime) >= :onOrAfter
AND DATE(o_latest.value_datetime) <= :onOrBefore
)
AND (
-- If latest appointment is within 28 days of end date, this would be compliant
DATE(o_appt.value_datetime) > DATE_SUB(:onOrBefore, INTERVAL 28 DAY)
OR
-- If latest appointment is more than 28 days before end date, and has subsequent visit, this would be compliant
(
DATE(o_appt.value_datetime) <= DATE_SUB(:onOrBefore, INTERVAL 28 DAY)
AND EXISTS (
SELECT 1
FROM encounter e_subsequent
INNER JOIN encounter_type et_subsequent ON e_subsequent.encounter_type = et_subsequent.encounter_type_id
INNER JOIN obs o_arv_subsequent ON o_arv_subsequent.encounter_id = e_subsequent.encounter_id
INNER JOIN concept c_arv_subsequent ON o_arv_subsequent.concept_id = c_arv_subsequent.concept_id
WHERE e_subsequent.patient_id = p.patient_id
AND e_subsequent.voided = 0
AND o_arv_subsequent.voided = 0
AND et_subsequent.uuid = 'cb0a65a7-0587-477e-89b9-cf2fd144f1d4' -- Consultation encounter type
AND c_arv_subsequent.uuid = '3a0709e9-d7a8-44b9-9512-111db5ce3989' -- ARV quantity concept
AND o_arv_subsequent.value_numeric IS NOT NULL
AND o_arv_subsequent.value_numeric > 0
AND DATE(e_subsequent.encounter_datetime) > DATE(o_appt.value_datetime)
AND DATE(e_subsequent.encounter_datetime) <= :onOrBefore
)
)
)
)
ORDER BY p.patient_id;
Original file line number Diff line number Diff line change
@@ -0,0 +1,73 @@
SELECT DISTINCT p.patient_id
FROM patient p
INNER JOIN person pe ON p.patient_id = pe.person_id
WHERE pe.voided = 0
AND p.voided = 0
AND EXISTS (
-- Check for "Next Refill Date" within or beyond date range
SELECT 1
FROM obs o_appt
INNER JOIN concept c_appt ON o_appt.concept_id = c_appt.concept_id
WHERE o_appt.person_id = p.patient_id
AND o_appt.voided = 0
AND c_appt.uuid = '162549AAAAAAAAAAAAAAAAAAAAAAAAAAAAAA'
AND DATE(o_appt.value_datetime) >= :onOrAfter
)
AND EXISTS (
-- Check ARV coverage: Either drugs cover entire range OR drugs end in range with appointment/visit logic
SELECT 1
FROM encounter e_consult
INNER JOIN encounter_type et ON e_consult.encounter_type = et.encounter_type_id
INNER JOIN obs o_arv ON o_arv.encounter_id = e_consult.encounter_id
INNER JOIN concept c_arv ON o_arv.concept_id = c_arv.concept_id
WHERE e_consult.patient_id = p.patient_id
AND e_consult.voided = 0
AND o_arv.voided = 0
AND et.uuid = 'cb0a65a7-0587-477e-89b9-cf2fd144f1d4'
AND c_arv.uuid = '3a0709e9-d7a8-44b9-9512-111db5ce3989'
AND DATE(e_consult.encounter_datetime) <= :onOrBefore
AND (
-- Either: ARV quantity covers the entire date range
DATE_ADD(DATE(e_consult.encounter_datetime), INTERVAL o_arv.value_numeric DAY) >= :onOrBefore
OR
-- Or: Drugs end within date range with appointment/visit logic based on timing
(
DATE_ADD(DATE(e_consult.encounter_datetime), INTERVAL o_arv.value_numeric DAY) < :onOrBefore
AND DATE_ADD(DATE(e_consult.encounter_datetime), INTERVAL o_arv.value_numeric DAY) >= :onOrAfter
AND EXISTS (
SELECT 1
FROM obs o_appt
INNER JOIN concept c_appt ON o_appt.concept_id = c_appt.concept_id
WHERE o_appt.person_id = p.patient_id
AND o_appt.voided = 0
AND c_appt.uuid = '162549AAAAAAAAAAAAAAAAAAAAAAAAAAAAAA'
AND (
-- If appointment is within 28 days of end date, just check it exists
(DATE(o_appt.value_datetime) > DATE_SUB(:onOrBefore, INTERVAL 28 DAY))
OR
-- If appointment is 28+ days before end date, must have subsequent visit WITH drug dispensing
(
DATE(o_appt.value_datetime) <= DATE_SUB(:onOrBefore, INTERVAL 28 DAY)
AND EXISTS (
SELECT 1
FROM encounter e_subsequent
INNER JOIN encounter_type et_subsequent ON e_subsequent.encounter_type = et_subsequent.encounter_type_id
INNER JOIN obs o_arv_subsequent ON o_arv_subsequent.encounter_id = e_subsequent.encounter_id
INNER JOIN concept c_arv_subsequent ON o_arv_subsequent.concept_id = c_arv_subsequent.concept_id
WHERE e_subsequent.patient_id = p.patient_id
AND e_subsequent.voided = 0
AND o_arv_subsequent.voided = 0
AND et_subsequent.uuid = 'cb0a65a7-0587-477e-89b9-cf2fd144f1d4'
AND c_arv_subsequent.uuid = '3a0709e9-d7a8-44b9-9512-111db5ce3989'
AND o_arv_subsequent.value_numeric IS NOT NULL
AND o_arv_subsequent.value_numeric > 0
AND DATE(e_subsequent.encounter_datetime) > DATE(o_appt.value_datetime)
AND DATE(e_subsequent.encounter_datetime) <= :onOrBefore
)
)
)
)
)
)
)
ORDER BY p.patient_id;
Loading