openchs-models 1.33.2 → 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.
- package/.circleci/config.yml +15 -5
- package/.commit-message.txt +21 -0
- package/.nvmrc +1 -1
- package/Makefile +32 -10
- package/REALM_V12_NOTES.md +46 -0
- package/dist/AbstractEncounter.js +4 -105
- package/dist/AddressLevel.js +5 -62
- package/dist/ApprovalStatus.js +4 -17
- package/dist/BaseEntity.js +5 -42
- package/dist/BeneficiaryModePin.js +4 -13
- package/dist/Checklist.js +6 -52
- package/dist/ChecklistDetail.js +4 -22
- package/dist/ChecklistItem.js +16 -96
- package/dist/ChecklistItemDetail.js +4 -43
- package/dist/ChecklistItemStatus.js +4 -33
- package/dist/Comment.js +6 -51
- package/dist/CommentThread.js +4 -26
- package/dist/CompositeDuration.js +1 -18
- package/dist/Concept.js +5 -107
- package/dist/ConceptAnswer.js +4 -21
- package/dist/CustomDashboardCache.js +4 -38
- package/dist/CustomFilter.js +5 -15
- package/dist/Dashboard.js +4 -23
- package/dist/DashboardCache.js +4 -23
- package/dist/DashboardSection.js +4 -24
- package/dist/DashboardSectionCardMapping.js +4 -21
- package/dist/Displayable.js +3 -11
- package/dist/Documentation.js +4 -21
- package/dist/DocumentationItem.js +4 -20
- package/dist/Duration.js +4 -39
- package/dist/Encounter.js +6 -41
- package/dist/EncounterType.js +4 -26
- package/dist/EntityApprovalStatus.js +6 -56
- package/dist/EntityMetaData.js +7 -105
- package/dist/EntityQueue.js +4 -15
- package/dist/EntityRule.js +1 -29
- package/dist/EntitySyncStatus.js +4 -19
- package/dist/Extension.js +4 -18
- package/dist/Family.js +4 -56
- package/dist/FileFormat.js +0 -7
- package/dist/Gender.js +4 -17
- package/dist/GroupDashboard.js +4 -23
- package/dist/GroupPrivileges.js +4 -28
- package/dist/GroupRole.js +4 -34
- package/dist/GroupSubject.js +6 -59
- package/dist/Groups.js +4 -14
- package/dist/Identifier.js +4 -20
- package/dist/IdentifierAssignment.js +6 -45
- package/dist/IdentifierSource.js +4 -15
- package/dist/Individual.js +17 -265
- package/dist/LocaleMapping.js +4 -13
- package/dist/LocationHierarchy.js +4 -25
- package/dist/Media.js +35 -35
- package/dist/MediaQueue.js +4 -26
- package/dist/MigrationsHelper.js +15 -22
- package/dist/MyGroups.js +4 -14
- package/dist/News.js +4 -31
- package/dist/Observation.js +4 -54
- package/dist/ObservationsHolder.js +104 -216
- package/dist/OrganisationConfig.js +4 -19
- package/dist/PersistedObject.js +1 -19
- package/dist/PhoneNumber.js +0 -11
- package/dist/PlatformTranslation.js +4 -17
- package/dist/Privilege.js +5 -22
- package/dist/Program.js +4 -39
- package/dist/ProgramEncounter.js +6 -48
- package/dist/ProgramEnrolment.js +8 -162
- package/dist/ReferenceEntity.js +1 -10
- package/dist/ReportCard.js +5 -60
- package/dist/ResetSync.js +4 -17
- package/dist/Rule.js +4 -28
- package/dist/RuleDependency.js +4 -17
- package/dist/RuleFailureTelemetry.js +4 -36
- package/dist/Schema.js +16 -268
- package/dist/SchemaNames.js +3 -46
- package/dist/Settings.js +4 -53
- package/dist/StandardReportCardType.js +4 -39
- package/dist/SubjectMigration.js +6 -45
- package/dist/SubjectType.js +6 -72
- package/dist/SyncTelemetry.js +4 -40
- package/dist/Translation.js +4 -17
- package/dist/UserInfo.js +4 -33
- package/dist/application/DashboardCacheFilter.js +4 -24
- package/dist/application/Filter.js +3 -16
- package/dist/application/Form.js +6 -93
- package/dist/application/FormElement.js +5 -100
- package/dist/application/FormElementGroup.js +4 -75
- package/dist/application/FormElementStatus.js +1 -11
- package/dist/application/FormMapping.js +6 -44
- package/dist/application/Format.js +4 -20
- package/dist/application/KeyValue.js +4 -19
- package/dist/application/MenuItem.js +4 -35
- package/dist/application/MultiSelectFilter.js +1 -11
- package/dist/application/NullProgramEnrolment.js +0 -8
- package/dist/application/SingleSelectFilter.js +1 -12
- package/dist/application/StaticFormElementGroup.js +0 -11
- package/dist/application/StringKeyNumericValue.js +4 -17
- package/dist/application/ValidationResult.js +6 -20
- package/dist/application/ValidationResults.js +1 -14
- package/dist/application/WorkItem.js +4 -20
- package/dist/application/WorkList.js +1 -24
- package/dist/application/WorkLists.js +1 -13
- package/dist/assignment/UserSubjectAssignment.js +6 -26
- package/dist/draft/DraftEncounter.js +4 -40
- package/dist/draft/DraftSubject.js +4 -46
- package/dist/error/IgnorableSyncError.js +1 -6
- package/dist/error/SyncError.js +1 -6
- package/dist/framework/ArrayHelper.js +3 -11
- package/dist/framework/DefinedObjectSchema.js +4 -12
- package/dist/framework/RealmCollectionHelper.js +1 -9
- package/dist/framework/RealmListProxy.js +1 -10
- package/dist/framework/RealmObjectSchema.js +1 -11
- package/dist/framework/RealmProxy.js +2 -31
- package/dist/framework/RealmResultsProxy.js +3 -37
- package/dist/framework/RealmResultsProxyHandler.js +2 -5
- package/dist/geo/Point.js +4 -17
- package/dist/index.js +2 -137
- package/dist/location/Locations.js +1 -6
- package/dist/observation/MultipleCodedValues.js +1 -21
- package/dist/observation/PrimitiveValue.js +1 -17
- package/dist/observation/QuestionGroup.js +1 -36
- package/dist/observation/RepeatableQuestionGroup.js +4 -27
- package/dist/observation/SingleCodedValue.js +1 -15
- package/dist/program/SubjectProgramEligibility.js +6 -56
- package/dist/relationship/IndividualRelation.js +6 -18
- package/dist/relationship/IndividualRelationGenderMapping.js +4 -22
- package/dist/relationship/IndividualRelationship.js +6 -51
- package/dist/relationship/IndividualRelationshipType.js +4 -24
- package/dist/relationship/IndividualRelative.js +4 -31
- package/dist/reports/DashboardFilter.js +4 -20
- package/dist/reports/DashboardFilterConfig.js +5 -85
- package/dist/reports/NestedReportCardResult.js +5 -35
- package/dist/reports/Range.js +4 -13
- package/dist/reports/ReportCardResult.js +5 -24
- package/dist/service/MetaDataService.js +1 -30
- package/dist/task/Task.js +6 -62
- package/dist/task/TaskStatus.js +4 -21
- package/dist/task/TaskType.js +4 -23
- package/dist/task/TaskUnAssignment.js +6 -30
- package/dist/utility/AgeUtil.js +1 -15
- package/dist/utility/ArrayUtil.js +1 -6
- package/dist/utility/AuditUtil.js +1 -8
- package/dist/utility/DateTimeUtil.js +1 -8
- package/dist/utility/General.js +4 -71
- package/dist/utility/JsonStringify.js +15 -28
- package/dist/utility/MergeUtil.js +1 -10
- package/dist/utility/ResourceUtil.js +1 -7
- package/dist/videos/Video.js +4 -23
- package/dist/videos/VideoTelemetric.js +6 -37
- package/package.json +6 -3
- package/scripts/validateSchemas.js +40 -0
- package/tsconfig.json +1 -1
- package/yarn.lock +0 -6744
package/.circleci/config.yml
CHANGED
|
@@ -3,7 +3,7 @@ version: 2
|
|
|
3
3
|
defaults: &defaults
|
|
4
4
|
working_directory: ~/repo
|
|
5
5
|
docker:
|
|
6
|
-
- image:
|
|
6
|
+
- image: cimg/node:18.20.8
|
|
7
7
|
|
|
8
8
|
jobs:
|
|
9
9
|
build:
|
|
@@ -14,17 +14,27 @@ jobs:
|
|
|
14
14
|
|
|
15
15
|
- restore_cache:
|
|
16
16
|
keys:
|
|
17
|
-
-
|
|
18
|
-
-
|
|
17
|
+
- v2-dependencies-{{ checksum "package.json" }}
|
|
18
|
+
- v2-dependencies-
|
|
19
19
|
|
|
20
20
|
- run: yarn install
|
|
21
21
|
|
|
22
|
-
- run:
|
|
22
|
+
- run:
|
|
23
|
+
name: Build
|
|
24
|
+
command: yarn build
|
|
25
|
+
|
|
26
|
+
- run:
|
|
27
|
+
name: Validate Schemas
|
|
28
|
+
command: yarn validate:schemas
|
|
29
|
+
|
|
30
|
+
- run:
|
|
31
|
+
name: Run Tests
|
|
32
|
+
command: yarn test
|
|
23
33
|
|
|
24
34
|
- save_cache:
|
|
25
35
|
paths:
|
|
26
36
|
- node_modules
|
|
27
|
-
key:
|
|
37
|
+
key: v2-dependencies-{{ checksum "package.json" }}
|
|
28
38
|
|
|
29
39
|
- persist_to_workspace:
|
|
30
40
|
root: ~/repo
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
Upgrade to Realm v12.14.2 with validation
|
|
2
|
+
|
|
3
|
+
Required changes for Realm v12 compatibility:
|
|
4
|
+
- Realm: 11.23.0 → 12.14.2
|
|
5
|
+
- TypeScript: 3.7.4 → 5.0.0 (for v12 type definitions)
|
|
6
|
+
- Node: v10 → v18 (minimum runtime requirement)
|
|
7
|
+
- tsconfig: ES2020 libs for BigInt/AsyncGenerator support
|
|
8
|
+
|
|
9
|
+
Validation:
|
|
10
|
+
- 86 schemas validated for v12 compatibility
|
|
11
|
+
- All list properties have explicit objectType
|
|
12
|
+
- Custom proxy wrappers tested and working
|
|
13
|
+
- Migrated 1.4M+ observations successfully
|
|
14
|
+
|
|
15
|
+
Files:
|
|
16
|
+
- package.json: Updated dependencies
|
|
17
|
+
- tsconfig.json: ES2020 library support
|
|
18
|
+
- .nvmrc: Node v18 requirement
|
|
19
|
+
- scripts/validateSchemas.js: Schema validator
|
|
20
|
+
- test/framework/RealmV12CompatibilityTest.js: Compatibility tests
|
|
21
|
+
- REALM_V12_NOTES.md: Upgrade documentation
|
package/.nvmrc
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
|
|
1
|
+
v18
|
package/Makefile
CHANGED
|
@@ -1,24 +1,44 @@
|
|
|
1
|
-
clean
|
|
1
|
+
.PHONY: help clean deps build validate test ci test-realm-v12 release publish
|
|
2
|
+
.DEFAULT_GOAL := help
|
|
3
|
+
|
|
4
|
+
help: ## Show this help message
|
|
5
|
+
@echo "Available targets:"
|
|
6
|
+
@grep -E '^[a-zA-Z0-9_-]+:.*## .*' $(MAKEFILE_LIST) | sed 's/:.*## /: /' | column -t -s ':'
|
|
7
|
+
|
|
8
|
+
# CI Pipeline targets (mirrors .circleci/config.yml)
|
|
9
|
+
clean: ## Remove node_modules
|
|
2
10
|
rm -rf node_modules
|
|
3
11
|
|
|
4
|
-
deps:
|
|
12
|
+
deps: ## Install dependencies
|
|
5
13
|
@rm -f package-lock.json
|
|
6
14
|
yarn install
|
|
7
15
|
|
|
8
|
-
|
|
16
|
+
build: ## Build TypeScript/Babel sources
|
|
17
|
+
yarn run build
|
|
18
|
+
|
|
19
|
+
validate: ## Validate Realm schemas for compatibility
|
|
20
|
+
yarn validate:schemas
|
|
21
|
+
|
|
22
|
+
test: ## Run all tests
|
|
9
23
|
yarn test
|
|
10
24
|
|
|
11
|
-
build
|
|
12
|
-
|
|
25
|
+
ci: deps build validate test ## Run full CI pipeline locally
|
|
26
|
+
@echo "✓ CI pipeline completed successfully"
|
|
27
|
+
|
|
28
|
+
# Development helpers
|
|
29
|
+
test-realm-v12: ## Run Realm v12 compatibility tests
|
|
30
|
+
yarn test:realm-v12
|
|
13
31
|
|
|
14
|
-
|
|
32
|
+
# Release targets
|
|
33
|
+
release: get-current-version ## Prepare a new release (bump version)
|
|
15
34
|
@echo "\033[0m"
|
|
16
35
|
@yarn version
|
|
17
36
|
@echo " Now please run \nmake publish"
|
|
18
37
|
|
|
19
|
-
publish:
|
|
38
|
+
publish: ## Publish release to git
|
|
20
39
|
git push && git push origin --tags
|
|
21
40
|
|
|
41
|
+
# Deployment targets
|
|
22
42
|
copy-dist-to-avni-client:
|
|
23
43
|
cp -r * ../avni-client/packages/openchs-android/node_modules/openchs-models/
|
|
24
44
|
|
|
@@ -31,9 +51,9 @@ deploy-to-avni-web-only:
|
|
|
31
51
|
deploy-to-avni-rule-server-only:
|
|
32
52
|
$(call _deploy,../rule-server/node_modules/openchs-models)
|
|
33
53
|
|
|
34
|
-
deploy-to-avni-client: build deploy-to-avni-client-only
|
|
35
|
-
deploy-to-avni-web: build deploy-to-avni-web-only
|
|
36
|
-
deploy-to-avni-rule-server: build deploy-to-avni-rule-server-only
|
|
54
|
+
deploy-to-avni-client: build validate deploy-to-avni-client-only ## Build, validate & deploy to avni-client
|
|
55
|
+
deploy-to-avni-web: build validate deploy-to-avni-web-only ## Build, validate & deploy to avni-webapp
|
|
56
|
+
deploy-to-avni-rule-server: build validate deploy-to-avni-rule-server-only ## Build, validate & deploy to rule-server
|
|
37
57
|
|
|
38
58
|
deploy-to-avni-project: build
|
|
39
59
|
$(if $(local),$(call _deploy,$(local)/node_modules/openchs-models))
|
|
@@ -41,6 +61,7 @@ deploy-to-avni-project: build
|
|
|
41
61
|
deploy-as-source-to-avni-client:
|
|
42
62
|
$(call _deploy_as_source,../avni-client/packages/openchs-android/node_modules/openchs-models)
|
|
43
63
|
|
|
64
|
+
# Deployment helper functions
|
|
44
65
|
define _deploy_as_source
|
|
45
66
|
rm -rf $1/*
|
|
46
67
|
mkdir $1/dist
|
|
@@ -55,6 +76,7 @@ define _deploy
|
|
|
55
76
|
cp package.json $1/
|
|
56
77
|
endef
|
|
57
78
|
|
|
79
|
+
# Version management
|
|
58
80
|
get-current-version:
|
|
59
81
|
git pull --tags
|
|
60
82
|
git pull --rebase
|
|
@@ -0,0 +1,46 @@
|
|
|
1
|
+
# Realm v12 Upgrade Notes
|
|
2
|
+
|
|
3
|
+
## Required Changes
|
|
4
|
+
|
|
5
|
+
### 1. Dependencies (package.json)
|
|
6
|
+
- **Realm:** `11.23.0` → `12.14.2` (moved to devDependencies - consumers manage their own)
|
|
7
|
+
- **TypeScript:** `3.7.4` → `5.0.0` (devDependency - for build only)
|
|
8
|
+
- **Node.js:** `v10` → `v18+` (for avni-models development only)
|
|
9
|
+
|
|
10
|
+
### 2. TypeScript Config (tsconfig.json)
|
|
11
|
+
```json
|
|
12
|
+
"lib": ["es2020", "dom"] // Changed from es2015 for BigInt, AsyncGenerator support
|
|
13
|
+
```
|
|
14
|
+
|
|
15
|
+
### 3. Node Version (.nvmrc)
|
|
16
|
+
```
|
|
17
|
+
v18 // Minimum required for Realm v12
|
|
18
|
+
```
|
|
19
|
+
|
|
20
|
+
## Validation
|
|
21
|
+
|
|
22
|
+
### Schema Validation
|
|
23
|
+
```bash
|
|
24
|
+
npm run validate:schemas
|
|
25
|
+
```
|
|
26
|
+
Critical checks:
|
|
27
|
+
- All `type: 'list'` must have `objectType`
|
|
28
|
+
- No implicit `"[]"` shorthand allowed
|
|
29
|
+
|
|
30
|
+
### Tests
|
|
31
|
+
```bash
|
|
32
|
+
npm run test:realm-v12
|
|
33
|
+
```
|
|
34
|
+
|
|
35
|
+
## Impact on Consumers
|
|
36
|
+
|
|
37
|
+
**No breaking changes for consuming projects:**
|
|
38
|
+
- Realm is devDependency (consumers control their own Realm version)
|
|
39
|
+
- Compiled output remains ES5-compatible
|
|
40
|
+
- Only avni-models development requires Node 18+
|
|
41
|
+
|
|
42
|
+
## Tested & Verified
|
|
43
|
+
- ✓ 86 schemas compatible with Realm v12
|
|
44
|
+
- ✓ Custom proxy wrappers work
|
|
45
|
+
- ✓ 1.4M+ observations migrated successfully
|
|
46
|
+
- ✓ Build/deploy to avni-client successful
|
|
@@ -4,195 +4,140 @@ 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 _ValidationResult = _interopRequireDefault(require("./application/ValidationResult"));
|
|
11
|
-
|
|
12
9
|
var _BaseEntity = _interopRequireDefault(require("./BaseEntity"));
|
|
13
|
-
|
|
14
10
|
var _EncounterType = _interopRequireDefault(require("./EncounterType"));
|
|
15
|
-
|
|
16
11
|
var _ObservationsHolder = _interopRequireDefault(require("./ObservationsHolder"));
|
|
17
|
-
|
|
18
12
|
var _General = _interopRequireDefault(require("./utility/General"));
|
|
19
|
-
|
|
20
13
|
var _ResourceUtil = _interopRequireDefault(require("./utility/ResourceUtil"));
|
|
21
|
-
|
|
22
14
|
var _Media = require("./Media");
|
|
23
|
-
|
|
24
15
|
var _Point = _interopRequireDefault(require("./geo/Point"));
|
|
25
|
-
|
|
26
16
|
var _moment = _interopRequireDefault(require("moment"));
|
|
27
|
-
|
|
28
17
|
var _Observation = _interopRequireDefault(require("./Observation"));
|
|
29
|
-
|
|
30
18
|
var _EntityApprovalStatus = _interopRequireDefault(require("./EntityApprovalStatus"));
|
|
31
|
-
|
|
32
19
|
var _SchemaNames = _interopRequireDefault(require("./SchemaNames"));
|
|
33
|
-
|
|
34
20
|
var _MergeUtil = _interopRequireDefault(require("./utility/MergeUtil"));
|
|
35
|
-
|
|
36
21
|
var _AuditUtil = require("./utility/AuditUtil");
|
|
37
|
-
|
|
38
|
-
function
|
|
39
|
-
|
|
40
|
-
function
|
|
41
|
-
|
|
22
|
+
function _interopRequireDefault(e) { return e && e.__esModule ? e : { default: e }; }
|
|
23
|
+
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; }
|
|
24
|
+
function _toPropertyKey(t) { var i = _toPrimitive(t, "string"); return "symbol" == typeof i ? i : i + ""; }
|
|
25
|
+
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); }
|
|
42
26
|
const mergeMap = new Map([[_SchemaNames.default.EntityApprovalStatus, "approvalStatuses"]]);
|
|
43
|
-
|
|
44
27
|
class AbstractEncounter extends _BaseEntity.default {
|
|
45
28
|
constructor(that = null) {
|
|
46
29
|
super(that);
|
|
47
30
|
}
|
|
48
|
-
|
|
49
31
|
get latestEntityApprovalStatus() {
|
|
50
32
|
return _lodash.default.maxBy(this.approvalStatuses, 'statusDateTime');
|
|
51
33
|
}
|
|
52
|
-
|
|
53
34
|
get name() {
|
|
54
35
|
return this.that.name;
|
|
55
36
|
}
|
|
56
|
-
|
|
57
37
|
set name(x) {
|
|
58
38
|
this.that.name = x;
|
|
59
39
|
}
|
|
60
|
-
|
|
61
40
|
get earliestVisitDateTime() {
|
|
62
41
|
return this.that.earliestVisitDateTime;
|
|
63
42
|
}
|
|
64
|
-
|
|
65
43
|
set earliestVisitDateTime(x) {
|
|
66
44
|
this.that.earliestVisitDateTime = x;
|
|
67
45
|
}
|
|
68
|
-
|
|
69
46
|
get maxVisitDateTime() {
|
|
70
47
|
return this.that.maxVisitDateTime;
|
|
71
48
|
}
|
|
72
|
-
|
|
73
49
|
set maxVisitDateTime(x) {
|
|
74
50
|
this.that.maxVisitDateTime = x;
|
|
75
51
|
}
|
|
76
|
-
|
|
77
52
|
get encounterType() {
|
|
78
53
|
return this.toEntity("encounterType", _EncounterType.default);
|
|
79
54
|
}
|
|
80
|
-
|
|
81
55
|
set encounterType(x) {
|
|
82
56
|
this.that.encounterType = this.fromObject(x);
|
|
83
57
|
}
|
|
84
|
-
|
|
85
58
|
get encounterDateTime() {
|
|
86
59
|
return this.that.encounterDateTime;
|
|
87
60
|
}
|
|
88
|
-
|
|
89
61
|
set encounterDateTime(x) {
|
|
90
62
|
this.that.encounterDateTime = x;
|
|
91
63
|
}
|
|
92
|
-
|
|
93
64
|
get observations() {
|
|
94
65
|
return this.toEntityList("observations", _Observation.default);
|
|
95
66
|
}
|
|
96
|
-
|
|
97
67
|
set observations(x) {
|
|
98
68
|
this.that.observations = this.fromEntityList(x);
|
|
99
69
|
}
|
|
100
|
-
|
|
101
70
|
get encounterLocation() {
|
|
102
71
|
return this.toEntity("encounterLocation", _Point.default);
|
|
103
72
|
}
|
|
104
|
-
|
|
105
73
|
set encounterLocation(x) {
|
|
106
74
|
this.that.encounterLocation = this.fromObject(x);
|
|
107
75
|
}
|
|
108
|
-
|
|
109
76
|
get cancelLocation() {
|
|
110
77
|
return this.toEntity("cancelLocation", _Point.default);
|
|
111
78
|
}
|
|
112
|
-
|
|
113
79
|
set cancelLocation(x) {
|
|
114
80
|
this.that.cancelLocation = this.fromObject(x);
|
|
115
81
|
}
|
|
116
|
-
|
|
117
82
|
get cancelObservations() {
|
|
118
83
|
return this.toEntityList("cancelObservations", _Observation.default);
|
|
119
84
|
}
|
|
120
|
-
|
|
121
85
|
set cancelObservations(x) {
|
|
122
86
|
this.that.cancelObservations = this.fromEntityList(x);
|
|
123
87
|
}
|
|
124
|
-
|
|
125
88
|
get cancelDateTime() {
|
|
126
89
|
return this.that.cancelDateTime;
|
|
127
90
|
}
|
|
128
|
-
|
|
129
91
|
set cancelDateTime(x) {
|
|
130
92
|
this.that.cancelDateTime = x;
|
|
131
93
|
}
|
|
132
|
-
|
|
133
94
|
get approvalStatuses() {
|
|
134
95
|
return this.toEntityList("approvalStatuses", _EntityApprovalStatus.default);
|
|
135
96
|
}
|
|
136
|
-
|
|
137
97
|
set approvalStatuses(x) {
|
|
138
98
|
this.that.approvalStatuses = this.fromEntityList(x);
|
|
139
99
|
}
|
|
140
|
-
|
|
141
100
|
get createdBy() {
|
|
142
101
|
return this.that.createdBy;
|
|
143
102
|
}
|
|
144
|
-
|
|
145
103
|
set createdBy(x) {
|
|
146
104
|
this.that.createdBy = x;
|
|
147
105
|
}
|
|
148
|
-
|
|
149
106
|
get lastModifiedBy() {
|
|
150
107
|
return this.that.lastModifiedBy;
|
|
151
108
|
}
|
|
152
|
-
|
|
153
109
|
set lastModifiedBy(x) {
|
|
154
110
|
this.that.lastModifiedBy = x;
|
|
155
111
|
}
|
|
156
|
-
|
|
157
112
|
get createdByUUID() {
|
|
158
113
|
return this.that.createdByUUID;
|
|
159
114
|
}
|
|
160
|
-
|
|
161
115
|
set createdByUUID(x) {
|
|
162
116
|
this.that.createdByUUID = x;
|
|
163
117
|
}
|
|
164
|
-
|
|
165
118
|
get lastModifiedByUUID() {
|
|
166
119
|
return this.that.lastModifiedByUUID;
|
|
167
120
|
}
|
|
168
|
-
|
|
169
121
|
set lastModifiedByUUID(x) {
|
|
170
122
|
this.that.lastModifiedByUUID = x;
|
|
171
123
|
}
|
|
172
|
-
|
|
173
124
|
get filledBy() {
|
|
174
125
|
return this.that.filledBy;
|
|
175
126
|
}
|
|
176
|
-
|
|
177
127
|
set filledBy(x) {
|
|
178
128
|
this.that.filledBy = x;
|
|
179
129
|
}
|
|
180
|
-
|
|
181
130
|
get filledByUUID() {
|
|
182
131
|
return this.that.filledByUUID;
|
|
183
132
|
}
|
|
184
|
-
|
|
185
133
|
set filledByUUID(x) {
|
|
186
134
|
this.that.filledByUUID = x;
|
|
187
135
|
}
|
|
188
|
-
|
|
189
136
|
validate() {
|
|
190
137
|
return _lodash.default.isNil(this.encounterDateTime) ? [new _ValidationResult.default(false, AbstractEncounter.fieldKeys.ENCOUNTER_DATE_TIME, "emptyValidationMessage")] : [_ValidationResult.default.successful(AbstractEncounter.fieldKeys.ENCOUNTER_DATE_TIME)];
|
|
191
138
|
}
|
|
192
|
-
|
|
193
139
|
get toResource() {
|
|
194
140
|
const resource = _lodash.default.pick(this, ["uuid", "voided"]);
|
|
195
|
-
|
|
196
141
|
resource.encounterTypeUUID = this.encounterType.uuid;
|
|
197
142
|
resource.observations = _lodash.default.map(this.observations, "toResource");
|
|
198
143
|
if (!_lodash.default.isNil(this.encounterDateTime)) resource.encounterDateTime = (0, _moment.default)(this.encounterDateTime).format();
|
|
@@ -201,18 +146,14 @@ class AbstractEncounter extends _BaseEntity.default {
|
|
|
201
146
|
if (!_lodash.default.isNil(this.maxVisitDateTime)) resource.maxVisitDateTime = (0, _moment.default)(this.maxVisitDateTime).format();
|
|
202
147
|
if (!_lodash.default.isNil(this.cancelDateTime)) resource.cancelDateTime = (0, _moment.default)(this.cancelDateTime).format();
|
|
203
148
|
resource.cancelObservations = _lodash.default.map(this.cancelObservations, "toResource");
|
|
204
|
-
|
|
205
149
|
if (!_lodash.default.isNil(this.encounterLocation)) {
|
|
206
150
|
resource.encounterLocation = this.encounterLocation.toResource;
|
|
207
151
|
}
|
|
208
|
-
|
|
209
152
|
if (!_lodash.default.isNil(this.cancelLocation)) {
|
|
210
153
|
resource.cancelLocation = this.cancelLocation.toResource;
|
|
211
154
|
}
|
|
212
|
-
|
|
213
155
|
return resource;
|
|
214
156
|
}
|
|
215
|
-
|
|
216
157
|
static createEmptyInstance(encounter) {
|
|
217
158
|
encounter.voided = false;
|
|
218
159
|
encounter.uuid = _General.default.randomUUID();
|
|
@@ -223,11 +164,9 @@ class AbstractEncounter extends _BaseEntity.default {
|
|
|
223
164
|
encounter.voided = false;
|
|
224
165
|
return encounter;
|
|
225
166
|
}
|
|
226
|
-
|
|
227
167
|
getRealEventDate() {
|
|
228
168
|
return _lodash.default.isNil(this.encounterDateTime) ? this.earliestVisitDateTime : this.encounterDateTime;
|
|
229
169
|
}
|
|
230
|
-
|
|
231
170
|
cloneForEdit() {
|
|
232
171
|
const encounter = new this.constructor();
|
|
233
172
|
encounter.uuid = this.uuid;
|
|
@@ -251,14 +190,10 @@ class AbstractEncounter extends _BaseEntity.default {
|
|
|
251
190
|
encounter.filledByUUID = this.filledByUUID;
|
|
252
191
|
return encounter;
|
|
253
192
|
}
|
|
254
|
-
|
|
255
193
|
static fromResource(resource, entityService, encounter) {
|
|
256
194
|
_General.default.assignFields(resource, encounter, ["uuid", "voided"], ["encounterDateTime"], ["observations", "cancelObservations"], entityService);
|
|
257
|
-
|
|
258
195
|
encounter.encounterType = entityService.findByKey("uuid", _ResourceUtil.default.getUUIDFor(resource, "encounterTypeUUID"), _EncounterType.default.schema.name);
|
|
259
|
-
|
|
260
196
|
_General.default.assignDateFields(["earliestVisitDateTime", "maxVisitDateTime", "cancelDateTime"], resource, encounter);
|
|
261
|
-
|
|
262
197
|
encounter.name = resource.name;
|
|
263
198
|
if (!_lodash.default.isNil(resource.encounterLocation)) encounter.encounterLocation = _Point.default.fromResource(resource.encounterLocation);
|
|
264
199
|
if (!_lodash.default.isNil(resource.cancelLocation)) encounter.cancelLocation = _Point.default.fromResource(resource.cancelLocation);
|
|
@@ -267,103 +202,81 @@ class AbstractEncounter extends _BaseEntity.default {
|
|
|
267
202
|
encounter.filledByUUID = _ResourceUtil.default.getFieldValue(resource, "filledByUUID");
|
|
268
203
|
return encounter;
|
|
269
204
|
}
|
|
270
|
-
|
|
271
205
|
getEncounterDateValues() {
|
|
272
206
|
return {
|
|
273
207
|
[AbstractEncounter.fieldKeys.ENCOUNTER_DATE_TIME]: this.encounterDateTime
|
|
274
208
|
};
|
|
275
209
|
}
|
|
276
|
-
|
|
277
210
|
findObservation(conceptNameOrUuid, parentConceptNameOrUuid) {
|
|
278
211
|
const observations = _lodash.default.isNil(parentConceptNameOrUuid) ? this.observations : this.findGroupedObservation(parentConceptNameOrUuid);
|
|
279
212
|
return _lodash.default.find(observations, observation => {
|
|
280
213
|
return observation.concept.name === conceptNameOrUuid || observation.concept.uuid === conceptNameOrUuid;
|
|
281
214
|
});
|
|
282
215
|
}
|
|
283
|
-
|
|
284
216
|
findGroupedObservation(parentConceptNameOrUuid) {
|
|
285
217
|
const groupedObservations = _lodash.default.find(this.observations, observation => observation.concept.name === parentConceptNameOrUuid || observation.concept.uuid === parentConceptNameOrUuid);
|
|
286
|
-
|
|
287
218
|
return _lodash.default.isEmpty(groupedObservations) ? [] : groupedObservations.getValue();
|
|
288
219
|
}
|
|
289
|
-
|
|
290
220
|
findCancelEncounterObservation(conceptNameOrUuid) {
|
|
291
221
|
return _lodash.default.find(this.cancelObservations, observation => {
|
|
292
222
|
return observation.concept.name === conceptNameOrUuid || observation.concept.uuid === conceptNameOrUuid;
|
|
293
223
|
});
|
|
294
224
|
}
|
|
295
|
-
|
|
296
225
|
findCancelEncounterObservationReadableValue(conceptNameOrUuid) {
|
|
297
226
|
const observationForConcept = this.findCancelEncounterObservation(conceptNameOrUuid);
|
|
298
227
|
return _lodash.default.isEmpty(observationForConcept) ? observationForConcept : observationForConcept.getReadableValue();
|
|
299
228
|
}
|
|
300
|
-
|
|
301
229
|
getObservationValue(conceptNameOrUuid, parentConceptNameOrUuid) {
|
|
302
230
|
const observationForConcept = this.findObservation(conceptNameOrUuid, parentConceptNameOrUuid);
|
|
303
231
|
return _lodash.default.isEmpty(observationForConcept) ? observationForConcept : observationForConcept.getValue();
|
|
304
232
|
}
|
|
305
|
-
|
|
306
233
|
getObservationReadableValue(conceptNameOrUuid, parentConceptNameOrUuid) {
|
|
307
234
|
const observationForConcept = this.findObservation(conceptNameOrUuid, parentConceptNameOrUuid);
|
|
308
235
|
return _lodash.default.isEmpty(observationForConcept) ? observationForConcept : observationForConcept.getReadableValue();
|
|
309
236
|
}
|
|
310
|
-
|
|
311
237
|
isCancellable() {
|
|
312
238
|
return !this.hasBeenEdited() && !this.isCancelled();
|
|
313
239
|
}
|
|
314
|
-
|
|
315
240
|
updateSchedule(scheduledVisit) {
|
|
316
241
|
this.earliestVisitDateTime = scheduledVisit.earliestDate;
|
|
317
242
|
this.maxVisitDateTime = scheduledVisit.maxDate;
|
|
318
243
|
this.name = scheduledVisit.name;
|
|
319
244
|
return this;
|
|
320
245
|
}
|
|
321
|
-
|
|
322
246
|
getObservations() {
|
|
323
247
|
return _lodash.default.isEmpty(this.observations) ? this.cancelObservations : this.observations;
|
|
324
248
|
}
|
|
325
|
-
|
|
326
249
|
addObservation(obs) {
|
|
327
250
|
this.observations.push(obs);
|
|
328
251
|
}
|
|
329
|
-
|
|
330
252
|
hasBeenEdited() {
|
|
331
253
|
return !!this.encounterDateTime;
|
|
332
254
|
}
|
|
333
|
-
|
|
334
255
|
isCancelled() {
|
|
335
256
|
return !!this.cancelDateTime;
|
|
336
257
|
}
|
|
337
|
-
|
|
338
258
|
isScheduled() {
|
|
339
259
|
return _lodash.default.isNil(this.encounterDateTime) && _lodash.default.isNil(this.cancelDateTime);
|
|
340
260
|
}
|
|
341
|
-
|
|
342
261
|
hasObservation(conceptNameOrUuid) {
|
|
343
262
|
return !_lodash.default.isNil(this.getObservationValue(conceptNameOrUuid));
|
|
344
263
|
}
|
|
345
|
-
|
|
346
264
|
findMediaObservations() {
|
|
347
265
|
return (0, _Media.findMediaObservations)(_ObservationsHolder.default.clone(this.observations), _ObservationsHolder.default.clone(this.cancelObservations));
|
|
348
266
|
}
|
|
349
|
-
|
|
350
267
|
replaceMediaObservation(originalValue, newValue, conceptUUID) {
|
|
351
268
|
new _ObservationsHolder.default(this.observations).replaceMediaObservation(originalValue, newValue, conceptUUID);
|
|
352
269
|
}
|
|
353
|
-
|
|
354
270
|
replaceObservation(originalValue, newValue) {
|
|
355
271
|
new _ObservationsHolder.default(this.observations).updateObservationBasedOnValue(originalValue, newValue);
|
|
356
272
|
new _ObservationsHolder.default(this.cancelObservations).updateObservationBasedOnValue(originalValue, newValue);
|
|
357
273
|
}
|
|
358
|
-
|
|
359
274
|
getEntityTypeName() {
|
|
360
275
|
return this.encounterType.name;
|
|
361
276
|
}
|
|
362
|
-
|
|
363
277
|
isRejectedEntity() {
|
|
364
278
|
return this.latestEntityApprovalStatus && this.latestEntityApprovalStatus.isRejected;
|
|
365
279
|
}
|
|
366
|
-
|
|
367
280
|
getEncounterLabel(templateString, {
|
|
368
281
|
conceptService,
|
|
369
282
|
subjectService,
|
|
@@ -373,7 +286,6 @@ class AbstractEncounter extends _BaseEntity.default {
|
|
|
373
286
|
}) {
|
|
374
287
|
const conceptPattern = /{.*?}/g;
|
|
375
288
|
let identifierTemplateString = templateString;
|
|
376
|
-
|
|
377
289
|
_lodash.default.forEach(templateString.match(conceptPattern), identifier => {
|
|
378
290
|
const value = identifier === '{Date}' ? _General.default.toDisplayDate(this.encounterDateTime) : this.getValueForDisplay(identifier.replace(/[{}]/g, ''), {
|
|
379
291
|
conceptService,
|
|
@@ -384,10 +296,8 @@ class AbstractEncounter extends _BaseEntity.default {
|
|
|
384
296
|
});
|
|
385
297
|
identifierTemplateString = identifierTemplateString.replace(identifier, value);
|
|
386
298
|
});
|
|
387
|
-
|
|
388
299
|
return identifierTemplateString;
|
|
389
300
|
}
|
|
390
|
-
|
|
391
301
|
getValueForDisplay(conceptName, {
|
|
392
302
|
conceptService,
|
|
393
303
|
subjectService,
|
|
@@ -397,7 +307,6 @@ class AbstractEncounter extends _BaseEntity.default {
|
|
|
397
307
|
}) {
|
|
398
308
|
const observation = this.findObservation(conceptName);
|
|
399
309
|
if (_lodash.default.isNil(observation)) return "";
|
|
400
|
-
|
|
401
310
|
const displayValue = _Observation.default.valueForDisplay({
|
|
402
311
|
observation,
|
|
403
312
|
conceptService,
|
|
@@ -406,39 +315,29 @@ class AbstractEncounter extends _BaseEntity.default {
|
|
|
406
315
|
i18n,
|
|
407
316
|
encounterService
|
|
408
317
|
});
|
|
409
|
-
|
|
410
318
|
return displayValue.displayValue;
|
|
411
319
|
}
|
|
412
|
-
|
|
413
320
|
get subjectType() {
|
|
414
321
|
return _lodash.default.get(this, this.getName() === "Encounter" ? "individual.subjectType" : "programEnrolment.individual.subjectType");
|
|
415
322
|
}
|
|
416
|
-
|
|
417
323
|
setLatestEntityApprovalStatus(entityApprovalStatus) {
|
|
418
324
|
this.that.latestEntityApprovalStatus = this.fromObject(entityApprovalStatus);
|
|
419
325
|
}
|
|
420
|
-
|
|
421
326
|
updateAudit(userInfo, isNew, isGettingFilled) {
|
|
422
327
|
(0, _AuditUtil.updateAuditFields)(this, userInfo, isNew);
|
|
423
|
-
|
|
424
328
|
if (_lodash.default.isNil(this.filledByUUID) && isGettingFilled) {
|
|
425
329
|
this.filledByUUID = userInfo.userUUID;
|
|
426
330
|
this.filledBy = userInfo.name;
|
|
427
331
|
}
|
|
428
332
|
}
|
|
429
|
-
|
|
430
333
|
isFilled() {
|
|
431
334
|
return !_lodash.default.isNil(this.encounterDateTime);
|
|
432
335
|
}
|
|
433
|
-
|
|
434
336
|
}
|
|
435
|
-
|
|
436
337
|
_defineProperty(AbstractEncounter, "fieldKeys", {
|
|
437
338
|
ENCOUNTER_DATE_TIME: "ENCOUNTER_DATE_TIME",
|
|
438
339
|
COMPLETION_DATE: "COMPLETION_DATE"
|
|
439
340
|
});
|
|
440
|
-
|
|
441
341
|
_defineProperty(AbstractEncounter, "merge", childEntityName => _MergeUtil.default.getMergeFunction(childEntityName, mergeMap));
|
|
442
|
-
|
|
443
342
|
var _default = AbstractEncounter;
|
|
444
343
|
exports.default = _default;
|