Skip to content

Commit

Permalink
avniproject/avni-server#1099 | introduce mapper for user
Browse files Browse the repository at this point in the history
  • Loading branch information
himeshr authored and petmongrels committed Mar 5, 2024
1 parent 770499b commit ab8e48d
Show file tree
Hide file tree
Showing 4 changed files with 29 additions and 8 deletions.
22 changes: 16 additions & 6 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

4 changes: 2 additions & 2 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand Down
2 changes: 2 additions & 0 deletions src/RuleExecutor.js
Original file line number Diff line number Diff line change
Expand Up @@ -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) => {
Expand All @@ -22,6 +23,7 @@ export const transformVisitScheduleDates = (visitSchedules) => {
return visitSchedules;
}
const mappers = {
"User": mapUser,
"Individual": mapIndividual,
"Subject": mapIndividual,
"ProgramEnrolment": mapProgramEnrolment,
Expand Down
9 changes: 9 additions & 0 deletions src/models/userModel.js
Original file line number Diff line number Diff line change
@@ -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);
};

0 comments on commit ab8e48d

Please sign in to comment.