From bd995f7d9c1737e0e532acd265b6da87e3c4f995 Mon Sep 17 00:00:00 2001 From: Tresor Mvumbi Date: Fri, 26 Feb 2021 16:59:47 +0200 Subject: [PATCH 01/14] COM-988 Fix bug PCR Report The child and mother's columns where reversed (i.e child's information was displayed in mother's columns and vise-versa) --- .../sql/georgetownPcrReport.sql | 20 +++++++++---------- 1 file changed, 10 insertions(+), 10 deletions(-) diff --git a/openmrs/apps/reports/GEORGETOWN_PCR_REPORT/sql/georgetownPcrReport.sql b/openmrs/apps/reports/GEORGETOWN_PCR_REPORT/sql/georgetownPcrReport.sql index 5e937e3c..34fb286b 100644 --- a/openmrs/apps/reports/GEORGETOWN_PCR_REPORT/sql/georgetownPcrReport.sql +++ b/openmrs/apps/reports/GEORGETOWN_PCR_REPORT/sql/georgetownPcrReport.sql @@ -1,15 +1,15 @@ SELECT CAST(@a:=@a+1 AS CHAR) as "serialNumber", - getPatientIdentifier(r.person_b) as "uniquePatientId", - getPatientBirthdate(r.person_b) as "dateOfBirth", - getPatientAgeInMonthsAtDate(r.person_b, NOW()) as "ageInMonths", - getPatientIdentifier(r.person_a) as "motherId", - CONCAT(getPatientPreciseLocation(r.person_a),", ",getPatientVillage(r.person_a)) as "mothersAddress", - getPatientPhoneNumber(r.person_a) as "mothersContact", - getMostRecentTestResultDate(r.person_b,"a5239a85-6f75-4882-9b9b-60168e54b7da","9bb7b360-3790-4e1a-8aca-0d1341663040") as "resultDatePcr", - getTestResultWithinReportingPeriod(r.person_b,"2000-01-01","2100-01-01","a5239a85-6f75-4882-9b9b-60168e54b7da","9bb7b360-3790-4e1a-8aca-0d1341663040") as "pcrResult", - getProgramAttributeDateValueFromAttributeAndProgramName(r.person_b, "PROGRAM_MANAGEMENT_2_PATIENT_TREATMENT_DATE", "HIV_PROGRAM_KEY") as "artInitiationDate", - getObsCodedValue(r.person_b, "3447254f-501f-4b07-815c-cd0f6da98158") as "reasonOfNonInitiation" + getPatientIdentifier(r.person_a) as "uniquePatientId", + getPatientBirthdate(r.person_a) as "dateOfBirth", + getPatientAgeInMonthsAtDate(r.person_a, NOW()) as "ageInMonths", + getPatientIdentifier(r.person_b) as "motherId", + CONCAT(getPatientPreciseLocation(r.person_b),", ",getPatientVillage(r.person_b)) as "mothersAddress", + getPatientPhoneNumber(r.person_b) as "mothersContact", + getMostRecentTestResultDate(r.person_a,"a5239a85-6f75-4882-9b9b-60168e54b7da","9bb7b360-3790-4e1a-8aca-0d1341663040") as "resultDatePcr", + getTestResultWithinReportingPeriod(r.person_a,"2000-01-01","2100-01-01","a5239a85-6f75-4882-9b9b-60168e54b7da","9bb7b360-3790-4e1a-8aca-0d1341663040") as "pcrResult", + getProgramAttributeDateValueFromAttributeAndProgramName(r.person_a, "PROGRAM_MANAGEMENT_2_PATIENT_TREATMENT_DATE", "HIV_PROGRAM_KEY") as "artInitiationDate", + getObsCodedValue(r.person_a, "3447254f-501f-4b07-815c-cd0f6da98158") as "reasonOfNonInitiation" FROM (SELECT @a:= 0) AS a, relationship r JOIN relationship_type rt ON rt.relationship_type_id = r.relationship AND rt.a_is_to_b = "RELATIONSHIP_BIO_MOTHER" JOIN patient_identifier pi ON pi.patient_id = r.person_a AND pi.preferred = 1; \ No newline at end of file From 62ad627bba02cdbda92c0dc7d2f2d487540379a7 Mon Sep 17 00:00:00 2001 From: Tresor Mvumbi Date: Fri, 26 Feb 2021 17:07:58 +0200 Subject: [PATCH 02/14] COM-988 Fix the unit tests Fixes unit tests --- .../georgetown_reports/GeorgetownPCRReportTests.java | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/report-testing-framework/report-testing/src/test/java/org/jembi/bahmni/report_testing/georgetown_reports/GeorgetownPCRReportTests.java b/report-testing-framework/report-testing/src/test/java/org/jembi/bahmni/report_testing/georgetown_reports/GeorgetownPCRReportTests.java index c0f3f32a..b059a730 100644 --- a/report-testing-framework/report-testing/src/test/java/org/jembi/bahmni/report_testing/georgetown_reports/GeorgetownPCRReportTests.java +++ b/report-testing-framework/report-testing/src/test/java/org/jembi/bahmni/report_testing/georgetown_reports/GeorgetownPCRReportTests.java @@ -55,8 +55,8 @@ public void childrenWithABiologicalMotherRelationship_shouldBeReported() throws /* record relationship between mother and child */ testDataGenerator.registration.addRelationshipToPatient( - patientIdMother, patientIdChild, + patientIdMother, RelationshipEnum.RELATIONSHIP_BIO_MOTHER, RelationshipEnum.RELATIONSHIP_BIO_CHILD); @@ -163,13 +163,13 @@ public void twoChildrenWithABiologicalMotherRelationship_shouldAllBeReported() t /* record relationship between mother and child */ testDataGenerator.registration.addRelationshipToPatient( - patientIdMother, patientIdChild1, + patientIdMother, RelationshipEnum.RELATIONSHIP_BIO_MOTHER, RelationshipEnum.RELATIONSHIP_BIO_CHILD); testDataGenerator.registration.addRelationshipToPatient( - patientIdMother, patientIdChild2, + patientIdMother, RelationshipEnum.RELATIONSHIP_BIO_MOTHER, RelationshipEnum.RELATIONSHIP_BIO_CHILD); From 2a505e2a1f526c320c0221619db5091e1f5d4a93 Mon Sep 17 00:00:00 2001 From: Tresor Mvumbi Date: Fri, 5 Mar 2021 11:06:35 +0200 Subject: [PATCH 03/14] COM-992 Display patients with no program historical attributes The report index testing line listing should display patients for which there is no program attribute historical data; this is important because in the production server, all the old patients will not have historical data --- metadata/reportssql/drug_functions.sql | 6 ++++-- .../sql/georgetownIndexTestingReport.sql | 10 +++++----- 2 files changed, 9 insertions(+), 7 deletions(-) diff --git a/metadata/reportssql/drug_functions.sql b/metadata/reportssql/drug_functions.sql index b569f556..01a1f606 100644 --- a/metadata/reportssql/drug_functions.sql +++ b/metadata/reportssql/drug_functions.sql @@ -93,7 +93,8 @@ BEGIN WHERE o.voided = 0 AND o.person_id = p_patientId AND o.order_id = p_orderId - AND c.uuid = uuidDispensedConcept; + AND c.uuid = uuidDispensedConcept + LIMIT 1; SELECT TRUE INTO retrospectiveDrugEntry FROM orders o @@ -105,7 +106,8 @@ BEGIN AND o.date_created > calculateTreatmentEndDate( o.scheduled_date, do.duration, - c.uuid); + c.uuid) + LIMIT 1; RETURN (drugDispensed OR retrospectiveDrugEntry); END$$ diff --git a/openmrs/apps/reports/GEORGETOWN_INDEX_TESTING_REPORT/sql/georgetownIndexTestingReport.sql b/openmrs/apps/reports/GEORGETOWN_INDEX_TESTING_REPORT/sql/georgetownIndexTestingReport.sql index 74ff7e95..49c76817 100644 --- a/openmrs/apps/reports/GEORGETOWN_INDEX_TESTING_REPORT/sql/georgetownIndexTestingReport.sql +++ b/openmrs/apps/reports/GEORGETOWN_INDEX_TESTING_REPORT/sql/georgetownIndexTestingReport.sql @@ -17,11 +17,11 @@ SELECT DISTINCT DATE(getProgramAttributeValueWithinReportingPeriod(p.patient_id, "2000-01-01","2100-01-01", "2dc1aafd-a708-11e6-91e9-0800270d80ce")) as "Date of Initiation", getPatientARTNumber(getFirstIndexID(p.patient_id)) as "Index Related ART Code", getPatientIdentifier(getFirstIndexID(p.patient_id)) as "Index Related Unique ID" -FROM patient p, patient_program_attribute_history ppah, patient_program pp, program_attribute_type pat +FROM patient p + LEFT JOIN patient_program pp ON pp.patient_id = p.patient_id + LEFT JOIN patient_program_attribute_history ppah ON ppah.patient_program_id = pp.patient_program_id + LEFT JOIN program_attribute_type pat ON pat.program_attribute_type_id = ppah.attribute_type_id + AND pat.name IN ("PROGRAM_MANAGEMENT_2_NOTIFICATION_DATE", "PROGRAM_MANAGEMENT_3_NOTIFICATION_OUTCOME") WHERE - ppah.patient_program_id = pp.patient_program_id AND - pp.patient_id = p.patient_id AND - pat.program_attribute_type_id = ppah.attribute_type_id AND - pat.name IN ("PROGRAM_MANAGEMENT_2_NOTIFICATION_DATE", "PROGRAM_MANAGEMENT_3_NOTIFICATION_OUTCOME") AND patientIsContact(p.patient_id) ORDER BY ppah.date_created DESC; \ No newline at end of file From 388a9251fec91cd8f6614d2875a65b746517e122 Mon Sep 17 00:00:00 2001 From: Tresor Mvumbi Date: Wed, 10 Mar 2021 12:45:53 +0200 Subject: [PATCH 04/14] COM-989 Use the most recent ARV dispensed for TX_CURR So that overall TX_CURR matches the disaggregation by ARV duration --- .../reportssql/treatment_report_functions.sql | 41 +++++++++++++++++-- 1 file changed, 37 insertions(+), 4 deletions(-) diff --git a/metadata/reportssql/treatment_report_functions.sql b/metadata/reportssql/treatment_report_functions.sql index 9d8bc3cc..f333a688 100644 --- a/metadata/reportssql/treatment_report_functions.sql +++ b/metadata/reportssql/treatment_report_functions.sql @@ -93,7 +93,7 @@ WHERE patientHasStartedARVTreatmentDuringOrBeforeReportingPeriod(pat.patient_id, p_endDate) AND IF ( isOldPatient(pat.patient_id, p_startDate), - (patientOnARTDuringPartOfReportingPeriodAndDurationBetween(pat.patient_id, p_startDate, p_minDuration, p_maxDuration) OR + (patientOnARTDuringPartOfReportingPeriodAndDurationBetween(pat.patient_id, p_startDate, p_endDate, p_minDuration, p_maxDuration) OR patientPickedARVDrugDuringReportingPeriodAndDurationBetween(pat.patient_id, p_startDate, p_endDate, p_minDuration, p_maxDuration)), patientPickedARVDrugDuringReportingPeriodAndDurationBetween(pat.patient_id, p_startDate, p_endDate, p_minDuration, p_maxDuration) ) AND @@ -101,7 +101,7 @@ WHERE patientIsNotLostToFollowUp(pat.patient_id) AND ( patientIsNotTransferredOut(pat.patient_id) OR - patientOnARTDuringPartOfReportingPeriodAndDurationBetween(pat.patient_id, p_startDate, 0, 2000) + patientOnARTDuringPartOfReportingPeriodAndDurationBetween(pat.patient_id, p_startDate, p_endDate, 0, 2000) ); RETURN (result); @@ -139,7 +139,7 @@ WHERE patientIsNotLostToFollowUp(pat.patient_id) AND ( patientIsNotTransferredOut(pat.patient_id) OR - patientOnARTDuringPartOfReportingPeriodAndDurationBetween(pat.patient_id, p_startDate, 0, 2000) + patientOnARTDuringPartOfReportingPeriodAndDurationBetween(pat.patient_id, p_startDate, p_endDate, 0, 2000) ); RETURN (result); @@ -610,12 +610,27 @@ DELIMITER $$ CREATE FUNCTION patientOnARTDuringPartOfReportingPeriodAndDurationBetween( p_patientId INT(11), p_startDate DATE, + p_endDate DATE, p_minDuration INT(11), p_maxDuration INT(11)) RETURNS TINYINT(1) DETERMINISTIC BEGIN DECLARE result TINYINT(1) DEFAULT 0; + DECLARE orderIdMostRecentDispense INT(11); + + SELECT o.order_id INTO orderIdMostRecentDispense + FROM orders o + JOIN drug_order do ON do.order_id = o.order_id + JOIN concept c ON do.duration_units = c.concept_id AND c.retired = 0 + JOIN drug d ON d.drug_id = do.drug_inventory_id AND d.retired = 0 + WHERE o.patient_id = p_patientId AND o.voided = 0 + AND drugIsARV(d.concept_id) + AND drugOrderIsDispensed(o.patient_id, o.order_id) + AND o.scheduled_date IS NOT NULL + AND o.scheduled_date <= p_endDate + ORDER BY o.scheduled_date + LIMIT 1; SELECT TRUE INTO result FROM orders o @@ -633,7 +648,9 @@ BEGIN ) >= p_startDate AND o.scheduled_date IS NOT NULL AND calculateDurationInMonths(o.scheduled_date, do.duration,c.uuid) >= p_minDuration - AND calculateDurationInMonths(o.scheduled_date, do.duration,c.uuid) < p_maxDuration + AND calculateDurationInMonths(o.scheduled_date, do.duration,c.uuid) < p_maxDuration + AND orderIdMostRecentDispense IS NOT NULL + AND o.order_id = orderIdMostRecentDispense GROUP BY o.patient_id; RETURN (result ); @@ -687,6 +704,20 @@ CREATE FUNCTION patientPickedARVDrugDuringReportingPeriodAndDurationBetween( BEGIN DECLARE result TINYINT(1) DEFAULT 0; + DECLARE orderIdMostRecentDispense INT(11); + + SELECT o.order_id INTO orderIdMostRecentDispense + FROM orders o + JOIN drug_order do ON do.order_id = o.order_id + JOIN concept c ON do.duration_units = c.concept_id AND c.retired = 0 + JOIN drug d ON d.drug_id = do.drug_inventory_id AND d.retired = 0 + WHERE o.patient_id = p_patientId AND o.voided = 0 + AND drugIsARV(d.concept_id) + AND drugOrderIsDispensed(o.patient_id, o.order_id) + AND o.scheduled_date IS NOT NULL + AND o.scheduled_date <= p_endDate + ORDER BY o.scheduled_date + LIMIT 1; SELECT TRUE INTO result FROM orders o @@ -700,6 +731,8 @@ BEGIN AND o.scheduled_date BETWEEN p_startDate AND p_endDate AND calculateDurationInMonths(o.scheduled_date, do.duration,c.uuid) >= p_minDuration AND calculateDurationInMonths(o.scheduled_date, do.duration,c.uuid) < p_maxDuration + AND orderIdMostRecentDispense IS NOT NULL + AND o.order_id = orderIdMostRecentDispense GROUP BY o.patient_id; RETURN (result ); From b038ad38b5cb66920f96615a3d424f2d79d46311 Mon Sep 17 00:00:00 2001 From: Tresor Mvumbi Date: Thu, 11 Mar 2021 11:32:31 +0200 Subject: [PATCH 05/14] COM-993 Add column "Patient Outcome" to patient information Adds the column "Patient Outcome" to patient information --- .../georgetownPatientInformationReport.sql | 1 + .../georgetownPatientInformationReport.xls | Bin 61440 -> 61440 bytes 2 files changed, 1 insertion(+) diff --git a/openmrs/apps/reports/GEORGETOWN_PATIENT_INFORMATION_REPORT/sql/georgetownPatientInformationReport.sql b/openmrs/apps/reports/GEORGETOWN_PATIENT_INFORMATION_REPORT/sql/georgetownPatientInformationReport.sql index 6af96ea0..2c9a5744 100644 --- a/openmrs/apps/reports/GEORGETOWN_PATIENT_INFORMATION_REPORT/sql/georgetownPatientInformationReport.sql +++ b/openmrs/apps/reports/GEORGETOWN_PATIENT_INFORMATION_REPORT/sql/georgetownPatientInformationReport.sql @@ -18,6 +18,7 @@ SELECT IF(patientIsEligibleForVL(p.patient_id), "Yes", "No") as "eligibilityForVl", getDateLatestARVRelatedVisit(p.patient_id) as "dateOfLastVisit", getDateMostRecentARVAppointment(p.patient_id) as "lastAppointmentDate", + getPatientMostRecentProgramOutcome(p.patient_id, "en", "HIV_PROGRAM_KEY") as "hivOutcome", getPatientMostRecentProgramAttributeCodedValue(p.patient_id, "39202f47-a709-11e6-91e9-0800270d80ce", "en") as "transferredIn", IF(getPatientMostRecentProgramOutcome(p.patient_id, "en", "HIV_PROGRAM_KEY")="Transferred Out", "Yes", "No") as "transfertOut", IF(getObsCodedValue(p.patient_id, "211f0857-61a3-4049-9777-374c4a592453") IS NOT NULL, "True", "False") as "kp", diff --git a/openmrs/apps/reports/GEORGETOWN_PATIENT_INFORMATION_REPORT/template/georgetownPatientInformationReport.xls b/openmrs/apps/reports/GEORGETOWN_PATIENT_INFORMATION_REPORT/template/georgetownPatientInformationReport.xls index 1751106ae0e2fb8b8844323b156371408036c3d0..0fc18c86b3f06d6cb2627d7bb6976be75080b45f 100644 GIT binary patch delta 4167 zcmbtYdr*|u6+idxw+~og7g-()i!3Ms4T2!73o7p70xA#DsG%7j_`vu;K*ToIR4`)_ zwbsYnAZen8m`OBR@bQ_5i4ROn?Mz#BXhck$4k2~oBXMjJrxQDw?K$7FE4%ndr~U4H z_k8Ev`#a~J$Gvxzf{%oDeYN771zBeuYdBIX-XuQ7Ce zTByj3uNDz~=La?8#u@TMjVV+ln$m>Y6eG$^CdraH>|?pw6gq-g<+bArSgr*wFde=C zId{WgneINm;Cnb203P%zyyihCQZ^eP3TdRcZ$Bu0w(CSou7jNxJ-L&(Gfa-m8=0;B zyEGAJ*kniTC21Nes94mvqPn)xI%8eqlDgH^ZpZ^2lq?4b!D+=S0CZ@6)JlN6NFO5o zkORE13LsYn5M2Y%i?mJ7Uwbmdc>1qjt+Ld7`0nHj{h8lRtO^snIaOV`0pNg~(HzQ~ z<`@ltX!s2(kH7|o$Gizla4qyP9|@6gIOH)Og`UkB#79H4A3g?Rpn1@EEX2a$u*di~ zh->mwU;ztU(|aZW55r}lKT1CwdmT3_-|^r;zwu!PMMjKQ<`|HXOMx;BicjXnHc5ko zUa)$Q%sWvtNamfV9VGM4qhbg&95hJgofqtpH7TBW73!Zbk#g=;=mm!=ve(E-Ulb@> z@!&7RS{fpw7!LQ%EB1siToIn}Q#eeK`G*?o1Ht|>s_x;UZgae$9KQh0K^QQssdDk= z=8Q3BC`XQ@!AN6~D~CAv899!8xl((C;0oej0|-hLA-Eqxr64F{gitAnXI}Q$pqvpx z<%f_I1m%tpl7cuofS~LVLh?hX{cNZeg#Hze4azMc)P4w!f}k9e4UK|$egHvPCWOWh zp;Zu+Y(i)i#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V$UA(6XUhybqKBvf$5oJrU*&Gv{ z2`M&5c1o)2Cf!sgsS<37j^repBSqZKRJ`%+T?$)+o%e2e!TICj-(aS~NXaaBerK2d E59wr&ng9R* From 284e2349d54ec467e5b71914a99016a3cd88939e Mon Sep 17 00:00:00 2001 From: Tresor Mvumbi Date: Thu, 11 Mar 2021 11:38:51 +0200 Subject: [PATCH 06/14] COM-993 Fix function getDateLatestARVRelatedVisit Adds ORDER BY so that the most recent visit date is returned --- metadata/reportssql/data_completeness_check_report_functions.sql | 1 + 1 file changed, 1 insertion(+) diff --git a/metadata/reportssql/data_completeness_check_report_functions.sql b/metadata/reportssql/data_completeness_check_report_functions.sql index e91ced09..5d494ee7 100644 --- a/metadata/reportssql/data_completeness_check_report_functions.sql +++ b/metadata/reportssql/data_completeness_check_report_functions.sql @@ -473,6 +473,7 @@ BEGIN "VISIT_TYPE_OPD", "Special OPD" ) + ORDER BY v.date_started DESC LIMIT 1; RETURN (result); From a9525b223b55f617496f1f9328f721c547b9ed31 Mon Sep 17 00:00:00 2001 From: Tresor Mvumbi Date: Fri, 12 Mar 2021 17:00:46 +0200 Subject: [PATCH 07/14] COM-988 Include only children <= 24 months in the report Includes only children <= 24 months in the report --- .../reports/GEORGETOWN_PCR_REPORT/sql/georgetownPcrReport.sql | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/openmrs/apps/reports/GEORGETOWN_PCR_REPORT/sql/georgetownPcrReport.sql b/openmrs/apps/reports/GEORGETOWN_PCR_REPORT/sql/georgetownPcrReport.sql index 34fb286b..4b1d4277 100644 --- a/openmrs/apps/reports/GEORGETOWN_PCR_REPORT/sql/georgetownPcrReport.sql +++ b/openmrs/apps/reports/GEORGETOWN_PCR_REPORT/sql/georgetownPcrReport.sql @@ -12,4 +12,5 @@ SELECT getObsCodedValue(r.person_a, "3447254f-501f-4b07-815c-cd0f6da98158") as "reasonOfNonInitiation" FROM (SELECT @a:= 0) AS a, relationship r JOIN relationship_type rt ON rt.relationship_type_id = r.relationship AND rt.a_is_to_b = "RELATIONSHIP_BIO_MOTHER" - JOIN patient_identifier pi ON pi.patient_id = r.person_a AND pi.preferred = 1; \ No newline at end of file + JOIN patient_identifier pi ON pi.patient_id = r.person_a AND pi.preferred = 1 +WHERE getPatientAgeInMonthsAtDate(r.person_a, NOW()) <= 24; \ No newline at end of file From 0fc3cbb432255a485ae0b9ff7bfe874db85213ff Mon Sep 17 00:00:00 2001 From: Tresor Mvumbi Date: Mon, 15 Mar 2021 09:25:37 +0200 Subject: [PATCH 08/14] COM-994 Remove filter on period for getTestingEntryPointWithinRepPeriod The function should return the most recent entry point, irrespective of when the entry point was captured --- metadata/reportssql/testing_report_functions.sql | 5 +---- .../sql/georgetownTestingReport.sql | 2 +- 2 files changed, 2 insertions(+), 5 deletions(-) diff --git a/metadata/reportssql/testing_report_functions.sql b/metadata/reportssql/testing_report_functions.sql index 0b02e6f2..d8d48a75 100644 --- a/metadata/reportssql/testing_report_functions.sql +++ b/metadata/reportssql/testing_report_functions.sql @@ -1806,9 +1806,7 @@ DROP FUNCTION IF EXISTS getTestingEntryPointWithinRepPeriod; DELIMITER $$ CREATE FUNCTION getTestingEntryPointWithinRepPeriod( - p_patientId INT(11), - p_startDate DATE, - p_endDate DATE) RETURNS VARCHAR(50) + p_patientId INT(11)) RETURNS VARCHAR(50) DETERMINISTIC BEGIN DECLARE result VARCHAR(50); @@ -1822,7 +1820,6 @@ BEGIN WHERE o.voided = 0 AND o.person_id = p_patientId AND c.uuid = uuidTestingEntryPoint - AND o.date_created BETWEEN p_startDate AND p_endDate ORDER BY o.date_created DESC LIMIT 1; diff --git a/openmrs/apps/reports/GEORGETOWN_TESTING_REPORT/sql/georgetownTestingReport.sql b/openmrs/apps/reports/GEORGETOWN_TESTING_REPORT/sql/georgetownTestingReport.sql index a0d894cb..6608590f 100644 --- a/openmrs/apps/reports/GEORGETOWN_TESTING_REPORT/sql/georgetownTestingReport.sql +++ b/openmrs/apps/reports/GEORGETOWN_TESTING_REPORT/sql/georgetownTestingReport.sql @@ -13,7 +13,7 @@ SELECT getHIVResult(p.patient_id,"#startDate#", "#endDate#") as "result", DATE(getProgramAttributeValueWithinReportingPeriod(p.patient_id, "2000-01-01", "2100-12-31", "2dc1aafd-a708-11e6-91e9-0800270d80ce")) as "dateOfArtInitiation", getObsCodedValue(p.patient_id, "3447254f-501f-4b07-815c-cd0f6da98158") as "reasonOfNonInitiation", - IF(wasHIVTestDoneInANCVisitWithinRepPeriod(p.patient_id, "#startDate#", "#endDate#"),"PMTCT [ANC1-only]",getTestingEntryPointWithinRepPeriod(p.patient_id, "#startDate#", "#endDate#")) as "facilityEntryPoint", + IF(wasHIVTestDoneInANCVisitWithinRepPeriod(p.patient_id, "#startDate#", "#endDate#"),"PMTCT [ANC1-only]",getTestingEntryPointWithinRepPeriod(p.patient_id)) as "facilityEntryPoint", getHIVTestDate(p.patient_id,"#startDate#", "#endDate#") as "dateFinalResultProvidedToPatient" FROM patient p, (SELECT @a:= 0) AS a WHERE getHIVTestDate(p.patient_id, "#startDate#", "#endDate#") IS NOT NULL; \ No newline at end of file From 0f1ce07ec6903466bef5b83e3f9146abff62fdd4 Mon Sep 17 00:00:00 2001 From: Tresor Mvumbi Date: Mon, 15 Mar 2021 11:16:35 +0200 Subject: [PATCH 09/14] COM-988 Include only mothers enrolled in HIV program in PCR report Includes only mothers enrolled in HIV program in PCR report --- .../sql/georgetownPcrReport.sql | 4 ++- .../data/backup-openmrs.sql | 24 ++++++++++--- .../GeorgetownPCRReportTests.java | 35 ++++++++++++++----- 3 files changed, 49 insertions(+), 14 deletions(-) diff --git a/openmrs/apps/reports/GEORGETOWN_PCR_REPORT/sql/georgetownPcrReport.sql b/openmrs/apps/reports/GEORGETOWN_PCR_REPORT/sql/georgetownPcrReport.sql index 4b1d4277..977f8797 100644 --- a/openmrs/apps/reports/GEORGETOWN_PCR_REPORT/sql/georgetownPcrReport.sql +++ b/openmrs/apps/reports/GEORGETOWN_PCR_REPORT/sql/georgetownPcrReport.sql @@ -13,4 +13,6 @@ SELECT FROM (SELECT @a:= 0) AS a, relationship r JOIN relationship_type rt ON rt.relationship_type_id = r.relationship AND rt.a_is_to_b = "RELATIONSHIP_BIO_MOTHER" JOIN patient_identifier pi ON pi.patient_id = r.person_a AND pi.preferred = 1 -WHERE getPatientAgeInMonthsAtDate(r.person_a, NOW()) <= 24; \ No newline at end of file +WHERE + getPatientAgeInMonthsAtDate(r.person_a, NOW()) <= 24 AND + patientHasEnrolledIntoHivProgram(r.person_b) = "Yes"; \ No newline at end of file diff --git a/report-testing-framework/data/backup-openmrs.sql b/report-testing-framework/data/backup-openmrs.sql index 5825510c..ef1c0b5f 100644 --- a/report-testing-framework/data/backup-openmrs.sql +++ b/report-testing-framework/data/backup-openmrs.sql @@ -1685,6 +1685,25 @@ LOCK TABLES `concept_name_tag` WRITE; /*!40000 ALTER TABLE `concept_name_tag` ENABLE KEYS */; UNLOCK TABLES; +DROP TABLE IF EXISTS `patient_program_attribute_history`; +CREATE TABLE `patient_program_attribute_history` ( + `patient_program_attribute_history_id` int(11) NOT NULL AUTO_INCREMENT, + `patient_program_id` int(11) NOT NULL, + `attribute_type_id` int(11) NOT NULL, + `value_reference` text NOT NULL, + `uuid` char(38) NOT NULL, + `creator` int(11) NOT NULL, + `date_created` datetime NOT NULL, + PRIMARY KEY (`patient_program_attribute_history_id`), + UNIQUE KEY `uuid` (`uuid`), + KEY `patient_program_attribute_history_programid_fk` (`patient_program_id`), + KEY `patient_program_attribute_history_attributetype_fk` (`attribute_type_id`), + KEY `patient_program_attribute_history_creator_fk` (`creator`), + CONSTRAINT `patient_program_attribute_history_attributetype_fk` FOREIGN KEY (`attribute_type_id`) REFERENCES `program_attribute_type` (`program_attribute_type_id`), + CONSTRAINT `patient_program_attribute_history_creator_fk` FOREIGN KEY (`creator`) REFERENCES `users` (`user_id`), + CONSTRAINT `patient_program_attribute_history_programid_fk` FOREIGN KEY (`patient_program_id`) REFERENCES `patient_program` (`patient_program_id`) +) ENGINE=InnoDB AUTO_INCREMENT=55 DEFAULT CHARSET=utf8; + -- -- Table structure for table `concept_name_tag_map` -- @@ -13247,9 +13266,7 @@ DELIMITER ; /*!50003 SET sql_mode = 'NO_ENGINE_SUBSTITUTION' */ ; DELIMITER ;; CREATE DEFINER=`root`@`localhost` FUNCTION `getTestingEntryPointWithinRepPeriod`( - p_patientId INT(11), - p_startDate DATE, - p_endDate DATE) RETURNS varchar(50) CHARSET utf8 + p_patientId INT(11)) RETURNS varchar(50) CHARSET utf8 DETERMINISTIC BEGIN DECLARE result VARCHAR(50); @@ -13263,7 +13280,6 @@ BEGIN WHERE o.voided = 0 AND o.person_id = p_patientId AND c.uuid = uuidTestingEntryPoint - AND o.date_created BETWEEN p_startDate AND p_endDate ORDER BY o.date_created DESC LIMIT 1; diff --git a/report-testing-framework/report-testing/src/test/java/org/jembi/bahmni/report_testing/georgetown_reports/GeorgetownPCRReportTests.java b/report-testing-framework/report-testing/src/test/java/org/jembi/bahmni/report_testing/georgetown_reports/GeorgetownPCRReportTests.java index b059a730..23efd1ea 100644 --- a/report-testing-framework/report-testing/src/test/java/org/jembi/bahmni/report_testing/georgetown_reports/GeorgetownPCRReportTests.java +++ b/report-testing-framework/report-testing/src/test/java/org/jembi/bahmni/report_testing/georgetown_reports/GeorgetownPCRReportTests.java @@ -43,10 +43,11 @@ public void childrenWithABiologicalMotherRelationship_shouldBeReported() throws "CAMEROON"); /* record child details */ + LocalDate date10MonthsAgo = new LocalDate().plusMonths(-10); int patientIdChild = testDataGenerator.registration.createPatient( "BAH203002", GenderEnum.MALE, - new LocalDate(2015, 10, 01), + new LocalDate(date10MonthsAgo.getYear(), date10MonthsAgo.getMonthOfYear(), date10MonthsAgo.getDayOfMonth()), "Junior", "Tambwe", null, @@ -75,6 +76,13 @@ public void childrenWithABiologicalMotherRelationship_shouldBeReported() throws ConceptEnum.WHO_STAGE_1, TherapeuticLineEnum.FIRST_LINE, new LocalDate(2020, 1, 3)); + + testDataGenerator.program.enrollPatientIntoHIVProgram( + patientIdMother, + new LocalDate(2020, 1, 2), + ConceptEnum.WHO_STAGE_1, + TherapeuticLineEnum.FIRST_LINE, + new LocalDate(2020, 1, 3)); /* record reason for not starting a treatment */ int encounterId = testDataGenerator.hivTestingAndCounsellingForm.recordHTCResult( @@ -104,8 +112,8 @@ public void childrenWithABiologicalMotherRelationship_shouldBeReported() throws assertEquals(result.size(), 1); assertEquals(result.get(0).get("serialNumber"), "1"); assertEquals(result.get(0).get("uniquePatientId"), "BAH203002"); - assertEquals(result.get(0).get("dateOfBirth"), "2015-10-01"); - assertEquals(result.get(0).get("ageInMonths"), Months.monthsBetween(new LocalDate(2015, 10, 01), LocalDate.now()).getMonths()); + assertEquals(result.get(0).get("dateOfBirth"), date10MonthsAgo.toString()); + assertEquals(result.get(0).get("ageInMonths"), Months.monthsBetween(date10MonthsAgo, LocalDate.now()).getMonths()); assertEquals(result.get(0).get("motherId"), "BAH203001"); assertEquals(result.get(0).get("mothersAddress"), "14 BAMBI STR, NKUM"); assertEquals(result.get(0).get("mothersContact"), "081234567"); @@ -141,20 +149,22 @@ public void twoChildrenWithABiologicalMotherRelationship_shouldAllBeReported() t "CAMEROON"); /* record child details */ + LocalDate date10MonthsAgo = new LocalDate().plusMonths(-10); int patientIdChild1 = testDataGenerator.registration.createPatient( "BAH203002", GenderEnum.MALE, - new LocalDate(2015, 10, 01), + new LocalDate(date10MonthsAgo.getYear(), date10MonthsAgo.getMonthOfYear(), date10MonthsAgo.getDayOfMonth()), "Junior", "Tambwe", null, null ); + LocalDate date12MonthsAgo = new LocalDate().plusMonths(-12); int patientIdChild2 = testDataGenerator.registration.createPatient( "BAH203003", GenderEnum.FEMALE, - new LocalDate(2018, 01, 01), + new LocalDate(date12MonthsAgo.getYear(), date12MonthsAgo.getMonthOfYear(), date12MonthsAgo.getDayOfMonth()), "Eva", "Tambwe", null, @@ -188,6 +198,13 @@ public void twoChildrenWithABiologicalMotherRelationship_shouldAllBeReported() t ConceptEnum.WHO_STAGE_1, TherapeuticLineEnum.FIRST_LINE, new LocalDate(2020, 1, 3)); + + testDataGenerator.program.enrollPatientIntoHIVProgram( + patientIdMother, + new LocalDate(2020, 1, 2), + ConceptEnum.WHO_STAGE_1, + TherapeuticLineEnum.FIRST_LINE, + new LocalDate(2020, 1, 3)); /* record reason for not starting a treatment */ int encounterId = testDataGenerator.hivTestingAndCounsellingForm.recordHTCResult( @@ -218,8 +235,8 @@ public void twoChildrenWithABiologicalMotherRelationship_shouldAllBeReported() t assertEquals(result.get(0).get("serialNumber"), "1"); assertEquals(result.get(0).get("uniquePatientId"), "BAH203002"); - assertEquals(result.get(0).get("dateOfBirth"), "2015-10-01"); - assertEquals(result.get(0).get("ageInMonths"), Months.monthsBetween(new LocalDate(2015, 10, 01), LocalDate.now()).getMonths()); + assertEquals(result.get(0).get("dateOfBirth"), date10MonthsAgo.toString()); + assertEquals(result.get(0).get("ageInMonths"), Months.monthsBetween(date10MonthsAgo, LocalDate.now()).getMonths()); assertEquals(result.get(0).get("motherId"), "BAH203001"); assertEquals(result.get(0).get("mothersAddress"), "14 BAMBI STR, NKUM"); assertEquals(result.get(0).get("mothersContact"), "081234567"); @@ -230,8 +247,8 @@ public void twoChildrenWithABiologicalMotherRelationship_shouldAllBeReported() t assertEquals(result.get(1).get("serialNumber"), "2"); assertEquals(result.get(1).get("uniquePatientId"), "BAH203003"); - assertEquals(result.get(1).get("dateOfBirth"), "2018-01-01"); - assertEquals(result.get(1).get("ageInMonths"), Months.monthsBetween(new LocalDate(2018, 01, 01), LocalDate.now()).getMonths()); + assertEquals(result.get(1).get("dateOfBirth"), date12MonthsAgo.toString()); + assertEquals(result.get(1).get("ageInMonths"), Months.monthsBetween(date12MonthsAgo, LocalDate.now()).getMonths()); assertEquals(result.get(1).get("motherId"), "BAH203001"); assertEquals(result.get(1).get("mothersAddress"), "14 BAMBI STR, NKUM"); assertEquals(result.get(1).get("mothersContact"), "081234567"); From 99ee75f62b5258f69a3579409c5713a1ca2d8d86 Mon Sep 17 00:00:00 2001 From: Tresor Mvumbi Date: Mon, 15 Mar 2021 15:27:16 +0200 Subject: [PATCH 10/14] COM-992 Fix patientIsContact To not use voided relationships when checking if a patient is contact --- metadata/reportssql/index_program_functions.sql | 13 ++++++------- 1 file changed, 6 insertions(+), 7 deletions(-) diff --git a/metadata/reportssql/index_program_functions.sql b/metadata/reportssql/index_program_functions.sql index e79cbe75..f751408a 100644 --- a/metadata/reportssql/index_program_functions.sql +++ b/metadata/reportssql/index_program_functions.sql @@ -141,14 +141,14 @@ CREATE FUNCTION getFirstIndexID( p_contactPatientId INT(11)) RETURNS INT(11) DETERMINISTIC BEGIN - DECLARE result TEXT DEFAULT 0; + DECLARE result INT(11); SELECT p.patient_id INTO result FROM patient p WHERE patientsAreRelated(p_contactPatientId, p.patient_id) AND patientIsIndex(p.patient_id) - ORDER BY p.date_created ASC - LIMIT 1; + ORDER BY p.date_created ASC + LIMIT 1; RETURN (result); END$$ @@ -191,10 +191,9 @@ BEGIN SELECT TRUE INTO result FROM relationship r - JOIN person pIndex ON (r.person_a = p_contactId AND r.person_b = pIndex.person_id) OR - (r.person_a = pIndex.person_id AND r.person_b = p_contactId) - WHERE - patientIsIndex(pIndex.person_id) + JOIN person pIndex ON (r.person_a = p_contactId AND r.person_b = pIndex.person_id AND patientIsIndex(r.person_b)) OR + (r.person_a = pIndex.person_id AND r.person_b = p_contactId AND patientIsIndex(r.person_a)) + WHERE r.voided = 0 LIMIT 1; RETURN (result); From a520e9da4bf9dc19c0c45c596b1da09af7af61bc Mon Sep 17 00:00:00 2001 From: Tresor Mvumbi Date: Wed, 17 Mar 2021 10:47:15 +0200 Subject: [PATCH 11/14] COM-996 Add column "TB Diagnostic Result" to TB Form Adds column "TB Diagnostic Result" to TB Form --- metadata/configuration/concepts/1280_TB_form.csv | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/metadata/configuration/concepts/1280_TB_form.csv b/metadata/configuration/concepts/1280_TB_form.csv index 1f77a977..d5172a9a 100644 --- a/metadata/configuration/concepts/1280_TB_form.csv +++ b/metadata/configuration/concepts/1280_TB_form.csv @@ -21,6 +21,7 @@ a196e44f-7911-4942-b586-b59cf79c202f,,,Site extrapulmonaire,Extrapulmonary site, 41bde817-b2e0-4f58-88be-f875e7b31eed,,,Confirmé bactériologiquement,Bacteriologically Confirmed,Confirmé bactériologiquement,Bacteriologically Confirmed,Misc,N/A,, c1e4f600-2cdd-4ce0-a687-af76e9e20721,,,"Non confirmé, diag cliniquement","Non-confirmed, clinically diag","Non confirmé, diag cliniquement","Non-confirmed, clinically diag",Misc,N/A,, c4bbc310-2e01-4c6d-be90-decc1b91a800,,"Bacteriologically Confirmed;Non-confirmed, clinically diag",Confirmation MTB,MTB confirmation,Confirmation MTB,MTB confirmation,Misc,Coded,, +6ab25a03-6ac3-45f1-aa04-af54186411e0,,Positive;Negative,Résultat Diagnostic TB,TB Diagnostic Result,Résultat Diagnostic TB,TB Diagnostic Result,Misc,Coded,, 91884f8a-36fe-4974-85bc-6b8b5c1c9da1,,,Prélèvement,Smear,Prélèvement,Smear,Misc,N/A,, 3f80913f-0d3e-43be-b033-324e8e351dc7,,,Xpert MTB/RIF,Xpert MTB/RIF,Xpert MTB/RIF,Xpert MTB/RIF,Misc,N/A,, 6ad904f9-8bb2-4dfa-b3a2-579e7e798f6b,,,Test de Hain,Hain test,Test de Hain,Hain test,Misc,N/A,, @@ -45,5 +46,5 @@ ae1baeb2-4e9b-4500-bdc8-39cd40f91715,,,Évaluation de 2 semaines,2 week assessme 7a4d5ae7-8d76-435d-84f1-ff4248304927,,,Évaluation mensuelle planifiée,Planned monthly assessment,Évaluation mensuelle planifiée,Planned monthly assessment,Misc,N/A,, 29c66c54-716b-4df1-adb0-db74c0c42c22,,,Autre évaluation,Other assessment,Autre évaluation,Other assessment,Misc,N/A,, ec81acc9-b48c-4497-9916-fe5d2bdf9193,,2 week assessment;Planned monthly assessment;Other assessment,Raison de la prochaine visite,Reason for next visit,Raison de la prochaine visite,Reason for next visit,Misc,Coded,, -9f22febc-7826-4550-9174-3e31ae95cc2c,WHO registration group;Previously treated group;Disease site;Extrapulmonary site;MTB confirmation;Method of confirmation;Other method of confirmation;Drug resistance profile;Sub-class of drug resistance profile;MDR-TB diagnosis date;Reason for next visit,,Définition du Cas,Case Definition,Définition du Cas,Case Definition,Misc,N/A,, +9f22febc-7826-4550-9174-3e31ae95cc2c,WHO registration group;Previously treated group;Disease site;Extrapulmonary site;MTB confirmation;TB Diagnostic Result;Method of confirmation;Other method of confirmation;Drug resistance profile;Sub-class of drug resistance profile;MDR-TB diagnosis date;Reason for next visit,,Définition du Cas,Case Definition,Définition du Cas,Case Definition,Misc,N/A,, 3804e2cc-dd14-4879-88d2-94391853f7fb,Date baseline assessment;Screened;Cough > 2 weeks;Fever > 2 weeks;Weight Loss;Night Sweats;TB Contact;Malnutrition;TB Status;3dce13a8-c7e5-45ec-a6f0-8050fd4a2ca2;Case Definition,,Formulaire TB,TB Form,Formulaire TB,TB Form,Misc,N/A,, \ No newline at end of file From aa114dccce899be6b52435c473bc6ff1414e61e2 Mon Sep 17 00:00:00 2001 From: Tresor Mvumbi Date: Wed, 17 Mar 2021 16:50:38 +0200 Subject: [PATCH 12/14] COM-997 Add columns TB Diagnostic Result and Date to TB Report Adds columns TB Diagnostic Result and Date to TB Report --- .../sql/georgetownTbReport.sql | 2 ++ .../template/georgetownTbReport.xls | Bin 60928 -> 61440 bytes .../GeorgetownTBReportTests.java | 2 +- .../test_utils/TBFormDataGenerator.java | 14 ++++++++++++++ 4 files changed, 17 insertions(+), 1 deletion(-) diff --git a/openmrs/apps/reports/GEORGETOWN_TB_REPORT/sql/georgetownTbReport.sql b/openmrs/apps/reports/GEORGETOWN_TB_REPORT/sql/georgetownTbReport.sql index cb389ecf..58d832b0 100644 --- a/openmrs/apps/reports/GEORGETOWN_TB_REPORT/sql/georgetownTbReport.sql +++ b/openmrs/apps/reports/GEORGETOWN_TB_REPORT/sql/georgetownTbReport.sql @@ -8,6 +8,8 @@ SELECT getPatientPhoneNumber(p.patient_id) as "telephone", getMostRecentCodedObservation(p.patient_id,"Method of confirmation","en") as "Type of Exam", getDateTBPosDiagnose(p.patient_id) as "dateTBPosDiag", + getMostRecentCodedObservation(p.patient_id,"TB Diagnostic Result","en") as "tbDiagnosticResult", + getMostRecentDateObservation(p.patient_id,"MDR-TB diagnosis date") as "tbDiagnosticDate", getProgramAttributeDateValueFromAttributeAndProgramName(p.patient_id, "PROGRAM_MANAGEMENT_2_PATIENT_TREATMENT_DATE", "TB_PROGRAM_KEY") as "dateOfTxTbStart", getHIVTestDate(p.patient_id,"2000-01-01","2100-01-01") as "dateOfHivTesting", getHIVResult(p.patient_id,"2000-01-01","2100-01-01") as "hivTestingResult", diff --git a/openmrs/apps/reports/GEORGETOWN_TB_REPORT/template/georgetownTbReport.xls b/openmrs/apps/reports/GEORGETOWN_TB_REPORT/template/georgetownTbReport.xls index 40fdd1316b9cf1da9529fa23cdbe7ee9fccd3232..0f0aaeaec63ba9ff430ed2dbff1f71796712cfe8 100644 GIT binary patch delta 6053 zcmbtYdtB7jwqJYyW`=>`F$jVlNCp%UMFo+kihyW7P!L~erdT39R1h%>Pr~(69X0hJ z%X6$WAWtR7)U?S$jt4QbEZ=73edr;t9Us?DnPwT8tZDC@1;2#V# zL@$msga$M;CofUeoiJW$oGXl~X5fK>G`*(%A5PwBPiNj{E0M`a^YYlo)X(ZiG_(BH z%F=S%)Y-G9W>4ZQ(;Ut>dGkxAS!PGoY2m1{=GpI=j%Zpq8F{c@gfQ`BzX8IFOZ}pS zng8H7SPbS?zjP7H|Ld0^;&`Zkwiv=?{wc;pdYwXfg(ZYf`}EV^pm4pcSq5ou(gP^> z<6KLW*v+MuT+zr!EKiF+bCPd@wudsg1+@diDvBL6n9P*+B#|!+Bq1Tq7+5G$?l$-h@McL=V!u%Fu5ZTSGhaO!zVy8} z#vZ$taA$OpzYm%?Q^JarIOFvRNitzB7KtHrK5FCv&tew8b9 zI)L+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uj|1cI`GRZ;yGoyc_?qJC5eZ_lSZ4tx9*dD5zCJ&vlD$2wFU_5@*h8c^`4y4vrVp zb{Oyjh3o5y3xc|*HC;n`^xUr#;RTh=HJ7<^yaUzMRiRc}o zW}*{Byz!|XjyIcYY&+e0!Xn-!Eq-_++Vvqf6Lk{-!|@%(>{mS8@eFo#h$vpkGw7E5 zt0@2X)Bd|%4opSD?!4#0;&4SWYLgXp&9Yj4a=J+_j=^t9C`c_-s&_OSen!7 z<=#`@+gA`~I=1-6eM6UUd>^TQ*;Nj-rp2hVZRTI@DcH;$=;_ zj)wRE?@O6-H26tvuWIadtZZ7T+D)pRfXlaJI8$zeTwU!D{T@>A%;Qg4E}vu&F8FpA zUi@|l4!P;W{)Vr9=&2(M1>N>wV~3X%a^aubS2*=HJet7Nh23p9HMqiISVVqDVLo=FRsIzE4u;FGFIR=p=M2h{ z8_S)C(dQk40Y2;~v6Y6>ul?hA(Fi9K=MlssiH7&cBZx;6jU=K~moX;k?$>%&ou7b~ z^Q}1TuQ^iACqFCc?}p5_AS`Z+#G`E<9^|XvLo)zuX)}2aIwWZ|hN0p@n)jd>kY%pm zgDb0jaoL4f&p|f;vRC4}7v?$h!=Cr%gTak{)%iuZSS^p{&_bL{#x1s~jdv*W1)r~D@U*ZZx?WV@bo9x*Es zKr&0BD4)Uf&zDLqpT9478|gUe?hX+I8bp|&pmzifNI`cIcWk&cL|I7|S1!5CrGtpu z`J=&aF3qP~o*r9oelm6Rq@+=CW5y)LrKTs2?n@yqnzZbcyxR;Aqis=Qp{-+u-1X%c8lCyQeO!;3V1^uVw*U#m5VOxJl6RwGv{=;Q4 zh@4>Xk3mee^-cxdxhn6hRL0VZzkshMXX1trT=CHXHU4nOi7vU%^^> conceptTree= new ArrayList(); + conceptTree.add(ConceptEnum.TB_FORM); + conceptTree.add(ConceptEnum.TB_DIAGNOSTIC_RESULT); + return TestDataGenerator.recordFormCodedValue(patientId, obsDateTime, conceptTree, value, encounterId, stmt); + } + + public int setTBDiagnosticDate(int patientId, LocalDateTime obsDateTime, LocalDate tbDiagnosticDate, Integer encounterId) throws Exception { + List conceptTree= new ArrayList(); + conceptTree.add(ConceptEnum.TB_FORM); + conceptTree.add(ConceptEnum.TB_DIAGNOSTIC_DATE); + return TestDataGenerator.recordFormDatetimeValue(patientId, obsDateTime, conceptTree, tbDiagnosticDate, encounterId, stmt); + } + public int setTBScreeningResult(int patientId, LocalDateTime obsDateTime, ConceptEnum result, Integer encounterId) throws Exception { List conceptTree= new ArrayList(); conceptTree.add(ConceptEnum.TB_FORM); From 470c7de71c61ed878f0afcd115a011c655627e51 Mon Sep 17 00:00:00 2001 From: Tresor Mvumbi Date: Wed, 17 Mar 2021 16:56:45 +0200 Subject: [PATCH 13/14] COM-997 Fix unit tests Fixes broken unit tests --- .../bahmni/report_testing/test_utils/models/ConceptEnum.java | 2 ++ 1 file changed, 2 insertions(+) diff --git a/report-testing-framework/report-testing/src/test/java/org/jembi/bahmni/report_testing/test_utils/models/ConceptEnum.java b/report-testing-framework/report-testing/src/test/java/org/jembi/bahmni/report_testing/test_utils/models/ConceptEnum.java index ff95ce1f..be6d50ff 100644 --- a/report-testing-framework/report-testing/src/test/java/org/jembi/bahmni/report_testing/test_utils/models/ConceptEnum.java +++ b/report-testing-framework/report-testing/src/test/java/org/jembi/bahmni/report_testing/test_utils/models/ConceptEnum.java @@ -31,6 +31,8 @@ public enum ConceptEnum { NO("b497171e-0410-4d8d-bbd4-7e1a8f8b504e"), DATE_BASELINE_ASSESSMENT("1d4a6dc4-c478-4021-982b-62e3c84f7857"), SCREENED("f0447183-d13f-463d-ad0f-1f45b99d97cc"), + TB_DIAGNOSTIC_RESULT("6ab25a03-6ac3-45f1-aa04-af54186411e0"), + TB_DIAGNOSTIC_DATE("f79780e8-72de-4162-be89-dd908ab2e5bb"), TB_STATUS("61931c8b-0637-40f9-97dc-07796431dd3b"), SUSPECTED_PROBABLE("ae0ad7b8-2e9b-4731-9563-137382f376d5"), REFUSED_STOPPED_TREATMENT("c53ea2a6-4d8f-4f3d-b6b1-f8eeda8864b4"), From a15df61ccc6ae2aacb29b0c91c8f0493cc74dd3c Mon Sep 17 00:00:00 2001 From: Tresor Mvumbi Date: Thu, 18 Mar 2021 10:11:57 +0200 Subject: [PATCH 14/14] COM-997 Include only patients with TB suspected in TB report Includes only patients with TB suspected in TB report --- .../reports/GEORGETOWN_TB_REPORT/sql/georgetownTbReport.sql | 2 +- .../georgetown_reports/GeorgetownTBReportTests.java | 6 ++++++ 2 files changed, 7 insertions(+), 1 deletion(-) diff --git a/openmrs/apps/reports/GEORGETOWN_TB_REPORT/sql/georgetownTbReport.sql b/openmrs/apps/reports/GEORGETOWN_TB_REPORT/sql/georgetownTbReport.sql index 58d832b0..9faa5025 100644 --- a/openmrs/apps/reports/GEORGETOWN_TB_REPORT/sql/georgetownTbReport.sql +++ b/openmrs/apps/reports/GEORGETOWN_TB_REPORT/sql/georgetownTbReport.sql @@ -17,4 +17,4 @@ SELECT FROM patient p, (SELECT @a:= 0) AS a WHERE getDateTBPosDiagnose(p.patient_id) IS NOT NULL AND - getObsCodedValue(p.patient_id, "f0447183-d13f-463d-ad0f-1f45b99d97cc") LIKE "Yes%"; \ No newline at end of file + getObsCodedValue(p.patient_id, "61931c8b-0637-40f9-97dc-07796431dd3b") = "Suspected / Probable"; \ No newline at end of file diff --git a/report-testing-framework/report-testing/src/test/java/org/jembi/bahmni/report_testing/georgetown_reports/GeorgetownTBReportTests.java b/report-testing-framework/report-testing/src/test/java/org/jembi/bahmni/report_testing/georgetown_reports/GeorgetownTBReportTests.java index f4f23a2a..72c0d9bf 100644 --- a/report-testing-framework/report-testing/src/test/java/org/jembi/bahmni/report_testing/georgetown_reports/GeorgetownTBReportTests.java +++ b/report-testing-framework/report-testing/src/test/java/org/jembi/bahmni/report_testing/georgetown_reports/GeorgetownTBReportTests.java @@ -74,6 +74,12 @@ public void patientThatIsScreenedAndTBPositive_shouldBeIncludedToTheReport() thr ConceptEnum.YES, encounterId); + testDataGenerator.tbForm.setTBScreeningResult( + patientId, + new LocalDateTime(2020, 1, 6, 10, 0), + ConceptEnum.SUSPECTED_PROBABLE, + encounterId); + testDataGenerator.tbForm.setMTBConfirmation( patientId, new LocalDateTime(2020, 1, 6, 10, 0),