@smile-cdr/fhirts 2.1.0 → 2.1.1

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/CHANGELOG.md CHANGED
@@ -1,5 +1,13 @@
1
1
  # Changelog
2
2
 
3
+ ## 2.1.1
4
+
5
+ * Fix issue with `BundleUtils.getResourceFromBundle` not being able get the values inside nested array under array of objects.
6
+
7
+ ## 2.1.0
8
+
9
+ * Remove static classes for `BundleUtilities` & `ResourceUtilities` to non static classes `BundleUtils` & `ResourceUtils.`
10
+
3
11
  ## 2.0.7
4
12
 
5
13
  ### Updates (R4)
package/GETTINGSTARTED.md CHANGED
@@ -97,7 +97,7 @@ If you try writing this out you will see that the variable `resource` inside the
97
97
  ### `v2.1.0`
98
98
  #### BundleUtils usage
99
99
  ```js
100
- import { BundleUtils } from '@smilecdr/fhirts';
100
+ import { BundleUtils } from '@smile-cdr/fhirts';
101
101
 
102
102
  const bundleUtils = new BundleUtils();
103
103
  // returns arrayof Claim resources from Bundle.entry
@@ -108,7 +108,7 @@ const resource = bundleUtils.getResourceFromBundle(Bundle.entry, '123');
108
108
 
109
109
  #### ResourceUtils usage
110
110
  ```js
111
- import { ResourceUtils } from '@smilecdr/fhirts';
111
+ import { ResourceUtils } from '@smile-cdr/fhirts';
112
112
  const resourceUtils = new ResourceUtils();
113
113
  // returns deserialized Patient resource
114
114
  const deserializedPatientResource = resourceUtils.deserializeResource(jsonPatientPayload, new Patient());
@@ -136,7 +136,7 @@ const references = resourceUtils.getAllReferencesFromResource(resourcePayload);
136
136
  ### `v2.0.0`
137
137
  #### BundleUtilities usage
138
138
  ```js
139
- import { BundleUtilities } from '@smilecdr/fhirts';
139
+ import { BundleUtilities } from '@smile-cdr/fhirts';
140
140
 
141
141
  // returns arrayof Claim resources from Bundle.entry
142
142
  const claimsList = BundleUtilities.getResourcesFromBundle(Bundle.entry, 'Claim');
@@ -144,7 +144,7 @@ const claimsList = BundleUtilities.getResourcesFromBundle(Bundle.entry, 'Claim')
144
144
 
145
145
  #### ResourceUtilities usage
146
146
  ```js
147
- import { ResourceUtilities } from '@smilecdr/fhirts';
147
+ import { ResourceUtilities } from '@smile-cdr/fhirts';
148
148
 
149
149
  // returns deserialized Patient resource
150
150
  const deserializedPatientResource = ResourceUtilities.deserializeResource(jsonPatientPayload, new Patient());
@@ -72,7 +72,12 @@ class ResourceUtils {
72
72
  let resultSet = [];
73
73
  for (let subPathIndex = 0; subPathIndex < resourcePathValue.length; subPathIndex++) {
74
74
  const subPathValue = resourcePathValue[subPathIndex];
75
- resultSet.push(...this.getValuesAtResourcePath(subPathValue, pathSections.slice(index).join(".")));
75
+ if (this.isPrimitive(subPathValue)) {
76
+ resultSet.push(subPathValue);
77
+ }
78
+ else {
79
+ resultSet.push(...this.getValuesAtResourcePath(subPathValue, pathSections.slice(index).join(".")));
80
+ }
76
81
  }
77
82
  return resultSet;
78
83
  }
@@ -187,6 +187,15 @@ describe("ResourceUtils", () => {
187
187
  expect(pathValues.length).toEqual(1);
188
188
  expect(pathValues[0]).toEqual("male");
189
189
  });
190
+ it("should return array with values for a array under object", () => {
191
+ // execute
192
+ const pathValues = resourceUtils.getValuesAtResourcePath(patientPayload, "Patient.name.given");
193
+ // validate
194
+ expect(pathValues.length).toEqual(3);
195
+ expect(pathValues[0]).toEqual("Pieter");
196
+ expect(pathValues[1]).toEqual("Peter");
197
+ expect(pathValues[2]).toEqual("Pieter");
198
+ });
190
199
  it("should return array with values if path exists for a deep array element", () => {
191
200
  // execute
192
201
  const pathValues = resourceUtils.getValuesAtResourcePath(patientPayload, "Patient.contact.relationship.coding.system");
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@smile-cdr/fhirts",
3
- "version": "2.1.0",
3
+ "version": "2.1.1",
4
4
  "description": "Fhir ts/js library for frontend apps",
5
5
  "license": "Apache-2.0",
6
6
  "main": "dist/index.js",
@@ -253,6 +253,16 @@ describe("ResourceUtils", () => {
253
253
  expect(pathValues[0]).toEqual("male");
254
254
  });
255
255
 
256
+ it("should return array with values for a array under object", () => {
257
+ // execute
258
+ const pathValues = resourceUtils.getValuesAtResourcePath(patientPayload, "Patient.name.given");
259
+ // validate
260
+ expect(pathValues.length).toEqual(3);
261
+ expect(pathValues[0]).toEqual("Pieter");
262
+ expect(pathValues[1]).toEqual("Peter");
263
+ expect(pathValues[2]).toEqual("Pieter");
264
+ });
265
+
256
266
  it("should return array with values if path exists for a deep array element", () => {
257
267
  // execute
258
268
  const pathValues = resourceUtils.getValuesAtResourcePath(patientPayload, "Patient.contact.relationship.coding.system");
@@ -80,8 +80,12 @@ export class ResourceUtils {
80
80
  let resultSet = [];
81
81
  for (let subPathIndex = 0; subPathIndex < resourcePathValue.length; subPathIndex++) {
82
82
  const subPathValue = resourcePathValue[subPathIndex];
83
- resultSet.push(...this.getValuesAtResourcePath(subPathValue,
84
- pathSections.slice(index).join(".")));
83
+ if(this.isPrimitive(subPathValue)) {
84
+ resultSet.push(subPathValue);
85
+ } else {
86
+ resultSet.push(...this.getValuesAtResourcePath(subPathValue,
87
+ pathSections.slice(index).join(".")));
88
+ }
85
89
  }
86
90
  return resultSet;
87
91
  } else if (typeof(resourcePathValue) === 'object') {
@@ -22,7 +22,8 @@
22
22
  "use": "usual",
23
23
  "family": "van de Heuvel",
24
24
  "given": [
25
- "Pieter"
25
+ "Pieter",
26
+ "Peter"
26
27
  ],
27
28
  "suffix": [
28
29
  "MSc"