openchs-models 1.31.55 → 1.31.57
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/AbstractEncounter.js +13 -0
- package/dist/AddressLevel.js +1 -1
- package/dist/ChecklistItem.js +1 -1
- package/dist/Encounter.js +4 -4
- package/dist/Family.js +1 -1
- package/dist/GroupDashboard.js +13 -1
- package/dist/Individual.js +6 -2
- package/dist/Observation.js +1 -2
- package/dist/ProgramEncounter.js +4 -4
- package/dist/ProgramEnrolment.js +8 -4
- package/dist/Schema.js +11 -98
- package/dist/SchemaNames.js +1 -1
- package/dist/application/Form.js +0 -26
- package/dist/draft/DraftEncounter.js +4 -4
- package/dist/draft/DraftSubject.js +2 -2
- package/dist/geo/Point.js +1 -2
- package/dist/program/SubjectProgramEligibility.js +1 -1
- package/dist/relationship/IndividualRelationship.js +1 -1
- package/dist/task/Task.js +2 -2
- package/dist/utility/AuditUtil.js +21 -5
- package/package.json +1 -1
|
@@ -412,6 +412,19 @@ class AbstractEncounter extends _BaseEntity.default {
|
|
|
412
412
|
this.that.latestEntityApprovalStatus = this.fromObject(entityApprovalStatus);
|
|
413
413
|
}
|
|
414
414
|
|
|
415
|
+
updateAudit(userInfo, isNew, isGettingFilled) {
|
|
416
|
+
(0, _AuditUtil.updateAuditFields)(this, userInfo, isNew);
|
|
417
|
+
|
|
418
|
+
if (_lodash.default.isNil(this.filledByUUID) && isGettingFilled) {
|
|
419
|
+
this.filledByUUID = userInfo.userUUID;
|
|
420
|
+
this.filledBy = userInfo.name;
|
|
421
|
+
}
|
|
422
|
+
}
|
|
423
|
+
|
|
424
|
+
isFilled() {
|
|
425
|
+
return !_lodash.default.isNil(this.encounterDateTime);
|
|
426
|
+
}
|
|
427
|
+
|
|
415
428
|
}
|
|
416
429
|
|
|
417
430
|
_defineProperty(AbstractEncounter, "fieldKeys", {
|
package/dist/AddressLevel.js
CHANGED
package/dist/ChecklistItem.js
CHANGED
package/dist/Encounter.js
CHANGED
|
@@ -132,10 +132,10 @@ _defineProperty(Encounter, "schema", {
|
|
|
132
132
|
individual: _SchemaNames.default.Individual,
|
|
133
133
|
observations: {
|
|
134
134
|
type: "list",
|
|
135
|
-
objectType: "
|
|
135
|
+
objectType: "Observation"
|
|
136
136
|
},
|
|
137
137
|
encounterLocation: {
|
|
138
|
-
type: _SchemaNames.default.
|
|
138
|
+
type: _SchemaNames.default.Point,
|
|
139
139
|
optional: true
|
|
140
140
|
},
|
|
141
141
|
name: {
|
|
@@ -156,10 +156,10 @@ _defineProperty(Encounter, "schema", {
|
|
|
156
156
|
},
|
|
157
157
|
cancelObservations: {
|
|
158
158
|
type: "list",
|
|
159
|
-
objectType: "
|
|
159
|
+
objectType: "Observation"
|
|
160
160
|
},
|
|
161
161
|
cancelLocation: {
|
|
162
|
-
type: _SchemaNames.default.
|
|
162
|
+
type: _SchemaNames.default.Point,
|
|
163
163
|
optional: true
|
|
164
164
|
},
|
|
165
165
|
voided: {
|
package/dist/Family.js
CHANGED
package/dist/GroupDashboard.js
CHANGED
|
@@ -32,6 +32,14 @@ class GroupDashboard extends _BaseEntity.default {
|
|
|
32
32
|
this.that.primaryDashboard = x;
|
|
33
33
|
}
|
|
34
34
|
|
|
35
|
+
get secondaryDashboard() {
|
|
36
|
+
return this.that.secondaryDashboard;
|
|
37
|
+
}
|
|
38
|
+
|
|
39
|
+
set secondaryDashboard(x) {
|
|
40
|
+
this.that.secondaryDashboard = x;
|
|
41
|
+
}
|
|
42
|
+
|
|
35
43
|
get group() {
|
|
36
44
|
return this.toEntity("group", _Groups.default);
|
|
37
45
|
}
|
|
@@ -49,7 +57,7 @@ class GroupDashboard extends _BaseEntity.default {
|
|
|
49
57
|
}
|
|
50
58
|
|
|
51
59
|
static fromResource(resource, entityService) {
|
|
52
|
-
const groupDashboard = _General.default.assignFields(resource, new GroupDashboard(), ["uuid", "primaryDashboard", "voided"]);
|
|
60
|
+
const groupDashboard = _General.default.assignFields(resource, new GroupDashboard(), ["uuid", "primaryDashboard", "secondaryDashboard", "voided"]);
|
|
53
61
|
|
|
54
62
|
groupDashboard.group = entityService.findByKey("uuid", _ResourceUtil.default.getUUIDFor(resource, "groupUUID"), _Groups.default.schema.name);
|
|
55
63
|
groupDashboard.dashboard = entityService.findByKey("uuid", _ResourceUtil.default.getUUIDFor(resource, "dashboardUUID"), _Dashboard.default.schema.name);
|
|
@@ -67,6 +75,10 @@ _defineProperty(GroupDashboard, "schema", {
|
|
|
67
75
|
type: "bool",
|
|
68
76
|
default: false
|
|
69
77
|
},
|
|
78
|
+
secondaryDashboard: {
|
|
79
|
+
type: "bool",
|
|
80
|
+
default: false
|
|
81
|
+
},
|
|
70
82
|
group: {
|
|
71
83
|
type: "Groups",
|
|
72
84
|
optional: true
|
package/dist/Individual.js
CHANGED
|
@@ -1066,6 +1066,10 @@ class Individual extends _BaseEntity.default {
|
|
|
1066
1066
|
return _SchemaNames.default.Individual;
|
|
1067
1067
|
}
|
|
1068
1068
|
|
|
1069
|
+
updateAudit(userInfo, isNew) {
|
|
1070
|
+
(0, _AuditUtil.updateAuditFields)(this, userInfo, isNew);
|
|
1071
|
+
}
|
|
1072
|
+
|
|
1069
1073
|
}
|
|
1070
1074
|
|
|
1071
1075
|
_defineProperty(Individual, "schema", {
|
|
@@ -1116,7 +1120,7 @@ _defineProperty(Individual, "schema", {
|
|
|
1116
1120
|
},
|
|
1117
1121
|
observations: {
|
|
1118
1122
|
type: "list",
|
|
1119
|
-
objectType: "
|
|
1123
|
+
objectType: "Observation"
|
|
1120
1124
|
},
|
|
1121
1125
|
relationships: {
|
|
1122
1126
|
type: "list",
|
|
@@ -1127,7 +1131,7 @@ _defineProperty(Individual, "schema", {
|
|
|
1127
1131
|
objectType: "GroupSubject"
|
|
1128
1132
|
},
|
|
1129
1133
|
registrationLocation: {
|
|
1130
|
-
type: _SchemaNames.default.
|
|
1134
|
+
type: _SchemaNames.default.Point,
|
|
1131
1135
|
optional: true
|
|
1132
1136
|
},
|
|
1133
1137
|
comments: {
|
package/dist/Observation.js
CHANGED
|
@@ -261,8 +261,7 @@ class Observation extends _PersistedObject.default {
|
|
|
261
261
|
}
|
|
262
262
|
|
|
263
263
|
_defineProperty(Observation, "schema", {
|
|
264
|
-
name: "
|
|
265
|
-
embedded: true,
|
|
264
|
+
name: "Observation",
|
|
266
265
|
properties: {
|
|
267
266
|
concept: "Concept",
|
|
268
267
|
valueJSON: "string"
|
package/dist/ProgramEncounter.js
CHANGED
|
@@ -194,7 +194,7 @@ _defineProperty(ProgramEncounter, "schema", {
|
|
|
194
194
|
programEnrolment: _SchemaNames.default.ProgramEnrolment,
|
|
195
195
|
observations: {
|
|
196
196
|
type: "list",
|
|
197
|
-
objectType: "
|
|
197
|
+
objectType: "Observation"
|
|
198
198
|
},
|
|
199
199
|
cancelDateTime: {
|
|
200
200
|
type: "date",
|
|
@@ -202,14 +202,14 @@ _defineProperty(ProgramEncounter, "schema", {
|
|
|
202
202
|
},
|
|
203
203
|
cancelObservations: {
|
|
204
204
|
type: "list",
|
|
205
|
-
objectType: "
|
|
205
|
+
objectType: "Observation"
|
|
206
206
|
},
|
|
207
207
|
encounterLocation: {
|
|
208
|
-
type: _SchemaNames.default.
|
|
208
|
+
type: _SchemaNames.default.Point,
|
|
209
209
|
optional: true
|
|
210
210
|
},
|
|
211
211
|
cancelLocation: {
|
|
212
|
-
type: _SchemaNames.default.
|
|
212
|
+
type: _SchemaNames.default.Point,
|
|
213
213
|
optional: true
|
|
214
214
|
},
|
|
215
215
|
voided: {
|
package/dist/ProgramEnrolment.js
CHANGED
|
@@ -646,6 +646,10 @@ class ProgramEnrolment extends _BaseEntity.default {
|
|
|
646
646
|
return _SchemaNames.default.ProgramEnrolment;
|
|
647
647
|
}
|
|
648
648
|
|
|
649
|
+
updateAudit(userInfo, isNew) {
|
|
650
|
+
(0, _AuditUtil.updateAuditFields)(this, userInfo, isNew);
|
|
651
|
+
}
|
|
652
|
+
|
|
649
653
|
}
|
|
650
654
|
|
|
651
655
|
_defineProperty(ProgramEnrolment, "schema", {
|
|
@@ -657,7 +661,7 @@ _defineProperty(ProgramEnrolment, "schema", {
|
|
|
657
661
|
enrolmentDateTime: "date",
|
|
658
662
|
observations: {
|
|
659
663
|
type: "list",
|
|
660
|
-
objectType: "
|
|
664
|
+
objectType: "Observation"
|
|
661
665
|
},
|
|
662
666
|
programExitDateTime: {
|
|
663
667
|
type: "date",
|
|
@@ -665,7 +669,7 @@ _defineProperty(ProgramEnrolment, "schema", {
|
|
|
665
669
|
},
|
|
666
670
|
programExitObservations: {
|
|
667
671
|
type: "list",
|
|
668
|
-
objectType: "
|
|
672
|
+
objectType: "Observation"
|
|
669
673
|
},
|
|
670
674
|
encounters: {
|
|
671
675
|
type: "list",
|
|
@@ -677,11 +681,11 @@ _defineProperty(ProgramEnrolment, "schema", {
|
|
|
677
681
|
},
|
|
678
682
|
individual: "Individual",
|
|
679
683
|
enrolmentLocation: {
|
|
680
|
-
type: _SchemaNames.default.
|
|
684
|
+
type: _SchemaNames.default.Point,
|
|
681
685
|
optional: true
|
|
682
686
|
},
|
|
683
687
|
exitLocation: {
|
|
684
|
-
type: _SchemaNames.default.
|
|
688
|
+
type: _SchemaNames.default.Point,
|
|
685
689
|
optional: true
|
|
686
690
|
},
|
|
687
691
|
voided: {
|
package/dist/Schema.js
CHANGED
|
@@ -3,7 +3,6 @@
|
|
|
3
3
|
Object.defineProperty(exports, "__esModule", {
|
|
4
4
|
value: true
|
|
5
5
|
});
|
|
6
|
-
exports.createTransactionDataMapForEmbeddedFields = createTransactionDataMapForEmbeddedFields;
|
|
7
6
|
exports.default = void 0;
|
|
8
7
|
|
|
9
8
|
var _Settings = _interopRequireDefault(require("./Settings"));
|
|
@@ -272,100 +271,7 @@ function migrateEmbeddedObjects(oldDB, newDB) {
|
|
|
272
271
|
newDB.deleteModel("StringKeyNumericValue");
|
|
273
272
|
}
|
|
274
273
|
|
|
275
|
-
|
|
276
|
-
db.commitTransaction();
|
|
277
|
-
db.beginTransaction();
|
|
278
|
-
}
|
|
279
|
-
|
|
280
|
-
function shouldFlush(numberOfRecords) {
|
|
281
|
-
const batchSize = 100;
|
|
282
|
-
return numberOfRecords % batchSize === batchSize - 1;
|
|
283
|
-
}
|
|
284
|
-
|
|
285
|
-
function createTransactionDataMapForEmbeddedFields() {
|
|
286
|
-
const map = new Map();
|
|
287
|
-
|
|
288
|
-
_MetaDataService.default.forEachPointField((fieldName, schemaName) => {
|
|
289
|
-
if (map.has(schemaName)) {
|
|
290
|
-
map.get(schemaName).push({
|
|
291
|
-
fieldName,
|
|
292
|
-
fieldType: "Point"
|
|
293
|
-
});
|
|
294
|
-
} else {
|
|
295
|
-
map.set(schemaName, [{
|
|
296
|
-
fieldName,
|
|
297
|
-
fieldType: "Point"
|
|
298
|
-
}]);
|
|
299
|
-
}
|
|
300
|
-
});
|
|
301
|
-
|
|
302
|
-
_MetaDataService.default.forEachObservationField((fieldName, schemaName) => {
|
|
303
|
-
if (map.has(schemaName)) {
|
|
304
|
-
map.get(schemaName).push({
|
|
305
|
-
fieldName,
|
|
306
|
-
fieldType: "Obs"
|
|
307
|
-
});
|
|
308
|
-
} else {
|
|
309
|
-
map.set(schemaName, [{
|
|
310
|
-
fieldName,
|
|
311
|
-
fieldType: "Obs"
|
|
312
|
-
}]);
|
|
313
|
-
}
|
|
314
|
-
});
|
|
315
|
-
|
|
316
|
-
return map;
|
|
317
|
-
}
|
|
318
|
-
|
|
319
|
-
function migrateAllEmbeddedForTxnData(oldDB, newDB) {
|
|
320
|
-
const startTime = new Date();
|
|
321
|
-
flush(newDB);
|
|
322
|
-
const map = createTransactionDataMapForEmbeddedFields();
|
|
323
|
-
let recordCounter = 0;
|
|
324
|
-
const conceptMap = new Map();
|
|
325
|
-
map.forEach((fields, schemaName) => {
|
|
326
|
-
console.log(`schema: ${schemaName}, fields: ${fields.length}`);
|
|
327
|
-
newDB.objects(schemaName).forEach(newDbParentEntity => {
|
|
328
|
-
if (shouldFlush(recordCounter)) {
|
|
329
|
-
flush(newDB);
|
|
330
|
-
}
|
|
331
|
-
|
|
332
|
-
fields.forEach(field => {
|
|
333
|
-
const oldEntity = oldDB.objects(schemaName).filtered(`uuid = "${newDbParentEntity.uuid}"`)[0];
|
|
334
|
-
const oldValue = oldEntity[field.fieldName];
|
|
335
|
-
|
|
336
|
-
if (!_lodash.default.isNil(oldValue)) {
|
|
337
|
-
if (field.fieldType === "Point") newDbParentEntity[field.fieldName] = {
|
|
338
|
-
x: oldValue.x,
|
|
339
|
-
y: oldValue.y
|
|
340
|
-
};else {
|
|
341
|
-
const newObsList = [];
|
|
342
|
-
oldValue.forEach(oldItemValue => {
|
|
343
|
-
let newConcept = conceptMap.get(oldItemValue.concept.uuid);
|
|
344
|
-
|
|
345
|
-
if (_lodash.default.isNil(newConcept)) {
|
|
346
|
-
newConcept = newDB.objects("Concept").filtered(`uuid = "${oldItemValue.concept.uuid}"`)[0];
|
|
347
|
-
conceptMap.set(oldItemValue.concept.uuid, newConcept);
|
|
348
|
-
}
|
|
349
|
-
|
|
350
|
-
newObsList.push({
|
|
351
|
-
concept: newConcept,
|
|
352
|
-
valueJSON: oldItemValue.valueJSON
|
|
353
|
-
});
|
|
354
|
-
});
|
|
355
|
-
newDbParentEntity[field.fieldName] = newObsList;
|
|
356
|
-
}
|
|
357
|
-
}
|
|
358
|
-
});
|
|
359
|
-
recordCounter++;
|
|
360
|
-
});
|
|
361
|
-
});
|
|
362
|
-
flush(newDB);
|
|
363
|
-
newDB.deleteModel("Point");
|
|
364
|
-
newDB.deleteModel("Observation");
|
|
365
|
-
const endTime = new Date();
|
|
366
|
-
const diff = (0, _moment.default)(endTime).diff(startTime, "seconds", true);
|
|
367
|
-
console.log("Total Time Taken", diff, "seconds");
|
|
368
|
-
}
|
|
274
|
+
const VersionWithEmbeddedMigrationProblem = 185;
|
|
369
275
|
|
|
370
276
|
function createRealmConfig() {
|
|
371
277
|
return {
|
|
@@ -375,9 +281,17 @@ function createRealmConfig() {
|
|
|
375
281
|
return doCompact;
|
|
376
282
|
},
|
|
377
283
|
//order is important, should be arranged according to the dependency
|
|
378
|
-
schemaVersion:
|
|
284
|
+
schemaVersion: 188,
|
|
379
285
|
onMigration: function (oldDB, newDB) {
|
|
380
286
|
console.log("[AvniModels.Schema]", `Running migration with old schema version: ${oldDB.schemaVersion} and new schema version: ${newDB.schemaVersion}`);
|
|
287
|
+
if (oldDB.schemaVersion === VersionWithEmbeddedMigrationProblem) throw new Error(`Update from schema version ${VersionWithEmbeddedMigrationProblem} is not allowed. Please uninstall and install app.`);
|
|
288
|
+
|
|
289
|
+
if (oldDB.schemaVersion < 10) {
|
|
290
|
+
const oldObjects = oldDB.objects("DecisionConfig");
|
|
291
|
+
oldObjects.forEach(decisionConfig => {
|
|
292
|
+
newDB.create(ConfigFile.schema.name, ConfigFile.create(decisionConfig.fileName, decisionConfig.decisionCode), true);
|
|
293
|
+
});
|
|
294
|
+
}
|
|
381
295
|
|
|
382
296
|
if (oldDB.schemaVersion < 17) {
|
|
383
297
|
const oldObjects = oldDB.objects("AddressLevel");
|
|
@@ -981,8 +895,7 @@ function createRealmConfig() {
|
|
|
981
895
|
migrateEmbeddedObjects(oldDB, newDB);
|
|
982
896
|
}
|
|
983
897
|
|
|
984
|
-
if (oldDB.schemaVersion <
|
|
985
|
-
migrateAllEmbeddedForTxnData(oldDB, newDB);
|
|
898
|
+
if (oldDB.schemaVersion < VersionWithEmbeddedMigrationProblem) {// removed migration code. keeping the version number in case this number is required for any checks later
|
|
986
899
|
}
|
|
987
900
|
|
|
988
901
|
if (oldDB.schemaVersion < 186) {// newDB.deleteModel("UserDefinedIndividualProperty");
|
package/dist/SchemaNames.js
CHANGED
|
@@ -91,7 +91,7 @@ _defineProperty(SchemaNames, "Concept", "Concept");
|
|
|
91
91
|
|
|
92
92
|
_defineProperty(SchemaNames, "EntityApprovalStatus", "EntityApprovalStatus");
|
|
93
93
|
|
|
94
|
-
_defineProperty(SchemaNames, "
|
|
94
|
+
_defineProperty(SchemaNames, "Point", "Point");
|
|
95
95
|
|
|
96
96
|
var _default = SchemaNames;
|
|
97
97
|
exports.default = _default;
|
package/dist/application/Form.js
CHANGED
|
@@ -227,32 +227,6 @@ class Form extends _BaseEntity.default {
|
|
|
227
227
|
|
|
228
228
|
const extraObs = observations.filter(obs => _lodash.default.isNil(orderedObservations.find(oobs => oobs.concept.uuid === obs.concept.uuid)));
|
|
229
229
|
return orderedObservations.concat(extraObs);
|
|
230
|
-
} //TODO add tests
|
|
231
|
-
|
|
232
|
-
|
|
233
|
-
orderObservationsPerFEG(observations) {
|
|
234
|
-
const orderedObservations = [];
|
|
235
|
-
|
|
236
|
-
const formElementOrdering = _lodash.default.sortBy(this.formElementGroups, feg => feg.displayOrder).map(feg => {
|
|
237
|
-
let fegOrderedObservations = [];
|
|
238
|
-
const returnValue = {};
|
|
239
|
-
returnValue.uuid = feg.uuid;
|
|
240
|
-
returnValue.feg = feg;
|
|
241
|
-
returnValue.sortedObservationsArray = fegOrderedObservations;
|
|
242
|
-
this.orderObservationsWithinAFEG(feg.getFormElements(), observations, fegOrderedObservations);
|
|
243
|
-
orderedObservations.concat(fegOrderedObservations);
|
|
244
|
-
return returnValue;
|
|
245
|
-
});
|
|
246
|
-
|
|
247
|
-
return formElementOrdering;
|
|
248
|
-
}
|
|
249
|
-
|
|
250
|
-
orderObservationsWithinAFEG(formElements, observations, orderedObservations) {
|
|
251
|
-
_lodash.default.sortBy(formElements, fe => fe.displayOrder).forEach(formElement => this.addSortedObservations(formElement, observations, orderedObservations));
|
|
252
|
-
|
|
253
|
-
const extraObs = observations.filter(obs => _lodash.default.isNil(orderedObservations.find(oobs => oobs.concept.uuid === obs.concept.uuid)));
|
|
254
|
-
orderedObservations.concat(extraObs);
|
|
255
|
-
return extraObs;
|
|
256
230
|
}
|
|
257
231
|
|
|
258
232
|
sectionWiseOrderedObservations(observations) {
|
|
@@ -170,10 +170,10 @@ _defineProperty(DraftEncounter, "schema", {
|
|
|
170
170
|
individual: "Individual",
|
|
171
171
|
observations: {
|
|
172
172
|
type: "list",
|
|
173
|
-
objectType: "
|
|
173
|
+
objectType: "Observation"
|
|
174
174
|
},
|
|
175
175
|
encounterLocation: {
|
|
176
|
-
type: _SchemaNames.default.
|
|
176
|
+
type: _SchemaNames.default.Point,
|
|
177
177
|
optional: true
|
|
178
178
|
},
|
|
179
179
|
name: {
|
|
@@ -194,10 +194,10 @@ _defineProperty(DraftEncounter, "schema", {
|
|
|
194
194
|
},
|
|
195
195
|
cancelObservations: {
|
|
196
196
|
type: "list",
|
|
197
|
-
objectType: "
|
|
197
|
+
objectType: "Observation"
|
|
198
198
|
},
|
|
199
199
|
cancelLocation: {
|
|
200
|
-
type: _SchemaNames.default.
|
|
200
|
+
type: _SchemaNames.default.Point,
|
|
201
201
|
optional: true
|
|
202
202
|
},
|
|
203
203
|
voided: {
|
|
@@ -211,10 +211,10 @@ _defineProperty(DraftSubject, "schema", {
|
|
|
211
211
|
lowestAddressLevel: "AddressLevel",
|
|
212
212
|
observations: {
|
|
213
213
|
type: "list",
|
|
214
|
-
objectType: "
|
|
214
|
+
objectType: "Observation"
|
|
215
215
|
},
|
|
216
216
|
registrationLocation: {
|
|
217
|
-
type: _SchemaNames.default.
|
|
217
|
+
type: _SchemaNames.default.Point,
|
|
218
218
|
optional: true
|
|
219
219
|
},
|
|
220
220
|
updatedOn: "date",
|
package/dist/geo/Point.js
CHANGED
package/dist/task/Task.js
CHANGED
|
@@ -230,7 +230,7 @@ _defineProperty(Task, "schema", {
|
|
|
230
230
|
},
|
|
231
231
|
metadata: {
|
|
232
232
|
type: "list",
|
|
233
|
-
objectType: "
|
|
233
|
+
objectType: "Observation"
|
|
234
234
|
},
|
|
235
235
|
subject: {
|
|
236
236
|
type: 'Individual',
|
|
@@ -238,7 +238,7 @@ _defineProperty(Task, "schema", {
|
|
|
238
238
|
},
|
|
239
239
|
observations: {
|
|
240
240
|
type: "list",
|
|
241
|
-
objectType: "
|
|
241
|
+
objectType: "Observation"
|
|
242
242
|
},
|
|
243
243
|
voided: {
|
|
244
244
|
type: 'bool',
|
|
@@ -3,10 +3,14 @@
|
|
|
3
3
|
Object.defineProperty(exports, "__esModule", {
|
|
4
4
|
value: true
|
|
5
5
|
});
|
|
6
|
-
exports.
|
|
6
|
+
exports.updateAuditFields = updateAuditFields;
|
|
7
|
+
exports.mapAuditFields = mapAuditFields;
|
|
8
|
+
exports.AuditFields = void 0;
|
|
7
9
|
|
|
8
10
|
var _ResourceUtil = _interopRequireDefault(require("./ResourceUtil"));
|
|
9
11
|
|
|
12
|
+
var _lodash = _interopRequireDefault(require("lodash"));
|
|
13
|
+
|
|
10
14
|
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
|
|
11
15
|
|
|
12
16
|
const AuditFields = {
|
|
@@ -29,11 +33,23 @@ const AuditFields = {
|
|
|
29
33
|
};
|
|
30
34
|
exports.AuditFields = AuditFields;
|
|
31
35
|
|
|
32
|
-
|
|
36
|
+
function updateAuditFields(entity, userInfo, isNew = false) {
|
|
37
|
+
// old entities may have createdByUUID as null if never synced after audit release
|
|
38
|
+
// isNew must be passed by callers to specify that it is indeed a create scenario
|
|
39
|
+
if (_lodash.default.isNil(entity.createdByUUID) && isNew) {
|
|
40
|
+
entity.createdByUUID = userInfo.userUUID;
|
|
41
|
+
entity.createdBy = userInfo.name;
|
|
42
|
+
}
|
|
43
|
+
|
|
44
|
+
if (_lodash.default.isNil(entity.lastModifiedByUUID)) {
|
|
45
|
+
entity.lastModifiedByUUID = userInfo.userUUID;
|
|
46
|
+
entity.lastModifiedBy = userInfo.name;
|
|
47
|
+
}
|
|
48
|
+
}
|
|
49
|
+
|
|
50
|
+
function mapAuditFields(txnEntity, txnResource) {
|
|
33
51
|
txnEntity.createdBy = _ResourceUtil.default.getFieldValue(txnResource, "createdBy");
|
|
34
52
|
txnEntity.createdByUUID = _ResourceUtil.default.getFieldValue(txnResource, "createdByUUID");
|
|
35
53
|
txnEntity.lastModifiedBy = _ResourceUtil.default.getFieldValue(txnResource, "lastModifiedBy");
|
|
36
54
|
txnEntity.lastModifiedByUUID = _ResourceUtil.default.getFieldValue(txnResource, "lastModifiedByUUID");
|
|
37
|
-
}
|
|
38
|
-
|
|
39
|
-
exports.mapAuditFields = mapAuditFields;
|
|
55
|
+
}
|