openchs-models 1.33.1 → 1.33.4

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.
Files changed (153) hide show
  1. package/.circleci/config.yml +15 -5
  2. package/.commit-message.txt +21 -0
  3. package/.nvmrc +1 -1
  4. package/Makefile +32 -10
  5. package/REALM_V12_NOTES.md +46 -0
  6. package/dist/AbstractEncounter.js +4 -105
  7. package/dist/AddressLevel.js +5 -62
  8. package/dist/ApprovalStatus.js +4 -17
  9. package/dist/BaseEntity.js +5 -42
  10. package/dist/BeneficiaryModePin.js +4 -13
  11. package/dist/Checklist.js +6 -52
  12. package/dist/ChecklistDetail.js +4 -22
  13. package/dist/ChecklistItem.js +16 -96
  14. package/dist/ChecklistItemDetail.js +4 -43
  15. package/dist/ChecklistItemStatus.js +6 -35
  16. package/dist/Comment.js +6 -51
  17. package/dist/CommentThread.js +4 -26
  18. package/dist/CompositeDuration.js +1 -18
  19. package/dist/Concept.js +5 -107
  20. package/dist/ConceptAnswer.js +4 -21
  21. package/dist/CustomDashboardCache.js +4 -38
  22. package/dist/CustomFilter.js +5 -15
  23. package/dist/Dashboard.js +4 -23
  24. package/dist/DashboardCache.js +4 -23
  25. package/dist/DashboardSection.js +4 -24
  26. package/dist/DashboardSectionCardMapping.js +4 -21
  27. package/dist/Displayable.js +3 -11
  28. package/dist/Documentation.js +4 -21
  29. package/dist/DocumentationItem.js +4 -20
  30. package/dist/Duration.js +4 -39
  31. package/dist/Encounter.js +6 -41
  32. package/dist/EncounterType.js +4 -26
  33. package/dist/EntityApprovalStatus.js +6 -56
  34. package/dist/EntityMetaData.js +7 -105
  35. package/dist/EntityQueue.js +4 -15
  36. package/dist/EntityRule.js +1 -29
  37. package/dist/EntitySyncStatus.js +4 -19
  38. package/dist/Extension.js +4 -18
  39. package/dist/Family.js +4 -56
  40. package/dist/FileFormat.js +0 -7
  41. package/dist/Gender.js +4 -17
  42. package/dist/GroupDashboard.js +4 -23
  43. package/dist/GroupPrivileges.js +4 -28
  44. package/dist/GroupRole.js +4 -34
  45. package/dist/GroupSubject.js +6 -59
  46. package/dist/Groups.js +4 -14
  47. package/dist/Identifier.js +4 -20
  48. package/dist/IdentifierAssignment.js +6 -45
  49. package/dist/IdentifierSource.js +4 -15
  50. package/dist/Individual.js +17 -265
  51. package/dist/LocaleMapping.js +4 -13
  52. package/dist/LocationHierarchy.js +4 -25
  53. package/dist/Media.js +35 -35
  54. package/dist/MediaQueue.js +4 -26
  55. package/dist/MigrationsHelper.js +15 -22
  56. package/dist/MyGroups.js +4 -14
  57. package/dist/News.js +4 -31
  58. package/dist/Observation.js +4 -54
  59. package/dist/ObservationsHolder.js +104 -216
  60. package/dist/OrganisationConfig.js +4 -19
  61. package/dist/PersistedObject.js +1 -19
  62. package/dist/PhoneNumber.js +0 -11
  63. package/dist/PlatformTranslation.js +4 -17
  64. package/dist/Privilege.js +5 -22
  65. package/dist/Program.js +4 -39
  66. package/dist/ProgramEncounter.js +6 -48
  67. package/dist/ProgramEnrolment.js +8 -162
  68. package/dist/ReferenceEntity.js +1 -10
  69. package/dist/ReportCard.js +5 -60
  70. package/dist/ResetSync.js +4 -17
  71. package/dist/Rule.js +4 -28
  72. package/dist/RuleDependency.js +4 -17
  73. package/dist/RuleFailureTelemetry.js +4 -36
  74. package/dist/Schema.js +16 -268
  75. package/dist/SchemaNames.js +3 -46
  76. package/dist/Settings.js +4 -53
  77. package/dist/StandardReportCardType.js +4 -39
  78. package/dist/SubjectMigration.js +6 -45
  79. package/dist/SubjectType.js +6 -72
  80. package/dist/SyncTelemetry.js +4 -40
  81. package/dist/Translation.js +4 -17
  82. package/dist/UserInfo.js +4 -33
  83. package/dist/application/DashboardCacheFilter.js +4 -24
  84. package/dist/application/Filter.js +3 -16
  85. package/dist/application/Form.js +6 -93
  86. package/dist/application/FormElement.js +5 -100
  87. package/dist/application/FormElementGroup.js +4 -75
  88. package/dist/application/FormElementStatus.js +1 -11
  89. package/dist/application/FormMapping.js +6 -44
  90. package/dist/application/Format.js +4 -20
  91. package/dist/application/KeyValue.js +4 -19
  92. package/dist/application/MenuItem.js +4 -35
  93. package/dist/application/MultiSelectFilter.js +1 -11
  94. package/dist/application/NullProgramEnrolment.js +0 -8
  95. package/dist/application/SingleSelectFilter.js +1 -12
  96. package/dist/application/StaticFormElementGroup.js +0 -11
  97. package/dist/application/StringKeyNumericValue.js +4 -17
  98. package/dist/application/ValidationResult.js +6 -20
  99. package/dist/application/ValidationResults.js +1 -14
  100. package/dist/application/WorkItem.js +4 -20
  101. package/dist/application/WorkList.js +1 -24
  102. package/dist/application/WorkLists.js +1 -13
  103. package/dist/assignment/UserSubjectAssignment.js +6 -26
  104. package/dist/draft/DraftEncounter.js +4 -40
  105. package/dist/draft/DraftSubject.js +4 -46
  106. package/dist/error/IgnorableSyncError.js +1 -6
  107. package/dist/error/SyncError.js +1 -6
  108. package/dist/framework/ArrayHelper.js +3 -11
  109. package/dist/framework/DefinedObjectSchema.js +4 -12
  110. package/dist/framework/RealmCollectionHelper.js +1 -9
  111. package/dist/framework/RealmListProxy.js +1 -10
  112. package/dist/framework/RealmObjectSchema.js +1 -11
  113. package/dist/framework/RealmProxy.js +2 -31
  114. package/dist/framework/RealmResultsProxy.js +3 -37
  115. package/dist/framework/RealmResultsProxyHandler.js +2 -5
  116. package/dist/geo/Point.js +4 -17
  117. package/dist/index.js +2 -137
  118. package/dist/location/Locations.js +1 -6
  119. package/dist/observation/MultipleCodedValues.js +1 -21
  120. package/dist/observation/PrimitiveValue.js +1 -17
  121. package/dist/observation/QuestionGroup.js +1 -36
  122. package/dist/observation/RepeatableQuestionGroup.js +4 -27
  123. package/dist/observation/SingleCodedValue.js +1 -15
  124. package/dist/program/SubjectProgramEligibility.js +6 -56
  125. package/dist/relationship/IndividualRelation.js +6 -18
  126. package/dist/relationship/IndividualRelationGenderMapping.js +4 -22
  127. package/dist/relationship/IndividualRelationship.js +6 -51
  128. package/dist/relationship/IndividualRelationshipType.js +4 -24
  129. package/dist/relationship/IndividualRelative.js +4 -31
  130. package/dist/reports/DashboardFilter.js +4 -20
  131. package/dist/reports/DashboardFilterConfig.js +5 -85
  132. package/dist/reports/NestedReportCardResult.js +5 -35
  133. package/dist/reports/Range.js +4 -13
  134. package/dist/reports/ReportCardResult.js +5 -24
  135. package/dist/service/MetaDataService.js +1 -30
  136. package/dist/task/Task.js +6 -62
  137. package/dist/task/TaskStatus.js +4 -21
  138. package/dist/task/TaskType.js +4 -23
  139. package/dist/task/TaskUnAssignment.js +6 -30
  140. package/dist/utility/AgeUtil.js +1 -15
  141. package/dist/utility/ArrayUtil.js +1 -6
  142. package/dist/utility/AuditUtil.js +1 -8
  143. package/dist/utility/DateTimeUtil.js +1 -8
  144. package/dist/utility/General.js +4 -71
  145. package/dist/utility/JsonStringify.js +15 -28
  146. package/dist/utility/MergeUtil.js +1 -10
  147. package/dist/utility/ResourceUtil.js +1 -7
  148. package/dist/videos/Video.js +4 -23
  149. package/dist/videos/VideoTelemetric.js +6 -37
  150. package/package.json +6 -3
  151. package/scripts/validateSchemas.js +40 -0
  152. package/tsconfig.json +1 -1
  153. package/yarn.lock +0 -6744
