Skip to content

Commit

Permalink
Mnch enhancements (#1251)
Browse files Browse the repository at this point in the history
* Initial commit for MNCH module

* MNCH enhancements

* Update programs/scope-builder.service.js

* Update programs/scope-builder.service.js

* Update programs/scope-builder.service.js

---------

Co-authored-by: Kipchumba Bett <[email protected]>
  • Loading branch information
drizzentic and corneliouzbett authored May 18, 2023
1 parent bcc796e commit 0f5822d
Show file tree
Hide file tree
Showing 3 changed files with 99 additions and 18 deletions.
8 changes: 8 additions & 0 deletions departments/department-programs-config.json
Original file line number Diff line number Diff line change
Expand Up @@ -186,6 +186,14 @@
{
"uuid": "52aeb285-fb18-455b-893e-3e53ccc77ceb",
"name": "ANTENATAL CARE PROGRAM"
},
{
"uuid": "d2552058-d7bd-47c6-aed1-480a4308027a",
"name": "POSTNATAL CARE PROGRAM"
},
{
"uuid": "01948855-8491-4164-b54f-9b16d174d93e",
"name": "MATERNITY CARE PROGRAM"
}
]
}
Expand Down
65 changes: 65 additions & 0 deletions programs/patient-program-config.json
Original file line number Diff line number Diff line change
Expand Up @@ -5341,5 +5341,70 @@
]
}
]
},
"d2552058-d7bd-47c6-aed1-480a4308027a": {
"name": "POSTNATAL CARE PROGRAM",
"dataDependencies": [
"patient",
"enrollment",
"patientEncounters",
"patientEnrollment"
],
"incompatibleWith": [],
"visitTypes": [
{
"uuid": "b1a978ca-9315-4ba2-ac2b-84efb9a68c5c",
"name": "PMTCT Postnatal Initial Visit",
"allowedIf": "programLocation === intendedVisitLocationUuid && isFirstPNCVisit && gender==='F'",
"encounterTypes": [
{
"uuid": "ded4ecf7-8129-4a9e-8aa3-a21a7adb7759",
"display": "PNCADULTINITIAL"
},
{
"uuid": "a44ad5e2-b3ec-42e7-8cfa-8ba3dbcf5ed7",
"display": "HIVTRIAGE"
}
]
},
{
"uuid": "0b1b6194-d2d5-4e4b-9f7c-c3b778ccc354",
"name": "PMTCT Postnatal Return Visit",
"allowedIf": "programLocation === intendedVisitLocationUuid && !isFirstPNCVisit && gender==='F'",
"encounterTypes": [
{
"uuid": "ded4ecf7-8129-4a9e-8aa3-a21a7adb7759",
"display": "PNCADULTRETURN"
},
{
"uuid": "db215741-de99-424a-a109-1f23eb3b680b",
"display": "HIVTRIAGE"
}
]
}
]
},
"01948855-8491-4164-b54f-9b16d174d93e": {
"name": "MATERNITY PROGRAM",
"dataDependencies": [
"patient",
"enrollment",
"patientEncounters",
"patientEnrollment"
],
"incompatibleWith": [],
"visitTypes": [
{
"uuid": "5dd2b2c7-66cc-4cd8-b1ce-ca8fc0189a12",
"name": "Maternity Visit",
"allowedIf": "programLocation === intendedVisitLocationUuid && gender==='F'",
"encounterTypes": [
{
"uuid": "2b928d9b-84ce-4777-9658-3fba6248b3bc",
"display": "LABORANDDELIVERY"
}
]
}
]
}
}
44 changes: 26 additions & 18 deletions programs/scope-builder.service.js
Original file line number Diff line number Diff line change
Expand Up @@ -76,7 +76,7 @@ function buildScope(dataDictionary) {
dataDictionary.patientEncounters,
dataDictionary.programUuid
);
buildANCScopeMembers(
buildMNCHScopeMembers(
scope,
dataDictionary.patientEncounters,
dataDictionary.patientEnrollment
Expand Down Expand Up @@ -269,30 +269,34 @@ function isInitialPMTCTVisit(patientEncounters) {

return initialPMTCTEncounters.length === 0;
}
function isInitialANCVisit(patientEncounters, patientEnrollment) {
const initialANCEncounterUuid = 'f5702679-6a16-43bd-8629-4b44c7a78ff1'; // ANC Initial
let initialANCEncounters = _.filter(patientEncounters, (encounter) => {
return initialANCEncounterUuid === encounter.encounterType.uuid;
function isInitialVisit(
patientEncounters,
patientEnrollment,
programUuid,
encounterUuid
) {
let initialEncounters = _.filter(patientEncounters, (encounter) => {
return encounterUuid === encounter.encounterType.uuid;
});
const activeEnrollments = _.filter(patientEnrollment, {
dateCompleted: null
});
let isEnrolledinANC = false;
let isEnrolled = false;
let dateEnrolled = '';
activeEnrollments.forEach((item) => {
if (item.program.uuid === '52aeb285-fb18-455b-893e-3e53ccc77ceb') {
isEnrolledinANC = true;
if (item.program.uuid === programUuid) {
isEnrolled = true;
dateEnrolled = item.dateEnrolled;
}
});
// get latest initial encounter and compare with dateenrolled to check wether it's a new enrollment
let latestEnc = initialANCEncounters[initialANCEncounters.length - 1];
// get latest initial encounter and compare with dateenrolled to check whether it's a new enrollment
let latestEnc = initialEncounters[initialEncounters.length - 1];
if (
initialANCEncounters.length > 0 &&
initialEncounters.length > 0 &&
dateEnrolled > latestEnc.encounterDatetime
) {
return true;
} else if (initialANCEncounters.length === 0) {
} else if (initialEncounters.length === 0) {
return true;
} else {
return false;
Expand Down Expand Up @@ -386,16 +390,20 @@ function buildOncologyScopeMembers(scope, patientEncounters, programUuid) {
programUuid
);
}
function buildANCScopeMembers(scope, patientEncounters, programEnrollment) {
function buildMNCHScopeMembers(scope, patientEncounters, programEnrollment) {
// If the client has not exited the antenatal program show return visit if they have an initial encounter

scope.isFirstANCVisit = isInitialANCVisit(
scope.isFirstANCVisit = isInitialVisit(
patientEncounters,
programEnrollment
programEnrollment,
'52aeb285-fb18-455b-893e-3e53ccc77ceb',
'f5702679-6a16-43bd-8629-4b44c7a78ff1'
);
console.log(
'Output',
isInitialANCVisit(patientEncounters, programEnrollment)
scope.isFirstPNCVisit = isInitialVisit(
patientEncounters,
programEnrollment,
'd2552058-d7bd-47c6-aed1-480a4308027a',
'ded4ecf7-8129-4a9e-8aa3-a21a7adb7759'
);
}
function isInitialHivVisit(patientEncounters) {
Expand Down

0 comments on commit 0f5822d

Please sign in to comment.