phenoml 17.2.0 → 17.3.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.
Files changed (41) hide show
  1. package/dist/cjs/BaseClient.js +2 -2
  2. package/dist/cjs/api/resources/fhir2Omop/client/Client.d.ts +15 -21
  3. package/dist/cjs/api/resources/fhir2Omop/client/Client.js +17 -21
  4. package/dist/cjs/api/resources/fhir2Omop/errors/ServiceUnavailableError.d.ts +5 -0
  5. package/dist/cjs/api/resources/fhir2Omop/errors/ServiceUnavailableError.js +54 -0
  6. package/dist/cjs/api/resources/fhir2Omop/errors/index.d.ts +1 -0
  7. package/dist/cjs/api/resources/fhir2Omop/errors/index.js +1 -0
  8. package/dist/cjs/api/resources/fhir2Omop/types/CreateOmopResponse.d.ts +10 -10
  9. package/dist/cjs/api/resources/fhir2Omop/types/MappingEntry.d.ts +37 -0
  10. package/dist/cjs/api/resources/fhir2Omop/types/Summary.d.ts +15 -0
  11. package/dist/cjs/api/resources/fhir2Omop/types/index.d.ts +2 -2
  12. package/dist/cjs/api/resources/fhir2Omop/types/index.js +2 -2
  13. package/dist/cjs/core/fetcher/signals.js +9 -1
  14. package/dist/cjs/version.d.ts +1 -1
  15. package/dist/cjs/version.js +1 -1
  16. package/dist/esm/BaseClient.mjs +2 -2
  17. package/dist/esm/api/resources/fhir2Omop/client/Client.d.mts +15 -21
  18. package/dist/esm/api/resources/fhir2Omop/client/Client.mjs +17 -21
  19. package/dist/esm/api/resources/fhir2Omop/errors/ServiceUnavailableError.d.mts +5 -0
  20. package/dist/esm/api/resources/fhir2Omop/errors/ServiceUnavailableError.mjs +17 -0
  21. package/dist/esm/api/resources/fhir2Omop/errors/index.d.mts +1 -0
  22. package/dist/esm/api/resources/fhir2Omop/errors/index.mjs +1 -0
  23. package/dist/esm/api/resources/fhir2Omop/types/CreateOmopResponse.d.mts +10 -10
  24. package/dist/esm/api/resources/fhir2Omop/types/MappingEntry.d.mts +37 -0
  25. package/dist/esm/api/resources/fhir2Omop/types/Summary.d.mts +15 -0
  26. package/dist/esm/api/resources/fhir2Omop/types/index.d.mts +2 -2
  27. package/dist/esm/api/resources/fhir2Omop/types/index.mjs +2 -2
  28. package/dist/esm/core/fetcher/signals.mjs +9 -1
  29. package/dist/esm/version.d.mts +1 -1
  30. package/dist/esm/version.mjs +1 -1
  31. package/openapi/openapi.json +57 -187
  32. package/package.json +1 -1
  33. package/reference.md +15 -22
  34. package/dist/cjs/api/resources/fhir2Omop/types/MappingReportEntry.d.ts +0 -32
  35. package/dist/cjs/api/resources/fhir2Omop/types/ScanSummary.d.ts +0 -41
  36. package/dist/esm/api/resources/fhir2Omop/types/MappingReportEntry.d.mts +0 -32
  37. package/dist/esm/api/resources/fhir2Omop/types/ScanSummary.d.mts +0 -41
  38. /package/dist/cjs/api/resources/fhir2Omop/types/{MappingReportEntry.js → MappingEntry.js} +0 -0
  39. /package/dist/cjs/api/resources/fhir2Omop/types/{ScanSummary.js → Summary.js} +0 -0
  40. /package/dist/esm/api/resources/fhir2Omop/types/{MappingReportEntry.mjs → MappingEntry.mjs} +0 -0
  41. /package/dist/esm/api/resources/fhir2Omop/types/{ScanSummary.mjs → Summary.mjs} +0 -0