@@ -4,38 +4,29 @@ Object.defineProperty(exports, "__esModule", {
4
4
  value: true
5
5
  });
6
6
  exports.default = void 0;
7
-
8
7
  var _BaseEntity = _interopRequireDefault(require("./BaseEntity"));
9
-
10
- function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
11
-
12
- function _defineProperty(obj, key, value) { if (key in obj) { Object.defineProperty(obj, key, { value: value, enumerable: true, configurable: true, writable: true }); } else { obj[key] = value; } return obj; }
13
-
8
+ function _interopRequireDefault(e) { return e && e.__esModule ? e : { default: e }; }
9
+ function _defineProperty(e, r, t) { return (r = _toPropertyKey(r)) in e ? Object.defineProperty(e, r, { value: t, enumerable: !0, configurable: !0, writable: !0 }) : e[r] = t, e; }
10
+ function _toPropertyKey(t) { var i = _toPrimitive(t, "string"); return "symbol" == typeof i ? i : i + ""; }
11
+ function _toPrimitive(t, r) { if ("object" != typeof t || !t) return t; var e = t[Symbol.toPrimitive]; if (void 0 !== e) { var i = e.call(t, r || "default"); if ("object" != typeof i) return i; throw new TypeError("@@toPrimitive must return a primitive value."); } return ("string" === r ? String : Number)(t); }
14
12
  class LocaleMapping extends _BaseEntity.default {
15
13
  constructor(that = null) {
16
14
  super(that);
17
15
  }
18
-
19
16
  get locale() {
20
17
  return this.that.locale;
21
18
  }
22
-
23
19
  set locale(x) {
24
20
  this.that.locale = x;
25
21
  }
26
-
27
22
  get displayText() {
28
23
  return this.that.displayText;
29
24
  }
30
-
31
25
  set displayText(x) {
32
26
  this.that.displayText = x;
33
27
  }
34
-
35
28
  }
