@ovok/core 0.4.50 → 0.4.51

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,9 +1,9 @@
1
1
  /**
2
- * The Ovok CMS locales (the CMS's `CMS_LOCALES`); `en` is its default and fallback.
2
+ * The Ovok CMS locales: every ISO 639-1 language, as the CMS carries them; `en` is its default and fallback.
3
3
  */
4
- export declare const OVOK_CMS_LOCALES: readonly ["en", "de", "fr", "es"];
4
+ export declare const OVOK_CMS_LOCALES: readonly ["en", "aa", "ab", "ae", "af", "ak", "am", "an", "ar", "as", "av", "ay", "az", "ba", "be", "bg", "bi", "bm", "bn", "bo", "br", "bs", "ca", "ce", "ch", "co", "cr", "cs", "cu", "cv", "cy", "da", "de", "dv", "dz", "ee", "el", "eo", "es", "et", "eu", "fa", "ff", "fi", "fj", "fo", "fr", "fy", "ga", "gd", "gl", "gn", "gu", "gv", "ha", "he", "hi", "ho", "hr", "ht", "hu", "hy", "hz", "ia", "id", "ie", "ig", "ii", "ik", "io", "is", "it", "iu", "ja", "jv", "ka", "kg", "ki", "kj", "kk", "kl", "km", "kn", "ko", "kr", "ks", "ku", "kv", "kw", "ky", "la", "lb", "lg", "li", "ln", "lo", "lt", "lu", "lv", "mg", "mh", "mi", "mk", "ml", "mn", "mr", "ms", "mt", "my", "na", "nb", "nd", "ne", "ng", "nl", "nn", "no", "nr", "nv", "ny", "oc", "oj", "om", "or", "os", "pa", "pi", "pl", "ps", "pt", "qu", "rm", "rn", "ro", "ru", "rw", "sa", "sc", "sd", "se", "sg", "si", "sk", "sl", "sm", "sn", "so", "sq", "sr", "ss", "st", "su", "sv", "sw", "ta", "te", "tg", "th", "ti", "tk", "tl", "tn", "to", "tr", "ts", "tt", "tw", "ty", "ug", "uk", "ur", "uz", "ve", "vi", "vo", "wa", "wo", "xh", "yi", "yo", "za", "zh", "zu"];
5
5
  /**
6
- * One of the supported CMS locales: `en`, `de`, `fr` or `es`.
6
+ * One of the supported CMS locales, an ISO 639-1 code such as `en`, `de` or `zh`.
7
7
  */
8
8
  export type OvokCmsLocale = (typeof OVOK_CMS_LOCALES)[number];
9
9
  /**
@@ -4,9 +4,21 @@ exports.OVOK_CMS_DEFAULT_LOCALE = exports.OVOK_CMS_LOCALES = void 0;
4
4
  exports.toCmsLocale = toCmsLocale;
5
5
  exports.defaultCmsLocale = defaultCmsLocale;
6
6
  /**
7
- * The Ovok CMS locales (the CMS's `CMS_LOCALES`); `en` is its default and fallback.
7
+ * The Ovok CMS locales: every ISO 639-1 language, as the CMS carries them; `en` is its default and fallback.
8
8
  */
9
- exports.OVOK_CMS_LOCALES = ["en", "de", "fr", "es"];
9
+ exports.OVOK_CMS_LOCALES = [
10
+ "en", "aa", "ab", "ae", "af", "ak", "am", "an", "ar", "as", "av", "ay", "az", "ba", "be", "bg", "bi", "bm",
11
+ "bn", "bo", "br", "bs", "ca", "ce", "ch", "co", "cr", "cs", "cu", "cv", "cy", "da", "de", "dv", "dz", "ee",
12
+ "el", "eo", "es", "et", "eu", "fa", "ff", "fi", "fj", "fo", "fr", "fy", "ga", "gd", "gl", "gn", "gu", "gv",
13
+ "ha", "he", "hi", "ho", "hr", "ht", "hu", "hy", "hz", "ia", "id", "ie", "ig", "ii", "ik", "io", "is", "it",
14
+ "iu", "ja", "jv", "ka", "kg", "ki", "kj", "kk", "kl", "km", "kn", "ko", "kr", "ks", "ku", "kv", "kw", "ky",
15
+ "la", "lb", "lg", "li", "ln", "lo", "lt", "lu", "lv", "mg", "mh", "mi", "mk", "ml", "mn", "mr", "ms", "mt",
16
+ "my", "na", "nb", "nd", "ne", "ng", "nl", "nn", "no", "nr", "nv", "ny", "oc", "oj", "om", "or", "os", "pa",
17
+ "pi", "pl", "ps", "pt", "qu", "rm", "rn", "ro", "ru", "rw", "sa", "sc", "sd", "se", "sg", "si", "sk", "sl",
18
+ "sm", "sn", "so", "sq", "sr", "ss", "st", "su", "sv", "sw", "ta", "te", "tg", "th", "ti", "tk", "tl", "tn",
19
+ "to", "tr", "ts", "tt", "tw", "ty", "ug", "uk", "ur", "uz", "ve", "vi", "vo", "wa", "wo", "xh", "yi", "yo",
20
+ "za", "zh", "zu"
21
+ ];
10
22
  /**
11
23
  * Locale the CMS answers in when none is requested or supported.
12
24
  */
