@metriport/shared 0.14.7 → 0.15.1-alpha.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.
@@ -0,0 +1,5 @@
1
+ /**
2
+ * Turns a string into a UUID in a deterministic manner
3
+ */
4
+ export declare function createUuidFromText(input: string): string;
5
+ //# sourceMappingURL=uuid.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"uuid.d.ts","sourceRoot":"","sources":["../../src/common/uuid.ts"],"names":[],"mappings":"AAEA;;GAEG;AACH,wBAAgB,kBAAkB,CAAC,KAAK,EAAE,MAAM,GAAG,MAAM,CAExD"}
@@ -0,0 +1,12 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.createUuidFromText = void 0;
4
+ const uuid_1 = require("uuid");
5
+ /**
6
+ * Turns a string into a UUID in a deterministic manner
7
+ */
8
+ function createUuidFromText(input) {
9
+ return (0, uuid_1.v3)(input, uuid_1.v3.URL);
10
+ }
11
+ exports.createUuidFromText = createUuidFromText;
12
+ //# sourceMappingURL=uuid.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"uuid.js","sourceRoot":"","sources":["../../src/common/uuid.ts"],"names":[],"mappings":";;;AAAA,+BAA0B;AAE1B;;GAEG;AACH,SAAgB,kBAAkB,CAAC,KAAa;IAC9C,OAAO,IAAA,SAAE,EAAC,KAAK,EAAE,SAAE,CAAC,GAAG,CAAC,CAAC;AAC3B,CAAC;AAFD,gDAEC"}
@@ -0,0 +1,4 @@
1
+ import { Observation } from "@medplum/fhirtypes";
2
+ export declare const observationDisplayComparator: (a: Observation, b: Observation) => number;
3
+ export declare const sortObservationsForDisplay: (observations: Observation[]) => Observation[];
4
+ //# sourceMappingURL=observation-ordering.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"observation-ordering.d.ts","sourceRoot":"","sources":["../../../src/medical/fhir/observation-ordering.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,WAAW,EAAE,MAAM,oBAAoB,CAAC;AAsCjD,eAAO,MAAM,4BAA4B,MAAO,WAAW,KAAK,WAAW,KAAG,MAO7E,CAAC;AAEF,eAAO,MAAM,0BAA0B,iBAAkB,WAAW,EAAE,KAAG,WAAW,EAEnF,CAAC"}
@@ -0,0 +1,43 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.sortObservationsForDisplay = exports.observationDisplayComparator = void 0;
4
+ // Not sure the names of the codes are correct,
5
+ // but they're related and should be grouped together regardless
6
+ const OXYGEN_SATURATION_LOINC = {
7
+ SpO2: "2708-6",
8
+ Sp02ByPulseOximetry: "59408-5",
9
+ Sp02ByDirectSampling: "20509-6",
10
+ Sp02InCapillaryBloodByPulseOximetry: "59466-1",
11
+ Sp02OnRoomAir: "59410-1",
12
+ };
13
+ const VITALS_LOINC = {
14
+ HeartRate: "8867-4",
15
+ BloodPressureSystolic: "8480-6",
16
+ BloodPressureDiastolic: "8462-4",
17
+ RespiratoryRate: "9279-1",
18
+ InhaledOxygenFlowRate: "3151-8",
19
+ Temperature: "8310-5",
20
+ ...OXYGEN_SATURATION_LOINC,
21
+ Weight: "29463-7",
22
+ Height: "8302-2",
23
+ BMI: "39156-5",
24
+ };
25
+ // Create display order based on the order of values in VITALS_LOINC
26
+ const VITALS_DISPLAY_ORDER = Object.values(VITALS_LOINC).reduce((acc, code, index) => ({
27
+ ...acc,
28
+ [code]: index,
29
+ }), {});
30
+ // Stable sort that puts VITALS_LOINC codes first, then defaults to the upstream order.
31
+ const observationDisplayComparator = (a, b) => {
32
+ const aCode = a.code?.coding?.[0]?.code;
33
+ const bCode = b.code?.coding?.[0]?.code;
34
+ const orderA = aCode ? VITALS_DISPLAY_ORDER[aCode] : Number.MAX_SAFE_INTEGER;
35
+ const orderB = bCode ? VITALS_DISPLAY_ORDER[bCode] : Number.MAX_SAFE_INTEGER;
36
+ return orderA - orderB;
37
+ };
38
+ exports.observationDisplayComparator = observationDisplayComparator;
39
+ const sortObservationsForDisplay = (observations) => {
40
+ return [...observations].sort(exports.observationDisplayComparator);
41
+ };
42
+ exports.sortObservationsForDisplay = sortObservationsForDisplay;
43
+ //# sourceMappingURL=observation-ordering.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"observation-ordering.js","sourceRoot":"","sources":["../../../src/medical/fhir/observation-ordering.ts"],"names":[],"mappings":";;;AAEA,+CAA+C;AAC/C,gEAAgE;AAChE,MAAM,uBAAuB,GAAG;IAC9B,IAAI,EAAE,QAAQ;IACd,mBAAmB,EAAE,SAAS;IAC9B,oBAAoB,EAAE,SAAS;IAC/B,mCAAmC,EAAE,SAAS;IAC9C,aAAa,EAAE,SAAS;CAChB,CAAC;AAEX,MAAM,YAAY,GAAG;IACnB,SAAS,EAAE,QAAQ;IACnB,qBAAqB,EAAE,QAAQ;IAC/B,sBAAsB,EAAE,QAAQ;IAChC,eAAe,EAAE,QAAQ;IACzB,qBAAqB,EAAE,QAAQ;IAC/B,WAAW,EAAE,QAAQ;IACrB,GAAG,uBAAuB;IAC1B,MAAM,EAAE,SAAS;IACjB,MAAM,EAAE,QAAQ;IAChB,GAAG,EAAE,SAAS;CACN,CAAC;AAKX,oEAAoE;AACpE,MAAM,oBAAoB,GAAgC,MAAM,CAAC,MAAM,CAAC,YAAY,CAAC,CAAC,MAAM,CAC1F,CAAC,GAAG,EAAE,IAAI,EAAE,KAAK,EAAE,EAAE,CAAC,CAAC;IACrB,GAAG,GAAG;IACN,CAAC,IAAI,CAAC,EAAE,KAAK;CACd,CAAC,EACF,EAAiC,CAClC,CAAC;AAEF,uFAAuF;AAChF,MAAM,4BAA4B,GAAG,CAAC,CAAc,EAAE,CAAc,EAAU,EAAE;IACrF,MAAM,KAAK,GAAG,CAAC,CAAC,IAAI,EAAE,MAAM,EAAE,CAAC,CAAC,CAAC,EAAE,IAA+B,CAAC;IACnE,MAAM,KAAK,GAAG,CAAC,CAAC,IAAI,EAAE,MAAM,EAAE,CAAC,CAAC,CAAC,EAAE,IAA+B,CAAC;IACnE,MAAM,MAAM,GAAG,KAAK,CAAC,CAAC,CAAC,oBAAoB,CAAC,KAAK,CAAC,CAAC,CAAC,CAAC,MAAM,CAAC,gBAAgB,CAAC;IAC7E,MAAM,MAAM,GAAG,KAAK,CAAC,CAAC,CAAC,oBAAoB,CAAC,KAAK,CAAC,CAAC,CAAC,CAAC,MAAM,CAAC,gBAAgB,CAAC;IAE7E,OAAO,MAAM,GAAG,MAAM,CAAC;AACzB,CAAC,CAAC;AAPW,QAAA,4BAA4B,gCAOvC;AAEK,MAAM,0BAA0B,GAAG,CAAC,YAA2B,EAAiB,EAAE;IACvF,OAAO,CAAC,GAAG,YAAY,CAAC,CAAC,IAAI,CAAC,oCAA4B,CAAC,CAAC;AAC9D,CAAC,CAAC;AAFW,QAAA,0BAA0B,8BAErC"}
@@ -0,0 +1,6 @@
1
+ import { Observation } from "@medplum/fhirtypes";
2
+ export declare const observationDisplayComparator: (a: Observation, b: Observation) => number;
3
+ export declare const sortObservationsForDisplay: (observations: Observation[]) => Observation[];
4
+ export declare function getObservationCode(observation: Observation): string | undefined;
5
+ export declare function getObservationUnits(observation: Observation): string | undefined;
6
+ //# sourceMappingURL=observations.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"observations.d.ts","sourceRoot":"","sources":["../../../src/medical/fhir/observations.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,WAAW,EAAE,MAAM,oBAAoB,CAAC;AAsCjD,eAAO,MAAM,4BAA4B,MAAO,WAAW,KAAK,WAAW,KAAG,MAO7E,CAAC;AAEF,eAAO,MAAM,0BAA0B,iBAAkB,WAAW,EAAE,KAAG,WAAW,EAEnF,CAAC;AAEF,wBAAgB,kBAAkB,CAAC,WAAW,EAAE,WAAW,GAAG,MAAM,GAAG,SAAS,CAE/E;AAED,wBAAgB,mBAAmB,CAAC,WAAW,EAAE,WAAW,GAAG,MAAM,GAAG,SAAS,CAEhF"}
@@ -0,0 +1,51 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.getObservationUnits = exports.getObservationCode = exports.sortObservationsForDisplay = exports.observationDisplayComparator = void 0;
4
+ // Not sure the names of the codes are correct,
5
+ // but they're related and should be grouped together regardless
6
+ const oxygenSaturationLoinc = {
7
+ SpO2: "2708-6",
8
+ Sp02ByPulseOximetry: "59408-5",
9
+ Sp02ByDirectSampling: "20509-6",
10
+ Sp02InCapillaryBloodByPulseOximetry: "59466-1",
11
+ Sp02OnRoomAir: "59410-1",
12
+ };
13
+ const vitalsLoinc = {
14
+ HeartRate: "8867-4",
15
+ BloodPressureSystolic: "8480-6",
16
+ BloodPressureDiastolic: "8462-4",
17
+ RespiratoryRate: "9279-1",
18
+ InhaledOxygenFlowRate: "3151-8",
19
+ Temperature: "8310-5",
20
+ ...oxygenSaturationLoinc,
21
+ Weight: "29463-7",
22
+ Height: "8302-2",
23
+ BMI: "39156-5",
24
+ };
25
+ // Create display order based on the order of values in VITALS_LOINC
26
+ const VITALS_DISPLAY_ORDER = Object.values(vitalsLoinc).reduce((acc, code, index) => ({
27
+ ...acc,
28
+ [code]: index,
29
+ }), {});
30
+ // Stable sort that puts VITALS_LOINC codes first, then defaults to the upstream order.
31
+ const observationDisplayComparator = (a, b) => {
32
+ const aCode = a.code?.coding?.[0]?.code;
33
+ const bCode = b.code?.coding?.[0]?.code;
34
+ const orderA = aCode ? VITALS_DISPLAY_ORDER[aCode] : Number.MAX_SAFE_INTEGER;
35
+ const orderB = bCode ? VITALS_DISPLAY_ORDER[bCode] : Number.MAX_SAFE_INTEGER;
36
+ return orderA - orderB;
37
+ };
38
+ exports.observationDisplayComparator = observationDisplayComparator;
39
+ const sortObservationsForDisplay = (observations) => {
40
+ return [...observations].sort(exports.observationDisplayComparator);
41
+ };
42
+ exports.sortObservationsForDisplay = sortObservationsForDisplay;
43
+ function getObservationCode(observation) {
44
+ return observation.code?.coding?.find(coding => coding?.code)?.code;
45
+ }
46
+ exports.getObservationCode = getObservationCode;
47
+ function getObservationUnits(observation) {
48
+ return observation.valueQuantity?.unit?.replace(/[{()}]/g, "").toLowerCase();
49
+ }
50
+ exports.getObservationUnits = getObservationUnits;
51
+ //# sourceMappingURL=observations.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"observations.js","sourceRoot":"","sources":["../../../src/medical/fhir/observations.ts"],"names":[],"mappings":";;;AAEA,+CAA+C;AAC/C,gEAAgE;AAChE,MAAM,qBAAqB,GAAG;IAC5B,IAAI,EAAE,QAAQ;IACd,mBAAmB,EAAE,SAAS;IAC9B,oBAAoB,EAAE,SAAS;IAC/B,mCAAmC,EAAE,SAAS;IAC9C,aAAa,EAAE,SAAS;CAChB,CAAC;AAEX,MAAM,WAAW,GAAG;IAClB,SAAS,EAAE,QAAQ;IACnB,qBAAqB,EAAE,QAAQ;IAC/B,sBAAsB,EAAE,QAAQ;IAChC,eAAe,EAAE,QAAQ;IACzB,qBAAqB,EAAE,QAAQ;IAC/B,WAAW,EAAE,QAAQ;IACrB,GAAG,qBAAqB;IACxB,MAAM,EAAE,SAAS;IACjB,MAAM,EAAE,QAAQ;IAChB,GAAG,EAAE,SAAS;CACN,CAAC;AAKX,oEAAoE;AACpE,MAAM,oBAAoB,GAAgC,MAAM,CAAC,MAAM,CAAC,WAAW,CAAC,CAAC,MAAM,CACzF,CAAC,GAAG,EAAE,IAAI,EAAE,KAAK,EAAE,EAAE,CAAC,CAAC;IACrB,GAAG,GAAG;IACN,CAAC,IAAI,CAAC,EAAE,KAAK;CACd,CAAC,EACF,EAAiC,CAClC,CAAC;AAEF,uFAAuF;AAChF,MAAM,4BAA4B,GAAG,CAAC,CAAc,EAAE,CAAc,EAAU,EAAE;IACrF,MAAM,KAAK,GAAG,CAAC,CAAC,IAAI,EAAE,MAAM,EAAE,CAAC,CAAC,CAAC,EAAE,IAA+B,CAAC;IACnE,MAAM,KAAK,GAAG,CAAC,CAAC,IAAI,EAAE,MAAM,EAAE,CAAC,CAAC,CAAC,EAAE,IAA+B,CAAC;IACnE,MAAM,MAAM,GAAG,KAAK,CAAC,CAAC,CAAC,oBAAoB,CAAC,KAAK,CAAC,CAAC,CAAC,CAAC,MAAM,CAAC,gBAAgB,CAAC;IAC7E,MAAM,MAAM,GAAG,KAAK,CAAC,CAAC,CAAC,oBAAoB,CAAC,KAAK,CAAC,CAAC,CAAC,CAAC,MAAM,CAAC,gBAAgB,CAAC;IAE7E,OAAO,MAAM,GAAG,MAAM,CAAC;AACzB,CAAC,CAAC;AAPW,QAAA,4BAA4B,gCAOvC;AAEK,MAAM,0BAA0B,GAAG,CAAC,YAA2B,EAAiB,EAAE;IACvF,OAAO,CAAC,GAAG,YAAY,CAAC,CAAC,IAAI,CAAC,oCAA4B,CAAC,CAAC;AAC9D,CAAC,CAAC;AAFW,QAAA,0BAA0B,8BAErC;AAEF,SAAgB,kBAAkB,CAAC,WAAwB;IACzD,OAAO,WAAW,CAAC,IAAI,EAAE,MAAM,EAAE,IAAI,CAAC,MAAM,CAAC,EAAE,CAAC,MAAM,EAAE,IAAI,CAAC,EAAE,IAAI,CAAC;AACtE,CAAC;AAFD,gDAEC;AAED,SAAgB,mBAAmB,CAAC,WAAwB;IAC1D,OAAO,WAAW,CAAC,aAAa,EAAE,IAAI,EAAE,OAAO,CAAC,SAAS,EAAE,EAAE,CAAC,CAAC,WAAW,EAAE,CAAC;AAC/E,CAAC;AAFD,kDAEC"}
@@ -1,6 +1,7 @@
1
1
  export * from "./fhir/bundle";
