@smile-cdr/fhirts 2.1.1 → 2.2.0
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/.github/workflows/npm-publish.yml +1 -1
- package/CHANGELOG.md +9 -0
- package/dist/FHIR-DSTU2.d.ts +22 -22
- package/dist/FHIR-R3.d.ts +21 -22
- package/dist/FHIR-R4/classes/extension.d.ts +1 -1
- package/dist/index.d.ts +2 -1
- package/dist/index.js +3 -1
- package/dist/library/QueryBuilder/QueryBuilder.d.ts +59 -0
- package/dist/library/QueryBuilder/QueryBuilder.js +112 -0
- package/dist/library/QueryBuilder/QueryBuilder.spec.d.ts +1 -0
- package/dist/library/QueryBuilder/QueryBuilder.spec.js +135 -0
- package/dist/library/ResourceUtils/ResourceUtils.d.ts +4 -3
- package/dist/library/ResourceUtils/ResourceUtils.spec.js +10 -7
- package/dist/library/constants.d.ts +4 -0
- package/dist/library/constants.js +8 -0
- package/dist/library/dataTypes.d.ts +10 -0
- package/dist/library/dataTypes.js +2 -0
- package/package.json +4 -6
- package/src/FHIR-DSTU2.ts +23 -23
- package/src/FHIR-R3.ts +58 -59
- package/src/FHIR-R4/classes/extension.ts +2 -2
- package/src/index.ts +2 -1
- package/src/library/QueryBuilder/QueryBuilder.spec.ts +149 -0
- package/src/library/QueryBuilder/QueryBuilder.ts +119 -0
- package/src/library/ResourceUtils/ResourceUtils.spec.ts +13 -11
- package/src/library/ResourceUtils/ResourceUtils.ts +25 -23
- package/src/library/constants.ts +4 -0
- package/src/library/dataTypes.ts +10 -0
|
@@ -1,3 +1,5 @@
|
|
|
1
|
+
import { Coding, CodingKeys, Extension, Identifier, IdentifierKeys } from "../dataTypes";
|
|
2
|
+
|
|
1
3
|
export class ResourceUtils {
|
|
2
4
|
/**
|
|
3
5
|
*
|
|
@@ -23,10 +25,10 @@ export class ResourceUtils {
|
|
|
23
25
|
* @limitations currently does not work with identifier.type, identifier.period & identifier.assigner
|
|
24
26
|
*/
|
|
25
27
|
getIdentifiersByProperty(
|
|
26
|
-
identifierList:
|
|
27
|
-
propertyToCompare:
|
|
28
|
-
propertyValue:
|
|
29
|
-
):
|
|
28
|
+
identifierList: Identifier[],
|
|
29
|
+
propertyToCompare: IdentifierKeys,
|
|
30
|
+
propertyValue: Identifier[IdentifierKeys]
|
|
31
|
+
): Identifier[] {
|
|
30
32
|
return identifierList?.length
|
|
31
33
|
? identifierList.filter((x) => x[propertyToCompare] === propertyValue)
|
|
32
34
|
: [];
|
|
@@ -38,7 +40,7 @@ export class ResourceUtils {
|
|
|
38
40
|
* @param extensionUrl Extension.url to compare
|
|
39
41
|
* @returns array of matches
|
|
40
42
|
*/
|
|
41
|
-
getExtensionsByUrl(extensionList:
|
|
43
|
+
getExtensionsByUrl(extensionList: Extension[], extensionUrl: string): Extension[] {
|
|
42
44
|
return extensionList?.length
|
|
43
45
|
? extensionList.filter((x) => x["url"] === extensionUrl)
|
|
44
46
|
: [];
|
|
@@ -52,10 +54,10 @@ export class ResourceUtils {
|
|
|
52
54
|
* @returns array of matches
|
|
53
55
|
*/
|
|
54
56
|
getCodingsByProperty(
|
|
55
|
-
codingList:
|
|
56
|
-
propertyToCompare:
|
|
57
|
-
propertyValue:
|
|
58
|
-
):
|
|
57
|
+
codingList: Coding[],
|
|
58
|
+
propertyToCompare: CodingKeys,
|
|
59
|
+
propertyValue: Coding[CodingKeys]
|
|
60
|
+
): Coding[] {
|
|
59
61
|
return codingList?.length
|
|
60
62
|
? codingList.filter((x) => x[propertyToCompare] === propertyValue)
|
|
61
63
|
: [];
|
|
@@ -77,18 +79,18 @@ export class ResourceUtils {
|
|
|
77
79
|
if (this.isPrimitive(resourcePathValue)) {
|
|
78
80
|
return [resourcePathValue];
|
|
79
81
|
} else if (Array.isArray(resourcePathValue) && resourcePathValue.length > 0) {
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
} else if (typeof(resourcePathValue) === 'object') {
|
|
82
|
+
let resultSet = [];
|
|
83
|
+
for (let subPathIndex = 0; subPathIndex < resourcePathValue.length; subPathIndex++) {
|
|
84
|
+
const subPathValue = resourcePathValue[subPathIndex];
|
|
85
|
+
if (this.isPrimitive(subPathValue)) {
|
|
86
|
+
resultSet.push(subPathValue);
|
|
87
|
+
} else {
|
|
88
|
+
resultSet.push(...this.getValuesAtResourcePath(subPathValue,
|
|
89
|
+
pathSections.slice(index).join(".")));
|
|
90
|
+
}
|
|
91
|
+
}
|
|
92
|
+
return resultSet;
|
|
93
|
+
} else if (typeof (resourcePathValue) === 'object') {
|
|
92
94
|
return this.getValuesAtResourcePath(resourcePathValue,
|
|
93
95
|
pathSections.slice(index).join("."));
|
|
94
96
|
}
|
|
@@ -100,7 +102,7 @@ export class ResourceUtils {
|
|
|
100
102
|
}
|
|
101
103
|
|
|
102
104
|
private isPrimitive(value: any) {
|
|
103
|
-
return typeof(value) === "boolean" || typeof(value) === "string";
|
|
105
|
+
return typeof (value) === "boolean" || typeof (value) === "string";
|
|
104
106
|
}
|
|
105
107
|
|
|
106
108
|
/**
|
|
@@ -117,7 +119,7 @@ export class ResourceUtils {
|
|
|
117
119
|
const referenceEnd = stringifiedResource.indexOf('"', referenceStart + 1);
|
|
118
120
|
const reference = stringifiedResource.substring(referenceStart, referenceEnd);
|
|
119
121
|
// this means the reference ends started reading from start again
|
|
120
|
-
if(referenceEnd < cursor) {
|
|
122
|
+
if (referenceEnd < cursor) {
|
|
121
123
|
break;
|
|
122
124
|
}
|
|
123
125
|
references.push(reference);
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
import * as DSTU2 from "../FHIR-DSTU2";
|
|
2
|
+
import * as R3 from "../FHIR-R3";
|
|
3
|
+
import { Coding as r4Coding } from "../FHIR-R4/classes/coding";
|
|
4
|
+
import { Extension as r4Extension } from "../FHIR-R4/classes/extension";
|
|
5
|
+
import { Identifier as r4Identifier } from "../FHIR-R4/classes/identifier";
|
|
6
|
+
export type Identifier = r4Identifier & R3.Identifier & DSTU2.Identifier;
|
|
7
|
+
export type IdentifierKeys = keyof Identifier;
|
|
8
|
+
export type Extension = r4Extension & R3.Extension & DSTU2.Extension;
|
|
9
|
+
export type Coding = r4Coding & R3.Coding & DSTU2.Coding;
|
|
10
|
+
export type CodingKeys = keyof Coding;
|