@@ -21,6 +21,8 @@ export type SeriesObservationParams = {
21
21
  * the series has no identifier and is saved once.
22
22
  */
23
23
  sourceId?: string;
24
+ /** Earlier sources of the same series; each adds an identifier, so a save finds the series saved under any of them. */
25
+ formerSourceIds?: string[];
24
26
  };
25
27
  /**
26
28
  * The values of a series observation, one per slot from `start`.
@@ -59,7 +61,7 @@ export type SeriesSummary = {
59
61
  *
60
62
  * @category measurements
61
63
  */
62
- export declare const seriesObservations: ({ series, patientId, device, status, sourceId, }: SeriesObservationParams) => Observation[];
64
+ export declare const seriesObservations: ({ series, patientId, device, status, sourceId, formerSourceIds, }: SeriesObservationParams) => Observation[];
63
65
  /**
64
66
  * The values of a series observation (`valueSampledData` with one dimension), or `undefined` for any other.
65
67
  *
@@ -8,7 +8,14 @@ const creator_1 = require("./services/creator");
8
8
  const getDeviceObject_1 = require("./utils/getDeviceObject");
9
9
  /** FHIR's mark for a slot with no value. */
10
10
  const NO_VALUE = "E";
11
- const identifierFor = (source, name, start) => source ? { identifier: [{ system: fhir_systems_1.SERIES_IDENTIFIER_SYSTEM, value: `${source}|${name}|${start.toISOString()}` }] } : {};
11
+ const identifierFor = (sources, name, start) => sources.length > 0
12
+ ? {
13
+ identifier: sources.map((source) => ({
14
+ system: fhir_systems_1.SERIES_IDENTIFIER_SYSTEM,
15
+ value: `${source}|${name}|${start.toISOString()}`,
16
+ })),
17
+ }
18
+ : {};
12
19
  const sampledData = (values, decimals) => values
13
20
  .map((value) => (value === null || !Number.isFinite(value) ? NO_VALUE : String(Number(value.toFixed(decimals)))))
14
21
  .join(" ");
@@ -21,8 +28,9 @@ const sampledData = (values, decimals) => values
21
28
  *
22
29
  * @category measurements
23
30
  */
24
- const seriesObservations = ({ series, patientId, device, status = "final", sourceId, }) => {
31
+ const seriesObservations = ({ series, patientId, device, status = "final", sourceId, formerSourceIds = [], }) => {
25
32
  const source = sourceId !== null && sourceId !== void 0 ? sourceId : ((device === null || device === void 0 ? void 0 : device.sn) || (device === null || device === void 0 ? void 0 : device.id));
33
+ const sources = source ? [source, ...formerSourceIds] : [];
26
34
  const service = creator_1.ObservationServiceCreator.getInstance().getService(series.measurementTypeKey);
27
35
  const codes = service.getObservationCodes();
28
36
  const slots = Math.max(0, ...Object.values(series.values).map((values) => { var _a; return (_a = values === null || values === void 0 ? void 0 : values.length) !== null && _a !== void 0 ? _a : 0; }));
@@ -50,11 +58,11 @@ const seriesObservations = ({ series, patientId, device, status = "final", sourc
50
58
  dimensions: 1,
51
59
  data: sampledData(values, field.decimals),
52
60
  },
53
- ...identifierFor(source, field.key, series.start),
61
+ ...identifierFor(sources, field.key, series.start),
54
62
  }];
55
63
  });