36
-
37
29
  exports.default = LocaleMapping;
38
-
39
30
  _defineProperty(LocaleMapping, "schema", {
40
31
  name: "LocaleMapping",
41
32
  primaryKey: "uuid",
@@ -4,68 +4,52 @@ Object.defineProperty(exports, "__esModule", {
4
4
  value: true
5
5
  });
6
6
  exports.default = void 0;
7
-
8
7
  var _BaseEntity = _interopRequireDefault(require("./BaseEntity"));
9
-
10
8
  var _lodash = _interopRequireDefault(require("lodash"));
11
-
12
- function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
13
-
14
- function _defineProperty(obj, key, value) { if (key in obj) { Object.defineProperty(obj, key, { value: value, enumerable: true, configurable: true, writable: true }); } else { obj[key] = value; } return obj; }
15
-
9
+ function _interopRequireDefault(e) { return e && e.__esModule ? e : { default: e }; }
10
+ function _defineProperty(e, r, t) { return (r = _toPropertyKey(r)) in e ? Object.defineProperty(e, r, { value: t, enumerable: !0, configurable: !0, writable: !0 }) : e[r] = t, e; }
11
+ function _toPropertyKey(t) { var i = _toPrimitive(t, "string"); return "symbol" == typeof i ? i : i + ""; }
12
+ function _toPrimitive(t, r) { if ("object" != typeof t || !t) return t; var e = t[Symbol.toPrimitive]; if (void 0 !== e) { var i = e.call(t, r || "default"); if ("object" != typeof i) return i; throw new TypeError("@@toPrimitive must return a primitive value."); } return ("string" === r ? String : Number)(t); }
16
13
  class LocationHierarchy extends _BaseEntity.default {
17
14
  constructor(that = null) {
18
15
  super(that);
19
16
  }
20
-
21
17
  get name() {
22
18
  return this.that.name;
23
19
  }
24
-
25
20
  set name(x) {
26
21
  this.that.name = x;
27
22
  }
28
-
29
23
  get type() {
30
24
  return this.that.type;
31
25
  }
32
-
33
26
  set type(x) {
34
27
  this.that.type = x;
35
28
  }
36
-
37
29
  get level() {
38
30
  return this.that.level;
39
31
  }
40
-
41
32
  set level(x) {
42
33
  this.that.level = x;
43
34
  }
44
-
45
35
  get parentUuid() {
46
36
  return this.that.parentUuid;
47
37
  }
48
-
49
38
  set parentUuid(x) {
50
39
  this.that.parentUuid = x;
51
40
  }
52
-
53
41
  get titleLineage() {
54
42
  return this.that.titleLineage;
55
43
  }
56
-
57
44
  set titleLineage(x) {
58
45
  this.that.titleLineage = x;
59
46
  }
60
-
61
47
  get typeUuid() {
62
48
  return this.that.typeUuid;
63
49
  }
64
-
65
50
  set typeUuid(x) {
66
51
  this.that.typeUuid = x;
67
52
  }
68
-
69
53
  static create({
70
54
  uuid,
71
55
  title,
@@ -87,11 +71,9 @@ class LocationHierarchy extends _BaseEntity.default {
87
71
  typeUuid
88
72
  });
89
73
  }
90
-
91
74
  static fromResource(resource) {
92
75
  return LocationHierarchy.create(resource);
93
76
  }
94
-
95
77
  cloneForReference() {
96
78
  return LocationHierarchy.create(_lodash.default.assignIn({
97
79
  title: this.name,
@@ -102,9 +84,7 @@ class LocationHierarchy extends _BaseEntity.default {
102
84
  voided: this.voided
103
85
  }, this));
104
86
  }
105
-
106
87
  }
107
-
108
88
  _defineProperty(LocationHierarchy, "schema", {
109
89
  name: "LocationHierarchy",
110
90
  primaryKey: "uuid",
@@ -134,6 +114,5 @@ _defineProperty(LocationHierarchy, "schema", {
134
114
  }
135
115
  }
136
116
  });
137
-
138
117
  var _default = LocationHierarchy;
139
118
  exports.default = _default;
package/dist/Media.js CHANGED
@@ -4,89 +4,89 @@ Object.defineProperty(exports, "__esModule", {
4
4
  value: true
5
5
  });
6
6
  exports.findMediaObservations = void 0;
7
-
8
7
  var _lodash = _interopRequireDefault(require("lodash"));
9
-
10
8
  var _Concept = _interopRequireDefault(require("./Concept"));
11
-
12
- function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
13
-
9
+ function _interopRequireDefault(e) { return e && e.__esModule ? e : { default: e }; }
14
10
  // Helper to check if an observation is a media observation
15
11
  const isMediaObservation = observation => {
16
12
  if (!observation || !observation.concept) return false;
17
13
  return _Concept.default.dataType.Media.includes(observation.concept.datatype);
18
- }; // Helper to collect media observations from an array of observations
19
-
14
+ };
20
15
 
16
+ // Helper to collect media observations from an array of observations
21
17
  const collectMediaObservations = observations => {
22
18
  return _lodash.default.filter(observations, isMediaObservation);
23
- }; // Helper to process observations in a question group
24
-
19
+ };
25
20
 
21
+ // Helper to process observations in a question group
26
22
  const processQuestionGroup = questionGroup => {
27
23
  // Get observations inside the question group
28
- const groupObservations = questionGroup.getValue && Array.isArray(questionGroup.getValue()) ? questionGroup.getValue() : []; // Return media observations inside the question group
24
+ const groupObservations = questionGroup.getValue && Array.isArray(questionGroup.getValue()) ? questionGroup.getValue() : [];
29
25
 
26
+ // Return media observations inside the question group
30
27
  return collectMediaObservations(groupObservations);
31
- }; // Helper to process observations in a repeatable question group
32
-
28
+ };
33
29
 
