avniproject / JSSCP

0 stars 0 forks source link

Fix rule failure with uuid "591b1009-ac31-403f-bfba-1b4c5f231e4e" #345

Closed Gojo-Taqi closed 2 months ago

Gojo-Taqi commented 3 months ago

Link to the report here

BEULAHEVANJALIN commented 3 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.


BEULAHEVANJALIN commented 3 months ago

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, [],[]);
};
BEULAHEVANJALIN commented 3 months ago

JSSCP.zip JSSCP UAT NEW.zip

BEULAHEVANJALIN commented 2 months ago

Uploaded the UAT bundle to prod on April 8th