2
- export * from "./fhir/resources";
3
2
  export * from "./fhir/conversion";
3
+ export * from "./fhir/observations";
4
+ export * from "./fhir/resources";
4
5
  export * from "./webhook/webhook-request";
5
6
  export * from "./webhook/webhook-status-response";
6
7
  //# sourceMappingURL=index.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/medical/index.ts"],"names":[],"mappings":"AAAA,cAAc,eAAe,CAAC;AAC9B,cAAc,kBAAkB,CAAC;AACjC,cAAc,mBAAmB,CAAC;AAClC,cAAc,2BAA2B,CAAC;AAC1C,cAAc,mCAAmC,CAAC"}
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/medical/index.ts"],"names":[],"mappings":"AAAA,cAAc,eAAe,CAAC;AAC9B,cAAc,mBAAmB,CAAC;AAClC,cAAc,qBAAqB,CAAC;AACpC,cAAc,kBAAkB,CAAC;AACjC,cAAc,2BAA2B,CAAC;AAC1C,cAAc,mCAAmC,CAAC"}
@@ -15,8 +15,9 @@ var __exportStar = (this && this.__exportStar) || function(m, exports) {
15
15
  };
16
16
  Object.defineProperty(exports, "__esModule", { value: true });
17
17
  __exportStar(require("./fhir/bundle"), exports);
