Skip to content

Commit

Permalink
Restrict pre-appointment visit
Browse files Browse the repository at this point in the history
  • Loading branch information
Angie-540 committed Sep 13, 2023
1 parent 899f739 commit 7365f1f
Show file tree
Hide file tree
Showing 5 changed files with 107 additions and 34 deletions.
4 changes: 3 additions & 1 deletion etl-routes.js
Original file line number Diff line number Diff line change
Expand Up @@ -79,8 +79,10 @@ 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';
const {
default: MlWeeklyPredictionsService
} = require('./service/ml-weekly-predictions.service');

module.exports = (function () {
var routes = [
Expand Down
19 changes: 17 additions & 2 deletions programs/patient-data-resolver.service.js
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +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 MlWeeklyPredictionsService = require('..service/ml-weekly-predictions.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 Down Expand Up @@ -202,4 +205,16 @@ function getLatestCovidAssessment(patientUuid) {
});
}

function getWeeklyPredictedPatients(patientUuid, week) {}
function getWeeklyPredictedPatients(patientUuid) {
console.log('patientuuid:', patientUuid);
return new Promise((resolve, reject) => {
let ml = new MlWeeklyPredictionsService();
ml.getPatientsWithPredictions(patientUuid).then((result) => {
if (result.length > 0) {
resolve(result);
} else {
resolve([]);
}
});
});
}
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 @@ -816,7 +817,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 @@ -1268,7 +1269,8 @@
"patientEnrollment",
"patientEncounters",
"isPatientTransferredOut",
"latestCovidAssessment"
"latestCovidAssessment",
"weeklyPredictedPatients"
],
"enrollmentOptions": {
"enrollIf": "gender === 'F'",
Expand Down Expand Up @@ -2010,7 +2012,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 @@ -2211,7 +2213,8 @@
"enrollment",
"hivLastTenClinicalEncounters",
"patientEncounters",
"latestCovidAssessment"
"latestCovidAssessment",
"weeklyPredictedPatients"
],
"enrollmentOptions": {
"requiredProgramQuestions": [
Expand Down Expand Up @@ -2400,7 +2403,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 @@ -2436,14 +2439,17 @@
}
]
},

"c19aec66-1a40-4588-9b03-b6be55a8dd1d": {
"name": "PrEP PROGRAM",
"dataDependencies": [
"patient",
"enrollment",
"hivLastTenClinicalEncounters",
"patientEncounters",
"latestCovidAssessment"
"latestCovidAssessment",
"weeklyPredictedPatients",
"weeklyPredictedPatients"
],
"enrollmentOptions": {
"requiredProgramQuestions": [
Expand Down Expand Up @@ -2628,7 +2634,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 @@ -2662,7 +2668,8 @@
"patient",
"enrollment",
"hivLastTenClinicalEncounters",
"latestCovidAssessment"
"latestCovidAssessment",
"weeklyPredictedPatients"
],
"enrollmentOptions": {
"requiredProgramQuestions": [
Expand Down Expand Up @@ -2845,7 +2852,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 @@ -2939,7 +2946,8 @@
"patientEncounters",
"isPatientTransferredOut",
"dcQualifedVisits",
"latestCovidAssessment"
"latestCovidAssessment",
"weeklyPredictedPatients"
],
"enrollmentOptions": {
"requiredProgramQuestions": [
Expand Down Expand Up @@ -3241,7 +3249,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 @@ -4169,7 +4177,8 @@
"dataDependencies": [
"patient",
"enrollment",
"hivLastTenClinicalEncounters"
"hivLastTenClinicalEncounters",
"weeklyPredictedPatients"
],
"enrollmentOptions": {
"requiredProgramQuestions": [
Expand Down Expand Up @@ -4273,7 +4282,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 @@ -4306,7 +4315,8 @@
"dataDependencies": [
"patient",
"enrollment",
"hivLastTenClinicalEncounters"
"hivLastTenClinicalEncounters",
"weeklyPredictedPatients"
],
"enrollmentOptions": {
"requiredProgramQuestions": [
Expand Down Expand Up @@ -4412,7 +4422,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 @@ -4547,7 +4557,8 @@
"patientEnrollment",
"isPatientTransferredOut",
"patientEncounters",
"latestCovidAssessment"
"latestCovidAssessment",
"weeklyPredictedPatients"
],
"enrollmentOptions": {
"requiredProgramQuestions": [
Expand Down Expand Up @@ -4793,7 +4804,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 @@ -4834,7 +4845,8 @@
"dataDependencies": [
"patient",
"enrollment",
"hivLastTenClinicalEncounters"
"hivLastTenClinicalEncounters",
"weeklyPredictedPatients"
],
"enrollmentOptions": {
"stateChangeEncounterTypes": {
Expand Down Expand Up @@ -4900,7 +4912,8 @@
"dataDependencies": [
"patient",
"enrollment",
"hivLastTenClinicalEncounters"
"hivLastTenClinicalEncounters",
"weeklyPredictedPatients"
],
"enrollmentOptions": {
"requiredProgramQuestions": [
Expand Down Expand Up @@ -5046,7 +5059,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 @@ -5115,7 +5128,8 @@
"dataDependencies": [
"patient",
"enrollment",
"hivLastTenClinicalEncounters"
"hivLastTenClinicalEncounters",
"weeklyPredictedPatients"
],
"incompatibleWith": [],
"visitTypes": [
Expand Down Expand Up @@ -5150,7 +5164,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 @@ -5509,7 +5523,8 @@
"patient",
"enrollment",
"patientEncounters",
"isPatientTransferredOut"
"isPatientTransferredOut",
"weeklyPredictedPatients"
],
"enrollmentOptions": {
"requiredProgramQuestions": [
Expand Down Expand Up @@ -5575,7 +5590,8 @@
"patient",
"enrollment",
"patientEncounters",
"patientEnrollment"
"patientEnrollment",
"weeklyPredictedPatients"
],
"enrollmentOptions": {
"enrollIf": "gender === 'F'"
Expand Down Expand Up @@ -5645,7 +5661,8 @@
"patient",
"enrollment",
"patientEncounters",
"patientEnrollment"
"patientEnrollment",
"weeklyPredictedPatients"
],
"enrollmentOptions": {
"enrollIf": "gender === 'F'"
Expand Down Expand Up @@ -5723,7 +5740,8 @@
"patient",
"enrollment",
"patientEncounters",
"patientEnrollment"
"patientEnrollment",
"weeklyPredictedPatients"
],
"enrollmentOptions": {
"enrollIf": "gender === 'F'"
Expand Down
11 changes: 8 additions & 3 deletions programs/scope-builder.service.js
Original file line number Diff line number Diff line change
Expand Up @@ -8,18 +8,23 @@ const def = {
module.exports = def;

function buildScope(dataDictionary) {
console.log(dataDictionary);
const scope = {
isPatientTransferredOut: false,
isFirstAMPATHHIVVisit: true,
qualifiesForStandardVisit: false,
qualifiesMedicationRefillVisit: false,
lastCovidScreeningDate: '',
retroSpective: false,
screenedForCovidToday: false
screenedForCovidToday: 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

0 comments on commit 7365f1f

Please sign in to comment.