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

POC-538 #1336

Open
wants to merge 6 commits into
base: master
Choose a base branch
from
Open

POC-538 #1336

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
68 changes: 55 additions & 13 deletions programs/patient-program-config.json
Original file line number Diff line number Diff line change
Expand Up @@ -213,7 +213,12 @@
},
{
"uuid": "8d5b2be0-c2cc-11de-8d13-0010c6dffd0f",
"display": "ADULTRETURN"
"display": "ADULTRETURN",
"allowedIf": "screenedForCovidToday && !isAdultReturnVisit",
"errors": {
"covidError": "To access clinical forms kindly fill Covid 19 Assessment Form",
"isAdultReturnVisitBeforeInitialVisit": "You cannot fill a return visit form for a date earlier than the initial visit!"
}
},
{
"uuid": "238625fc-8a25-44b2-aa5a-8bf48fa0e18d",
Expand Down Expand Up @@ -1334,7 +1339,12 @@
},
{
"uuid": "8d5b2be0-c2cc-11de-8d13-0010c6dffd0f",
"display": "ADULTRETURN"
"display": "ADULTRETURN",
"allowedIf": "screenedForCovidToday && !isAdultReturnVisit",
"errors": {
"covidError": "To access clinical forms kindly fill Covid 19 Assessment Form",
"isAdultReturnVisitBeforeInitialVisit": "You cannot fill a return visit form for a date earlier than the initial visit!"
}
},
{
"uuid": "8e942fd1-135d-42bd-9701-04560f180ec5",
Expand Down Expand Up @@ -1407,7 +1417,12 @@
},
{
"uuid": "8d5b2be0-c2cc-11de-8d13-0010c6dffd0f",
"display": "ADULTRETURN"
"display": "ADULTRETURN",
"allowedIf": "screenedForCovidToday && !isAdultReturnVisit",
"errors": {
"covidError": "To access clinical forms kindly fill Covid 19 Assessment Form",
"isAdultReturnVisitBeforeInitialVisit": "You cannot fill a return visit form for a date earlier than the initial visit!"
}
},
{
"uuid": "8e942fd1-135d-42bd-9701-04560f180ec5",
Expand Down Expand Up @@ -1536,12 +1551,17 @@
{
"uuid": "02e3ce61-fa24-445e-a1f0-6e3299142966",
"message": "Patient must have prior clinical encounter.",
"allowedIf": "!isFirstPMTCTVisit && !isEnrolledInViremiaPMTCT && programLocation === intendedVisitLocationUuid",
"allowedIf": "!isFirstPMTCTVisit && !isEnrolledInViremiaPMTCT && programLocation === intendedVisitLocationUuid ",
"name": "PMTCT Antenatal Return Visit",
"encounterTypes": [
{
"uuid": "8d5b2be0-c2cc-11de-8d13-0010c6dffd0f",
"display": "ADULTRETURN"
"display": "ADULTRETURN",
"allowedIf": "screenedForCovidToday && !isAdultReturnVisit",
"errors": {
"covidError": "To access clinical forms kindly fill Covid 19 Assessment Form",
"isAdultReturnVisitBeforeInitialVisit": "You cannot fill a return visit form for a date earlier than the initial visit!"
}
},
{
"uuid": "a44ad5e2-b3ec-42e7-8cfa-8ba3dbcf5ed7",
Expand Down Expand Up @@ -1687,7 +1707,12 @@
"encounterTypes": [
{
"uuid": "8d5b2be0-c2cc-11de-8d13-0010c6dffd0f",
"display": "ADULTRETURN"
"display": "ADULTRETURN",
"allowedIf": "screenedForCovidToday && !isAdultReturnVisit",
"errors": {
"covidError": "To access clinical forms kindly fill Covid 19 Assessment Form",
"isAdultReturnVisitBeforeInitialVisit": "You cannot fill a return visit form for a date earlier than the initial visit!"
}
},
{
"uuid": "a44ad5e2-b3ec-42e7-8cfa-8ba3dbcf5ed7",
Expand Down Expand Up @@ -2221,7 +2246,12 @@
"encounterTypes": [
{
"uuid": "f091b833-9e1a-4eef-8364-fc289095a832",
"display": "PEPRETURN"
"display": "PEPRETURN",
"allowedIf": "screenedForCovidToday && !isAdultReturnVisit",
"errors": {
"covidError": "To access clinical forms kindly fill Covid 19 Assessment Form",
"isAdultReturnVisitBeforeInitialVisit": "You cannot fill a return visit form for a date earlier than the initial visit!"
}
},
{
"uuid": "a44ad5e2-b3ec-42e7-8cfa-8ba3dbcf5ed7",
Expand Down Expand Up @@ -2449,7 +2479,12 @@
},
{
"uuid": "ddd96f1c-524f-4caa-81a6-1a6f9789a4bc",
"display": "PREPRETURN"
"display": "PREPRETURN",
"allowedIf": "screenedForCovidToday && !isAdultReturnVisit",
"errors": {
"covidError": "To access clinical forms kindly fill Covid 19 Assessment Form",
"isAdultReturnVisitBeforeInitialVisit": "You cannot fill a return visit form for a date earlier than the initial visit!"
}
},
{
"uuid": "df55584c-1350-11df-a1f1-0026b9348838",
Expand Down Expand Up @@ -2613,7 +2648,12 @@
},
{
"uuid": "8d5b2be0-c2cc-11de-8d13-0010c6dffd0f",
"display": "ADULTRETURN"
"display": "ADULTRETURN",
"allowedIf": "screenedForCovidToday && !isAdultReturnVisit",
"errors": {
"covidError": "To access clinical forms kindly fill Covid 19 Assessment Form",
"isAdultReturnVisitBeforeInitialVisit": "You cannot fill a return visit form for a date earlier than the initial visit!"
}
},
{
"uuid": "b690e24a-6dc7-40a8-8cbd-0924dd507dca",
Expand Down Expand Up @@ -2955,9 +2995,10 @@
{
"uuid": "8d5b2be0-c2cc-11de-8d13-0010c6dffd0f",
"display": "ADULTRETURN",
"allowedIf": " age > 24",
"allowedIf": "age > 24 && screenedForCovidToday && !isAdultReturnVisit",
"errors": {
"covidError": "To access clinical forms kindly fill Covid 19 Assessment Form"
"covidError": "To access clinical forms kindly fill Covid 19 Assessment Form",
"isAdultReturnVisitBeforeInitialVisit": "You cannot fill a return visit form for a date earlier than the initial visit!"
}
},
{
Expand Down Expand Up @@ -4428,9 +4469,10 @@
{
"uuid": "8d5b2be0-c2cc-11de-8d13-0010c6dffd0f",
"display": "ADULTRETURN",
"allowedIf": "!isViremicHighVL && age > 24",
"allowedIf": "screenedForCovidToday && !isAdultReturnVisit",
"errors": {
"viremiaError": "To access clinical forms kindly fill Enhanced Adherence Encounter Form"
"covidError": "To access clinical forms kindly fill Covid 19 Assessment Form",
"isAdultReturnVisitBeforeInitialVisit": "You cannot fill a return visit form for a date earlier than the initial visit!"
}
},
{
Expand Down
30 changes: 30 additions & 0 deletions programs/scope-builder.service.js
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@ function buildScope(dataDictionary) {
lastCovidScreeningDate: '',
retroSpective: false,
screenedForCovidToday: false,
isAdultReturnVisitBeforeInitialVisit: false,
isViremicHighVL: false
};
let isStandardDcVisit = false;
Expand Down Expand Up @@ -121,6 +122,15 @@ function buildScope(dataDictionary) {
scope.retroSpective = dataDictionary.retroSpective;
}

if (dataDictionary.retroSpective === 'true') {
const isAdultEncounterDateB4InitialEncounterDate = checkRetrospectiveInitialEncounterDate(
dataDictionary.patientEncounters
);
if (isAdultEncounterDateB4InitialEncounterDate) {
scope.isAdultReturnVisitBeforeInitialVisit = true;
}
}

if (dataDictionary.isPatientTransferredOut) {
scope['isPatientTransferredOut'] = dataDictionary.isPatientTransferredOut;
}
Expand Down Expand Up @@ -180,6 +190,26 @@ function conditionalDCVisits(patient) {
}
}

function checkRetrospectiveInitialEncounterDate(patientEncounters) {
const adultInitial = '8d5b27bc-c2cc-11de-8d13-0010c6dffd0f';
const adultReturn = '8d5b2be0-c2cc-11de-8d13-0010c6dffd0f';
return patientEncounters.map((encounter) => {
const encounterType = encounter?.encounterType?.uuid;
const encounterDate = encounter?.encounterDatetime;
if (encounterType === adultInitial) {
const adultReturnEncounter = patientEncounters.find((encounter) => {
const encounterType = encounter?.encounterType?.uuid;
return encounterType === adultReturn;
});
if (encounterDate > adultReturnEncounter?.encounterDatetime) {
return true;
} else {
return false;
}
}
});
}

function buildPatientScopeMembers(scope, patient) {
scope.age = patient.person.age;
scope.gender = patient.person.gender;
Expand Down
Loading