@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.
@@ -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: any[],
27
- propertyToCompare: string,
28
- propertyValue: string
29
- ): any[] {
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: any[], extensionUrl: string): any[] {
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: any[],
56
- propertyToCompare: string,
57
- propertyValue: string | boolean
58
- ): any[] {
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
- let resultSet = [];
81
- for (let subPathIndex = 0; subPathIndex < resourcePathValue.length; subPathIndex++) {
82
- const subPathValue = resourcePathValue[subPathIndex];
83
- if(this.isPrimitive(subPathValue)) {
84
- resultSet.push(subPathValue);
85
- } else {
86
- resultSet.push(...this.getValuesAtResourcePath(subPathValue,
87
- pathSections.slice(index).join(".")));
88
- }
89
- }
90
- return resultSet;
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,4 @@
1
+ export enum SORT_ORDER {
2
+ ASCENDING,
3
+ DESCENDING
4
+ }
@@ -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;