@@ -43,8 +43,8 @@ function normalizeClientOptions(options) {
43
43
  const headers = (0, headers_js_1.mergeHeaders)({
44
44
  "X-Fern-Language": "JavaScript",
45
45
  "X-Fern-SDK-Name": "phenoml",
46
- "X-Fern-SDK-Version": "17.2.0",
47
- "User-Agent": "phenoml/17.2.0",
46
+ "X-Fern-SDK-Version": "17.3.0",
47
+ "User-Agent": "phenoml/17.3.0",
48
48
  "X-Fern-Runtime": core.RUNTIME.type,
49
49
  "X-Fern-Runtime-Version": core.RUNTIME.version,
50
50
  }, options === null || options === void 0 ? void 0 : options.headers);
@@ -11,30 +11,23 @@ export declare class Fhir2OmopClient {
11
11
  protected readonly _options: NormalizedClientOptionsWithAuth<Fhir2OmopClient.Options>;
12
12
  constructor(options?: Fhir2OmopClient.Options);
13
13
  /**
14
- * Shapes a FHIR R4 resource or Bundle into OMOP Common Data Model v5.4 rows
14
+ * Maps a FHIR R4 resource or Bundle into OMOP Common Data Model v5.4 rows
15
15
  * (person, visit_occurrence, condition_occurrence, drug_exposure,
16
16
  * procedure_occurrence, measurement, observation).
17
17
  *
18
- * **Two resolution modes, reported in `mode`.** `mode` reflects which
19
- * resolver is wired, not the path an individual coding took. With a
20
- * concept-resolver configured (the default), `mode` is `"resolved"` and the
21
- * resource's primary clinical coding is resolved to a real OMOP `concept_id`;
22
- * with no resolver configured, `mode` is `"structural"` and every clinical
23
- * and source `concept_id` is `0`. In `"resolved"` mode individual codings can
24
- * still land at `concept_id` `0` without changing the mode: a coding the
25
- * service finds no match for is `UNMAPPED`, and a coding that fell back to the
26
- * structural tier (the resolver was briefly unavailable, or the resource was
27
- * text-only) is surfaced in `scan_summary` (`concept_resolver_note`,
28
- * `construe_resolutions`). A `concept_id` of `0` is "no matching concept" per
29
- * OMOP semantics, deliberately not omitted. Only the primary clinical coding
30
- * is resolved — `gender`/`race`/`ethnicity`/`visit`/`value`/`unit`
31
- * `concept_id`s are always `0`.
18
+ * Each resource's primary clinical coding is resolved to a standard OMOP
19
+ * `concept_id`. Alongside the OMOP rows grouped by table (`tables`), the
20
+ * response carries `mappings` (how each source coding resolved, linked back
21
+ * to the row it produced), `dropped` (resources that could not be shaped
22
+ * into a row), `vocab_version` (the OMOP vocabulary release codes were
23
+ * resolved against), and a small `summary` of the resolution outcomes.
32
24
  *
33
- * In every mode each `*_source_value` carries the verbatim FHIR coding
34
- * (`system#code`), `*_type_concept_id` is set to `32817` (EHR), and the
35
- * response `report` lists one Usagi-shaped entry per source coding describing
36
- * how it resolved (`ALREADY_STANDARD`, `MAPPED`, an `UNCHECKED` suggestion,
37
- * or `UNMAPPED`).
25
+ * A `concept_id` of `0` means "no matching standard concept" (OMOP
26
+ * semantics) and is reported, not omitted a coding with no match is
27
+ * `UNMAPPED`. Only the primary clinical coding is resolved;
28
+ * `gender`/`race`/`ethnicity`/`visit`/`value`/`unit` `concept_id`s are
29
+ * always `0`. Each `*_source_value` carries the verbatim FHIR coding
30
+ * (`system#code`), and `*_type_concept_id` is set to `32817` (EHR).
38
31
  *
39
32
  * Medication codes are resolved whether they appear inline
40
33
  * (`medicationCodeableConcept`) or via a `medicationReference` to a contained,
@@ -42,7 +35,7 @@ export declare class Fhir2OmopClient {
42
35
  * Resources that cannot be shaped into a row — a medication with no usable
43
36
  * code, resolvable reference, or display, or any clinical resource whose
44
37
  * subject/patient reference cannot be tied to a person — are reported under
45
- * `scan_summary.dropped_resources` rather than emitted as blank rows. The
38
+ * `dropped` rather than emitted as blank rows. The
46
39
  * bundle must contain at least one Patient resource.
47
40
  *
48
41
  * @param {phenoml.fhir2Omop.CreateOmopRequest} request
@@ -51,6 +44,7 @@ export declare class Fhir2OmopClient {
51
44
  * @throws {@link phenoml.fhir2Omop.BadRequestError}
52
45
  * @throws {@link phenoml.fhir2Omop.UnauthorizedError}
53
46
  * @throws {@link phenoml.fhir2Omop.InternalServerError}
47
+ * @throws {@link phenoml.fhir2Omop.ServiceUnavailableError}
54
48
  *
55
49
  * @example
56
50
  * await client.fhir2Omop.create({
@@ -56,30 +56,23 @@ class Fhir2OmopClient {
56
56
  this._options = (0, BaseClient_js_1.normalizeClientOptionsWithAuth)(options);
57
57
  }
58
58
  /**
59
- * Shapes a FHIR R4 resource or Bundle into OMOP Common Data Model v5.4 rows
59
+ * Maps a FHIR R4 resource or Bundle into OMOP Common Data Model v5.4 rows
60
60
  * (person, visit_occurrence, condition_occurrence, drug_exposure,
61
61
  * procedure_occurrence, measurement, observation).
62
62
  *
63
- * **Two resolution modes, reported in `mode`.** `mode` reflects which
64
- * resolver is wired, not the path an individual coding took. With a
65
- * concept-resolver configured (the default), `mode` is `"resolved"` and the
66
- * resource's primary clinical coding is resolved to a real OMOP `concept_id`;
67
- * with no resolver configured, `mode` is `"structural"` and every clinical
68
- * and source `concept_id` is `0`. In `"resolved"` mode individual codings can
69
- * still land at `concept_id` `0` without changing the mode: a coding the
70
- * service finds no match for is `UNMAPPED`, and a coding that fell back to the
71
- * structural tier (the resolver was briefly unavailable, or the resource was
72
- * text-only) is surfaced in `scan_summary` (`concept_resolver_note`,
73
- * `construe_resolutions`). A `concept_id` of `0` is "no matching concept" per
74
- * OMOP semantics, deliberately not omitted. Only the primary clinical coding
75
- * is resolved — `gender`/`race`/`ethnicity`/`visit`/`value`/`unit`
76
- * `concept_id`s are always `0`.
63
+ * Each resource's primary clinical coding is resolved to a standard OMOP
64
+ * `concept_id`. Alongside the OMOP rows grouped by table (`tables`), the
65
+ * response carries `mappings` (how each source coding resolved, linked back
66
+ * to the row it produced), `dropped` (resources that could not be shaped
67
+ * into a row), `vocab_version` (the OMOP vocabulary release codes were
68
+ * resolved against), and a small `summary` of the resolution outcomes.
77
69
  *
78
- * In every mode each `*_source_value` carries the verbatim FHIR coding
79
- * (`system#code`), `*_type_concept_id` is set to `32817` (EHR), and the
80
- * response `report` lists one Usagi-shaped entry per source coding describing
81
- * how it resolved (`ALREADY_STANDARD`, `MAPPED`, an `UNCHECKED` suggestion,
82
- * or `UNMAPPED`).
70
+ * A `concept_id` of `0` means "no matching standard concept" (OMOP
71
+ * semantics) and is reported, not omitted a coding with no match is
72
+ * `UNMAPPED`. Only the primary clinical coding is resolved;
73
+ * `gender`/`race`/`ethnicity`/`visit`/`value`/`unit` `concept_id`s are
74
+ * always `0`. Each `*_source_value` carries the verbatim FHIR coding
75
+ * (`system#code`), and `*_type_concept_id` is set to `32817` (EHR).
83
76
  *
84
77
  * Medication codes are resolved whether they appear inline
85
78
  * (`medicationCodeableConcept`) or via a `medicationReference` to a contained,
@@ -87,7 +80,7 @@ class Fhir2OmopClient {
87
80
  * Resources that cannot be shaped into a row — a medication with no usable
88
81
  * code, resolvable reference, or display, or any clinical resource whose
89
82
  * subject/patient reference cannot be tied to a person — are reported under
90
- * `scan_summary.dropped_resources` rather than emitted as blank rows. The
83
+ * `dropped` rather than emitted as blank rows. The
91
84
  * bundle must contain at least one Patient resource.
92
85
  *
93
86
  * @param {phenoml.fhir2Omop.CreateOmopRequest} request
@@ -96,6 +89,7 @@ class Fhir2OmopClient {
96
89
  * @throws {@link phenoml.fhir2Omop.BadRequestError}
97
90
  * @throws {@link phenoml.fhir2Omop.UnauthorizedError}
98
91
  * @throws {@link phenoml.fhir2Omop.InternalServerError}
92
+ * @throws {@link phenoml.fhir2Omop.ServiceUnavailableError}
99
93
  *
100
94
  * @example
101
95
  * await client.fhir2Omop.create({
@@ -196,6 +190,8 @@ class Fhir2OmopClient {
196
190
  throw new phenoml.fhir2Omop.UnauthorizedError(_response.error.body, _response.rawResponse);
197
191
  case 500:
198
192
  throw new phenoml.fhir2Omop.InternalServerError(_response.error.body, _response.rawResponse);
193
+ case 503:
194
+ throw new phenoml.fhir2Omop.ServiceUnavailableError(_response.error.body, _response.rawResponse);
199
195
  default:
200
196
  throw new errors.phenomlError({
201
197
  statusCode: _response.error.statusCode,
@@ -0,0 +1,5 @@
1
+ import type * as core from "../../../../core/index.js";
2
+ import * as errors from "../../../../errors/index.js";
3
+ export declare class ServiceUnavailableError extends errors.phenomlError {
4
+ constructor(body?: unknown, rawResponse?: core.RawResponse);
5
+ }
@@ -0,0 +1,54 @@
1
+ "use strict";
2
+ // This file was auto-generated by Fern from our API Definition.
3
+ var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
4
+ if (k2 === undefined) k2 = k;
5
+ var desc = Object.getOwnPropertyDescriptor(m, k);
6
+ if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
7
+ desc = { enumerable: true, get: function() { return m[k]; } };
8
+ }
9
+ Object.defineProperty(o, k2, desc);
10
+ }) : (function(o, m, k, k2) {
11
+ if (k2 === undefined) k2 = k;
12
+ o[k2] = m[k];
13
+ }));
14
+ var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
15
+ Object.defineProperty(o, "default", { enumerable: true, value: v });
16
+ }) : function(o, v) {
17
+ o["default"] = v;
18
+ });
19
+ var __importStar = (this && this.__importStar) || (function () {
20
+ var ownKeys = function(o) {
21
+ ownKeys = Object.getOwnPropertyNames || function (o) {
22
+ var ar = [];
23
+ for (var k in o) if (Object.prototype.hasOwnProperty.call(o, k)) ar[ar.length] = k;
24
+ return ar;
25
+ };
26
+ return ownKeys(o);
27
+ };
28
+ return function (mod) {
29
+ if (mod && mod.__esModule) return mod;
30
+ var result = {};
31
+ if (mod != null) for (var k = ownKeys(mod), i = 0; i < k.length; i++) if (k[i] !== "default") __createBinding(result, mod, k[i]);
32
+ __setModuleDefault(result, mod);
33
+ return result;
34
+ };
35
+ })();
36
+ Object.defineProperty(exports, "__esModule", { value: true });
37
+ exports.ServiceUnavailableError = void 0;
38
+ const errors = __importStar(require("../../../../errors/index.js"));
39
+ class ServiceUnavailableError extends errors.phenomlError {
40
+ constructor(body, rawResponse) {
41
+ super({
42
+ message: "ServiceUnavailableError",
43
+ statusCode: 503,
44
+ body: body,
45
+ rawResponse: rawResponse,
46
+ });
47
+ Object.setPrototypeOf(this, new.target.prototype);
48
+ if (Error.captureStackTrace) {
49
+ Error.captureStackTrace(this, this.constructor);
50
+ }
51
+ this.name = this.constructor.name;
52
+ }
53
+ }
54
+ exports.ServiceUnavailableError = ServiceUnavailableError;
@@ -1,3 +1,4 @@
1
1
  export * from "./BadRequestError.js";
2
2
  export * from "./InternalServerError.js";
3
+ export * from "./ServiceUnavailableError.js";
3
4
  export * from "./UnauthorizedError.js";
@@ -16,4 +16,5 @@ var __exportStar = (this && this.__exportStar) || function(m, exports) {
16
16
  Object.defineProperty(exports, "__esModule", { value: true });
17
17
  __exportStar(require("./BadRequestError.js"), exports);
18
18
  __exportStar(require("./InternalServerError.js"), exports);
19
+ __exportStar(require("./ServiceUnavailableError.js"), exports);
19
20
  __exportStar(require("./UnauthorizedError.js"), exports);
@@ -2,16 +2,16 @@ import type * as phenoml from "../../../index.js";
2
2
  export interface CreateOmopResponse {
3
3
  success?: boolean | undefined;
4
4
  message?: string | undefined;
5
+ tables?: phenoml.fhir2Omop.OmopTables | undefined;
6
+ /** One entry per source coding (or one entry for a text-only resource with no coding), describing how it resolved and linking back to the row it produced. */
7
+ mappings?: phenoml.fhir2Omop.MappingEntry[] | undefined;
8
+ /** Resources that could not be shaped into an OMOP row (rather than emitted as blank rows). */
9
+ dropped?: phenoml.fhir2Omop.DroppedResource[] | undefined;
5
10
  /**
6
- * Resolution mode. `resolved` (default) means clinical `concept_id`s were
7
- * filled by the concept-resolver service; `structural` means no resolver
8
- * was configured, so all clinical `concept_id`s are `0`. Reflects which
9
- * resolver is wired, not the path an individual coding took — per-coding
10
- * degradation is surfaced in `scan_summary`, not the mode.
11
+ * The OMOP vocabulary release the clinical codes were resolved against
12
+ * (e.g. "v20240229"), for reproducibility. Present when at least one
13
+ * coded concept was resolved.
11
14
  */
12
- mode?: string | undefined;
13
- tables?: phenoml.fhir2Omop.OmopTables | undefined;
14
- /** One Usagi-shaped entry per source coding routed through concept resolution. */
15
- report?: phenoml.fhir2Omop.MappingReportEntry[] | undefined;
16
- scan_summary?: phenoml.fhir2Omop.ScanSummary | undefined;
15
+ vocab_version?: string | undefined;
16
+ summary?: phenoml.fhir2Omop.Summary | undefined;
17
17
  }
@@ -0,0 +1,37 @@
1
+ /**
2
+ * How one source coding (or a text-only resource's free text) resolved to an OMOP standard concept.
3
+ */
4
+ export interface MappingEntry {
5
+ resource_type?: string | undefined;
6
+ resource_id?: string | undefined;
7
+ omop_table?: string | undefined;
8
+ /**
9
+ * The id of the OMOP row this coding produced (e.g. `condition_occurrence_id`),
10
+ * within `omop_table`. A resource with multiple codings yields one entry
11
+ * per coding, all sharing this id.
12
+ */
13
+ omop_id?: number | undefined;
14
+ source_system?: string | undefined;
15
+ source_code?: string | undefined;
16
+ source_name?: string | undefined;
17
+ target_vocabulary?: string | undefined;
18
+ /**
19
+ * The standard concept's code, when present. Populated only for an
20
+ * `UNCHECKED` suggestion (where the API normalized a text-only resource
21
+ * to a suggested code); omitted for codings resolved through concept
22
+ * resolution (`ALREADY_STANDARD` / `MAPPED` / `UNMAPPED`), which are
23
+ * identified by `target_vocabulary`, `target_name`, and the row's
24
+ * `*_concept_id` rather than by code.
25
+ */
26
+ target_code?: string | undefined;
27
+ target_name?: string | undefined;
28
+ /**
29
+ * ALREADY_STANDARD (source coding is already a standard OMOP concept),
30
+ * MAPPED (source coding was mapped to a standard concept), UNCHECKED (a
31
+ * standard code was suggested — e.g. for a text-only resource — but not
32
+ * verified against the OMOP vocabulary, so `concept_id` stays `0`), or
33
+ * UNMAPPED (no standard concept found).
34
+ */
35
+ mapping_status?: string | undefined;
36
+ note?: string | undefined;
37
+ }
@@ -0,0 +1,15 @@
1
+ /**
2
+ * The request's data-quality headline: how the coded concepts split across
3
+ * resolution outcomes, and the share that was not already in a target
4
+ * standard vocabulary.
5
+ */
6
+ export interface Summary {
7
+ /** Codings already a standard OMOP concept. */
8
+ codes_already_standard?: number | undefined;
9
+ /** Codings mapped or suggested to a standard concept (MAPPED or UNCHECKED). */
10
+ codes_normalized?: number | undefined;
11
+ /** Codings with no standard concept found. */
12
+ codes_unmapped?: number | undefined;
13
+ /** Share of coded concepts not already standard ((normalized + unmapped) / total). */
14
+ off_vocab_rate?: number | undefined;
15
+ }
@@ -2,11 +2,11 @@ export * from "./ConditionOccurrenceRow.js";
2
2
  export * from "./CreateOmopResponse.js";
3
3
  export * from "./DroppedResource.js";
4
4
  export * from "./DrugExposureRow.js";
5
- export * from "./MappingReportEntry.js";
5
+ export * from "./MappingEntry.js";
6
6
  export * from "./MeasurementRow.js";
7
7
  export * from "./ObservationRow.js";
8
8
  export * from "./OmopTables.js";
9
9
  export * from "./PersonRow.js";
10
10
  export * from "./ProcedureOccurrenceRow.js";
11
- export * from "./ScanSummary.js";
11
+ export * from "./Summary.js";
12
12
  export * from "./VisitOccurrenceRow.js";
@@ -18,11 +18,11 @@ __exportStar(require("./ConditionOccurrenceRow.js"), exports);
18
18
  __exportStar(require("./CreateOmopResponse.js"), exports);
19
19
  __exportStar(require("./DroppedResource.js"), exports);
20
20
  __exportStar(require("./DrugExposureRow.js"), exports);
21
- __exportStar(require("./MappingReportEntry.js"), exports);
21
+ __exportStar(require("./MappingEntry.js"), exports);
22
22
  __exportStar(require("./MeasurementRow.js"), exports);
23
23
  __exportStar(require("./ObservationRow.js"), exports);
24
24
  __exportStar(require("./OmopTables.js"), exports);
25
25
  __exportStar(require("./PersonRow.js"), exports);
26
26
  __exportStar(require("./ProcedureOccurrenceRow.js"), exports);
27
- __exportStar(require("./ScanSummary.js"), exports);
27
+ __exportStar(require("./Summary.js"), exports);
28
28
  __exportStar(require("./VisitOccurrenceRow.js"), exports);
@@ -14,11 +14,19 @@ function anySignal(...args) {
14
14
  for (const signal of signals) {
15
15
  if (signal.aborted) {
16
16
  controller.abort(signal === null || signal === void 0 ? void 0 : signal.reason);
17
- break;
17
+ return controller.signal;
18
18
  }
19
19
  signal.addEventListener("abort", () => controller.abort(signal === null || signal === void 0 ? void 0 : signal.reason), {
20
20
  signal: controller.signal,
21
21
  });
22
+ // Re-check after adding listener: the signal may have aborted
23
+ // between the initial `signal.aborted` check and the `addEventListener`
24
+ // call above. If it did, the abort event was already dispatched and
25
+ // the listener will never fire — we must manually abort.
26
+ if (signal.aborted) {
27
+ controller.abort(signal === null || signal === void 0 ? void 0 : signal.reason);
28
+ return controller.signal;
29
+ }
22
30
  }
23
31
  return controller.signal;
24
32
  }
@@ -1 +1 @@
1
- export declare const SDK_VERSION = "17.2.0";
1
+ export declare const SDK_VERSION = "17.3.0";
@@ -1,4 +1,4 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.SDK_VERSION = void 0;
4
- exports.SDK_VERSION = "17.2.0";
4
+ exports.SDK_VERSION = "17.3.0";
@@ -6,8 +6,8 @@ export function normalizeClientOptions(options) {
6
6
  const headers = mergeHeaders({
7
7
  "X-Fern-Language": "JavaScript",
8
8
  "X-Fern-SDK-Name": "phenoml",
9
- "X-Fern-SDK-Version": "17.2.0",
10
- "User-Agent": "phenoml/17.2.0",
9
+ "X-Fern-SDK-Version": "17.3.0",
10
+ "User-Agent": "phenoml/17.3.0",
11
11
  "X-Fern-Runtime": core.RUNTIME.type,
12
12
  "X-Fern-Runtime-Version": core.RUNTIME.version,
13
13
  }, options === null || options === void 0 ? void 0 : options.headers);
@@ -11,30 +11,23 @@ export declare class Fhir2OmopClient {
11
11
  protected readonly _options: NormalizedClientOptionsWithAuth<Fhir2OmopClient.Options>;
12
12
  constructor(options?: Fhir2OmopClient.Options);
13
13
  /**
14
- * Shapes a FHIR R4 resource or Bundle into OMOP Common Data Model v5.4 rows
14
+ * Maps a FHIR R4 resource or Bundle into OMOP Common Data Model v5.4 rows
15
15
  * (person, visit_occurrence, condition_occurrence, drug_exposure,
16
16
  * procedure_occurrence, measurement, observation).
17
17
  *
18
- * **Two resolution modes, reported in `mode`.** `mode` reflects which
19
- * resolver is wired, not the path an individual coding took. With a
20
- * concept-resolver configured (the default), `mode` is `"resolved"` and the
21
- * resource's primary clinical coding is resolved to a real OMOP `concept_id`;
22
- * with no resolver configured, `mode` is `"structural"` and every clinical
23
- * and source `concept_id` is `0`. In `"resolved"` mode individual codings can
24
- * still land at `concept_id` `0` without changing the mode: a coding the
25
- * service finds no match for is `UNMAPPED`, and a coding that fell back to the
26
- * structural tier (the resolver was briefly unavailable, or the resource was
27
- * text-only) is surfaced in `scan_summary` (`concept_resolver_note`,
28
- * `construe_resolutions`). A `concept_id` of `0` is "no matching concept" per
29
- * OMOP semantics, deliberately not omitted. Only the primary clinical coding
30
- * is resolved — `gender`/`race`/`ethnicity`/`visit`/`value`/`unit`
31
- * `concept_id`s are always `0`.
18
+ * Each resource's primary clinical coding is resolved to a standard OMOP
19
+ * `concept_id`. Alongside the OMOP rows grouped by table (`tables`), the
20
+ * response carries `mappings` (how each source coding resolved, linked back
21
+ * to the row it produced), `dropped` (resources that could not be shaped
22
+ * into a row), `vocab_version` (the OMOP vocabulary release codes were
23
+ * resolved against), and a small `summary` of the resolution outcomes.
32
24
  *
33
- * In every mode each `*_source_value` carries the verbatim FHIR coding
34
- * (`system#code`), `*_type_concept_id` is set to `32817` (EHR), and the
35
- * response `report` lists one Usagi-shaped entry per source coding describing
36
- * how it resolved (`ALREADY_STANDARD`, `MAPPED`, an `UNCHECKED` suggestion,
37
- * or `UNMAPPED`).
25
+ * A `concept_id` of `0` means "no matching standard concept" (OMOP
26
+ * semantics) and is reported, not omitted a coding with no match is
27
+ * `UNMAPPED`. Only the primary clinical coding is resolved;
28
+ * `gender`/`race`/`ethnicity`/`visit`/`value`/`unit` `concept_id`s are
29
+ * always `0`. Each `*_source_value` carries the verbatim FHIR coding
30
+ * (`system#code`), and `*_type_concept_id` is set to `32817` (EHR).
38
31
  *
39
32
  * Medication codes are resolved whether they appear inline
40
33
  * (`medicationCodeableConcept`) or via a `medicationReference` to a contained,
@@ -42,7 +35,7 @@ export declare class Fhir2OmopClient {
42
35
  * Resources that cannot be shaped into a row — a medication with no usable
43
36
  * code, resolvable reference, or display, or any clinical resource whose
44
37
  * subject/patient reference cannot be tied to a person — are reported under
45
- * `scan_summary.dropped_resources` rather than emitted as blank rows. The
38
+ * `dropped` rather than emitted as blank rows. The
46
39
  * bundle must contain at least one Patient resource.
47
40
  *
48
41
  * @param {phenoml.fhir2Omop.CreateOmopRequest} request
@@ -51,6 +44,7 @@ export declare class Fhir2OmopClient {
51
44
  * @throws {@link phenoml.fhir2Omop.BadRequestError}
52
45
  * @throws {@link phenoml.fhir2Omop.UnauthorizedError}
53
46
  * @throws {@link phenoml.fhir2Omop.InternalServerError}
47
+ * @throws {@link phenoml.fhir2Omop.ServiceUnavailableError}
54
48
  *
55
49
  * @example
56
50
  * await client.fhir2Omop.create({
@@ -20,30 +20,23 @@ export class Fhir2OmopClient {
20
20
  this._options = normalizeClientOptionsWithAuth(options);
21
21
  }
22
22
  /**
23
- * Shapes a FHIR R4 resource or Bundle into OMOP Common Data Model v5.4 rows
23
+ * Maps a FHIR R4 resource or Bundle into OMOP Common Data Model v5.4 rows
24
24
  * (person, visit_occurrence, condition_occurrence, drug_exposure,
25
25
  * procedure_occurrence, measurement, observation).
26
26
  *
27
- * **Two resolution modes, reported in `mode`.** `mode` reflects which
28
- * resolver is wired, not the path an individual coding took. With a
29
- * concept-resolver configured (the default), `mode` is `"resolved"` and the
30
- * resource's primary clinical coding is resolved to a real OMOP `concept_id`;
31
- * with no resolver configured, `mode` is `"structural"` and every clinical
32
- * and source `concept_id` is `0`. In `"resolved"` mode individual codings can
33
- * still land at `concept_id` `0` without changing the mode: a coding the
34
- * service finds no match for is `UNMAPPED`, and a coding that fell back to the
35
- * structural tier (the resolver was briefly unavailable, or the resource was
36
- * text-only) is surfaced in `scan_summary` (`concept_resolver_note`,
37
- * `construe_resolutions`). A `concept_id` of `0` is "no matching concept" per
38
- * OMOP semantics, deliberately not omitted. Only the primary clinical coding
39
- * is resolved — `gender`/`race`/`ethnicity`/`visit`/`value`/`unit`
40
- * `concept_id`s are always `0`.
27
+ * Each resource's primary clinical coding is resolved to a standard OMOP
28
+ * `concept_id`. Alongside the OMOP rows grouped by table (`tables`), the
29
+ * response carries `mappings` (how each source coding resolved, linked back
30
+ * to the row it produced), `dropped` (resources that could not be shaped
31
+ * into a row), `vocab_version` (the OMOP vocabulary release codes were
32
+ * resolved against), and a small `summary` of the resolution outcomes.
41
33
  *
42
- * In every mode each `*_source_value` carries the verbatim FHIR coding
43
- * (`system#code`), `*_type_concept_id` is set to `32817` (EHR), and the
44
- * response `report` lists one Usagi-shaped entry per source coding describing
45
- * how it resolved (`ALREADY_STANDARD`, `MAPPED`, an `UNCHECKED` suggestion,
46
- * or `UNMAPPED`).
34
+ * A `concept_id` of `0` means "no matching standard concept" (OMOP
35
+ * semantics) and is reported, not omitted a coding with no match is
36
+ * `UNMAPPED`. Only the primary clinical coding is resolved;
37
+ * `gender`/`race`/`ethnicity`/`visit`/`value`/`unit` `concept_id`s are
38
+ * always `0`. Each `*_source_value` carries the verbatim FHIR coding
39
+ * (`system#code`), and `*_type_concept_id` is set to `32817` (EHR).
47
40
  *
48
41
  * Medication codes are resolved whether they appear inline
49
42
  * (`medicationCodeableConcept`) or via a `medicationReference` to a contained,
@@ -51,7 +44,7 @@ export class Fhir2OmopClient {
51
44
  * Resources that cannot be shaped into a row — a medication with no usable
52
45
  * code, resolvable reference, or display, or any clinical resource whose
53
46
  * subject/patient reference cannot be tied to a person — are reported under
54
- * `scan_summary.dropped_resources` rather than emitted as blank rows. The
47
+ * `dropped` rather than emitted as blank rows. The
55
48
  * bundle must contain at least one Patient resource.
56
49
  *
57
50
  * @param {phenoml.fhir2Omop.CreateOmopRequest} request
@@ -60,6 +53,7 @@ export class Fhir2OmopClient {
60
53
  * @throws {@link phenoml.fhir2Omop.BadRequestError}
61
54
  * @throws {@link phenoml.fhir2Omop.UnauthorizedError}
62
55
  * @throws {@link phenoml.fhir2Omop.InternalServerError}
56
+ * @throws {@link phenoml.fhir2Omop.ServiceUnavailableError}
63
57
  *
64
58
  * @example
65
59
  * await client.fhir2Omop.create({
@@ -160,6 +154,8 @@ export class Fhir2OmopClient {
160
154
  throw new phenoml.fhir2Omop.UnauthorizedError(_response.error.body, _response.rawResponse);
161
155
  case 500:
162
156
  throw new phenoml.fhir2Omop.InternalServerError(_response.error.body, _response.rawResponse);
157
+ case 503:
158
+ throw new phenoml.fhir2Omop.ServiceUnavailableError(_response.error.body, _response.rawResponse);
163
159
  default:
164
160
  throw new errors.phenomlError({
165
161
  statusCode: _response.error.statusCode,
@@ -0,0 +1,5 @@
1
+ import type * as core from "../../../../core/index.mjs";
2
+ import * as errors from "../../../../errors/index.mjs";
3
+ export declare class ServiceUnavailableError extends errors.phenomlError {
4
+ constructor(body?: unknown, rawResponse?: core.RawResponse);
5
+ }
@@ -0,0 +1,17 @@
1
+ // This file was auto-generated by Fern from our API Definition.
2
+ import * as errors from "../../../../errors/index.mjs";
3
+ export class ServiceUnavailableError extends errors.phenomlError {
4
+ constructor(body, rawResponse) {
5
+ super({
6
+ message: "ServiceUnavailableError",
7
+ statusCode: 503,
8
+ body: body,
9
+ rawResponse: rawResponse,
10
+ });
11
+ Object.setPrototypeOf(this, new.target.prototype);
12
+ if (Error.captureStackTrace) {
13
+ Error.captureStackTrace(this, this.constructor);
14
+ }
15
+ this.name = this.constructor.name;
16
+ }
17
+ }
@@ -1,3 +1,4 @@
1
1
  export * from "./BadRequestError.mjs";
2
2
  export * from "./InternalServerError.mjs";
3
+ export * from "./ServiceUnavailableError.mjs";
3
4
  export * from "./UnauthorizedError.mjs";
@@ -1,3 +1,4 @@
1
1
  export * from "./BadRequestError.mjs";
2
2
  export * from "./InternalServerError.mjs";
3
+ export * from "./ServiceUnavailableError.mjs";
3
4
  export * from "./UnauthorizedError.mjs";
@@ -2,16 +2,16 @@ import type * as phenoml from "../../../index.mjs";
2
2
  export interface CreateOmopResponse {
3
3
  success?: boolean | undefined;
4
4
  message?: string | undefined;
5
+ tables?: phenoml.fhir2Omop.OmopTables | undefined;
6
+ /** One entry per source coding (or one entry for a text-only resource with no coding), describing how it resolved and linking back to the row it produced. */
7
+ mappings?: phenoml.fhir2Omop.MappingEntry[] | undefined;
8
+ /** Resources that could not be shaped into an OMOP row (rather than emitted as blank rows). */
9
+ dropped?: phenoml.fhir2Omop.DroppedResource[] | undefined;
5
10
  /**
6
- * Resolution mode. `resolved` (default) means clinical `concept_id`s were
7
- * filled by the concept-resolver service; `structural` means no resolver
8
- * was configured, so all clinical `concept_id`s are `0`. Reflects which
9
- * resolver is wired, not the path an individual coding took — per-coding
10
- * degradation is surfaced in `scan_summary`, not the mode.
11
+ * The OMOP vocabulary release the clinical codes were resolved against
12
+ * (e.g. "v20240229"), for reproducibility. Present when at least one
13
+ * coded concept was resolved.
11
14
  */
12
- mode?: string | undefined;
13
- tables?: phenoml.fhir2Omop.OmopTables | undefined;
14
- /** One Usagi-shaped entry per source coding routed through concept resolution. */
15
- report?: phenoml.fhir2Omop.MappingReportEntry[] | undefined;
16
- scan_summary?: phenoml.fhir2Omop.ScanSummary | undefined;
15
+ vocab_version?: string | undefined;
16
+ summary?: phenoml.fhir2Omop.Summary | undefined;
17
17
  }
@@ -0,0 +1,37 @@
1
+ /**
2
+ * How one source coding (or a text-only resource's free text) resolved to an OMOP standard concept.
3
+ */
4
+ export interface MappingEntry {
5
+ resource_type?: string | undefined;
6
+ resource_id?: string | undefined;
7
+ omop_table?: string | undefined;
8
+ /**
9
+ * The id of the OMOP row this coding produced (e.g. `condition_occurrence_id`),
10
+ * within `omop_table`. A resource with multiple codings yields one entry
11
+ * per coding, all sharing this id.
12
+ */
13
+ omop_id?: number | undefined;
14
+ source_system?: string | undefined;
15
+ source_code?: string | undefined;
16
+ source_name?: string | undefined;
17
+ target_vocabulary?: string | undefined;
18
+ /**
19
+ * The standard concept's code, when present. Populated only for an
20
+ * `UNCHECKED` suggestion (where the API normalized a text-only resource
21
+ * to a suggested code); omitted for codings resolved through concept
22
+ * resolution (`ALREADY_STANDARD` / `MAPPED` / `UNMAPPED`), which are
23
+ * identified by `target_vocabulary`, `target_name`, and the row's
24
+ * `*_concept_id` rather than by code.
25
+ */
26
+ target_code?: string | undefined;
27
+ target_name?: string | undefined;
28
+ /**
29
+ * ALREADY_STANDARD (source coding is already a standard OMOP concept),
30
+ * MAPPED (source coding was mapped to a standard concept), UNCHECKED (a
31
+ * standard code was suggested — e.g. for a text-only resource — but not
32
+ * verified against the OMOP vocabulary, so `concept_id` stays `0`), or
33
+ * UNMAPPED (no standard concept found).
34
+ */
35
+ mapping_status?: string | undefined;
36
+ note?: string | undefined;
37
+ }