Open kameshbhariya opened 3 weeks ago
I've added below rule in mentioned encounter.
Validation Rule:
'use strict';
({params, imports}) => {
const encounter = params.entity;
const moment = imports.moment;
const validationResults = [];
const scheduledOrCompletedEncountersOfType = (encounterType, encounterDateTime) => {
const month = moment(encounterDateTime).month();
const year = moment(encounterDateTime).year();
const data = encounter.individual.encounters.filter((enc) =>
enc.encounterType.name === encounterType &&
enc.voided == false &&
enc.uuid != encounter.uuid &&
enc.cancelDateTime == null &&
moment(enc.encounterDateTime).year() == year &&
moment(enc.encounterDateTime).month() == month
);
return data;
}
const condition11 = scheduledOrCompletedEncountersOfType(encounter.encounterType.name,encounter.encounterDateTime).length != 0;
if(condition11 ){
validationResults.push(imports.common.createValidationError("same form cannot be filled twice in the same month"));
}
return validationResults;
};
@nupoorkhandelwal moving card to review lane.
Make the changes in UAT.
[x] Add a validation rule that, same form cannot be filled twice in the same month.
[x] 1. Tank Cleaning Encounter
[x] 2. WIMC meeting Encounter
[x] 3. Jal Chaupal
[x] 4. Log book record
[x] 5. Water Quality testing