@claudebernard/web-component-fhir-utils 2.1.5 → 2.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.
- package/dist/dosage/get-dosage.d.ts +21 -0
- package/dist/dosage/get-dosage.d.ts.map +1 -0
- package/dist/dosage/get-dosage.js +19 -0
- package/dist/dosage/get-dosage.js.map +1 -0
- package/dist/index.d.ts +1 -0
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +1 -0
- package/dist/index.js.map +1 -1
- package/package.json +5 -1
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
import type { Dosage, MedicationRequest, MedicationStatement } from "fhir/r5";
|
|
2
|
+
/**
|
|
3
|
+
* A resource that carries a `Dosage[]`, under a field name that differs by resource type:
|
|
4
|
+
* `MedicationRequest.dosageInstruction` vs `MedicationStatement.dosage`. Both hold the exact same
|
|
5
|
+
* `Dosage[]` shape (FHIR R5) under different field names — `getDosage`/`withDosage` are the single
|
|
6
|
+
* home for that field-naming difference, so callers that already work in terms of `Dosage`/`Dosage[]`
|
|
7
|
+
* (e.g. a posology form mapper) never need to branch on `resourceType` themselves.
|
|
8
|
+
*/
|
|
9
|
+
export type DosageCarrier = MedicationRequest | MedicationStatement;
|
|
10
|
+
/**
|
|
11
|
+
* Reads the `Dosage[]` off either a MedicationRequest (`dosageInstruction`) or a MedicationStatement
|
|
12
|
+
* (`dosage`), without the caller branching on `resourceType` itself.
|
|
13
|
+
*/
|
|
14
|
+
export declare function getDosage(resource: DosageCarrier): Dosage[] | undefined;
|
|
15
|
+
/**
|
|
16
|
+
* Returns a new resource of the same concrete type as `resource`, with `dosage` written onto the
|
|
17
|
+
* correct field for that type (`dosageInstruction` for a MedicationRequest, `dosage` for a
|
|
18
|
+
* MedicationStatement). All other fields are carried over unchanged.
|
|
19
|
+
*/
|
|
20
|
+
export declare function withDosage<T extends DosageCarrier>(resource: T, dosage: Dosage[]): T;
|
|
21
|
+
//# sourceMappingURL=get-dosage.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"get-dosage.d.ts","sourceRoot":"","sources":["../../src/dosage/get-dosage.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,MAAM,EAAE,iBAAiB,EAAE,mBAAmB,EAAE,MAAM,SAAS,CAAC;AAE9E;;;;;;GAMG;AACH,MAAM,MAAM,aAAa,GAAG,iBAAiB,GAAG,mBAAmB,CAAC;AAEpE;;;GAGG;AACH,wBAAgB,SAAS,CAAC,QAAQ,EAAE,aAAa,GAAG,MAAM,EAAE,GAAG,SAAS,CAEvE;AAED;;;;GAIG;AACH,wBAAgB,UAAU,CAAC,CAAC,SAAS,aAAa,EAAE,QAAQ,EAAE,CAAC,EAAE,MAAM,EAAE,MAAM,EAAE,GAAG,CAAC,CAKpF"}
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Reads the `Dosage[]` off either a MedicationRequest (`dosageInstruction`) or a MedicationStatement
|
|
3
|
+
* (`dosage`), without the caller branching on `resourceType` itself.
|
|
4
|
+
*/
|
|
5
|
+
export function getDosage(resource) {
|
|
6
|
+
return resource.resourceType === "MedicationRequest" ? resource.dosageInstruction : resource.dosage;
|
|
7
|
+
}
|
|
8
|
+
/**
|
|
9
|
+
* Returns a new resource of the same concrete type as `resource`, with `dosage` written onto the
|
|
10
|
+
* correct field for that type (`dosageInstruction` for a MedicationRequest, `dosage` for a
|
|
11
|
+
* MedicationStatement). All other fields are carried over unchanged.
|
|
12
|
+
*/
|
|
13
|
+
export function withDosage(resource, dosage) {
|
|
14
|
+
if (resource.resourceType === "MedicationRequest") {
|
|
15
|
+
return { ...resource, dosageInstruction: dosage };
|
|
16
|
+
}
|
|
17
|
+
return { ...resource, dosage };
|
|
18
|
+
}
|
|
19
|
+
//# sourceMappingURL=get-dosage.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"get-dosage.js","sourceRoot":"","sources":["../../src/dosage/get-dosage.ts"],"names":[],"mappings":"AAWA;;;GAGG;AACH,MAAM,UAAU,SAAS,CAAC,QAAuB;IAC/C,OAAO,QAAQ,CAAC,YAAY,KAAK,mBAAmB,CAAC,CAAC,CAAC,QAAQ,CAAC,iBAAiB,CAAC,CAAC,CAAC,QAAQ,CAAC,MAAM,CAAC;AACtG,CAAC;AAED;;;;GAIG;AACH,MAAM,UAAU,UAAU,CAA0B,QAAW,EAAE,MAAgB;IAC/E,IAAI,QAAQ,CAAC,YAAY,KAAK,mBAAmB,EAAE,CAAC;QAClD,OAAO,EAAE,GAAG,QAAQ,EAAE,iBAAiB,EAAE,MAAM,EAAO,CAAC;IACzD,CAAC;IACD,OAAO,EAAE,GAAG,QAAQ,EAAE,MAAM,EAAO,CAAC;AACtC,CAAC","sourcesContent":["import type { Dosage, MedicationRequest, MedicationStatement } from \"fhir/r5\";\n\n/**\n * A resource that carries a `Dosage[]`, under a field name that differs by resource type:\n * `MedicationRequest.dosageInstruction` vs `MedicationStatement.dosage`. Both hold the exact same\n * `Dosage[]` shape (FHIR R5) under different field names — `getDosage`/`withDosage` are the single\n * home for that field-naming difference, so callers that already work in terms of `Dosage`/`Dosage[]`\n * (e.g. a posology form mapper) never need to branch on `resourceType` themselves.\n */\nexport type DosageCarrier = MedicationRequest | MedicationStatement;\n\n/**\n * Reads the `Dosage[]` off either a MedicationRequest (`dosageInstruction`) or a MedicationStatement\n * (`dosage`), without the caller branching on `resourceType` itself.\n */\nexport function getDosage(resource: DosageCarrier): Dosage[] | undefined {\n return resource.resourceType === \"MedicationRequest\" ? resource.dosageInstruction : resource.dosage;\n}\n\n/**\n * Returns a new resource of the same concrete type as `resource`, with `dosage` written onto the\n * correct field for that type (`dosageInstruction` for a MedicationRequest, `dosage` for a\n * MedicationStatement). All other fields are carried over unchanged.\n */\nexport function withDosage<T extends DosageCarrier>(resource: T, dosage: Dosage[]): T {\n if (resource.resourceType === \"MedicationRequest\") {\n return { ...resource, dosageInstruction: dosage } as T;\n }\n return { ...resource, dosage } as T;\n}\n"]}
|
package/dist/index.d.ts
CHANGED
package/dist/index.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,cAAc,sCAAsC,CAAC;AACrD,cAAc,mCAAmC,CAAC;AAClD,cAAc,oCAAoC,CAAC;AACnD,cAAc,mCAAmC,CAAC;AAClD,cAAc,kCAAkC,CAAC;AACjD,cAAc,6BAA6B,CAAC"}
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,cAAc,sCAAsC,CAAC;AACrD,cAAc,qBAAqB,CAAC;AACpC,cAAc,mCAAmC,CAAC;AAClD,cAAc,oCAAoC,CAAC;AACnD,cAAc,mCAAmC,CAAC;AAClD,cAAc,kCAAkC,CAAC;AACjD,cAAc,6BAA6B,CAAC"}
|
package/dist/index.js
CHANGED
package/dist/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,cAAc,sCAAsC,CAAC;AACrD,cAAc,mCAAmC,CAAC;AAClD,cAAc,oCAAoC,CAAC;AACnD,cAAc,mCAAmC,CAAC;AAClD,cAAc,kCAAkC,CAAC;AACjD,cAAc,6BAA6B,CAAC","sourcesContent":["export * from \"./constants/prior-prescription.const\";\nexport * from \"./bundle/create-collection-bundle\";\nexport * from \"./bundle/create-transaction-bundle\";\nexport * from \"./bundle/apply-transaction-bundle\";\nexport * from \"./bundle/find-resource-in-bundle\";\nexport * from \"./bundle/supersede-resource\";\n"]}
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,cAAc,sCAAsC,CAAC;AACrD,cAAc,qBAAqB,CAAC;AACpC,cAAc,mCAAmC,CAAC;AAClD,cAAc,oCAAoC,CAAC;AACnD,cAAc,mCAAmC,CAAC;AAClD,cAAc,kCAAkC,CAAC;AACjD,cAAc,6BAA6B,CAAC","sourcesContent":["export * from \"./constants/prior-prescription.const\";\nexport * from \"./dosage/get-dosage\";\nexport * from \"./bundle/create-collection-bundle\";\nexport * from \"./bundle/create-transaction-bundle\";\nexport * from \"./bundle/apply-transaction-bundle\";\nexport * from \"./bundle/find-resource-in-bundle\";\nexport * from \"./bundle/supersede-resource\";\n"]}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@claudebernard/web-component-fhir-utils",
|
|
3
|
-
"version": "2.
|
|
3
|
+
"version": "2.3.0",
|
|
4
4
|
"description": "Shared FHIR Bundle utilities (collection/transaction bundles, prior-prescription linking) for Claude Bernard web components and their integrators.",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"types": "dist/index.d.ts",
|
|
@@ -18,6 +18,10 @@
|
|
|
18
18
|
"types": "./dist/constants/prior-prescription.const.d.ts",
|
|
19
19
|
"import": "./dist/constants/prior-prescription.const.js"
|
|
20
20
|
},
|
|
21
|
+
"./dosage/get-dosage": {
|
|
22
|
+
"types": "./dist/dosage/get-dosage.d.ts",
|
|
23
|
+
"import": "./dist/dosage/get-dosage.js"
|
|
24
|
+
},
|
|
21
25
|
"./bundle/create-collection-bundle": {
|
|
22
26
|
"types": "./dist/bundle/create-collection-bundle.d.ts",
|
|
23
27
|
"import": "./dist/bundle/create-collection-bundle.js"
|