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 committed Dec 21, 2023
1 parent 1a3f09a commit 46c99a3
Show file tree
Hide file tree
Showing 4 changed files with 25 additions and 4 deletions.
16 changes: 13 additions & 3 deletions package-lock.json

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

2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -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"
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 46c99a3

Please sign in to comment.