@smile-cdr/fhirts 2.2.6 → 2.2.7
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 +4 -0
- package/GETTINGSTARTED.md +2 -0
- package/dist/library/BundleUtils/BundleUtils.d.ts +7 -0
- package/dist/library/BundleUtils/BundleUtils.js +9 -0
- package/dist/library/BundleUtils/BundleUtils.spec.js +21 -1
- package/package.json +1 -1
- package/src/library/BundleUtils/BundleUtils.spec.ts +30 -1
- package/src/library/BundleUtils/BundleUtils.ts +9 -0
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,9 @@
|
|
|
1
1
|
# Changelog
|
|
2
2
|
|
|
3
|
+
## 2.2.7
|
|
4
|
+
|
|
5
|
+
* Added `BundleUtils.getResourceByFullUrl` to get a resource by its full url from a bundle.
|
|
6
|
+
|
|
3
7
|
## 2.2.6
|
|
4
8
|
|
|
5
9
|
* Fixed issue with `ResourceUtils.getValuesAtResourcePath` not being able to get an array with values if path exists for a top level element and is an object.
|
package/GETTINGSTARTED.md
CHANGED
|
@@ -151,6 +151,8 @@ const bundleUtils = new BundleUtils();
|
|
|
151
151
|
const claimsList = bundleUtils.getResources(Bundle.entry, 'Claim');
|
|
152
152
|
// returns a single resource with ID 123 from Bundle.entry
|
|
153
153
|
const resource = bundleUtils.getResource(Bundle.entry, '123');
|
|
154
|
+
// returns a single resource with full url 123 from Bundle.entry
|
|
155
|
+
const resource = bundleUtils.getResourceByFullUrl(Bundle.entry, 'http://server-host/fhir/Patient/123');
|
|
154
156
|
```
|
|
155
157
|
|
|
156
158
|
#### ResourceUtils
|
|
@@ -13,4 +13,11 @@ export declare class BundleUtils {
|
|
|
13
13
|
* @returns single resource
|
|
14
14
|
*/
|
|
15
15
|
getResource(bundleEntry: any[], resourceId: string): any;
|
|
16
|
+
/**
|
|
17
|
+
*
|
|
18
|
+
* @param bundleEntry Bundle.entry[] i.e. the bundle entries to filter
|
|
19
|
+
* @param fullUrl Full Url to filter from bundle entries
|
|
20
|
+
* @returns single resource
|
|
21
|
+
*/
|
|
22
|
+
getResourceByFullUrl(bundleEntry: any[], fullUrl: string): any;
|
|
16
23
|
}
|
|
@@ -20,5 +20,14 @@ class BundleUtils {
|
|
|
20
20
|
getResource(bundleEntry, resourceId) {
|
|
21
21
|
return (bundleEntry === null || bundleEntry === void 0 ? void 0 : bundleEntry.length) ? bundleEntry.find(x => x['resource']['id'] === resourceId) : null;
|
|
22
22
|
}
|
|
23
|
+
/**
|
|
24
|
+
*
|
|
25
|
+
* @param bundleEntry Bundle.entry[] i.e. the bundle entries to filter
|
|
26
|
+
* @param fullUrl Full Url to filter from bundle entries
|
|
27
|
+
* @returns single resource
|
|
28
|
+
*/
|
|
29
|
+
getResourceByFullUrl(bundleEntry, fullUrl) {
|
|
30
|
+
return (bundleEntry === null || bundleEntry === void 0 ? void 0 : bundleEntry.length) ? bundleEntry.find(x => x['fullUrl'] === fullUrl) : null;
|
|
31
|
+
}
|
|
23
32
|
}
|
|
24
33
|
exports.BundleUtils = BundleUtils;
|
|
@@ -41,7 +41,27 @@ describe("BundleUtils", () => {
|
|
|
41
41
|
// execute
|
|
42
42
|
const actual = bundleUtils.getResource(inputPayload.entry, "ec0bb1b3-b229-36cf-7e34-3f5fec9d3afe");
|
|
43
43
|
// validate
|
|
44
|
-
expect(actual).not.
|
|
44
|
+
expect(actual).not.toBeUndefined();
|
|
45
|
+
});
|
|
46
|
+
});
|
|
47
|
+
describe("#getResourceByFullUrl()", () => {
|
|
48
|
+
it("should return null if null is passed as bundle entries", () => {
|
|
49
|
+
// execute
|
|
50
|
+
const actual = bundleUtils.getResourceByFullUrl(null, "123");
|
|
51
|
+
// validate
|
|
52
|
+
expect(actual).toBeNull();
|
|
53
|
+
});
|
|
54
|
+
it("should return undefined if fullUrl is not found", () => {
|
|
55
|
+
// execute
|
|
56
|
+
const actual = bundleUtils.getResourceByFullUrl(inputPayload.entry, "123");
|
|
57
|
+
// validate
|
|
58
|
+
expect(actual).toBeUndefined();
|
|
59
|
+
});
|
|
60
|
+
it("should return resource if resource is found", () => {
|
|
61
|
+
// execute
|
|
62
|
+
const actual = bundleUtils.getResourceByFullUrl(inputPayload.entry, "urn:uuid:7c52dd91-73f8-83e1-cab2-2ffdd7a34601");
|
|
63
|
+
// validate
|
|
64
|
+
expect(actual).not.toBeUndefined();
|
|
45
65
|
});
|
|
46
66
|
});
|
|
47
67
|
});
|
package/package.json
CHANGED
|
@@ -59,7 +59,36 @@ describe("BundleUtils", () => {
|
|
|
59
59
|
"ec0bb1b3-b229-36cf-7e34-3f5fec9d3afe"
|
|
60
60
|
);
|
|
61
61
|
// validate
|
|
62
|
-
expect(actual).not.
|
|
62
|
+
expect(actual).not.toBeUndefined();
|
|
63
63
|
});
|
|
64
64
|
});
|
|
65
|
+
|
|
66
|
+
describe("#getResourceByFullUrl()", () => {
|
|
67
|
+
it("should return null if null is passed as bundle entries", () => {
|
|
68
|
+
// execute
|
|
69
|
+
const actual = bundleUtils.getResourceByFullUrl(null, "123");
|
|
70
|
+
// validate
|
|
71
|
+
expect(actual).toBeNull();
|
|
72
|
+
});
|
|
73
|
+
|
|
74
|
+
it("should return undefined if fullUrl is not found", () => {
|
|
75
|
+
// execute
|
|
76
|
+
const actual = bundleUtils.getResourceByFullUrl(
|
|
77
|
+
inputPayload.entry,
|
|
78
|
+
"123"
|
|
79
|
+
);
|
|
80
|
+
// validate
|
|
81
|
+
expect(actual).toBeUndefined();
|
|
82
|
+
});
|
|
83
|
+
|
|
84
|
+
it("should return resource if resource is found", () => {
|
|
85
|
+
// execute
|
|
86
|
+
const actual = bundleUtils.getResourceByFullUrl(
|
|
87
|
+
inputPayload.entry,
|
|
88
|
+
"urn:uuid:7c52dd91-73f8-83e1-cab2-2ffdd7a34601"
|
|
89
|
+
);
|
|
90
|
+
// validate
|
|
91
|
+
expect(actual).not.toBeUndefined();
|
|
92
|
+
});
|
|
93
|
+
})
|
|
65
94
|
});
|
|
@@ -20,6 +20,15 @@ export class BundleUtils {
|
|
|
20
20
|
return bundleEntry?.length ? bundleEntry.find(x => x['resource']['id'] === resourceId) : null;
|
|
21
21
|
}
|
|
22
22
|
|
|
23
|
+
/**
|
|
24
|
+
*
|
|
25
|
+
* @param bundleEntry Bundle.entry[] i.e. the bundle entries to filter
|
|
26
|
+
* @param fullUrl Full Url to filter from bundle entries
|
|
27
|
+
* @returns single resource
|
|
28
|
+
*/
|
|
29
|
+
getResourceByFullUrl(bundleEntry: any[], fullUrl: string): any {
|
|
30
|
+
return bundleEntry?.length ? bundleEntry.find(x => x['fullUrl'] === fullUrl) : null;
|
|
31
|
+
}
|
|
23
32
|
}
|
|
24
33
|
|
|
25
34
|
|