From ab8e48d13e62ccfd6dc92ce2ec86498738f54881 Mon Sep 17 00:00:00 2001 From: himeshr Date: Thu, 21 Dec 2023 15:00:21 +0530 Subject: [PATCH] avniproject/avni-server#1099 | introduce mapper for user --- package-lock.json | 22 ++++++++++++++++------ package.json | 4 ++-- src/RuleExecutor.js | 2 ++ src/models/userModel.js | 9 +++++++++ 4 files changed, 29 insertions(+), 8 deletions(-) create mode 100644 src/models/userModel.js diff --git a/package-lock.json b/package-lock.json index 25fddee..33373e8 100644 --- a/package-lock.json +++ b/package-lock.json @@ -6257,9 +6257,9 @@ "dev": true }, "avni-health-modules": { - "version": "0.0.22", - "resolved": "https://registry.npmjs.org/avni-health-modules/-/avni-health-modules-0.0.22.tgz", - "integrity": "sha512-GzKDk8c22Eucx4gB9SdY8h4kSg/jV8T8tCOiVKnSbIyzcozJfWH7oEHNJ03p3O0kfasdKrsIZNOtQNwFG9wxcw==" + "version": "0.0.24", + "resolved": "https://registry.npmjs.org/avni-health-modules/-/avni-health-modules-0.0.24.tgz", + "integrity": "sha512-2xwKWUyVymEuqBusErOqx/Lu9lP/PNZBflF3KkPuiukjh4gSM2t6uBEBSGTDZ7IQBe3NWt/5+6mFf52vjZ2tTQ==" }, "aws-amplify": { "version": "4.3.14", @@ -11617,9 +11617,19 @@ } }, "openchs-models": { - "version": "1.30.87", - "resolved": "https://registry.npmjs.org/openchs-models/-/openchs-models-1.30.87.tgz", - "integrity": "sha512-TXLOQc79JCvto3MNS7VTvE2FYL9U/OxvQPgjdVekD0n6HKmPddyqpI1h4YnHW73yTByJUcliVv4EQlfaBOYDIQ==" + "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 0ab71dd..77c0bf9 100644 --- a/package.json +++ b/package.json @@ -10,8 +10,8 @@ "express": "^4.14.0", "safe-eval": "^0.4.1", "uuid": "^7.0.2", - "avni-health-modules": "0.0.22", - "openchs-models": "1.30.87", + "avni-health-modules": "0.0.24", + "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