@smile-cdr/fhirts 2.1.2 → 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 +6 -1
- 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/library/ResourceUtils/ResourceUtils.d.ts +4 -3
- package/dist/library/ResourceUtils/ResourceUtils.spec.js +10 -7
- package/dist/library/dataTypes.d.ts +10 -0
- package/dist/library/dataTypes.js +2 -0
- package/package.json +1 -1
- 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/library/ResourceUtils/ResourceUtils.spec.ts +13 -11
- package/src/library/ResourceUtils/ResourceUtils.ts +25 -23
- package/src/library/dataTypes.ts +10 -0
package/CHANGELOG.md
CHANGED
|
@@ -1,6 +1,11 @@
|
|
|
1
1
|
# Changelog
|
|
2
2
|
|
|
3
|
-
## 2.2.
|
|
3
|
+
## 2.2.0
|
|
4
|
+
|
|
5
|
+
* Update `ResourceUtils` with strong typing to catch incorrect input data types for all FHIR versions.
|
|
6
|
+
* Update some cardinalities for base data types and structures
|
|
7
|
+
|
|
8
|
+
## 2.1.2
|
|
4
9
|
|
|
5
10
|
* Add `QueryBuilder` for ease of generating queries.
|
|
6
11
|
|
package/dist/FHIR-DSTU2.d.ts
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
export declare class FHIRElement {
|
|
2
|
-
id
|
|
3
|
-
extension
|
|
2
|
+
id?: string;
|
|
3
|
+
extension?: Extension[];
|
|
4
4
|
}
|
|
5
5
|
export declare class BackboneElement extends FHIRElement {
|
|
6
6
|
modifierExtension: any;
|
|
@@ -38,12 +38,12 @@ export declare class CodeableConcept extends FHIRElement {
|
|
|
38
38
|
text: string;
|
|
39
39
|
}
|
|
40
40
|
export declare class Identifier extends FHIRElement {
|
|
41
|
-
use
|
|
42
|
-
type
|
|
43
|
-
system
|
|
44
|
-
value
|
|
45
|
-
period
|
|
46
|
-
assigner
|
|
41
|
+
use?: string;
|
|
42
|
+
type?: CodeableConcept;
|
|
43
|
+
system?: string;
|
|
44
|
+
value?: string;
|
|
45
|
+
period?: Period;
|
|
46
|
+
assigner?: Reference;
|
|
47
47
|
}
|
|
48
48
|
export declare class Reference extends FHIRElement {
|
|
49
49
|
reference: string;
|
|
@@ -61,24 +61,24 @@ export declare class HumanName extends FHIRElement {
|
|
|
61
61
|
}
|
|
62
62
|
export declare class Extension {
|
|
63
63
|
url: string;
|
|
64
|
-
valueString
|
|
65
|
-
valueCode
|
|
66
|
-
valueAddress
|
|
64
|
+
valueString?: string;
|
|
65
|
+
valueCode?: string;
|
|
66
|
+
valueAddress?: Address;
|
|
67
67
|
valueBoolean?: boolean;
|
|
68
|
-
valueHumanName
|
|
69
|
-
valueReference
|
|
70
|
-
valueDate
|
|
71
|
-
valueIdentifier
|
|
68
|
+
valueHumanName?: HumanName;
|
|
69
|
+
valueReference?: Reference;
|
|
70
|
+
valueDate?: Date;
|
|
71
|
+
valueIdentifier?: string;
|
|
72
72
|
valueDecimal?: number;
|
|
73
|
-
valueInteger
|
|
74
|
-
valuePeriod
|
|
73
|
+
valueInteger?: number;
|
|
74
|
+
valuePeriod?: Period;
|
|
75
75
|
}
|
|
76
76
|
export declare class Coding extends FHIRElement {
|
|
77
|
-
system
|
|
78
|
-
version
|
|
79
|
-
code
|
|
80
|
-
display
|
|
81
|
-
userSelected
|
|
77
|
+
system?: string;
|
|
78
|
+
version?: string;
|
|
79
|
+
code?: string;
|
|
80
|
+
display?: string;
|
|
81
|
+
userSelected?: boolean;
|
|
82
82
|
}
|
|
83
83
|
export declare class Period extends FHIRElement {
|
|
84
84
|
start: string;
|
package/dist/FHIR-R3.d.ts
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
export declare class FHIRElement {
|
|
2
|
-
id
|
|
3
|
-
extension
|
|
2
|
+
id?: string;
|
|
3
|
+
extension?: Extension[];
|
|
4
4
|
}
|
|
5
5
|
export declare class BackboneElement extends FHIRElement {
|
|
6
6
|
modifierExtension: any;
|
|
@@ -32,12 +32,11 @@ export declare class Code extends FHIRElement {
|
|
|
32
32
|
toString(): string;
|
|
33
33
|
}
|
|
34
34
|
export declare class Coding extends FHIRElement {
|
|
35
|
-
system
|
|
36
|
-
version
|
|
37
|
-
code
|
|
38
|
-
display
|
|
39
|
-
userSelected
|
|
40
|
-
value: string;
|
|
35
|
+
system?: string;
|
|
36
|
+
version?: string;
|
|
37
|
+
code?: string;
|
|
38
|
+
display?: string;
|
|
39
|
+
userSelected?: boolean;
|
|
41
40
|
}
|
|
42
41
|
export declare class DoseCoding extends FHIRElement {
|
|
43
42
|
system: string;
|
|
@@ -55,16 +54,16 @@ export declare class HumanName extends FHIRElement {
|
|
|
55
54
|
}
|
|
56
55
|
export declare class Extension {
|
|
57
56
|
url: string;
|
|
58
|
-
valueString
|
|
59
|
-
valueCode
|
|
60
|
-
valueAddress
|
|
57
|
+
valueString?: string;
|
|
58
|
+
valueCode?: string;
|
|
59
|
+
valueAddress?: Address;
|
|
61
60
|
valueBoolean?: boolean;
|
|
62
|
-
valueHumanName
|
|
63
|
-
valueReference
|
|
64
|
-
valueDate
|
|
65
|
-
valueIdentifier
|
|
61
|
+
valueHumanName?: HumanName;
|
|
62
|
+
valueReference?: Reference;
|
|
63
|
+
valueDate?: Date;
|
|
64
|
+
valueIdentifier?: string;
|
|
66
65
|
valueDecimal?: number;
|
|
67
|
-
valueInteger
|
|
66
|
+
valueInteger?: number;
|
|
68
67
|
}
|
|
69
68
|
export declare class Address extends FHIRElement {
|
|
70
69
|
use: Code;
|
|
@@ -188,12 +187,12 @@ export declare class Reference extends FHIRElement {
|
|
|
188
187
|
display: string;
|
|
189
188
|
}
|
|
190
189
|
export declare class Identifier extends FHIRElement {
|
|
191
|
-
use
|
|
192
|
-
type
|
|
193
|
-
system
|
|
194
|
-
value
|
|
195
|
-
period
|
|
196
|
-
assigner
|
|
190
|
+
use?: string;
|
|
191
|
+
type?: CodeableConcept;
|
|
192
|
+
system?: string;
|
|
193
|
+
value?: string;
|
|
194
|
+
period?: Period;
|
|
195
|
+
assigner?: Reference;
|
|
197
196
|
}
|
|
198
197
|
export declare class Payload extends BackboneElement {
|
|
199
198
|
contentString: string;
|
|
@@ -55,7 +55,7 @@ export declare class Extension {
|
|
|
55
55
|
/**
|
|
56
56
|
* Source of the definition for the extension code - a logical name or a URL.
|
|
57
57
|
*/
|
|
58
|
-
url
|
|
58
|
+
url: Uri;
|
|
59
59
|
/**
|
|
60
60
|
* Value of extension - must be one of a constrained set of the data types (see [Extensibility](extensibility.html) for a list).
|
|
61
61
|
*/
|
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import { Coding, CodingKeys, Extension, Identifier, IdentifierKeys } from "../dataTypes";
|
|
1
2
|
export declare class ResourceUtils {
|
|
2
3
|
/**
|
|
3
4
|
*
|
|
@@ -15,14 +16,14 @@ export declare class ResourceUtils {
|
|
|
15
16
|
* @returns array of matches
|
|
16
17
|
* @limitations currently does not work with identifier.type, identifier.period & identifier.assigner
|
|
17
18
|
*/
|
|
18
|
-
getIdentifiersByProperty(identifierList:
|
|
19
|
+
getIdentifiersByProperty(identifierList: Identifier[], propertyToCompare: IdentifierKeys, propertyValue: Identifier[IdentifierKeys]): Identifier[];
|
|
19
20
|
/**
|
|
20
21
|
*
|
|
21
22
|
* @param extensionList list of extensions
|
|
22
23
|
* @param extensionUrl Extension.url to compare
|
|
23
24
|
* @returns array of matches
|
|
24
25
|
*/
|
|
25
|
-
getExtensionsByUrl(extensionList:
|
|
26
|
+
getExtensionsByUrl(extensionList: Extension[], extensionUrl: string): Extension[];
|
|
26
27
|
/**
|
|
27
28
|
*
|
|
28
29
|
* @param codingList list of codings
|
|
@@ -30,7 +31,7 @@ export declare class ResourceUtils {
|
|
|
30
31
|
* @param propertyValue value we want to compare against string or boolean
|
|
31
32
|
* @returns array of matches
|
|
32
33
|
*/
|
|
33
|
-
getCodingsByProperty(codingList:
|
|
34
|
+
getCodingsByProperty(codingList: Coding[], propertyToCompare: CodingKeys, propertyValue: Coding[CodingKeys]): Coding[];
|
|
34
35
|
/**
|
|
35
36
|
*
|
|
36
37
|
* @param resource resource for which path needs to be validated
|
|
@@ -42,9 +42,9 @@ describe("ResourceUtils", () => {
|
|
|
42
42
|
];
|
|
43
43
|
it("should return empty array if null is passed as identifier list", () => {
|
|
44
44
|
// setup
|
|
45
|
-
const value = "
|
|
45
|
+
const value = "shouldBeIgnored";
|
|
46
46
|
// execute
|
|
47
|
-
const actual = resourceUtils.getIdentifiersByProperty(null, "
|
|
47
|
+
const actual = resourceUtils.getIdentifiersByProperty(null, "id", value);
|
|
48
48
|
// validate
|
|
49
49
|
expect(actual.length).toEqual(0);
|
|
50
50
|
});
|
|
@@ -52,7 +52,8 @@ describe("ResourceUtils", () => {
|
|
|
52
52
|
// setup
|
|
53
53
|
const value = "abc";
|
|
54
54
|
// execute
|
|
55
|
-
const actual = resourceUtils.getIdentifiersByProperty(identifierList, "
|
|
55
|
+
const actual = resourceUtils.getIdentifiersByProperty(identifierList, "extension", // no extensions in test data
|
|
56
|
+
value);
|
|
56
57
|
// validate
|
|
57
58
|
expect(actual.length).toEqual(0);
|
|
58
59
|
});
|
|
@@ -94,11 +95,12 @@ describe("ResourceUtils", () => {
|
|
|
94
95
|
// setup
|
|
95
96
|
const extensionListInvalid = [
|
|
96
97
|
{
|
|
98
|
+
// @ts-ignore
|
|
97
99
|
use: "temp",
|
|
98
100
|
system: "http://hl7.org/fhir/sid/us-ssn",
|
|
99
101
|
value: "abc",
|
|
100
102
|
},
|
|
101
|
-
];
|
|
103
|
+
]; // disabling compiler warning for the test
|
|
102
104
|
const url = "http://ns.electronichealth.net.au/id/hi/ihi/1.0";
|
|
103
105
|
// execute
|
|
104
106
|
const actual = resourceUtils.getExtensionsByUrl(extensionListInvalid, url);
|
|
@@ -140,9 +142,9 @@ describe("ResourceUtils", () => {
|
|
|
140
142
|
];
|
|
141
143
|
it("should return empty array if null is passed as coding list", () => {
|
|
142
144
|
// setup
|
|
143
|
-
const value = "
|
|
145
|
+
const value = "shouldBeIgnored";
|
|
144
146
|
// execute
|
|
145
|
-
const actual = resourceUtils.getCodingsByProperty(null, "
|
|
147
|
+
const actual = resourceUtils.getCodingsByProperty(null, "extension", value);
|
|
146
148
|
// validate
|
|
147
149
|
expect(actual.length).toEqual(0);
|
|
148
150
|
});
|
|
@@ -150,7 +152,8 @@ describe("ResourceUtils", () => {
|
|
|
150
152
|
// setup
|
|
151
153
|
const value = "abc";
|
|
152
154
|
// execute
|
|
153
|
-
const actual = resourceUtils.getCodingsByProperty(codingList, "
|
|
155
|
+
const actual = resourceUtils.getCodingsByProperty(codingList, "id", // expect no ID in codingList
|
|
156
|
+
value);
|
|
154
157
|
// validate
|
|
155
158
|
expect(actual.length).toEqual(0);
|
|
156
159
|
});
|
|
@@ -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;
|
package/package.json
CHANGED
package/src/FHIR-DSTU2.ts
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
/* This is base class from which other elements are derived */
|
|
2
2
|
export class FHIRElement {
|
|
3
|
-
id
|
|
4
|
-
extension
|
|
3
|
+
id?: string;
|
|
4
|
+
extension?: Extension[];
|
|
5
5
|
}
|
|
6
6
|
|
|
7
7
|
export class BackboneElement extends FHIRElement {
|
|
@@ -22,7 +22,7 @@ export class Id {
|
|
|
22
22
|
}
|
|
23
23
|
}
|
|
24
24
|
|
|
25
|
-
export class DomainResource
|
|
25
|
+
export class DomainResource {
|
|
26
26
|
text: Narrative;
|
|
27
27
|
contained: Resource[];
|
|
28
28
|
extension: Extension[];
|
|
@@ -56,12 +56,12 @@ export class CodeableConcept extends FHIRElement {
|
|
|
56
56
|
}
|
|
57
57
|
|
|
58
58
|
export class Identifier extends FHIRElement {
|
|
59
|
-
use
|
|
60
|
-
type
|
|
61
|
-
system
|
|
62
|
-
value
|
|
63
|
-
period
|
|
64
|
-
assigner
|
|
59
|
+
use?: string;
|
|
60
|
+
type?: CodeableConcept;
|
|
61
|
+
system?: string;
|
|
62
|
+
value?: string;
|
|
63
|
+
period?: Period;
|
|
64
|
+
assigner?: Reference;
|
|
65
65
|
}
|
|
66
66
|
|
|
67
67
|
export class Reference extends FHIRElement {
|
|
@@ -83,25 +83,25 @@ export class HumanName extends FHIRElement {
|
|
|
83
83
|
|
|
84
84
|
export class Extension {
|
|
85
85
|
url: string;
|
|
86
|
-
valueString
|
|
87
|
-
valueCode
|
|
88
|
-
valueAddress
|
|
86
|
+
valueString?: string;
|
|
87
|
+
valueCode?: string;
|
|
88
|
+
valueAddress?: Address;
|
|
89
89
|
valueBoolean?: boolean;
|
|
90
|
-
valueHumanName
|
|
91
|
-
valueReference
|
|
92
|
-
valueDate
|
|
93
|
-
valueIdentifier
|
|
90
|
+
valueHumanName?: HumanName;
|
|
91
|
+
valueReference?: Reference;
|
|
92
|
+
valueDate?: Date;
|
|
93
|
+
valueIdentifier?: string;
|
|
94
94
|
valueDecimal?: number;
|
|
95
|
-
valueInteger
|
|
96
|
-
valuePeriod
|
|
95
|
+
valueInteger?: number;
|
|
96
|
+
valuePeriod?: Period;
|
|
97
97
|
}
|
|
98
98
|
|
|
99
99
|
export class Coding extends FHIRElement {
|
|
100
|
-
system
|
|
101
|
-
version
|
|
102
|
-
code
|
|
103
|
-
display
|
|
104
|
-
userSelected
|
|
100
|
+
system?: string;
|
|
101
|
+
version?: string;
|
|
102
|
+
code?: string;
|
|
103
|
+
display?: string;
|
|
104
|
+
userSelected?: boolean;
|
|
105
105
|
}
|
|
106
106
|
|
|
107
107
|
export class Period extends FHIRElement {
|
package/src/FHIR-R3.ts
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
/* This is base class from which other elements are derived */
|
|
2
2
|
export class FHIRElement {
|
|
3
|
-
id
|
|
4
|
-
extension
|
|
3
|
+
id?: string;
|
|
4
|
+
extension?: Extension[];
|
|
5
5
|
}
|
|
6
6
|
|
|
7
7
|
export class BackboneElement extends FHIRElement {
|
|
@@ -9,7 +9,7 @@ export class BackboneElement extends FHIRElement {
|
|
|
9
9
|
}
|
|
10
10
|
/* FHIR classes used in resources */
|
|
11
11
|
|
|
12
|
-
export class DomainResource
|
|
12
|
+
export class DomainResource {
|
|
13
13
|
text: Narrative;
|
|
14
14
|
contained: Resource[];
|
|
15
15
|
extension: Extension[];
|
|
@@ -60,13 +60,12 @@ export class Code extends FHIRElement {
|
|
|
60
60
|
}
|
|
61
61
|
|
|
62
62
|
export class Coding extends FHIRElement {
|
|
63
|
-
system
|
|
64
|
-
version
|
|
63
|
+
system?: string;
|
|
64
|
+
version?: string;
|
|
65
65
|
// should be of type Code
|
|
66
|
-
code
|
|
67
|
-
display
|
|
68
|
-
userSelected
|
|
69
|
-
value: string;
|
|
66
|
+
code?: string;
|
|
67
|
+
display?: string;
|
|
68
|
+
userSelected?: boolean;
|
|
70
69
|
}
|
|
71
70
|
|
|
72
71
|
export class DoseCoding extends FHIRElement {
|
|
@@ -87,16 +86,16 @@ export class HumanName extends FHIRElement {
|
|
|
87
86
|
|
|
88
87
|
export class Extension {
|
|
89
88
|
url: string;
|
|
90
|
-
valueString
|
|
91
|
-
valueCode
|
|
92
|
-
valueAddress
|
|
89
|
+
valueString?: string;
|
|
90
|
+
valueCode?: string;
|
|
91
|
+
valueAddress?: Address;
|
|
93
92
|
valueBoolean?: boolean;
|
|
94
|
-
valueHumanName
|
|
95
|
-
valueReference
|
|
96
|
-
valueDate
|
|
97
|
-
valueIdentifier
|
|
93
|
+
valueHumanName?: HumanName;
|
|
94
|
+
valueReference?: Reference;
|
|
95
|
+
valueDate?: Date;
|
|
96
|
+
valueIdentifier?: string;
|
|
98
97
|
valueDecimal?: number;
|
|
99
|
-
valueInteger
|
|
98
|
+
valueInteger?: number;
|
|
100
99
|
}
|
|
101
100
|
|
|
102
101
|
export class Address extends FHIRElement {
|
|
@@ -256,12 +255,12 @@ export class Reference extends FHIRElement {
|
|
|
256
255
|
}
|
|
257
256
|
|
|
258
257
|
export class Identifier extends FHIRElement {
|
|
259
|
-
use
|
|
260
|
-
type
|
|
261
|
-
system
|
|
262
|
-
value
|
|
263
|
-
period
|
|
264
|
-
assigner
|
|
258
|
+
use?: string;
|
|
259
|
+
type?: CodeableConcept;
|
|
260
|
+
system?: string;
|
|
261
|
+
value?: string;
|
|
262
|
+
period?: Period;
|
|
263
|
+
assigner?: Reference;
|
|
265
264
|
}
|
|
266
265
|
|
|
267
266
|
export class Payload extends BackboneElement {
|
|
@@ -815,48 +814,48 @@ export class Encounter extends BaseResource {
|
|
|
815
814
|
identifier: Identifier[];
|
|
816
815
|
status: 'planned' | 'arrived' | 'triaged' | 'in-progress' | 'onleave' | 'finished' | 'cancelled' | 'entered-in-error' | 'unknown';
|
|
817
816
|
statusHistory: {
|
|
818
|
-
status:'planned' | 'arrived' | 'triaged' | 'in-progress' | 'onleave' | 'finished' | 'cancelled' | 'entered-in-error' | 'unknown';
|
|
817
|
+
status: 'planned' | 'arrived' | 'triaged' | 'in-progress' | 'onleave' | 'finished' | 'cancelled' | 'entered-in-error' | 'unknown';
|
|
819
818
|
period: Period;
|
|
820
819
|
}[];
|
|
821
|
-
class:Coding;
|
|
822
|
-
classHistory:{
|
|
823
|
-
class:Coding;
|
|
824
|
-
period:Period;
|
|
820
|
+
class: Coding;
|
|
821
|
+
classHistory: {
|
|
822
|
+
class: Coding;
|
|
823
|
+
period: Period;
|
|
825
824
|
}[];
|
|
826
|
-
type:CodeableConcept[];
|
|
827
|
-
priority:CodeableConcept;
|
|
825
|
+
type: CodeableConcept[];
|
|
826
|
+
priority: CodeableConcept;
|
|
828
827
|
episodeOfCare: Reference[];
|
|
829
828
|
subject: Reference;
|
|
830
|
-
incomingReferral:Reference[];
|
|
829
|
+
incomingReferral: Reference[];
|
|
831
830
|
participant: EncounterParticipant[];
|
|
832
|
-
appointment:Reference;
|
|
833
|
-
period:Period;
|
|
834
|
-
length:Quantity;
|
|
835
|
-
reason:CodeableConcept[];
|
|
836
|
-
diagnosis:{
|
|
837
|
-
condition:Reference;
|
|
838
|
-
role:CodeableConcept;
|
|
839
|
-
rank:number
|
|
831
|
+
appointment: Reference;
|
|
832
|
+
period: Period;
|
|
833
|
+
length: Quantity;
|
|
834
|
+
reason: CodeableConcept[];
|
|
835
|
+
diagnosis: {
|
|
836
|
+
condition: Reference;
|
|
837
|
+
role: CodeableConcept;
|
|
838
|
+
rank: number
|
|
840
839
|
}[];
|
|
841
|
-
account:Reference[];
|
|
842
|
-
hospitalization:{
|
|
843
|
-
preAdmissionIdentifer:Identifier;
|
|
844
|
-
origin:Reference;
|
|
845
|
-
admitSource:CodeableConcept;
|
|
846
|
-
reAdmission:CodeableConcept;
|
|
847
|
-
dietPreference:CodeableConcept[];
|
|
848
|
-
specialCourtesy:CodeableConcept[];
|
|
849
|
-
specialArrangement:CodeableConcept[];
|
|
850
|
-
destination:Reference;
|
|
851
|
-
dischargeDiposition:CodeableConcept;
|
|
840
|
+
account: Reference[];
|
|
841
|
+
hospitalization: {
|
|
842
|
+
preAdmissionIdentifer: Identifier;
|
|
843
|
+
origin: Reference;
|
|
844
|
+
admitSource: CodeableConcept;
|
|
845
|
+
reAdmission: CodeableConcept;
|
|
846
|
+
dietPreference: CodeableConcept[];
|
|
847
|
+
specialCourtesy: CodeableConcept[];
|
|
848
|
+
specialArrangement: CodeableConcept[];
|
|
849
|
+
destination: Reference;
|
|
850
|
+
dischargeDiposition: CodeableConcept;
|
|
852
851
|
};
|
|
853
|
-
location:{
|
|
854
|
-
location:Reference;
|
|
852
|
+
location: {
|
|
853
|
+
location: Reference;
|
|
855
854
|
status: 'planned' | 'active' | 'reserved' | 'completed';
|
|
856
855
|
period: Period
|
|
857
856
|
}[];
|
|
858
|
-
serviceProvider:Reference;
|
|
859
|
-
partOf:Reference;
|
|
857
|
+
serviceProvider: Reference;
|
|
858
|
+
partOf: Reference;
|
|
860
859
|
}
|
|
861
860
|
|
|
862
861
|
export class CareTeamParticipant extends BackboneElement {
|
|
@@ -1283,11 +1282,11 @@ export class AllergyIntoleranceReaction extends BackboneElement {
|
|
|
1283
1282
|
}
|
|
1284
1283
|
|
|
1285
1284
|
export class Age extends FHIRElement {
|
|
1286
|
-
|
|
1287
|
-
|
|
1288
|
-
|
|
1289
|
-
|
|
1290
|
-
|
|
1285
|
+
value: number;
|
|
1286
|
+
comparator: '<' | '<=' | '>=' | '>';
|
|
1287
|
+
unit: string;
|
|
1288
|
+
system: string;
|
|
1289
|
+
code: Code;
|
|
1291
1290
|
}
|
|
1292
1291
|
|
|
1293
1292
|
export class ValueSet extends BaseResource {
|
|
@@ -45,7 +45,7 @@ import { UsageContext } from './usageContext';
|
|
|
45
45
|
/**
|
|
46
46
|
* Optional Extension Element - found in all resources.
|
|
47
47
|
*/
|
|
48
|
-
export class Extension {
|
|
48
|
+
export class Extension {
|
|
49
49
|
/**
|
|
50
50
|
* Unique id for the element within a resource (for internal references). This may be any string value that does not contain spaces.
|
|
51
51
|
*/
|
|
@@ -57,7 +57,7 @@ export class Extension {
|
|
|
57
57
|
/**
|
|
58
58
|
* Source of the definition for the extension code - a logical name or a URL.
|
|
59
59
|
*/
|
|
60
|
-
url
|
|
60
|
+
url: Uri;
|
|
61
61
|
/**
|
|
62
62
|
* Value of extension - must be one of a constrained set of the data types (see [Extensibility](extensibility.html) for a list).
|
|
63
63
|
*/
|
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import { ResourceUtils } from "./ResourceUtils";
|
|
2
|
+
import { Coding, Extension, Identifier, } from "../dataTypes";
|
|
2
3
|
|
|
3
4
|
const patientPayload = require("./../../test-resources/Patient-R4.json");
|
|
4
5
|
const careTeamPayload = require("./../../test-resources/CareTeam-R4.json");
|
|
@@ -41,7 +42,7 @@ describe("ResourceUtils", () => {
|
|
|
41
42
|
});
|
|
42
43
|
|
|
43
44
|
describe("#getIdentifiersByProperty()", () => {
|
|
44
|
-
const identifierList = [
|
|
45
|
+
const identifierList: Identifier[] = [
|
|
45
46
|
{
|
|
46
47
|
use: "temp",
|
|
47
48
|
system: "http://hl7.org/fhir/sid/us-ssn",
|
|
@@ -56,11 +57,11 @@ describe("ResourceUtils", () => {
|
|
|
56
57
|
|
|
57
58
|
it("should return empty array if null is passed as identifier list", () => {
|
|
58
59
|
// setup
|
|
59
|
-
const value = "
|
|
60
|
+
const value = "shouldBeIgnored";
|
|
60
61
|
// execute
|
|
61
62
|
const actual = resourceUtils.getIdentifiersByProperty(
|
|
62
63
|
null,
|
|
63
|
-
"
|
|
64
|
+
"id",
|
|
64
65
|
value
|
|
65
66
|
);
|
|
66
67
|
// validate
|
|
@@ -73,7 +74,7 @@ describe("ResourceUtils", () => {
|
|
|
73
74
|
// execute
|
|
74
75
|
const actual = resourceUtils.getIdentifiersByProperty(
|
|
75
76
|
identifierList,
|
|
76
|
-
"
|
|
77
|
+
"extension", // no extensions in test data
|
|
77
78
|
value
|
|
78
79
|
);
|
|
79
80
|
// validate
|
|
@@ -108,7 +109,7 @@ describe("ResourceUtils", () => {
|
|
|
108
109
|
});
|
|
109
110
|
|
|
110
111
|
describe("#getExtensionsByUrl()", () => {
|
|
111
|
-
const extensionList = [
|
|
112
|
+
const extensionList: Extension[] = [
|
|
112
113
|
{
|
|
113
114
|
url: "http://hl7.org/fhir/sid/us-ssn",
|
|
114
115
|
valueBoolean: true,
|
|
@@ -130,11 +131,12 @@ describe("ResourceUtils", () => {
|
|
|
130
131
|
// setup
|
|
131
132
|
const extensionListInvalid = [
|
|
132
133
|
{
|
|
134
|
+
// @ts-ignore
|
|
133
135
|
use: "temp",
|
|
134
136
|
system: "http://hl7.org/fhir/sid/us-ssn",
|
|
135
137
|
value: "abc",
|
|
136
138
|
},
|
|
137
|
-
];
|
|
139
|
+
] as Extension[]; // disabling compiler warning for the test
|
|
138
140
|
const url = "http://ns.electronichealth.net.au/id/hi/ihi/1.0";
|
|
139
141
|
// execute
|
|
140
142
|
const actual = resourceUtils.getExtensionsByUrl(
|
|
@@ -165,7 +167,7 @@ describe("ResourceUtils", () => {
|
|
|
165
167
|
});
|
|
166
168
|
|
|
167
169
|
describe("#getCodingsByProperty()", () => {
|
|
168
|
-
const codingList = [
|
|
170
|
+
const codingList: Coding[] = [
|
|
169
171
|
{
|
|
170
172
|
version: "1.0",
|
|
171
173
|
system: "http://hl7.org/fhir/sid/us-ssn",
|
|
@@ -183,9 +185,9 @@ describe("ResourceUtils", () => {
|
|
|
183
185
|
|
|
184
186
|
it("should return empty array if null is passed as coding list", () => {
|
|
185
187
|
// setup
|
|
186
|
-
const value = "
|
|
188
|
+
const value = "shouldBeIgnored";
|
|
187
189
|
// execute
|
|
188
|
-
const actual = resourceUtils.getCodingsByProperty(null, "
|
|
190
|
+
const actual = resourceUtils.getCodingsByProperty(null, "extension", value);
|
|
189
191
|
// validate
|
|
190
192
|
expect(actual.length).toEqual(0);
|
|
191
193
|
});
|
|
@@ -196,7 +198,7 @@ describe("ResourceUtils", () => {
|
|
|
196
198
|
// execute
|
|
197
199
|
const actual = resourceUtils.getCodingsByProperty(
|
|
198
200
|
codingList,
|
|
199
|
-
"
|
|
201
|
+
"id", // expect no ID in codingList
|
|
200
202
|
value
|
|
201
203
|
);
|
|
202
204
|
// validate
|
|
@@ -244,7 +246,7 @@ describe("ResourceUtils", () => {
|
|
|
244
246
|
});
|
|
245
247
|
|
|
246
248
|
describe("#getValuesAtResourcePath()", () => {
|
|
247
|
-
|
|
249
|
+
|
|
248
250
|
it("should return array with values if path exists for a top level element", () => {
|
|
249
251
|
// execute
|
|
250
252
|
const pathValues = resourceUtils.getValuesAtResourcePath(patientPayload, "Patient.gender");
|
|
@@ -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;
|