Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fixed bug on clients eligible for VL indicator query for realtime fac… #2125

Merged
merged 1 commit into from
Mar 11, 2025
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
Original file line number Diff line number Diff line change
Expand Up @@ -211,7 +211,7 @@ public static Long getPregnantPostpartumNotInPrep() {

/**
* Surveillance dashboards
* 3. Delayed viral load testing. Eligible without VL test taken
* Clients eligible for VL test
* @return long value
*/
public static Long getEligibleForVl() {
Expand Down Expand Up @@ -269,31 +269,7 @@ public static Long getEligibleForVl() {
" TIMESTAMPDIFF(MONTH, v.date_test_requested, DATE_SUB(CURRENT_DATE, INTERVAL 7 DAY)) >=\n" +
" 12) and\n" +
" v.vl_result < 200) -- PG & BF after PG/BF baseline < 200\n" +
") b on e.patient_id = b.patient_id;\n" +
"\n" +
"-- Eligible for VL sample not taken\n" +
"select count(v.patient_id) as eligible_for_vl\n" +
"from kenyaemr_etl.etl_viral_load_validity_tracker v\n" +
" inner join kenyaemr_etl.etl_patient_demographics d on v.patient_id = d.patient_id\n" +
"where ((TIMESTAMPDIFF(MONTH, v.date_started_art, DATE_SUB(CURRENT_DATE, INTERVAL 7 DAY)) >= 3 and\n" +
" v.base_viral_load_test_result is null) -- First VL new on ART\n" +
" OR ((v.pregnancy_status = 1065 or v.breastfeeding_status = 1065) and\n" +
" TIMESTAMPDIFF(MONTH, v.date_started_art, DATE_SUB(CURRENT_DATE, INTERVAL 7 DAY)) >= 3 and\n" +
" (v.vl_result is not null and v.date_test_requested < v.latest_hiv_followup_visit)) -- immediate for PG & BF\n" +
" OR (v.vl_result >= 200 AND\n" +
" TIMESTAMPDIFF(MONTH, v.date_test_requested, DATE_SUB(CURRENT_DATE, INTERVAL 7 DAY)) >= 3) -- Unsuppressed VL\n" +
" OR (v.vl_result < 200 AND\n" +
" TIMESTAMPDIFF(MONTH, v.date_test_requested, DATE_SUB(CURRENT_DATE, INTERVAL 7 DAY)) >= 6 and\n" +
" TIMESTAMPDIFF(YEAR, v.date_test_requested, d.DOB) BETWEEN 0 AND 24) -- 0-24 with last suppressed vl\n" +
" OR (v.vl_result < 200 AND\n" +
" TIMESTAMPDIFF(MONTH, v.date_test_requested, DATE_SUB(CURRENT_DATE, INTERVAL 7 DAY)) >= 12 and\n" +
" TIMESTAMPDIFF(YEAR, v.date_test_requested, d.DOB) > 24) -- > 24 with last suppressed vl\n" +
" OR ((v.pregnancy_status = 1065 or v.breastfeeding_status = 1065) and\n" +
" TIMESTAMPDIFF(MONTH, v.date_started_art, DATE_SUB(CURRENT_DATE, INTERVAL 7 DAY)) >= 3\n" +
" and (v.order_reason in (159882, 1434) and\n" +
" TIMESTAMPDIFF(MONTH, v.date_test_requested, DATE_SUB(CURRENT_DATE, INTERVAL 7 DAY)) >= 12) and\n" +
" v.vl_result < 200)) -- PG & BF after PG/BF baseline < 200\n" +
" and v.latest_hiv_followup_visit != v.date_test_requested;";
") b on e.patient_id = b.patient_id;";

try {
Context.addProxyPrivilege(PrivilegeConstants.SQL_LEVEL_ACCESS);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -917,11 +917,11 @@ public CohortDefinition eligibleForVLSampleNotTaken() {
" v.vl_result < 200)) -- PG & BF after PG/BF baseline < 200\n" +
" and v.latest_hiv_followup_visit > v.date_test_requested;\n";
SqlCohortDefinition cd = new SqlCohortDefinition();
cd.setName("allSuppressedWithoutEAC");
cd.setName("eligibleForVLSampleNotTaken");
cd.setQuery(sqlQuery);
cd.addParameter(new Parameter("startDate", "Start Date", Date.class));
cd.addParameter(new Parameter("endDate", "End Date", Date.class));
cd.setDescription("Patients with unsuppressed without Enhanced Adherence Counseling");
cd.setDescription("Patients Eligible for VL, no sample taken during last visit");
return cd;
}

Expand Down