@fuego-systems/core 0.1.15 → 0.1.17

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,34 @@
1
+ import type { Bundle, PlanDefinition } from '@medplum/fhirtypes';
2
+ /** A `$resolve-protocol` bundle entry with its `search.mode` preserved. */
3
+ export interface ResolvedProtocolEntry {
4
+ pd: PlanDefinition;
5
+ mode?: string;
6
+ }
7
+ export interface ClassifiedResolvedProtocol {
8
+ /** The configured protocol-group PD (absent in single-variant order-set mode, #194). */
9
+ protocolGroup?: PlanDefinition;
10
+ /** Bookable order-set PDs (`search.mode: 'match'`). */
11
+ orderSets: PlanDefinition[];
12
+ /** Mandatory-component PDs (`search.mode: 'include'`, #193) — preparation sources, not bookable. */
13
+ components: PlanDefinition[];
14
+ }
15
+ /**
16
+ * Splits `$resolve-protocol` results by `search.mode`: `match` entries are the
17
+ * bookable order-sets, non-protocol-group `include` entries are the
18
+ * mandatory-component PDs (#193/#194). Entries without a mode are treated as
19
+ * bookable, preserving the legacy classification.
20
+ *
21
+ * @param entries - Bundle entries with their `search.mode` preserved.
22
+ * @returns The configured protocol-group, bookable order-sets, and components.
23
+ */
24
+ export declare function classifyResolvedProtocolEntries(entries: ResolvedProtocolEntry[]): ClassifiedResolvedProtocol;
25
+ /**
26
+ * Convenience over {@link classifyResolvedProtocolEntries} that reads a raw
27
+ * `$resolve-protocol` response Bundle, keeping each entry's `search.mode` and
28
+ * ignoring non-PlanDefinition resources.
29
+ *
30
+ * @param bundle - The `$resolve-protocol` response Bundle.
31
+ * @returns The configured protocol-group, bookable order-sets, and components.
32
+ */
33
+ export declare function classifyResolvedProtocolBundle(bundle: Bundle<PlanDefinition>): ClassifiedResolvedProtocol;
34
+ //# sourceMappingURL=resolved-protocol.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"resolved-protocol.d.ts","sourceRoot":"","sources":["../src/resolved-protocol.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,MAAM,EAAE,cAAc,EAAE,MAAM,oBAAoB,CAAA;AAGhE,2EAA2E;AAC3E,MAAM,WAAW,qBAAqB;IACpC,EAAE,EAAE,cAAc,CAAA;IAClB,IAAI,CAAC,EAAE,MAAM,CAAA;CACd;AAED,MAAM,WAAW,0BAA0B;IACzC,wFAAwF;IACxF,aAAa,CAAC,EAAE,cAAc,CAAA;IAC9B,uDAAuD;IACvD,SAAS,EAAE,cAAc,EAAE,CAAA;IAC3B,oGAAoG;IACpG,UAAU,EAAE,cAAc,EAAE,CAAA;CAC7B;AAED;;;;;;;;GAQG;AACH,wBAAgB,+BAA+B,CAAE,OAAO,EAAE,qBAAqB,EAAE,GAAG,0BAA0B,CAc7G;AAED;;;;;;;GAOG;AACH,wBAAgB,8BAA8B,CAAE,MAAM,EAAE,MAAM,CAAC,cAAc,CAAC,GAAG,0BAA0B,CAQ1G"}
@@ -0,0 +1,50 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.classifyResolvedProtocolEntries = classifyResolvedProtocolEntries;
4
+ exports.classifyResolvedProtocolBundle = classifyResolvedProtocolBundle;
5
+ const plan_definition_group_1 = require("./plan-definition-group");
6
+ /**
7
+ * Splits `$resolve-protocol` results by `search.mode`: `match` entries are the
8
+ * bookable order-sets, non-protocol-group `include` entries are the
9
+ * mandatory-component PDs (#193/#194). Entries without a mode are treated as
10
+ * bookable, preserving the legacy classification.
11
+ *
12
+ * @param entries - Bundle entries with their `search.mode` preserved.
13
+ * @returns The configured protocol-group, bookable order-sets, and components.
14
+ */
15
+ function classifyResolvedProtocolEntries(entries) {
16
+ let protocolGroup;
17
+ const orderSets = [];
18
+ const components = [];
19
+ for (const { pd, mode } of entries) {
20
+ if (!protocolGroup && (0, plan_definition_group_1.isProtocolGroup)(pd)) {
21
+ protocolGroup = pd;
22
+ }
23
+ else if (mode === 'include') {
24
+ components.push(pd);
25
+ }
26
+ else {
27
+ orderSets.push(pd);
28
+ }
29
+ }
30
+ return { protocolGroup, orderSets, components };
31
+ }
32
+ /**
33
+ * Convenience over {@link classifyResolvedProtocolEntries} that reads a raw
34
+ * `$resolve-protocol` response Bundle, keeping each entry's `search.mode` and
35
+ * ignoring non-PlanDefinition resources.
36
+ *
37
+ * @param bundle - The `$resolve-protocol` response Bundle.
38
+ * @returns The configured protocol-group, bookable order-sets, and components.
39
+ */
40
+ function classifyResolvedProtocolBundle(bundle) {
41
+ var _a, _b, _c;
42
+ const entries = [];
43
+ for (const entry of (_a = bundle.entry) !== null && _a !== void 0 ? _a : []) {
44
+ if (((_b = entry.resource) === null || _b === void 0 ? void 0 : _b.resourceType) === 'PlanDefinition') {
45
+ entries.push({ pd: entry.resource, mode: (_c = entry.search) === null || _c === void 0 ? void 0 : _c.mode });
46
+ }
47
+ }
48
+ return classifyResolvedProtocolEntries(entries);
49
+ }
50
+ //# sourceMappingURL=resolved-protocol.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"resolved-protocol.js","sourceRoot":"","sources":["../src/resolved-protocol.ts"],"names":[],"mappings":";;AA2BA,0EAcC;AAUD,wEAQC;AA1DD,mEAAyD;AAiBzD;;;;;;;;GAQG;AACH,SAAgB,+BAA+B,CAAE,OAAgC;IAC/E,IAAI,aAAyC,CAAA;IAC7C,MAAM,SAAS,GAAqB,EAAE,CAAA;IACtC,MAAM,UAAU,GAAqB,EAAE,CAAA;IACvC,KAAK,MAAM,EAAE,EAAE,EAAE,IAAI,EAAE,IAAI,OAAO,EAAE,CAAC;QACnC,IAAI,CAAC,aAAa,IAAI,IAAA,uCAAe,EAAC,EAAE,CAAC,EAAE,CAAC;YAC1C,aAAa,GAAG,EAAE,CAAA;QACpB,CAAC;aAAM,IAAI,IAAI,KAAK,SAAS,EAAE,CAAC;YAC9B,UAAU,CAAC,IAAI,CAAC,EAAE,CAAC,CAAA;QACrB,CAAC;aAAM,CAAC;YACN,SAAS,CAAC,IAAI,CAAC,EAAE,CAAC,CAAA;QACpB,CAAC;IACH,CAAC;IACD,OAAO,EAAE,aAAa,EAAE,SAAS,EAAE,UAAU,EAAE,CAAA;AACjD,CAAC;AAED;;;;;;;GAOG;AACH,SAAgB,8BAA8B,CAAE,MAA8B;;IAC5E,MAAM,OAAO,GAA4B,EAAE,CAAA;IAC3C,KAAK,MAAM,KAAK,IAAI,MAAA,MAAM,CAAC,KAAK,mCAAI,EAAE,EAAE,CAAC;QACvC,IAAI,CAAA,MAAA,KAAK,CAAC,QAAQ,0CAAE,YAAY,MAAK,gBAAgB,EAAE,CAAC;YACtD,OAAO,CAAC,IAAI,CAAC,EAAE,EAAE,EAAE,KAAK,CAAC,QAAQ,EAAE,IAAI,EAAE,MAAA,KAAK,CAAC,MAAM,0CAAE,IAAI,EAAE,CAAC,CAAA;QAChE,CAAC;IACH,CAAC;IACD,OAAO,+BAA+B,CAAC,OAAO,CAAC,CAAA;AACjD,CAAC","sourcesContent":["import type { Bundle, PlanDefinition } from '@medplum/fhirtypes'\nimport { isProtocolGroup } from './plan-definition-group'\n\n/** A `$resolve-protocol` bundle entry with its `search.mode` preserved. */\nexport interface ResolvedProtocolEntry {\n pd: PlanDefinition\n mode?: string\n}\n\nexport interface ClassifiedResolvedProtocol {\n /** The configured protocol-group PD (absent in single-variant order-set mode, #194). */\n protocolGroup?: PlanDefinition\n /** Bookable order-set PDs (`search.mode: 'match'`). */\n orderSets: PlanDefinition[]\n /** Mandatory-component PDs (`search.mode: 'include'`, #193) — preparation sources, not bookable. */\n components: PlanDefinition[]\n}\n\n/**\n * Splits `$resolve-protocol` results by `search.mode`: `match` entries are the\n * bookable order-sets, non-protocol-group `include` entries are the\n * mandatory-component PDs (#193/#194). Entries without a mode are treated as\n * bookable, preserving the legacy classification.\n *\n * @param entries - Bundle entries with their `search.mode` preserved.\n * @returns The configured protocol-group, bookable order-sets, and components.\n */\nexport function classifyResolvedProtocolEntries (entries: ResolvedProtocolEntry[]): ClassifiedResolvedProtocol {\n let protocolGroup: PlanDefinition | undefined\n const orderSets: PlanDefinition[] = []\n const components: PlanDefinition[] = []\n for (const { pd, mode } of entries) {\n if (!protocolGroup && isProtocolGroup(pd)) {\n protocolGroup = pd\n } else if (mode === 'include') {\n components.push(pd)\n } else {\n orderSets.push(pd)\n }\n }\n return { protocolGroup, orderSets, components }\n}\n\n/**\n * Convenience over {@link classifyResolvedProtocolEntries} that reads a raw\n * `$resolve-protocol` response Bundle, keeping each entry's `search.mode` and\n * ignoring non-PlanDefinition resources.\n *\n * @param bundle - The `$resolve-protocol` response Bundle.\n * @returns The configured protocol-group, bookable order-sets, and components.\n */\nexport function classifyResolvedProtocolBundle (bundle: Bundle<PlanDefinition>): ClassifiedResolvedProtocol {\n const entries: ResolvedProtocolEntry[] = []\n for (const entry of bundle.entry ?? []) {\n if (entry.resource?.resourceType === 'PlanDefinition') {\n entries.push({ pd: entry.resource, mode: entry.search?.mode })\n }\n }\n return classifyResolvedProtocolEntries(entries)\n}\n"]}