diff --git a/package-lock.json b/package-lock.json index fdf13ec..89c12e0 100644 --- a/package-lock.json +++ b/package-lock.json @@ -11617,9 +11617,19 @@ } }, "openchs-models": { - "version": "1.30.61", - "resolved": "https://registry.npmjs.org/openchs-models/-/openchs-models-1.30.61.tgz", - "integrity": "sha512-9oQOI6vKKkBHr/x+AftWk5cZ3e++VMZYnGyM2wdX7qKsie7vN5nQ/TNg/J2sDY93wDrtk9WepgQ34OPgG24INA==" + "version": "1.31.6", + "resolved": "https://registry.npmjs.org/openchs-models/-/openchs-models-1.31.6.tgz", + "integrity": "sha512-gcosVBegsDRNbQor4pwknXvrppzNVsbIIGwt8DHCB1yIoJYe1nT6LORMmBDVBht3hgEC5jZUhNig/ccjjQV3yg==", + "requires": { + "uuid": "^9.0.1" + }, + "dependencies": { + "uuid": { + "version": "9.0.1", + "resolved": "https://registry.npmjs.org/uuid/-/uuid-9.0.1.tgz", + "integrity": "sha512-b+1eJOlsR9K8HJpow9Ok3fiWOWSIcIzXodvv0rQjVoOVNpWMpxf1wZNpt4y9h10odCNrqnYp1OBzRktckBe3sA==" + } + } }, "optionator": { "version": "0.8.3", diff --git a/package.json b/package.json index 6f7ba3e..2fe4aa9 100644 --- a/package.json +++ b/package.json @@ -11,7 +11,7 @@ "safe-eval": "^0.4.1", "uuid": "^7.0.2", "avni-health-modules": "latest", - "openchs-models": "1.30.87", + "openchs-models": "1.31.6", "rules-config": "https://github.com/avniproject/rules-config.git#fe552da405368bfd138e2f38e605c1d307e3ebe4", "lodash": "^4.17.11", "moment": "^2.22.2" diff --git a/src/RuleExecutor.js b/src/RuleExecutor.js index 29ccaa8..4b56271 100644 --- a/src/RuleExecutor.js +++ b/src/RuleExecutor.js @@ -13,6 +13,7 @@ import { isEligibleForEntityType } from './services/RuleEvalService'; import {map} from 'lodash'; +import {mapUser} from './models/userModel'; export const transformVisitScheduleDates = (visitSchedules) => { visitSchedules.forEach((visitSchedule, index, array) => { @@ -22,6 +23,7 @@ export const transformVisitScheduleDates = (visitSchedules) => { return visitSchedules; } const mappers = { + "User": mapUser, "Individual": mapIndividual, "Subject": mapIndividual, "ProgramEnrolment": mapProgramEnrolment, diff --git a/src/models/userModel.js b/src/models/userModel.js new file mode 100644 index 0000000..e274727 --- /dev/null +++ b/src/models/userModel.js @@ -0,0 +1,9 @@ +import {isNil} from 'lodash'; +import {UserInfo} from 'openchs-models'; + +export const mapUser = userDetails => { + if (isNil(userDetails)) { + return new UserInfo(); + } + return UserInfo.fromResource(userDetails); +}; \ No newline at end of file