18
- __exportStar(require("./fhir/resources"), exports);
19
18
  __exportStar(require("./fhir/conversion"), exports);
19
+ __exportStar(require("./fhir/observations"), exports);
20
+ __exportStar(require("./fhir/resources"), exports);
20
21
  __exportStar(require("./webhook/webhook-request"), exports);
21
22
  __exportStar(require("./webhook/webhook-status-response"), exports);
22
23
  //# sourceMappingURL=index.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/medical/index.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;AAAA,gDAA8B;AAC9B,mDAAiC;AACjC,oDAAkC;AAClC,4DAA0C;AAC1C,oEAAkD"}
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/medical/index.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;AAAA,gDAA8B;AAC9B,oDAAkC;AAClC,sDAAoC;AACpC,mDAAiC;AACjC,4DAA0C;AAC1C,oEAAkD"}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@metriport/shared",
3
- "version": "0.14.7",
3
+ "version": "0.15.1-alpha.0",
4
4
  "description": "Common code shared across packages - by Metriport Inc.",
5
5
  "author": "Metriport Inc. <contact@metriport.com>",
6
6
  "homepage": "https://metriport.com/",
@@ -93,5 +93,5 @@
93
93
  "ts-jest": "29.1.1",
94
94
  "typescript": "^4.9.5"
95
95
  },
96
- "gitHead": "79df67adfd8ac7fb3bdd8daa339ae31f2920677f"
96
+ "gitHead": "1db7df102449b92aeec8b18f4b0c26066cd46ead"
97
97
  }