@openhi/constructs 0.0.143 → 0.0.145

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.
@@ -44,7 +44,7 @@ import {
44
44
  membershipListByUserOperation,
45
45
  switchUserTenantWorkspaceOperation,
46
46
  updateUserOperation
47
- } from "./chunk-UT7ADSEJ.mjs";
47
+ } from "./chunk-AOSEKL7U.mjs";
48
48
  import {
49
49
  batchGetWithRetry,
50
50
  buildUpdatedResourceWithAudit,
@@ -5942,6 +5942,72 @@ var FAMILYMEMBERHISTORY_SEARCH_PARAMETERS = [
5942
5942
  { code: "identifier", type: "token", jsonbPath: "$.identifier[*]" }
5943
5943
  ];
5944
5944
 
5945
+ // src/data/search/registry/immunization-search-parameters.ts
5946
+ var IMMUNIZATION_SEARCH_PARAMETERS = [
5947
+ { code: "status", type: "token", jsonbPath: "$.status" },
5948
+ { code: "status-reason", type: "token", jsonbPath: "$.statusReason" },
5949
+ { code: "vaccine-code", type: "token", jsonbPath: "$.vaccineCode" },
5950
+ { code: "patient", type: "reference", jsonbPath: "$.patient" },
5951
+ { code: "date", type: "date", jsonbPath: "$.occurrenceDateTime" },
5952
+ { code: "performer", type: "reference", jsonbPath: "$.performer[*].actor" },
5953
+ { code: "location", type: "reference", jsonbPath: "$.location" },
5954
+ {
5955
+ code: "lot-number",
5956
+ type: "string",
5957
+ jsonbPath: "$.lotNumber",
5958
+ modifiers: ["exact", "contains", "missing", "not"]
5959
+ },
5960
+ { code: "manufacturer", type: "reference", jsonbPath: "$.manufacturer" },
5961
+ { code: "reaction", type: "reference", jsonbPath: "$.reaction[*].detail" },
5962
+ { code: "reason-code", type: "token", jsonbPath: "$.reasonCode[*]" },
5963
+ {
5964
+ code: "reason-reference",
5965
+ type: "reference",
5966
+ jsonbPath: "$.reasonReference[*]"
5967
+ },
5968
+ { code: "identifier", type: "token", jsonbPath: "$.identifier[*]" }
5969
+ ];
5970
+
5971
+ // src/data/search/registry/medicationrequest-search-parameters.ts
5972
+ var MEDICATIONREQUEST_SEARCH_PARAMETERS = [
5973
+ { code: "status", type: "token", jsonbPath: "$.status" },
5974
+ { code: "intent", type: "token", jsonbPath: "$.intent" },
5975
+ { code: "category", type: "token", jsonbPath: "$.category[*]" },
5976
+ { code: "priority", type: "token", jsonbPath: "$.priority" },
5977
+ { code: "code", type: "token", jsonbPath: "$.medicationCodeableConcept" },
5978
+ { code: "subject", type: "reference", jsonbPath: "$.subject" },
5979
+ { code: "patient", type: "reference", jsonbPath: "$.subject" },
5980
+ { code: "encounter", type: "reference", jsonbPath: "$.encounter" },
5981
+ { code: "authored-on", type: "date", jsonbPath: "$.authoredOn" },
5982
+ { code: "requester", type: "reference", jsonbPath: "$.requester" },
5983
+ { code: "performer", type: "reference", jsonbPath: "$.performer" },
5984
+ { code: "identifier", type: "token", jsonbPath: "$.identifier[*]" }
5985
+ ];
5986
+
5987
+ // src/data/search/registry/medicationstatement-search-parameters.ts
5988
+ var MEDICATIONSTATEMENT_SEARCH_PARAMETERS = [
5989
+ { code: "status", type: "token", jsonbPath: "$.status" },
5990
+ { code: "category", type: "token", jsonbPath: "$.category" },
5991
+ { code: "code", type: "token", jsonbPath: "$.medicationCodeableConcept" },
5992
+ { code: "subject", type: "reference", jsonbPath: "$.subject" },
5993
+ { code: "patient", type: "reference", jsonbPath: "$.subject" },
5994
+ { code: "context", type: "reference", jsonbPath: "$.context" },
5995
+ { code: "effective", type: "date", jsonbPath: "$.effectiveDateTime" },
5996
+ {
5997
+ code: "information-source",
5998
+ type: "reference",
5999
+ jsonbPath: "$.informationSource"
6000
+ },
6001
+ {
6002
+ code: "medication",
6003
+ type: "reference",
6004
+ jsonbPath: "$.medicationReference"
6005
+ },
6006
+ { code: "source", type: "reference", jsonbPath: "$.informationSource" },
6007
+ { code: "identifier", type: "token", jsonbPath: "$.identifier[*]" },
6008
+ { code: "part-of", type: "reference", jsonbPath: "$.partOf[*]" }
6009
+ ];
6010
+
5945
6011
  // src/data/search/registry/observation-search-parameters.ts
5946
6012
  var OBSERVATION_SEARCH_PARAMETERS = [
5947
6013
  { code: "status", type: "token", jsonbPath: "$.status" },
@@ -6033,6 +6099,9 @@ var STATIC_SEARCH_PARAMETER_MAP = {
6033
6099
  Condition: CONDITION_SEARCH_PARAMETERS,
6034
6100
  Encounter: ENCOUNTER_SEARCH_PARAMETERS,
6035
6101
  FamilyMemberHistory: FAMILYMEMBERHISTORY_SEARCH_PARAMETERS,
6102
+ Immunization: IMMUNIZATION_SEARCH_PARAMETERS,
6103
+ MedicationRequest: MEDICATIONREQUEST_SEARCH_PARAMETERS,
6104
+ MedicationStatement: MEDICATIONSTATEMENT_SEARCH_PARAMETERS,
6036
6105
  Observation: OBSERVATION_SEARCH_PARAMETERS,
6037
6106
  Patient: PATIENT_SEARCH_PARAMETERS,
6038
6107
  Procedure: PROCEDURE_SEARCH_PARAMETERS
@@ -17882,15 +17951,108 @@ async function listImmunizationsOperation(params) {
17882
17951
  }
17883
17952
 
17884
17953
  // src/data/rest-api/routes/data/immunization/immunization-list-route.ts
17885
- async function listImmunizationsRoute(req, res) {
17886
- return handleListRoute({
17887
- req,
17888
- res,
17889
- basePath: BASE_PATH.IMMUNIZATION,
17890
- listOperation: listImmunizationsOperation,
17891
- errorLogContext: "GET /Immunization list error:"
17954
+ var IMMUNIZATION_RESOURCE_TYPE = "Immunization";
17955
+ function stripModifier6(key) {
17956
+ const idx = key.indexOf(":");
17957
+ return idx === -1 ? key : key.slice(0, idx);
17958
+ }
17959
+ function isResultParameter6(key) {
17960
+ return key.startsWith("_");
17961
+ }
17962
+ function sendInvalidSearch4006(res, diagnostics) {
17963
+ return res.status(400).json({
17964
+ resourceType: "OperationOutcome",
17965
+ issue: [{ severity: "error", code: "invalid", diagnostics }]
17892
17966
  });
17893
17967
  }
17968
+ function extractSearchParamKeys6(query) {
17969
+ const out = [];
17970
+ for (const rawKey of Object.keys(query)) {
17971
+ if (isResultParameter6(rawKey)) {
17972
+ continue;
17973
+ }
17974
+ out.push({ rawKey, code: stripModifier6(rawKey) });
17975
+ }
17976
+ return out;
17977
+ }
17978
+ function buildUnknownParamDiagnostics6(unknownCodes) {
17979
+ const validCodes = getRegisteredSearchParameters(IMMUNIZATION_RESOURCE_TYPE).map((p) => p.code).sort().join(", ");
17980
+ const codes = unknownCodes.join(", ");
17981
+ const isPlural = unknownCodes.length !== 1;
17982
+ return [
17983
+ `Unknown search ${isPlural ? "parameters" : "parameter"} for Immunization: ${codes}.`,
17984
+ `Valid codes: ${validCodes}.`
17985
+ ].join(" ");
17986
+ }
17987
+ function findMalformedReference6(query, searchParamKeys) {
17988
+ const referenceCodes = new Set(
17989
+ getRegisteredSearchParameters(IMMUNIZATION_RESOURCE_TYPE).filter((p) => p.type === "reference").map((p) => p.code)
17990
+ );
17991
+ for (const { rawKey, code } of searchParamKeys) {
17992
+ if (!referenceCodes.has(code)) {
17993
+ continue;
17994
+ }
17995
+ const raw = query[rawKey];
17996
+ const values = typeof raw === "string" ? raw.split(",") : Array.isArray(raw) ? raw.flatMap((v) => v.split(",")) : [];
17997
+ for (const v of values) {
17998
+ const trimmed = v.trim();
17999
+ if (trimmed.length === 0) {
18000
+ continue;
18001
+ }
18002
+ if (parseTypedReference(trimmed) === void 0) {
18003
+ return { rawKey, value: trimmed };
18004
+ }
18005
+ }
18006
+ }
18007
+ return void 0;
18008
+ }
18009
+ async function listImmunizationsRoute(req, res) {
18010
+ const searchParamKeys = extractSearchParamKeys6(
18011
+ req.query
18012
+ );
18013
+ if (searchParamKeys.length === 0) {
18014
+ return handleListRoute({
18015
+ req,
18016
+ res,
18017
+ basePath: BASE_PATH.IMMUNIZATION,
18018
+ listOperation: listImmunizationsOperation,
18019
+ errorLogContext: "GET /Immunization list error:"
18020
+ });
18021
+ }
18022
+ const registered = getRegisteredSearchParameters(IMMUNIZATION_RESOURCE_TYPE);
18023
+ const validCodes = new Set(registered.map((p) => p.code));
18024
+ const unknownCodes = searchParamKeys.map((k) => k.code).filter((code) => !validCodes.has(code));
18025
+ if (unknownCodes.length > 0) {
18026
+ return sendInvalidSearch4006(
18027
+ res,
18028
+ buildUnknownParamDiagnostics6([...new Set(unknownCodes)])
18029
+ );
18030
+ }
18031
+ const malformedRef = findMalformedReference6(
18032
+ req.query,
18033
+ searchParamKeys
18034
+ );
18035
+ if (malformedRef !== void 0) {
18036
+ return sendInvalidSearch4006(
18037
+ res,
18038
+ `?${malformedRef.rawKey} must be a typed reference like "Practitioner/<id>"; got "${malformedRef.value}".`
18039
+ );
18040
+ }
18041
+ const ctx = req.openhiContext;
18042
+ try {
18043
+ const result = await genericSearchOperation({
18044
+ resourceType: IMMUNIZATION_RESOURCE_TYPE,
18045
+ tenantId: ctx.tenantId,
18046
+ workspaceId: ctx.workspaceId,
18047
+ query: req.query,
18048
+ resolver: defaultSearchParameterResolver
18049
+ });
18050
+ const bundle = buildSearchsetBundle(BASE_PATH.IMMUNIZATION, result.entries);
18051
+ return res.json(bundle);
18052
+ } catch (err) {
18053
+ return sendOperationOutcome500(res, err, "GET /Immunization search error:");
18054
+ }
18055
+ }
17894
18056
 
17895
18057
  // src/data/operations/data/immunization/immunization-update-operation.ts
17896
18058
  async function updateImmunizationOperation(params) {
@@ -21363,15 +21525,119 @@ async function listMedicationRequestsOperation(params) {
21363
21525
  }
21364
21526
 
21365
21527
  // src/data/rest-api/routes/data/medicationrequest/medicationrequest-list-route.ts
21366
- async function listMedicationRequestsRoute(req, res) {
21367
- return handleListRoute({
21368
- req,
21369
- res,
21370
- basePath: BASE_PATH.MEDICATIONREQUEST,
21371
- listOperation: listMedicationRequestsOperation,
21372
- errorLogContext: "GET /MedicationRequest list error:"
21528
+ var MEDICATIONREQUEST_RESOURCE_TYPE = "MedicationRequest";
21529
+ function stripModifier7(key) {
21530
+ const idx = key.indexOf(":");
21531
+ return idx === -1 ? key : key.slice(0, idx);
21532
+ }
21533
+ function isResultParameter7(key) {
21534
+ return key.startsWith("_");
21535
+ }
21536
+ function sendInvalidSearch4007(res, diagnostics) {
21537
+ return res.status(400).json({
21538
+ resourceType: "OperationOutcome",
21539
+ issue: [{ severity: "error", code: "invalid", diagnostics }]
21373
21540
  });
21374
21541
  }
21542
+ function extractSearchParamKeys7(query) {
21543
+ const out = [];
21544
+ for (const rawKey of Object.keys(query)) {
21545
+ if (isResultParameter7(rawKey)) {
21546
+ continue;
21547
+ }
21548
+ out.push({ rawKey, code: stripModifier7(rawKey) });
21549
+ }
21550
+ return out;
21551
+ }
21552
+ function buildUnknownParamDiagnostics7(unknownCodes) {
21553
+ const validCodes = getRegisteredSearchParameters(
21554
+ MEDICATIONREQUEST_RESOURCE_TYPE
21555
+ ).map((p) => p.code).sort().join(", ");
21556
+ const codes = unknownCodes.join(", ");
21557
+ const isPlural = unknownCodes.length !== 1;
21558
+ return [
21559
+ `Unknown search ${isPlural ? "parameters" : "parameter"} for MedicationRequest: ${codes}.`,
21560
+ `Valid codes: ${validCodes}.`
21561
+ ].join(" ");
21562
+ }
21563
+ function findMalformedReference7(query, searchParamKeys) {
21564
+ const referenceCodes = new Set(
21565
+ getRegisteredSearchParameters(MEDICATIONREQUEST_RESOURCE_TYPE).filter((p) => p.type === "reference").map((p) => p.code)
21566
+ );
21567
+ for (const { rawKey, code } of searchParamKeys) {
21568
+ if (!referenceCodes.has(code)) {
21569
+ continue;
21570
+ }
21571
+ const raw = query[rawKey];
21572
+ const values = typeof raw === "string" ? raw.split(",") : Array.isArray(raw) ? raw.flatMap((v) => v.split(",")) : [];
21573
+ for (const v of values) {
21574
+ const trimmed = v.trim();
21575
+ if (trimmed.length === 0) {
21576
+ continue;
21577
+ }
21578
+ if (parseTypedReference(trimmed) === void 0) {
21579
+ return { rawKey, value: trimmed };
21580
+ }
21581
+ }
21582
+ }
21583
+ return void 0;
21584
+ }
21585
+ async function listMedicationRequestsRoute(req, res) {
21586
+ const searchParamKeys = extractSearchParamKeys7(
21587
+ req.query
21588
+ );
21589
+ if (searchParamKeys.length === 0) {
21590
+ return handleListRoute({
21591
+ req,
21592
+ res,
21593
+ basePath: BASE_PATH.MEDICATIONREQUEST,
21594
+ listOperation: listMedicationRequestsOperation,
21595
+ errorLogContext: "GET /MedicationRequest list error:"
21596
+ });
21597
+ }
21598
+ const registered = getRegisteredSearchParameters(
21599
+ MEDICATIONREQUEST_RESOURCE_TYPE
21600
+ );
21601
+ const validCodes = new Set(registered.map((p) => p.code));
21602
+ const unknownCodes = searchParamKeys.map((k) => k.code).filter((code) => !validCodes.has(code));
21603
+ if (unknownCodes.length > 0) {
21604
+ return sendInvalidSearch4007(
21605
+ res,
21606
+ buildUnknownParamDiagnostics7([...new Set(unknownCodes)])
21607
+ );
21608
+ }
21609
+ const malformedRef = findMalformedReference7(
21610
+ req.query,
21611
+ searchParamKeys
21612
+ );
21613
+ if (malformedRef !== void 0) {
21614
+ return sendInvalidSearch4007(
21615
+ res,
21616
+ `?${malformedRef.rawKey} must be a typed reference like "Practitioner/<id>"; got "${malformedRef.value}".`
21617
+ );
21618
+ }
21619
+ const ctx = req.openhiContext;
21620
+ try {
21621
+ const result = await genericSearchOperation({
21622
+ resourceType: MEDICATIONREQUEST_RESOURCE_TYPE,
21623
+ tenantId: ctx.tenantId,
21624
+ workspaceId: ctx.workspaceId,
21625
+ query: req.query,
21626
+ resolver: defaultSearchParameterResolver
21627
+ });
21628
+ const bundle = buildSearchsetBundle(
21629
+ BASE_PATH.MEDICATIONREQUEST,
21630
+ result.entries
21631
+ );
21632
+ return res.json(bundle);
21633
+ } catch (err) {
21634
+ return sendOperationOutcome500(
21635
+ res,
21636
+ err,
21637
+ "GET /MedicationRequest search error:"
21638
+ );
21639
+ }
21640
+ }
21375
21641
 
21376
21642
  // src/data/operations/data/medicationrequest/medicationrequest-update-operation.ts
21377
21643
  async function updateMedicationRequestOperation(params) {
@@ -21570,15 +21836,119 @@ async function listMedicationStatementsOperation(params) {
21570
21836
  }
21571
21837
 
21572
21838
  // src/data/rest-api/routes/data/medicationstatement/medicationstatement-list-route.ts
21573
- async function listMedicationStatementsRoute(req, res) {
21574
- return handleListRoute({
21575
- req,
21576
- res,
21577
- basePath: BASE_PATH.MEDICATIONSTATEMENT,
21578
- listOperation: listMedicationStatementsOperation,
21579
- errorLogContext: "GET /MedicationStatement list error:"
21839
+ var MEDICATIONSTATEMENT_RESOURCE_TYPE = "MedicationStatement";
21840
+ function stripModifier8(key) {
21841
+ const idx = key.indexOf(":");
21842
+ return idx === -1 ? key : key.slice(0, idx);
21843
+ }
21844
+ function isResultParameter8(key) {
21845
+ return key.startsWith("_");
21846
+ }
21847
+ function sendInvalidSearch4008(res, diagnostics) {
21848
+ return res.status(400).json({
21849
+ resourceType: "OperationOutcome",
21850
+ issue: [{ severity: "error", code: "invalid", diagnostics }]
21580
21851
  });
21581
21852
  }
21853
+ function extractSearchParamKeys8(query) {
21854
+ const out = [];
21855
+ for (const rawKey of Object.keys(query)) {
21856
+ if (isResultParameter8(rawKey)) {
21857
+ continue;
21858
+ }
21859
+ out.push({ rawKey, code: stripModifier8(rawKey) });
21860
+ }
21861
+ return out;
21862
+ }
21863
+ function buildUnknownParamDiagnostics8(unknownCodes) {
21864
+ const validCodes = getRegisteredSearchParameters(
21865
+ MEDICATIONSTATEMENT_RESOURCE_TYPE
21866
+ ).map((p) => p.code).sort().join(", ");
21867
+ const codes = unknownCodes.join(", ");
21868
+ const isPlural = unknownCodes.length !== 1;
21869
+ return [
21870
+ `Unknown search ${isPlural ? "parameters" : "parameter"} for MedicationStatement: ${codes}.`,
21871
+ `Valid codes: ${validCodes}.`
21872
+ ].join(" ");
21873
+ }
21874
+ function findMalformedReference8(query, searchParamKeys) {
21875
+ const referenceCodes = new Set(
21876
+ getRegisteredSearchParameters(MEDICATIONSTATEMENT_RESOURCE_TYPE).filter((p) => p.type === "reference").map((p) => p.code)
21877
+ );
21878
+ for (const { rawKey, code } of searchParamKeys) {
21879
+ if (!referenceCodes.has(code)) {
21880
+ continue;
21881
+ }
21882
+ const raw = query[rawKey];
21883
+ const values = typeof raw === "string" ? raw.split(",") : Array.isArray(raw) ? raw.flatMap((v) => v.split(",")) : [];
21884
+ for (const v of values) {
21885
+ const trimmed = v.trim();
21886
+ if (trimmed.length === 0) {
21887
+ continue;
21888
+ }
21889
+ if (parseTypedReference(trimmed) === void 0) {
21890
+ return { rawKey, value: trimmed };
21891
+ }
21892
+ }
21893
+ }
21894
+ return void 0;
21895
+ }
21896
+ async function listMedicationStatementsRoute(req, res) {
21897
+ const searchParamKeys = extractSearchParamKeys8(
21898
+ req.query
21899
+ );
21900
+ if (searchParamKeys.length === 0) {
21901
+ return handleListRoute({
21902
+ req,
21903
+ res,
21904
+ basePath: BASE_PATH.MEDICATIONSTATEMENT,
21905
+ listOperation: listMedicationStatementsOperation,
21906
+ errorLogContext: "GET /MedicationStatement list error:"
21907
+ });
21908
+ }
21909
+ const registered = getRegisteredSearchParameters(
21910
+ MEDICATIONSTATEMENT_RESOURCE_TYPE
21911
+ );
21912
+ const validCodes = new Set(registered.map((p) => p.code));
21913
+ const unknownCodes = searchParamKeys.map((k) => k.code).filter((code) => !validCodes.has(code));
21914
+ if (unknownCodes.length > 0) {
21915
+ return sendInvalidSearch4008(
21916
+ res,
21917
+ buildUnknownParamDiagnostics8([...new Set(unknownCodes)])
21918
+ );
21919
+ }
21920
+ const malformedRef = findMalformedReference8(
21921
+ req.query,
21922
+ searchParamKeys
21923
+ );
21924
+ if (malformedRef !== void 0) {
21925
+ return sendInvalidSearch4008(
21926
+ res,
21927
+ `?${malformedRef.rawKey} must be a typed reference like "Practitioner/<id>"; got "${malformedRef.value}".`
21928
+ );
21929
+ }
21930
+ const ctx = req.openhiContext;
21931
+ try {
21932
+ const result = await genericSearchOperation({
21933
+ resourceType: MEDICATIONSTATEMENT_RESOURCE_TYPE,
21934
+ tenantId: ctx.tenantId,
21935
+ workspaceId: ctx.workspaceId,
21936
+ query: req.query,
21937
+ resolver: defaultSearchParameterResolver
21938
+ });
21939
+ const bundle = buildSearchsetBundle(
21940
+ BASE_PATH.MEDICATIONSTATEMENT,
21941
+ result.entries
21942
+ );
21943
+ return res.json(bundle);
21944
+ } catch (err) {
21945
+ return sendOperationOutcome500(
21946
+ res,
21947
+ err,
21948
+ "GET /MedicationStatement search error:"
21949
+ );
21950
+ }
21951
+ }
21582
21952
 
21583
21953
  // src/data/operations/data/medicationstatement/medicationstatement-update-operation.ts
21584
21954
  async function updateMedicationStatementOperation(params) {
@@ -24934,30 +25304,30 @@ async function listObservationsOperation(params) {
24934
25304
 
24935
25305
  // src/data/rest-api/routes/data/observation/observation-list-route.ts
24936
25306
  var OBSERVATION_RESOURCE_TYPE = "Observation";
24937
- function stripModifier6(key) {
25307
+ function stripModifier9(key) {
24938
25308
  const idx = key.indexOf(":");
24939
25309
  return idx === -1 ? key : key.slice(0, idx);
24940
25310
  }
24941
- function isResultParameter6(key) {
25311
+ function isResultParameter9(key) {
24942
25312
  return key.startsWith("_");
24943
25313
  }
24944
- function sendInvalidSearch4006(res, diagnostics) {
25314
+ function sendInvalidSearch4009(res, diagnostics) {
24945
25315
  return res.status(400).json({
24946
25316
  resourceType: "OperationOutcome",
24947
25317
  issue: [{ severity: "error", code: "invalid", diagnostics }]
24948
25318
  });
24949
25319
  }
24950
- function extractSearchParamKeys6(query) {
25320
+ function extractSearchParamKeys9(query) {
24951
25321
  const out = [];
24952
25322
  for (const rawKey of Object.keys(query)) {
24953
- if (isResultParameter6(rawKey)) {
25323
+ if (isResultParameter9(rawKey)) {
24954
25324
  continue;
24955
25325
  }
24956
- out.push({ rawKey, code: stripModifier6(rawKey) });
25326
+ out.push({ rawKey, code: stripModifier9(rawKey) });
24957
25327
  }
24958
25328
  return out;
24959
25329
  }
24960
- function buildUnknownParamDiagnostics6(unknownCodes) {
25330
+ function buildUnknownParamDiagnostics9(unknownCodes) {
24961
25331
  const validCodes = getRegisteredSearchParameters(OBSERVATION_RESOURCE_TYPE).map((p) => p.code).sort().join(", ");
24962
25332
  const codes = unknownCodes.join(", ");
24963
25333
  const isPlural = unknownCodes.length !== 1;
@@ -24966,7 +25336,7 @@ function buildUnknownParamDiagnostics6(unknownCodes) {
24966
25336
  `Valid codes: ${validCodes}.`
24967
25337
  ].join(" ");
24968
25338
  }
24969
- function findMalformedReference6(query, searchParamKeys) {
25339
+ function findMalformedReference9(query, searchParamKeys) {
24970
25340
  const referenceCodes = new Set(
24971
25341
  getRegisteredSearchParameters(OBSERVATION_RESOURCE_TYPE).filter((p) => p.type === "reference").map((p) => p.code)
24972
25342
  );
@@ -24989,7 +25359,7 @@ function findMalformedReference6(query, searchParamKeys) {
24989
25359
  return void 0;
24990
25360
  }
24991
25361
  async function listObservationsRoute(req, res) {
24992
- const searchParamKeys = extractSearchParamKeys6(
25362
+ const searchParamKeys = extractSearchParamKeys9(
24993
25363
  req.query
24994
25364
  );
24995
25365
  if (searchParamKeys.length === 0) {
@@ -25005,17 +25375,17 @@ async function listObservationsRoute(req, res) {
25005
25375
  const validCodes = new Set(registered.map((p) => p.code));
25006
25376
  const unknownCodes = searchParamKeys.map((k) => k.code).filter((code) => !validCodes.has(code));
25007
25377
  if (unknownCodes.length > 0) {
25008
- return sendInvalidSearch4006(
25378
+ return sendInvalidSearch4009(
25009
25379
  res,
25010
- buildUnknownParamDiagnostics6([...new Set(unknownCodes)])
25380
+ buildUnknownParamDiagnostics9([...new Set(unknownCodes)])
25011
25381
  );
25012
25382
  }
25013
- const malformedRef = findMalformedReference6(
25383
+ const malformedRef = findMalformedReference9(
25014
25384
  req.query,
25015
25385
  searchParamKeys
25016
25386
  );
25017
25387
  if (malformedRef !== void 0) {
25018
- return sendInvalidSearch4006(
25388
+ return sendInvalidSearch4009(
25019
25389
  res,
25020
25390
  `?${malformedRef.rawKey} must be a typed reference like "Practitioner/<id>"; got "${malformedRef.value}".`
25021
25391
  );
@@ -26010,30 +26380,30 @@ async function listPatientsOperation(params) {
26010
26380
 
26011
26381
  // src/data/rest-api/routes/data/patient/patient-list-route.ts
26012
26382
  var PATIENT_RESOURCE_TYPE = "Patient";
26013
- function stripModifier7(key) {
26383
+ function stripModifier10(key) {
26014
26384
  const idx = key.indexOf(":");
26015
26385
  return idx === -1 ? key : key.slice(0, idx);
26016
26386
  }
26017
- function isResultParameter7(key) {
26387
+ function isResultParameter10(key) {
26018
26388
  return key.startsWith("_");
26019
26389
  }
26020
- function sendInvalidSearch4007(res, diagnostics) {
26390
+ function sendInvalidSearch40010(res, diagnostics) {
26021
26391
  return res.status(400).json({
26022
26392
  resourceType: "OperationOutcome",
26023
26393
  issue: [{ severity: "error", code: "invalid", diagnostics }]
26024
26394
  });
26025
26395
  }
26026
- function extractSearchParamKeys7(query) {
26396
+ function extractSearchParamKeys10(query) {
26027
26397
  const out = [];
26028
26398
  for (const rawKey of Object.keys(query)) {
26029
- if (isResultParameter7(rawKey)) {
26399
+ if (isResultParameter10(rawKey)) {
26030
26400
  continue;
26031
26401
  }
26032
- out.push({ rawKey, code: stripModifier7(rawKey) });
26402
+ out.push({ rawKey, code: stripModifier10(rawKey) });
26033
26403
  }
26034
26404
  return out;
26035
26405
  }
26036
- function buildUnknownParamDiagnostics7(unknownCodes) {
26406
+ function buildUnknownParamDiagnostics10(unknownCodes) {
26037
26407
  const validCodes = getRegisteredSearchParameters(PATIENT_RESOURCE_TYPE).map((p) => p.code).sort().join(", ");
26038
26408
  const codes = unknownCodes.join(", ");
26039
26409
  const isPlural = unknownCodes.length !== 1;
@@ -26042,7 +26412,7 @@ function buildUnknownParamDiagnostics7(unknownCodes) {
26042
26412
  `Valid codes: ${validCodes}.`
26043
26413
  ].join(" ");
26044
26414
  }
26045
- function findMalformedReference7(query, searchParamKeys) {
26415
+ function findMalformedReference10(query, searchParamKeys) {
26046
26416
  const referenceCodes = new Set(
26047
26417
  getRegisteredSearchParameters(PATIENT_RESOURCE_TYPE).filter((p) => p.type === "reference").map((p) => p.code)
26048
26418
  );
@@ -26065,7 +26435,7 @@ function findMalformedReference7(query, searchParamKeys) {
26065
26435
  return void 0;
26066
26436
  }
26067
26437
  async function listPatientsRoute(req, res) {
26068
- const searchParamKeys = extractSearchParamKeys7(
26438
+ const searchParamKeys = extractSearchParamKeys10(
26069
26439
  req.query
26070
26440
  );
26071
26441
  if (searchParamKeys.length === 0) {
@@ -26081,17 +26451,17 @@ async function listPatientsRoute(req, res) {
26081
26451
  const validCodes = new Set(registered.map((p) => p.code));
26082
26452
  const unknownCodes = searchParamKeys.map((k) => k.code).filter((code) => !validCodes.has(code));
26083
26453
  if (unknownCodes.length > 0) {
26084
- return sendInvalidSearch4007(
26454
+ return sendInvalidSearch40010(
26085
26455
  res,
26086
- buildUnknownParamDiagnostics7([...new Set(unknownCodes)])
26456
+ buildUnknownParamDiagnostics10([...new Set(unknownCodes)])
26087
26457
  );
26088
26458
  }
26089
- const malformedRef = findMalformedReference7(
26459
+ const malformedRef = findMalformedReference10(
26090
26460
  req.query,
26091
26461
  searchParamKeys
26092
26462
  );
26093
26463
  if (malformedRef !== void 0) {
26094
- return sendInvalidSearch4007(
26464
+ return sendInvalidSearch40010(
26095
26465
  res,
26096
26466
  `?${malformedRef.rawKey} must be a typed reference like "Practitioner/<id>"; got "${malformedRef.value}".`
26097
26467
  );
@@ -27431,30 +27801,30 @@ async function listProceduresOperation(params) {
27431
27801
 
27432
27802
  // src/data/rest-api/routes/data/procedure/procedure-list-route.ts
27433
27803
  var PROCEDURE_RESOURCE_TYPE = "Procedure";
27434
- function stripModifier8(key) {
27804
+ function stripModifier11(key) {
27435
27805
  const idx = key.indexOf(":");
27436
27806
  return idx === -1 ? key : key.slice(0, idx);
27437
27807
  }
27438
- function isResultParameter8(key) {
27808
+ function isResultParameter11(key) {
27439
27809
  return key.startsWith("_");
27440
27810
  }
27441
- function sendInvalidSearch4008(res, diagnostics) {
27811
+ function sendInvalidSearch40011(res, diagnostics) {
27442
27812
  return res.status(400).json({
27443
27813
  resourceType: "OperationOutcome",
27444
27814
  issue: [{ severity: "error", code: "invalid", diagnostics }]
27445
27815
  });
27446
27816
  }
27447
- function extractSearchParamKeys8(query) {
27817
+ function extractSearchParamKeys11(query) {
27448
27818
  const out = [];
27449
27819
  for (const rawKey of Object.keys(query)) {
27450
- if (isResultParameter8(rawKey)) {
27820
+ if (isResultParameter11(rawKey)) {
27451
27821
  continue;
27452
27822
  }
27453
- out.push({ rawKey, code: stripModifier8(rawKey) });
27823
+ out.push({ rawKey, code: stripModifier11(rawKey) });
27454
27824
  }
27455
27825
  return out;
27456
27826
  }
27457
- function buildUnknownParamDiagnostics8(unknownCodes) {
27827
+ function buildUnknownParamDiagnostics11(unknownCodes) {
27458
27828
  const validCodes = getRegisteredSearchParameters(PROCEDURE_RESOURCE_TYPE).map((p) => p.code).sort().join(", ");
27459
27829
  const codes = unknownCodes.join(", ");
27460
27830
  const isPlural = unknownCodes.length !== 1;
@@ -27463,7 +27833,7 @@ function buildUnknownParamDiagnostics8(unknownCodes) {
27463
27833
  `Valid codes: ${validCodes}.`
27464
27834
  ].join(" ");
27465
27835
  }
27466
- function findMalformedReference8(query, searchParamKeys) {
27836
+ function findMalformedReference11(query, searchParamKeys) {
27467
27837
  const referenceCodes = new Set(
27468
27838
  getRegisteredSearchParameters(PROCEDURE_RESOURCE_TYPE).filter((p) => p.type === "reference").map((p) => p.code)
27469
27839
  );
@@ -27486,7 +27856,7 @@ function findMalformedReference8(query, searchParamKeys) {
27486
27856
  return void 0;
27487
27857
  }
27488
27858
  async function listProceduresRoute(req, res) {
27489
- const searchParamKeys = extractSearchParamKeys8(
27859
+ const searchParamKeys = extractSearchParamKeys11(
27490
27860
  req.query
27491
27861
  );
27492
27862
  if (searchParamKeys.length === 0) {
@@ -27502,17 +27872,17 @@ async function listProceduresRoute(req, res) {
27502
27872
  const validCodes = new Set(registered.map((p) => p.code));
27503
27873
  const unknownCodes = searchParamKeys.map((k) => k.code).filter((code) => !validCodes.has(code));
27504
27874
  if (unknownCodes.length > 0) {
27505
- return sendInvalidSearch4008(
27875
+ return sendInvalidSearch40011(
27506
27876
  res,
27507
- buildUnknownParamDiagnostics8([...new Set(unknownCodes)])
27877
+ buildUnknownParamDiagnostics11([...new Set(unknownCodes)])
27508
27878
  );
27509
27879
  }
27510
- const malformedRef = findMalformedReference8(
27880
+ const malformedRef = findMalformedReference11(
27511
27881
  req.query,
27512
27882
  searchParamKeys
27513
27883
  );
27514
27884
  if (malformedRef !== void 0) {
27515
- return sendInvalidSearch4008(
27885
+ return sendInvalidSearch40011(
27516
27886
  res,
27517
27887
  `?${malformedRef.rawKey} must be a typed reference like "Practitioner/<id>"; got "${malformedRef.value}".`
27518
27888
  );
@@ -30039,7 +30409,7 @@ function singleStringQueryParam(req, name) {
30039
30409
  const trimmed = v.trim();
30040
30410
  return trimmed === "" ? void 0 : trimmed;
30041
30411
  }
30042
- function sendInvalidSearch4009(res, diagnostics) {
30412
+ function sendInvalidSearch40012(res, diagnostics) {
30043
30413
  return res.status(400).json({
30044
30414
  resourceType: "OperationOutcome",
30045
30415
  issue: [{ severity: "error", code: "invalid", diagnostics }]
@@ -30049,7 +30419,7 @@ async function listSchedulesRoute(req, res) {
30049
30419
  const actorRef = singleStringQueryParam(req, "actor");
30050
30420
  if (actorRef !== void 0) {
30051
30421
  if (parseTypedReference(actorRef) === void 0) {
30052
- return sendInvalidSearch4009(
30422
+ return sendInvalidSearch40012(
30053
30423
  res,
30054
30424
  `?actor must be a typed reference like "Practitioner/<id>"; got "${actorRef}".`
30055
30425
  );
@@ -33847,7 +34217,7 @@ function singleStringQueryParam2(req, name) {
33847
34217
  const trimmed = v.trim();
33848
34218
  return trimmed === "" ? void 0 : trimmed;
33849
34219
  }
33850
- function sendInvalidSearch40010(res, diagnostics) {
34220
+ function sendInvalidSearch40013(res, diagnostics) {
33851
34221
  return res.status(400).json({
33852
34222
  resourceType: "OperationOutcome",
33853
34223
  issue: [{ severity: "error", code: "invalid", diagnostics }]
@@ -33857,14 +34227,14 @@ async function listTasksRoute(req, res) {
33857
34227
  const ownerRef = singleStringQueryParam2(req, "owner");
33858
34228
  const requesterRef = singleStringQueryParam2(req, "requester");
33859
34229
  if (ownerRef !== void 0 && requesterRef !== void 0) {
33860
- return sendInvalidSearch40010(
34230
+ return sendInvalidSearch40013(
33861
34231
  res,
33862
34232
  "?owner= and ?requester= cannot be combined on the same request."
33863
34233
  );
33864
34234
  }
33865
34235
  if (ownerRef !== void 0) {
33866
34236
  if (parseTypedReference(ownerRef) === void 0) {
33867
- return sendInvalidSearch40010(
34237
+ return sendInvalidSearch40013(
33868
34238
  res,
33869
34239
  `?owner must be a typed reference like "Practitioner/<id>"; got "${ownerRef}".`
33870
34240
  );
@@ -33887,7 +34257,7 @@ async function listTasksRoute(req, res) {
33887
34257
  }
33888
34258
  if (requesterRef !== void 0) {
33889
34259
  if (parseTypedReference(requesterRef) === void 0) {
33890
- return sendInvalidSearch40010(
34260
+ return sendInvalidSearch40013(
33891
34261
  res,
33892
34262
  `?requester must be a typed reference like "Practitioner/<id>"; got "${requesterRef}".`
33893
34263
  );