Closed Gojo-Taqi closed 2 months ago
The motherCalculations
in avni-health-modules
expects lastMenstrualPeriodConceptName
to compute gestational age. Although our code doesn't directly use this concept, this is erroring out because it expects a date lmp (which is undefined). So added a simple check to do the calculation only when LMP date exists.
Changes have been made in the UAT and will be moved to prod once QA done.
Old script:
"use strict";
({params, imports}) => {
const programEnrolment = params.entity;
const formElement = params.formElement;
const value =
imports.motherCalculations.currentTrimester(programEnrolment,programEnrolment.enrolmentDateTime);
var isRegisterredWithinThreeMonths;
if(value > 1)
isRegisterredWithinThreeMonths = 'No';
else
isRegisterredWithinThreeMonths = 'Yes';
return new imports.rulesConfig.FormElementStatus(formElement.uuid, true, isRegisterredWithinThreeMonths);
};
Updated script:
'use strict';
({params, imports}) => {
const programEnrolment = params.entity;
const formElement = params.formElement;
let value = null;
const condition11 = new imports.rulesConfig.RuleCondition({programEnrolment, formElement}).when.valueInEnrolment("814f1780-aa3d-4c46-b881-71face696220").defined.matches();
if(condition11 ){
const currentTrimester = imports.motherCalculations.currentTrimester(programEnrolment,programEnrolment.enrolmentDateTime);
value = currentTrimester > 1 ? 'No' : 'Yes';
}
return new imports.rulesConfig.FormElementStatus(formElement.uuid, true, value, [],[]);
};
Uploaded the UAT bundle to prod on April 8th
Link to the report here