30
+ // Helper to process observations in a repeatable question group
34
31
  const processRepeatableQuestionGroup = repeatableQuestionGroup => {
35
32
  // Get all question groups from the repeatable question group
36
- const allGroups = repeatableQuestionGroup.getAllQuestionGroupObservations && repeatableQuestionGroup.getAllQuestionGroupObservations() || []; // Process each question group and collect all media observations
33
+ const allGroups = repeatableQuestionGroup.getAllQuestionGroupObservations && repeatableQuestionGroup.getAllQuestionGroupObservations() || [];
37
34
 
35
+ // Process each question group and collect all media observations
38
36
  return _lodash.default.flatten(allGroups.map(group => processQuestionGroup(group)));
39
- }; // Process an individual observation and its nested structure if applicable
40
-
37
+ };
41
38
 
39
+ // Process an individual observation and its nested structure if applicable
42
40
  const processObservation = observation => {
43
41
  if (!observation) return [];
44
- const result = []; // Case 1: Direct media observation
42
+ const result = [];
45
43
 
44
+ // Case 1: Direct media observation
46
45
  if (isMediaObservation(observation)) {
47
46
  result.push(observation);
48
- } // Check for nested observations in value wrapper
49
-
47
+ }
50
48
 
49
+ // Check for nested observations in value wrapper
51
50
  try {
52
51
  const valueWrapper = observation.getValueWrapper && observation.getValueWrapper();
53
-
54
52
  if (!valueWrapper) {
55
53
  return result;
56
- } // Case 2a: Regular Question Group
57
-
54
+ }
58
55
 
