Skip to content

Poc 496 #1444

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

Merged
merged 6 commits into from
Jun 13, 2025
Merged

Poc 496 #1444

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
4 changes: 3 additions & 1 deletion etl-routes.js
Original file line number Diff line number Diff line change
Expand Up @@ -79,9 +79,11 @@ import { DefaulterListService } from './service/defaulter-list-service';
import { ClinicFlowService } from './service/clinic-flow-service';
import { getPatientCovidVaccinationStatus } from './service/covid-19/covid-19-vaccination-summary';
import { Covid19MonthlyReport } from './service/covid-19/covid-19-monthly-report';
import { MlWeeklyPredictionsService } from './service/ml-weekly-predictions.service';
import { getPatientPredictedScore } from './service/predictions/ml-prediction-service';
import { CohortModuleService } from './app/otz/cohort-module.service';
const {
default: MlWeeklyPredictionsService
} = require('./service/ml-weekly-predictions.service');

module.exports = (function () {
var routes = [
Expand Down
27 changes: 25 additions & 2 deletions programs/patient-data-resolver.service.js
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,11 @@ const etlHivSummary = require('../dao/patient/etl-patient-hiv-summary-dao');
const encounterService = require('../service/openmrs-rest/encounter');
const dcPatientvisitEvaluator = require('../service/dc-patient-visit-evaluator');
const covidAssessmentService = require('../service/covid-assessment-service');
const weeklyPredictionsService = require('../service/ml-weekly-predictions.service');
var _ = require('underscore');
const {
default: MlWeeklyPredictionsService
} = require('../service/ml-weekly-predictions.service');

const availableKeys = {
patient: getPatient,
Expand All @@ -20,7 +24,8 @@ const availableKeys = {
dcQualifedVisits: getQualifiedDcVisits,
validateMedicationRefill: getMedicationRefillVisits,
latestCovidAssessment: getLatestCovidAssessment,
isViremicHighVL: getLatestVL
isViremicHighVL: getLatestVL,
weeklyPredictedPatients: getWeeklyPredictedPatients
};

const def = {
Expand All @@ -35,7 +40,8 @@ const def = {
dcQualifedVisits: getQualifiedDcVisits,
validateMedicationRefill: getMedicationRefillVisits,
getLatestCovidAssessment: getLatestCovidAssessment,
isViremicHighVL: getLatestVL
isViremicHighVL: getLatestVL,
getWeeklyPredictedPatients: getWeeklyPredictedPatients
};

module.exports = def;
Expand Down Expand Up @@ -257,3 +263,20 @@ function getLatestVL(patientUuid) {
});
});
}

function getWeeklyPredictedPatients(patientUuid) {
return new Promise((resolve, reject) => {
let ml = new MlWeeklyPredictionsService();
ml.getPatientsWithPredictions(patientUuid)
.then((result) => {
if (result.length > 0) {
resolve(result);
} else {
resolve([]);
}
})
.catch((error) => {
reject(error);
});
});
}
72 changes: 45 additions & 27 deletions programs/patient-program-config.json
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,8 @@
"enrollment",
"patientEncounters",
"isPatientTransferredOut",
"latestCovidAssessment"
"latestCovidAssessment",
"weeklyPredictedPatients"
],
"enrollmentOptions": {
"requiredProgramQuestions": [
Expand Down Expand Up @@ -806,7 +807,7 @@
{
"uuid": "6bdec0cd-d3fb-41da-9ef3-20076f349dc1",
"name": "Pre Appointment Follow Up Visit",
"allowedIf": "programLocation === intendedVisitLocationUuid && MlLocations",
"allowedIf": "programLocation === intendedVisitLocationUuid && inPrediction",
"encounterTypes": [
{
"uuid": "d5e2d3b3-2061-4721-86f1-5852cde6475a",
Expand Down Expand Up @@ -1258,7 +1259,8 @@
"patientEnrollment",
"patientEncounters",
"isPatientTransferredOut",
"latestCovidAssessment"
"latestCovidAssessment",
"weeklyPredictedPatients"
],
"enrollmentOptions": {
"enrollIf": "gender === 'F'",
Expand Down Expand Up @@ -1968,7 +1970,7 @@
{
"uuid": "6bdec0cd-d3fb-41da-9ef3-20076f349dc1",
"name": "Pre Appointment Follow Up Visit",
"allowedIf": "programLocation === intendedVisitLocationUuid && MlLocations",
"allowedIf": "programLocation === intendedVisitLocationUuid && inPrediction",
"encounterTypes": [
{
"uuid": "d5e2d3b3-2061-4721-86f1-5852cde6475a",
Expand Down Expand Up @@ -2214,7 +2216,8 @@
"enrollment",
"hivLastTenClinicalEncounters",
"patientEncounters",
"latestCovidAssessment"
"latestCovidAssessment",
"weeklyPredictedPatients"
],
"enrollmentOptions": {
"requiredProgramQuestions": [
Expand Down Expand Up @@ -2383,7 +2386,7 @@
{
"uuid": "6bdec0cd-d3fb-41da-9ef3-20076f349dc1",
"name": "Pre Appointment Follow Up Visit",
"allowedIf": "programLocation === intendedVisitLocationUuid && MlLocations",
"allowedIf": "programLocation === intendedVisitLocationUuid && inPrediction",
"encounterTypes": [
{
"uuid": "d5e2d3b3-2061-4721-86f1-5852cde6475a",
Expand Down Expand Up @@ -2419,14 +2422,17 @@
}
]
},

"c19aec66-1a40-4588-9b03-b6be55a8dd1d": {
"name": "PrEP PROGRAM",
"dataDependencies": [
"patient",
"enrollment",
"hivLastTenClinicalEncounters",
"patientEncounters",
"latestCovidAssessment"
"latestCovidAssessment",
"weeklyPredictedPatients",
"weeklyPredictedPatients"
],
"enrollmentOptions": {
"requiredProgramQuestions": [
Expand Down Expand Up @@ -2611,7 +2617,7 @@
{
"uuid": "6bdec0cd-d3fb-41da-9ef3-20076f349dc1",
"name": "Pre Appointment Follow Up Visit",
"allowedIf": "MlLocations",
"allowedIf": "inPrediction",
"encounterTypes": [
{
"uuid": "d5e2d3b3-2061-4721-86f1-5852cde6475a",
Expand Down Expand Up @@ -2649,7 +2655,8 @@
"patient",
"enrollment",
"hivLastTenClinicalEncounters",
"latestCovidAssessment"
"latestCovidAssessment",
"weeklyPredictedPatients"
],
"enrollmentOptions": {
"requiredProgramQuestions": [
Expand Down Expand Up @@ -2812,7 +2819,7 @@
{
"uuid": "6bdec0cd-d3fb-41da-9ef3-20076f349dc1",
"name": "Pre Appointment Follow Up Visit",
"allowedIf": "MlLocations",
"allowedIf": "inPrediction",
"encounterTypes": [
{
"uuid": "d5e2d3b3-2061-4721-86f1-5852cde6475a",
Expand Down Expand Up @@ -2907,7 +2914,8 @@
"isPatientTransferredOut",
"dcQualifedVisits",
"validateMedicationRefill",
"latestCovidAssessment"
"latestCovidAssessment",
"weeklyPredictedPatients"
],
"enrollmentOptions": {
"requiredProgramQuestions": [
Expand Down Expand Up @@ -3189,7 +3197,7 @@
{
"uuid": "6bdec0cd-d3fb-41da-9ef3-20076f349dc1",
"name": "Pre Appointment Follow Up Visit",
"allowedIf": "programLocation === intendedVisitLocationUuid && MlLocations",
"allowedIf": "programLocation === intendedVisitLocationUuid && inPrediction",
"encounterTypes": [
{
"uuid": "d5e2d3b3-2061-4721-86f1-5852cde6475a",
Expand Down Expand Up @@ -4108,7 +4116,8 @@
"dataDependencies": [
"patient",
"enrollment",
"hivLastTenClinicalEncounters"
"hivLastTenClinicalEncounters",
"weeklyPredictedPatients"
],
"enrollmentOptions": {
"requiredProgramQuestions": [
Expand Down Expand Up @@ -4212,7 +4221,7 @@
{
"uuid": "6bdec0cd-d3fb-41da-9ef3-20076f349dc1",
"name": "Pre Appointment Follow Up Visit",
"allowedIf": "programLocation === intendedVisitLocationUuid && MlLocations",
"allowedIf": "programLocation === intendedVisitLocationUuid && inPrediction",
"encounterTypes": [
{
"uuid": "d5e2d3b3-2061-4721-86f1-5852cde6475a",
Expand Down Expand Up @@ -4245,7 +4254,8 @@
"dataDependencies": [
"patient",
"enrollment",
"hivLastTenClinicalEncounters"
"hivLastTenClinicalEncounters",
"weeklyPredictedPatients"
],
"enrollmentOptions": {
"requiredProgramQuestions": [
Expand Down Expand Up @@ -4351,7 +4361,7 @@
{
"uuid": "6bdec0cd-d3fb-41da-9ef3-20076f349dc1",
"name": "Pre Appointment Follow Up Visit",
"allowedIf": "MlLocations",
"allowedIf": "inPrediction",
"encounterTypes": [
{
"uuid": "d5e2d3b3-2061-4721-86f1-5852cde6475a",
Expand Down Expand Up @@ -4487,7 +4497,8 @@
"isPatientTransferredOut",
"patientEncounters",
"latestCovidAssessment",
"isViremicHighVL"
"isViremicHighVL",
"weeklyPredictedPatients"
],
"enrollmentOptions": {
"requiredProgramQuestions": [
Expand Down Expand Up @@ -4725,7 +4736,7 @@
{
"uuid": "6bdec0cd-d3fb-41da-9ef3-20076f349dc1",
"name": "Pre Appointment Follow Up Visit",
"allowedIf": "MlLocations",
"allowedIf": "inPrediction",
"encounterTypes": [
{
"uuid": "d5e2d3b3-2061-4721-86f1-5852cde6475a",
Expand Down Expand Up @@ -4766,7 +4777,8 @@
"dataDependencies": [
"patient",
"enrollment",
"hivLastTenClinicalEncounters"
"hivLastTenClinicalEncounters",
"weeklyPredictedPatients"
],
"enrollmentOptions": {
"stateChangeEncounterTypes": {
Expand Down Expand Up @@ -4832,7 +4844,8 @@
"dataDependencies": [
"patient",
"enrollment",
"hivLastTenClinicalEncounters"
"hivLastTenClinicalEncounters",
"weeklyPredictedPatients"
],
"enrollmentOptions": {
"requiredProgramQuestions": [
Expand Down Expand Up @@ -4978,7 +4991,7 @@
{
"uuid": "6bdec0cd-d3fb-41da-9ef3-20076f349dc1",
"name": "Pre Appointment Follow Up Visit",
"allowedIf": "MlLocations",
"allowedIf": "inPrediction",
"encounterTypes": [
{
"uuid": "d5e2d3b3-2061-4721-86f1-5852cde6475a",
Expand Down Expand Up @@ -5047,7 +5060,8 @@
"dataDependencies": [
"patient",
"enrollment",
"hivLastTenClinicalEncounters"
"hivLastTenClinicalEncounters",
"weeklyPredictedPatients"
],
"incompatibleWith": [],
"visitTypes": [
Expand Down Expand Up @@ -5082,7 +5096,7 @@
{
"uuid": "6bdec0cd-d3fb-41da-9ef3-20076f349dc1",
"name": "Pre Appointment Follow Up Visit",
"allowedIf": "programLocation === intendedVisitLocationUuid && MlLocations",
"allowedIf": "programLocation === intendedVisitLocationUuid && inPrediction",
"encounterTypes": [
{
"uuid": "d5e2d3b3-2061-4721-86f1-5852cde6475a",
Expand Down Expand Up @@ -5441,7 +5455,8 @@
"patient",
"enrollment",
"patientEncounters",
"isPatientTransferredOut"
"isPatientTransferredOut",
"weeklyPredictedPatients"
],
"enrollmentOptions": {
"requiredProgramQuestions": [
Expand Down Expand Up @@ -5507,7 +5522,8 @@
"patient",
"enrollment",
"patientEncounters",
"patientEnrollment"
"patientEnrollment",
"weeklyPredictedPatients"
],
"enrollmentOptions": {
"enrollIf": "gender === 'F'"
Expand Down Expand Up @@ -5599,7 +5615,8 @@
"patient",
"enrollment",
"patientEncounters",
"patientEnrollment"
"patientEnrollment",
"weeklyPredictedPatients"
],
"enrollmentOptions": {
"enrollIf": "gender === 'F'"
Expand Down Expand Up @@ -5703,7 +5720,8 @@
"patient",
"enrollment",
"patientEncounters",
"patientEnrollment"
"patientEnrollment",
"weeklyPredictedPatients"
],
"enrollmentOptions": {
"enrollIf": "gender === 'F'"
Expand Down
10 changes: 9 additions & 1 deletion programs/scope-builder.service.js
Original file line number Diff line number Diff line change
Expand Up @@ -18,10 +18,18 @@ function buildScope(dataDictionary) {
screenedForCovidToday: false,
isViremicHighVL: false,
isEligibleForMedicationRefill: false,
isEligibleForCommunityVisit: false
isEligibleForCommunityVisit: false,
inPrediction: false
};

let isStandardDcVisit = false;

if (
dataDictionary.weeklyPredictedPatients &&
dataDictionary.weeklyPredictedPatients.length > 0
) {
scope.inPrediction = true;
}
// Restrict to Pilot locations
scope.MlLocations = [
'08feb8ae-1352-11df-a1f1-0026b9348838',
Expand Down
Loading