@metriport/shared 0.16.0 → 0.17.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,9 @@
1
+ import { Observation } from "@medplum/fhirtypes";
2
+ /**
3
+ * Stable sort that puts VITALS_LOINC codes first, then defaults to the input order.
4
+ */
5
+ export declare function compareObservationsForDisplay(a: Observation, b: Observation): number;
6
+ export declare function sortObservationsForDisplay(observations: Observation[]): Observation[];
7
+ export declare function getObservationCode(observation: Observation): string | undefined;
8
+ export declare function getObservationUnits(observation: Observation): string | undefined;
9
+ //# 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;AAyCjD;;GAEG;AACH,wBAAgB,6BAA6B,CAAC,CAAC,EAAE,WAAW,EAAE,CAAC,EAAE,WAAW,GAAG,MAAM,CAIpF;AAED,wBAAgB,0BAA0B,CAAC,YAAY,EAAE,WAAW,EAAE,GAAG,WAAW,EAAE,CAErF;AAED,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,56 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.getObservationUnits = exports.getObservationCode = exports.sortObservationsForDisplay = exports.compareObservationsForDisplay = void 0;
4
+ const oxygenSaturationLoinc = {
5
+ SpO2: "2708-6",
6
+ Sp02ByPulseOximetry: "59408-5",
7
+ Sp02ByDirectSampling: "20509-6",
8
+ Sp02InCapillaryBloodByPulseOximetry: "59466-1",
9
+ Sp02OnRoomAir: "59410-1",
10
+ };
11
+ const vitalsLoinc = {
12
+ HeartRate: "8867-4",
13
+ BloodPressureSystolic: "8480-6",
14
+ BloodPressureDiastolic: "8462-4",
15
+ RespiratoryRate: "9279-1",
16
+ InhaledOxygenFlowRate: "3151-8",
17
+ Temperature: "8310-5",
18
+ ...oxygenSaturationLoinc,
19
+ Weight: "29463-7",
20
+ Height: "8302-2",
21
+ BMI: "39156-5",
22
+ };
23
+ const vitalsDisplayOrder = Object.values(vitalsLoinc).reduce((acc, code, index) => ({
24
+ ...acc,
25
+ [code]: index,
26
+ }), {});
27
+ /**
28
+ * Gets the display priority for an observation code. Useful for sorting.
29
+ */
30
+ function getDisplayOrder(code) {
31
+ if (!code)
32
+ return Number.MAX_SAFE_INTEGER;
33
+ return vitalsDisplayOrder[code] ?? Number.MAX_SAFE_INTEGER;
34
+ }
35
+ /**
36
+ * Stable sort that puts VITALS_LOINC codes first, then defaults to the input order.
37
+ */
38
+ function compareObservationsForDisplay(a, b) {
39
+ const orderA = getDisplayOrder(getObservationCode(a));
40
+ const orderB = getDisplayOrder(getObservationCode(b));
41
+ return orderA - orderB;
42
+ }
43
+ exports.compareObservationsForDisplay = compareObservationsForDisplay;
44
+ function sortObservationsForDisplay(observations) {
45
+ return [...observations].sort(compareObservationsForDisplay);
46
+ }
47
+ exports.sortObservationsForDisplay = sortObservationsForDisplay;
48
+ function getObservationCode(observation) {
49
+ return observation.code?.coding?.find(coding => coding?.code)?.code;
50
+ }
51
+ exports.getObservationCode = getObservationCode;
52
+ function getObservationUnits(observation) {
53
+ return observation.valueQuantity?.unit?.replace(/[{()}]/g, "").toLowerCase();
54
+ }
55
+ exports.getObservationUnits = getObservationUnits;
56
+ //# sourceMappingURL=observations.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"observations.js","sourceRoot":"","sources":["../../../src/medical/fhir/observations.ts"],"names":[],"mappings":";;;AAEA,MAAM,qBAAqB,GAAG;IAC5B,IAAI,EAAE,QAAQ;IACd,mBAAmB,EAAE,SAAS;IAC9B,oBAAoB,EAAE,SAAS;I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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.16.0",
3
+ "version": "0.17.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": "9108620248a678e0bd251fb2f2e000184342ab69"
96
+ "gitHead": "b5032db931abdf5ba6a61513231fae826587a510"
97
97
  }