56
+ // Case 2a: Regular Question Group
59
57
  if (!valueWrapper.isRepeatable || !valueWrapper.isRepeatable()) {
60
58
  result.push(...processQuestionGroup(valueWrapper));
61
- } // Case 2b: Repeatable Question Group
59
+ }
60
+ // Case 2b: Repeatable Question Group
62
61
  else {
63
- result.push(...processRepeatableQuestionGroup(valueWrapper));
64
- }
62
+ result.push(...processRepeatableQuestionGroup(valueWrapper));
63
+ }
65
64
  } catch (error) {
66
65
  // Silently handle parsing errors or invalid structures
67
66
  console.log(`[INFO] Error processing observation: ${error.message}`);
68
67
  }
69
-
70
68
  return result;
71
- }; // Main function to find all media observations
72
-
69
+ };
73
70
 
71
+ // Main function to find all media observations
74
72
  const findMediaObservations = (...observations) => {
75
- console.log(`[INFO] Finding media observations in ${observations.length} observation arrays`); // Handle null or undefined input
76
-
77
- if (!observations || !observations.length) return []; // Filter out null or undefined values
73
+ console.log(`[INFO] Finding media observations in ${observations.length} observation arrays`);
78
74
 
79
- const validObservations = observations.filter(obs => obs != null); // Process all input observation arrays
75
+ // Handle null or undefined input
76
+ if (!observations || !observations.length) return [];
80
77
 
81
- const flattenedObservations = _lodash.default.flatten(validObservations); // Handle empty array
78
+ // Filter out null or undefined values
79
+ const validObservations = observations.filter(obs => obs != null);
82
80
 
81
+ // Process all input observation arrays
82
+ const flattenedObservations = _lodash.default.flatten(validObservations);
83
83
 
84
- if (!flattenedObservations || !flattenedObservations.length) return []; // Process each observation and collect results
84
+ // Handle empty array
85
+ if (!flattenedObservations || !flattenedObservations.length) return [];
85
86
 
87
+ // Process each observation and collect results
86
88
  const result = _lodash.default.flatten(flattenedObservations.map(processObservation).filter(item => item != null));
87
-
88
89
  console.log(`[INFO] Found ${result.length} media observations`);
89
90
  return result;
90
91
  };
91
-
92
92
  exports.findMediaObservations = findMediaObservations;
@@ -4,70 +4,53 @@ Object.defineProperty(exports, "__esModule", {
4
4
  value: true
5
5
  });
6
6
  exports.default = void 0;
7
-
8
7
  var _General = _interopRequireDefault(require("./utility/General"));
9
-
10
8
  var _BaseEntity = _interopRequireDefault(require("./BaseEntity"));
11
-
12
9
  var _lodash = _interopRequireDefault(require("lodash"));