56
64
  const group = (0, reading_group_1.readingGroupOf)(series.measurementTypeKey, parts);
57
- return group ? [...parts, { ...group, ...identifierFor(source, "group", series.start) }] : parts;
65
+ return group ? [...parts, { ...group, ...identifierFor(sources, "group", series.start) }] : parts;
58
66
  };
59
67
  exports.seriesObservations = seriesObservations;
60
68
  /**
@@ -14,6 +14,8 @@ export type GenerateObservationBodyParams = {
14
14
  patientId?: string;
15
15
  /** Stable ID from the originating device reading. */
16
16
  sourceId?: string;
17
+ /** Earlier stable IDs of the same reading; a save that finds an observation under any of them creates nothing. */
18
+ formerSourceIds?: string[];
17
19
  /** The measurement to convert. */
18
20
  measurement: Measurement;
19
21
  };
@@ -26,7 +26,7 @@ exports.OVOK_CORE_REQUIREMENTS = {
26
26
  description: "The FHIR surface a server must provide for the @ovok/core client library's own methods to function.",
27
27
  software: {
28
28
  name: "@ovok/core",
29
- version: "0.4.50",
29
+ version: "0.4.51",
30
30
  },
31
31
  fhirVersion: "4.0.1",
32
32
  format: ["json"],
@@ -8,6 +8,7 @@ const creator_1 = require("../../../client/observation/services/creator");
8
8
  const getDeviceObject_1 = require("../../../client/observation/utils/getDeviceObject");
9
9
  /** One measurement's Observations about `subject`, a reference such as `Patient/1`; several end with their group. */
10
10
  function buildObservations(params, subject) {
11
+ var _a;
11
12
  const measurement = timedMeasurement(params.measurement, params.effectiveDateTime);
12
13
  const service = creator_1.ObservationServiceCreator.getInstance().getService(measurement.measurementTypeKey);
13
14
  const device = (0, getDeviceObject_1.getDeviceObject)(params.device);
@@ -19,7 +20,9 @@ function buildObservations(params, subject) {
19
20
  const parts = (0, observation_coding_1.withDeviceUser)(observations, measurement.memorySlot);
20
21
  const group = (0, reading_group_1.readingGroupOf)(measurement.measurementTypeKey, parts);
21
22
  const reading = group ? [...parts, group] : parts;
22
- return params.sourceId ? namedAfterSource(reading, subject, params.sourceId) : reading;
23
+ return params.sourceId
24
+ ? namedAfterSources(reading, subject, [params.sourceId, ...((_a = params.formerSourceIds) !== null && _a !== void 0 ? _a : [])])
25
+ : reading;
23
26
  }
24
27
  /** The caller's time stands in for a measurement that carries none, so every observation of it shares one time. */
25
28
  const timedMeasurement = (measurement, effectiveDateTime) => measurement.recordedAt || !effectiveDateTime ? measurement : { ...measurement, recordedAt: effectiveDateTime };
@@ -54,13 +57,13 @@ const hasValue = (observation) => {
54
57
  const datedAt = (observation, effectiveDateTime) => effectiveDateTime && !observation.effectivePeriod
55
58
  ? { ...observation, effectiveDateTime: effectiveDateTime.toISOString() }
56
59
  : observation;
57
- const namedAfterSource = (observations, subject, sourceId) => observations.map((observation, index) => {
60
+ const namedAfterSources = (observations, subject, sourceIds) => observations.map((observation, index) => {
58
61
  var _a;
59
62
  return ({
60
63
  ...observation,
61
64
  identifier: [
62
65
  ...((_a = observation.identifier) !== null && _a !== void 0 ? _a : []),
63
- { system: fhir_systems_1.DEVICE_READING_IDENTIFIER_SYSTEM, value: `${subject}/${sourceId}/${index}` },
66
+ ...sourceIds.map((sourceId) => ({ system: fhir_systems_1.DEVICE_READING_IDENTIFIER_SYSTEM, value: `${subject}/${sourceId}/${index}` })),
64
67
  ],
65
68
  });
66
69
  });
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@ovok/core",
3
- "version": "0.4.50",
3
+ "version": "0.4.51",
4
4
  "private": false,
5
5
  "main": "dist/next/index.js",
6
6
  "types": "dist/next/index.d.ts",