13
-
14
- function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
15
-
16
- function _defineProperty(obj, key, value) { if (key in obj) { Object.defineProperty(obj, key, { value: value, enumerable: true, configurable: true, writable: true }); } else { obj[key] = value; } return obj; }
17
-
10
+ function _interopRequireDefault(e) { return e && e.__esModule ? e : { default: e }; }
11
+ function _defineProperty(e, r, t) { return (r = _toPropertyKey(r)) in e ? Object.defineProperty(e, r, { value: t, enumerable: !0, configurable: !0, writable: !0 }) : e[r] = t, e; }
12
+ function _toPropertyKey(t) { var i = _toPrimitive(t, "string"); return "symbol" == typeof i ? i : i + ""; }
13
+ function _toPrimitive(t, r) { if ("object" != typeof t || !t) return t; var e = t[Symbol.toPrimitive]; if (void 0 !== e) { var i = e.call(t, r || "default"); if ("object" != typeof i) return i; throw new TypeError("@@toPrimitive must return a primitive value."); } return ("string" === r ? String : Number)(t); }
18
14
  class MediaQueue extends _BaseEntity.default {
19
15
  constructor(that = null) {
20
16
  super(that);
21
17
  }
22
-
23
18
  get entityUUID() {
24
19
  return this.that.entityUUID;
25
20
  }
26
-
27
21
  set entityUUID(x) {
28
22
  this.that.entityUUID = x;
29
23
  }
30
-
31
24
  get entityName() {
32
25
  return this.that.entityName;
33
26
  }
34
-
35
27
  set entityName(x) {
36
28
  this.that.entityName = x;
37
29
  }
38
-
39
30
  get entityTargetField() {
40
31
  return this.that.entityTargetField;
41
32
  }
42
-
43
33
  set entityTargetField(x) {
44
34
  this.that.entityTargetField = x;
45
35
  }
46
-
47
36
  get fileName() {
48
37
  return this.that.fileName;
49
38
  }
50
-
51
39
  set fileName(x) {
52
40
  this.that.fileName = x;
53
41
  }
54
-
55
42
  get type() {
56
43
  return this.that.type;
57
44
  }
58
-
59
45
  set type(x) {
60
46
  this.that.type = x;
61
47
  }
62
-
63
48
  get conceptUUID() {
64
49
  return this.that.conceptUUID;
65
50
  }
66
-
67
51
  set conceptUUID(x) {
68
52
  this.that.conceptUUID = x;
69
53
  }
70
-
71
54
  static create(entityUUID, entityName, fileName, type, entityTargetField, conceptUUID, uuid = _General.default.randomUUID()) {
72
55
  const mediaQueue = new MediaQueue();
73
56
  mediaQueue.entityUUID = entityUUID;
@@ -79,7 +62,6 @@ class MediaQueue extends _BaseEntity.default {
79
62
  mediaQueue.conceptUUID = conceptUUID;
80
63
  return mediaQueue;
81
64
  }
82
-
83
65
  clone() {
84
66
  const mediaQueueItem = new MediaQueue();
85
67
  mediaQueueItem.uuid = this.uuid;
@@ -91,7 +73,6 @@ class MediaQueue extends _BaseEntity.default {
91
73
  mediaQueueItem.conceptUUID = this.conceptUUID;
92
74
  return mediaQueueItem;
93
75
  }
94
-
95
76
  getDisplayText() {
96
77
  // generate safe to string
97
78
  let str = "";
@@ -103,9 +84,7 @@ class MediaQueue extends _BaseEntity.default {
103
84
  if (!_lodash.default.isNil(this.conceptUUID)) str += "ConceptUUID: " + this.conceptUUID;
104
85
  return str;
105
86
  }
106
-
107
87
  }
108
-
109
88
  _defineProperty(MediaQueue, "schema", {
110
89
  name: "MediaQueue",
111
90
  primaryKey: "uuid",
@@ -122,6 +101,5 @@ _defineProperty(MediaQueue, "schema", {
122
101
  }
123
102
  }
124
103
  });
125
-
126
104
  var _default = MediaQueue;
127
105
  exports.default = _default;
@@ -4,13 +4,9 @@ Object.defineProperty(exports, "__esModule", {
4
4
  value: true
5
5
  });
6
6
  exports.default = void 0;
7
-
8
7
  var _lodash = _interopRequireDefault(require("lodash"));
9
-
10
8
  var _IndividualRelationship = _interopRequireDefault(require("./relationship/IndividualRelationship"));
11
-
12
- function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
13
-
9
+ function _interopRequireDefault(e) { return e && e.__esModule ? e : { default: e }; }
14
10
  function deleteIndividual(individual, db) {
15
11
  // SUBJECT children (program enrolments)
16
12
  _lodash.default.forEach(individual.enrolments, enrolment => {
@@ -18,65 +14,62 @@ function deleteIndividual(individual, db) {
18
14
  //For some reason, the last element shows up as undefined when there are multiple enrolments for a subject
19
15
  if (_lodash.default.isNil(enrolment)) {
20
16
  return;
21
- } // ENROLMENT children (encounters)
22
-
17
+ }
23
18
 
19
+ // ENROLMENT children (encounters)
24
20
  _lodash.default.forEach(enrolment.encounters, programEncounter => {
25
21
  // PROGRAM ENCOUNTER
26
22
  // PROGRAM ENCOUNTER children (others)
27
23
  db.delete(programEncounter.approvalStatuses);
28
24
  });
25
+ db.delete(enrolment.encounters);
29
26
 
30
- db.delete(enrolment.encounters); // ENROLMENT children (checklists)
31
-
27
+ // ENROLMENT children (checklists)
32
28
  _lodash.default.forEach(enrolment.checklists, checklist => {
33
29
  // CHECKLIST
34
30
  if (_lodash.default.isNil(checklist)) {
35
31
  return;
36
- } // CHECKLIST children (checklist items)
37
-
32
+ }
38
33
 
34
+ // CHECKLIST children (checklist items)
39
35
  _lodash.default.forEach(checklist.items, checklistItem => {
40
36
  // CHECKLIST ITEM
41
37
  if (_lodash.default.isNil(checklistItem)) {
42
38
  return;
43
- } // CHECKLIST ITEM children (others)
44
-
39
+ }
45
40
 
41
+ // CHECKLIST ITEM children (others)
46
42
  db.delete(checklistItem.observations);
47
43
  db.delete(checklistItem.approvalStatuses);
48
44
  });
49
-
50
45
  db.delete(checklist.items);
51
46
  });
47
+ db.delete(enrolment.checklists);
52
48
 
53
- db.delete(enrolment.checklists); // ENROLMENT children (others)
54
-
49
+ // ENROLMENT children (others)
55
50
  db.delete(enrolment.observations);
56
51
  db.delete(enrolment.programExitObservations);
57
52
  db.delete(enrolment.approvalStatuses);
58
53
  });
59
-
60
54
  db.delete(individual.enrolments);
61
-
62
55
  _lodash.default.forEach(individual.encounters, encounter => {
63
56
  // ENCOUNTER
64
57
  // ENCOUNTER children (others)
65
58
  db.delete(encounter.approvalStatuses);
66
59
  });
60
+ db.delete(individual.encounters);
67
61
 
68
- db.delete(individual.encounters); // SUBJECT children (others)
69
-
62
+ // SUBJECT children (others)
70
63
  const subjectRelationships = db.objects(_IndividualRelationship.default.schema.name).filtered('individualA = $0 or individualB = $0', individual);
71
64
  db.delete(subjectRelationships);
72
65
  db.delete(individual.comments);
73
66
  db.delete(individual.groupSubjects);
74
67
  db.delete(individual.groups);
75
- db.delete(individual.approvalStatuses); // SUBJECT root
68
+ db.delete(individual.approvalStatuses);
76
69
 
70
+ // SUBJECT root
77
71
  db.delete(individual);
78
72
  }
79
-
80
73
  var _default = {
81
74
  deleteIndividual
82
75
  };
package/dist/MyGroups.js CHANGED
@@ -4,34 +4,27 @@ Object.defineProperty(exports, "__esModule", {
4
4
  value: true
5
5
  });
6
6
  exports.default = void 0;
7
-
8
7
  var _BaseEntity = _interopRequireDefault(require("./BaseEntity"));
9
-
10
- function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
11
-
12
- function _defineProperty(obj, key, value) { if (key in obj) { Object.defineProperty(obj, key, { value: value, enumerable: true, configurable: true, writable: true }); } else { obj[key] = value; } return obj; }
13
-
8
+ function _interopRequireDefault(e) { return e && e.__esModule ? e : { default: e }; }
9
+ function _defineProperty(e, r, t) { return (r = _toPropertyKey(r)) in e ? Object.defineProperty(e, r, { value: t, enumerable: !0, configurable: !0, writable: !0 }) : e[r] = t, e; }
10
+ function _toPropertyKey(t) { var i = _toPrimitive(t, "string"); return "symbol" == typeof i ? i : i + ""; }
11
+ function _toPrimitive(t, r) { if ("object" != typeof t || !t) return t; var e = t[Symbol.toPrimitive]; if (void 0 !== e) { var i = e.call(t, r || "default"); if ("object" != typeof i) return i; throw new TypeError("@@toPrimitive must return a primitive value."); } return ("string" === r ? String : Number)(t); }
14
12
  class MyGroups extends _BaseEntity.default {
15
13
  constructor(that = null) {
16
14
  super(that);
17
15
  }
18
-
19
16
  get groupUuid() {
20
17
  return this.that.groupUuid;
21
18
  }
22
-
23
19
  set groupUuid(x) {
24
20
  this.that.groupUuid = x;
25
21
  }
26
-
27
22
  get groupName() {
28
23
  return this.that.groupName;
29
24
  }
30
-
31
25
  set groupName(x) {
32
26
  this.that.groupName = x;
33
27
  }
34
-
35
28
  static fromResource(resource) {
36
29
  let myGroups = new MyGroups();
37
30
  myGroups.uuid = resource.uuid;
@@ -40,9 +33,7 @@ class MyGroups extends _BaseEntity.default {
40
33
  myGroups.voided = resource.voided;
41
34
  return myGroups;
42
35
  }
43
-
44
36
  }
45
-
46
37
  _defineProperty(MyGroups, "schema", {
47
38
  name: "MyGroups",
48
39
  primaryKey: "uuid",
@@ -56,6 +47,5 @@ _defineProperty(MyGroups, "schema", {
56
47
  }
57
48
  }
58
49
  });
59
-
60
50
  var _default = MyGroups;
61
51
  exports.default = _default;
package/dist/News.js CHANGED
@@ -4,96 +4,72 @@ Object.defineProperty(exports, "__esModule", {
4
4
  value: true
5
5
  });
6
6
  exports.default = void 0;
7
-
8
7
  var _BaseEntity = _interopRequireDefault(require("./BaseEntity"));
9
-
10
8
  var _General = _interopRequireDefault(require("./utility/General"));
11
-
12
9
  var _moment = _interopRequireDefault(require("moment"));
13
-
14
- function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
15
-
16
- function _defineProperty(obj, key, value) { if (key in obj) { Object.defineProperty(obj, key, { value: value, enumerable: true, configurable: true, writable: true }); } else { obj[key] = value; } return obj; }
17
-
10
+ function _interopRequireDefault(e) { return e && e.__esModule ? e : { default: e }; }
11
+ function _defineProperty(e, r, t) { return (r = _toPropertyKey(r)) in e ? Object.defineProperty(e, r, { value: t, enumerable: !0, configurable: !0, writable: !0 }) : e[r] = t, e; }
12
+ function _toPropertyKey(t) { var i = _toPrimitive(t, "string"); return "symbol" == typeof i ? i : i + ""; }
13
+ function _toPrimitive(t, r) { if ("object" != typeof t || !t) return t; var e = t[Symbol.toPrimitive]; if (void 0 !== e) { var i = e.call(t, r || "default"); if ("object" != typeof i) return i; throw new TypeError("@@toPrimitive must return a primitive value."); } return ("string" === r ? String : Number)(t); }
18
14
  class News extends _BaseEntity.default {
19
15
  constructor(that = null) {
20
16
  super(that);
21
17
  }
22
-
23
18
  get title() {
24
19
  return this.that.title;
25
20
  }
26
-
27
21
  set title(x) {
28
22
  this.that.title = x;
29
23
  }
30
-
31
24
  get publishedDate() {
32
25
  return this.that.publishedDate;
33
26
  }
34
-
35
27
  set publishedDate(x) {
36
28
  this.that.publishedDate = x;
37
29
  }
38
-
39
30
  get heroImage() {
40
31
  return this.that.heroImage;
41
32
  }
42
-
43
33
  set heroImage(x) {
44
34
  this.that.heroImage = x;
45
35
  }
46
-
47
36
  get content() {
48
37
  return this.that.content;
49
38
  }
50
-
51
39
  set content(x) {
52
40
  this.that.content = x;
53
41
  }
54
-
55
42
  get contentHtml() {
56
43
  return this.that.contentHtml;
57
44
  }
58
-
59
45
  set contentHtml(x) {
60
46
  this.that.contentHtml = x;
61
47
  }
62
-
63
48
  get read() {
64
49
  return this.that.read;
65
50
  }
66
-
67
51
  set read(x) {
68
52
  this.that.read = x;
69
53
  }
70
-
71
54
  get lastModifiedDateTime() {
72
55
  return this.that.lastModifiedDateTime;
73
56
  }
74
-
75
57
  set lastModifiedDateTime(x) {
76
58
  this.that.lastModifiedDateTime = x;
77
59
  }
78
-
79
60
  static fromResource(resource, entityService) {
80
61
  const news = _General.default.assignFields(resource, new News(), ['uuid', 'title', 'heroImage', 'content', 'contentHtml', 'voided'], ['publishedDate', 'lastModifiedDateTime']);
81
-
82
62
  const olderNews = entityService.findByKey('uuid', news.uuid, News.schema.name);
83
-
84
63
  if (olderNews && (0, _moment.default)(news.lastModifiedDateTime).isAfter(olderNews.lastModifiedDateTime)) {
85
64
  news.read = false;
86
65
  }
87
-
88
66
  return news;
89
67
  }
90
-
91
68
  markRead() {
92
69
  const news = this.cloneForEdit();
93
70
  news.read = true;
94
71
  return news;
95
72
  }
96
-
97
73
  cloneForEdit() {
98
74
  const news = new News();
99
75
  news.uuid = this.uuid;
@@ -106,9 +82,7 @@ class News extends _BaseEntity.default {
106
82
  news.read = this.read;
107
83
  return news;
108
84
  }
109
-
110
85
  }
111
-
112
86
  _defineProperty(News, "schema", {
113
87
  name: 'News',
114
88
  primaryKey: 'uuid',
@@ -139,6 +113,5 @@ _defineProperty(News, "schema", {
139
113
  lastModifiedDateTime: 'date'
140
114
  }
141
115
  });
142
-
143
116
  var _default = News;
144
117
  exports.default = _default;