@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.
@@ -7639,16 +7639,23 @@ function getCognitoSubFromRequest(req) {
7639
7639
  async function findUserBySubOperation(params) {
7640
7640
  const { cognitoSub, tableName } = params;
7641
7641
  const service = getDynamoControlService(tableName);
7642
- const result = await service.entities.user.query.gsi2({ cognitoSub }).go({ limit: 1 });
7643
- const item = result.data?.[0];
7644
- if (!item) {
7642
+ const indexResult = await service.entities.user.query.gsi2({ cognitoSub }).go({ limit: 1, attributes: ["id"] });
7643
+ const indexItem = indexResult.data?.[0];
7644
+ if (!indexItem) {
7645
+ return void 0;
7646
+ }
7647
+ const canonical = await service.entities.user.get({ id: indexItem.id, sk: "CURRENT" }).go();
7648
+ const row = canonical.data;
7649
+ if (!row) {
7645
7650
  return void 0;
7646
7651
  }
7647
7652
  return {
7648
- id: item.id,
7649
- cognitoSub: item.cognitoSub,
7650
- resource: item.resource,
7651
- vid: item.vid
7653
+ id: row.id,
7654
+ cognitoSub: row.cognitoSub,
7655
+ resource: row.resource,
7656
+ summary: row.summary,
7657
+ vid: row.vid,
7658
+ lastUpdated: row.lastUpdated
7652
7659
  };
7653
7660
  }
7654
7661
 
@@ -10173,6 +10180,72 @@ var FAMILYMEMBERHISTORY_SEARCH_PARAMETERS = [
10173
10180
  { code: "identifier", type: "token", jsonbPath: "$.identifier[*]" }
10174
10181
  ];
10175
10182
 
10183
+ // src/data/search/registry/immunization-search-parameters.ts
10184
+ var IMMUNIZATION_SEARCH_PARAMETERS = [
10185
+ { code: "status", type: "token", jsonbPath: "$.status" },
10186
+ { code: "status-reason", type: "token", jsonbPath: "$.statusReason" },
10187
+ { code: "vaccine-code", type: "token", jsonbPath: "$.vaccineCode" },
10188
+ { code: "patient", type: "reference", jsonbPath: "$.patient" },
10189
+ { code: "date", type: "date", jsonbPath: "$.occurrenceDateTime" },
10190
+ { code: "performer", type: "reference", jsonbPath: "$.performer[*].actor" },
10191
+ { code: "location", type: "reference", jsonbPath: "$.location" },
10192
+ {
10193
+ code: "lot-number",
10194
+ type: "string",
10195
+ jsonbPath: "$.lotNumber",
10196
+ modifiers: ["exact", "contains", "missing", "not"]
10197
+ },
10198
+ { code: "manufacturer", type: "reference", jsonbPath: "$.manufacturer" },
10199
+ { code: "reaction", type: "reference", jsonbPath: "$.reaction[*].detail" },
10200
+ { code: "reason-code", type: "token", jsonbPath: "$.reasonCode[*]" },
10201
+ {
10202
+ code: "reason-reference",
10203
+ type: "reference",
10204
+ jsonbPath: "$.reasonReference[*]"
10205
+ },
10206
+ { code: "identifier", type: "token", jsonbPath: "$.identifier[*]" }
10207
+ ];
10208
+
10209
+ // src/data/search/registry/medicationrequest-search-parameters.ts
10210
+ var MEDICATIONREQUEST_SEARCH_PARAMETERS = [
10211
+ { code: "status", type: "token", jsonbPath: "$.status" },
10212
+ { code: "intent", type: "token", jsonbPath: "$.intent" },
10213
+ { code: "category", type: "token", jsonbPath: "$.category[*]" },
10214
+ { code: "priority", type: "token", jsonbPath: "$.priority" },
10215
+ { code: "code", type: "token", jsonbPath: "$.medicationCodeableConcept" },
10216
+ { code: "subject", type: "reference", jsonbPath: "$.subject" },
10217
+ { code: "patient", type: "reference", jsonbPath: "$.subject" },
10218
+ { code: "encounter", type: "reference", jsonbPath: "$.encounter" },
10219
+ { code: "authored-on", type: "date", jsonbPath: "$.authoredOn" },
10220
+ { code: "requester", type: "reference", jsonbPath: "$.requester" },
10221
+ { code: "performer", type: "reference", jsonbPath: "$.performer" },
10222
+ { code: "identifier", type: "token", jsonbPath: "$.identifier[*]" }
10223
+ ];
10224
+
10225
+ // src/data/search/registry/medicationstatement-search-parameters.ts
10226
+ var MEDICATIONSTATEMENT_SEARCH_PARAMETERS = [
10227
+ { code: "status", type: "token", jsonbPath: "$.status" },
10228
+ { code: "category", type: "token", jsonbPath: "$.category" },
10229
+ { code: "code", type: "token", jsonbPath: "$.medicationCodeableConcept" },
10230
+ { code: "subject", type: "reference", jsonbPath: "$.subject" },
10231
+ { code: "patient", type: "reference", jsonbPath: "$.subject" },
10232
+ { code: "context", type: "reference", jsonbPath: "$.context" },
10233
+ { code: "effective", type: "date", jsonbPath: "$.effectiveDateTime" },
10234
+ {
10235
+ code: "information-source",
10236
+ type: "reference",
10237
+ jsonbPath: "$.informationSource"
10238
+ },
10239
+ {
10240
+ code: "medication",
10241
+ type: "reference",
10242
+ jsonbPath: "$.medicationReference"
10243
+ },
10244
+ { code: "source", type: "reference", jsonbPath: "$.informationSource" },
10245
+ { code: "identifier", type: "token", jsonbPath: "$.identifier[*]" },
10246
+ { code: "part-of", type: "reference", jsonbPath: "$.partOf[*]" }
10247
+ ];
10248
+
10176
10249
  // src/data/search/registry/observation-search-parameters.ts
10177
10250
  var OBSERVATION_SEARCH_PARAMETERS = [
10178
10251
  { code: "status", type: "token", jsonbPath: "$.status" },
@@ -10264,6 +10337,9 @@ var STATIC_SEARCH_PARAMETER_MAP = {
10264
10337
  Condition: CONDITION_SEARCH_PARAMETERS,
10265
10338
  Encounter: ENCOUNTER_SEARCH_PARAMETERS,
10266
10339
  FamilyMemberHistory: FAMILYMEMBERHISTORY_SEARCH_PARAMETERS,
10340
+ Immunization: IMMUNIZATION_SEARCH_PARAMETERS,
10341
+ MedicationRequest: MEDICATIONREQUEST_SEARCH_PARAMETERS,
10342
+ MedicationStatement: MEDICATIONSTATEMENT_SEARCH_PARAMETERS,
10267
10343
  Observation: OBSERVATION_SEARCH_PARAMETERS,
10268
10344
  Patient: PATIENT_SEARCH_PARAMETERS,
10269
10345
  Procedure: PROCEDURE_SEARCH_PARAMETERS
@@ -22148,15 +22224,108 @@ async function listImmunizationsOperation(params) {
22148
22224
  }
22149
22225
 
22150
22226
  // src/data/rest-api/routes/data/immunization/immunization-list-route.ts
22151
- async function listImmunizationsRoute(req, res) {
22152
- return handleListRoute({
22153
- req,
22154
- res,
22155
- basePath: BASE_PATH.IMMUNIZATION,
22156
- listOperation: listImmunizationsOperation,
22157
- errorLogContext: "GET /Immunization list error:"
22227
+ var IMMUNIZATION_RESOURCE_TYPE = "Immunization";
22228
+ function stripModifier6(key) {
22229
+ const idx = key.indexOf(":");
22230
+ return idx === -1 ? key : key.slice(0, idx);
22231
+ }
22232
+ function isResultParameter6(key) {
22233
+ return key.startsWith("_");
22234
+ }
22235
+ function sendInvalidSearch4006(res, diagnostics) {
22236
+ return res.status(400).json({
22237
+ resourceType: "OperationOutcome",
22238
+ issue: [{ severity: "error", code: "invalid", diagnostics }]
22158
22239
  });
22159
22240
  }
22241
+ function extractSearchParamKeys6(query) {
22242
+ const out = [];
22243
+ for (const rawKey of Object.keys(query)) {
22244
+ if (isResultParameter6(rawKey)) {
22245
+ continue;
22246
+ }
22247
+ out.push({ rawKey, code: stripModifier6(rawKey) });
22248
+ }
22249
+ return out;
22250
+ }
22251
+ function buildUnknownParamDiagnostics6(unknownCodes) {
22252
+ const validCodes = getRegisteredSearchParameters(IMMUNIZATION_RESOURCE_TYPE).map((p) => p.code).sort().join(", ");
22253
+ const codes = unknownCodes.join(", ");
22254
+ const isPlural = unknownCodes.length !== 1;
22255
+ return [
22256
+ `Unknown search ${isPlural ? "parameters" : "parameter"} for Immunization: ${codes}.`,
22257
+ `Valid codes: ${validCodes}.`
22258
+ ].join(" ");
22259
+ }
22260
+ function findMalformedReference6(query, searchParamKeys) {
22261
+ const referenceCodes = new Set(
22262
+ getRegisteredSearchParameters(IMMUNIZATION_RESOURCE_TYPE).filter((p) => p.type === "reference").map((p) => p.code)
22263
+ );
22264
+ for (const { rawKey, code } of searchParamKeys) {
22265
+ if (!referenceCodes.has(code)) {
22266
+ continue;
22267
+ }
22268
+ const raw = query[rawKey];
22269
+ const values = typeof raw === "string" ? raw.split(",") : Array.isArray(raw) ? raw.flatMap((v) => v.split(",")) : [];
22270
+ for (const v of values) {
22271
+ const trimmed = v.trim();
22272
+ if (trimmed.length === 0) {
22273
+ continue;
22274
+ }
22275
+ if (parseTypedReference(trimmed) === void 0) {
22276
+ return { rawKey, value: trimmed };
22277
+ }
22278
+ }
22279
+ }
22280
+ return void 0;
22281
+ }
22282
+ async function listImmunizationsRoute(req, res) {
22283
+ const searchParamKeys = extractSearchParamKeys6(
22284
+ req.query
22285
+ );
22286
+ if (searchParamKeys.length === 0) {
22287
+ return handleListRoute({
22288
+ req,
22289
+ res,
22290
+ basePath: BASE_PATH.IMMUNIZATION,
22291
+ listOperation: listImmunizationsOperation,
22292
+ errorLogContext: "GET /Immunization list error:"
22293
+ });
22294
+ }
22295
+ const registered = getRegisteredSearchParameters(IMMUNIZATION_RESOURCE_TYPE);
22296
+ const validCodes = new Set(registered.map((p) => p.code));
22297
+ const unknownCodes = searchParamKeys.map((k) => k.code).filter((code) => !validCodes.has(code));
22298
+ if (unknownCodes.length > 0) {
22299
+ return sendInvalidSearch4006(
22300
+ res,
22301
+ buildUnknownParamDiagnostics6([...new Set(unknownCodes)])
22302
+ );
22303
+ }
22304
+ const malformedRef = findMalformedReference6(
22305
+ req.query,
22306
+ searchParamKeys
22307
+ );
22308
+ if (malformedRef !== void 0) {
22309
+ return sendInvalidSearch4006(
22310
+ res,
22311
+ `?${malformedRef.rawKey} must be a typed reference like "Practitioner/<id>"; got "${malformedRef.value}".`
22312
+ );
22313
+ }
22314
+ const ctx = req.openhiContext;
22315
+ try {
22316
+ const result = await genericSearchOperation({
22317
+ resourceType: IMMUNIZATION_RESOURCE_TYPE,
22318
+ tenantId: ctx.tenantId,
22319
+ workspaceId: ctx.workspaceId,
22320
+ query: req.query,
22321
+ resolver: defaultSearchParameterResolver
22322
+ });
22323
+ const bundle = buildSearchsetBundle(BASE_PATH.IMMUNIZATION, result.entries);
22324
+ return res.json(bundle);
22325
+ } catch (err) {
22326
+ return sendOperationOutcome500(res, err, "GET /Immunization search error:");
22327
+ }
22328
+ }
22160
22329
 
22161
22330
  // src/data/operations/data/immunization/immunization-update-operation.ts
22162
22331
  async function updateImmunizationOperation(params) {
@@ -25629,15 +25798,119 @@ async function listMedicationRequestsOperation(params) {
25629
25798
  }
25630
25799
 
25631
25800
  // src/data/rest-api/routes/data/medicationrequest/medicationrequest-list-route.ts
25632
- async function listMedicationRequestsRoute(req, res) {
25633
- return handleListRoute({
25634
- req,
25635
- res,
25636
- basePath: BASE_PATH.MEDICATIONREQUEST,
25637
- listOperation: listMedicationRequestsOperation,
25638
- errorLogContext: "GET /MedicationRequest list error:"
25801
+ var MEDICATIONREQUEST_RESOURCE_TYPE = "MedicationRequest";
25802
+ function stripModifier7(key) {
25803
+ const idx = key.indexOf(":");
25804
+ return idx === -1 ? key : key.slice(0, idx);
25805
+ }
25806
+ function isResultParameter7(key) {
25807
+ return key.startsWith("_");
25808
+ }
25809
+ function sendInvalidSearch4007(res, diagnostics) {
25810
+ return res.status(400).json({
25811
+ resourceType: "OperationOutcome",
25812
+ issue: [{ severity: "error", code: "invalid", diagnostics }]
25639
25813
  });
25640
25814
  }
25815
+ function extractSearchParamKeys7(query) {
25816
+ const out = [];
25817
+ for (const rawKey of Object.keys(query)) {
25818
+ if (isResultParameter7(rawKey)) {
25819
+ continue;
25820
+ }
25821
+ out.push({ rawKey, code: stripModifier7(rawKey) });
25822
+ }
25823
+ return out;
25824
+ }
25825
+ function buildUnknownParamDiagnostics7(unknownCodes) {
25826
+ const validCodes = getRegisteredSearchParameters(
25827
+ MEDICATIONREQUEST_RESOURCE_TYPE
25828
+ ).map((p) => p.code).sort().join(", ");
25829
+ const codes = unknownCodes.join(", ");
25830
+ const isPlural = unknownCodes.length !== 1;
25831
+ return [
25832
+ `Unknown search ${isPlural ? "parameters" : "parameter"} for MedicationRequest: ${codes}.`,
25833
+ `Valid codes: ${validCodes}.`
25834
+ ].join(" ");
25835
+ }
25836
+ function findMalformedReference7(query, searchParamKeys) {
25837
+ const referenceCodes = new Set(
25838
+ getRegisteredSearchParameters(MEDICATIONREQUEST_RESOURCE_TYPE).filter((p) => p.type === "reference").map((p) => p.code)
25839
+ );
25840
+ for (const { rawKey, code } of searchParamKeys) {
25841
+ if (!referenceCodes.has(code)) {
25842
+ continue;
25843
+ }
25844
+ const raw = query[rawKey];
25845
+ const values = typeof raw === "string" ? raw.split(",") : Array.isArray(raw) ? raw.flatMap((v) => v.split(",")) : [];
25846
+ for (const v of values) {
25847
+ const trimmed = v.trim();
25848
+ if (trimmed.length === 0) {
25849
+ continue;
25850
+ }
25851
+ if (parseTypedReference(trimmed) === void 0) {
25852
+ return { rawKey, value: trimmed };
25853
+ }
25854
+ }
25855
+ }
25856
+ return void 0;
25857
+ }
25858
+ async function listMedicationRequestsRoute(req, res) {
25859
+ const searchParamKeys = extractSearchParamKeys7(
25860
+ req.query
25861
+ );
25862
+ if (searchParamKeys.length === 0) {
25863
+ return handleListRoute({
25864
+ req,
25865
+ res,
25866
+ basePath: BASE_PATH.MEDICATIONREQUEST,
25867
+ listOperation: listMedicationRequestsOperation,
25868
+ errorLogContext: "GET /MedicationRequest list error:"
25869
+ });
25870
+ }
25871
+ const registered = getRegisteredSearchParameters(
25872
+ MEDICATIONREQUEST_RESOURCE_TYPE
25873
+ );
25874
+ const validCodes = new Set(registered.map((p) => p.code));
25875
+ const unknownCodes = searchParamKeys.map((k) => k.code).filter((code) => !validCodes.has(code));
25876
+ if (unknownCodes.length > 0) {
25877
+ return sendInvalidSearch4007(
25878
+ res,
25879
+ buildUnknownParamDiagnostics7([...new Set(unknownCodes)])
25880
+ );
25881
+ }
25882
+ const malformedRef = findMalformedReference7(
25883
+ req.query,
25884
+ searchParamKeys
25885
+ );
25886
+ if (malformedRef !== void 0) {
25887
+ return sendInvalidSearch4007(
25888
+ res,
25889
+ `?${malformedRef.rawKey} must be a typed reference like "Practitioner/<id>"; got "${malformedRef.value}".`
25890
+ );
25891
+ }
25892
+ const ctx = req.openhiContext;
25893
+ try {
25894
+ const result = await genericSearchOperation({
25895
+ resourceType: MEDICATIONREQUEST_RESOURCE_TYPE,
25896
+ tenantId: ctx.tenantId,
25897
+ workspaceId: ctx.workspaceId,
25898
+ query: req.query,
25899
+ resolver: defaultSearchParameterResolver
25900
+ });
25901
+ const bundle = buildSearchsetBundle(
25902
+ BASE_PATH.MEDICATIONREQUEST,
25903
+ result.entries
25904
+ );
25905
+ return res.json(bundle);
25906
+ } catch (err) {
25907
+ return sendOperationOutcome500(
25908
+ res,
25909
+ err,
25910
+ "GET /MedicationRequest search error:"
25911
+ );
25912
+ }
25913
+ }
25641
25914
 
25642
25915
  // src/data/operations/data/medicationrequest/medicationrequest-update-operation.ts
25643
25916
  async function updateMedicationRequestOperation(params) {
@@ -25836,15 +26109,119 @@ async function listMedicationStatementsOperation(params) {
25836
26109
  }
25837
26110
 
25838
26111
  // src/data/rest-api/routes/data/medicationstatement/medicationstatement-list-route.ts
25839
- async function listMedicationStatementsRoute(req, res) {
25840
- return handleListRoute({
25841
- req,
25842
- res,
25843
- basePath: BASE_PATH.MEDICATIONSTATEMENT,
25844
- listOperation: listMedicationStatementsOperation,
25845
- errorLogContext: "GET /MedicationStatement list error:"
26112
+ var MEDICATIONSTATEMENT_RESOURCE_TYPE = "MedicationStatement";
26113
+ function stripModifier8(key) {
26114
+ const idx = key.indexOf(":");
26115
+ return idx === -1 ? key : key.slice(0, idx);
26116
+ }
26117
+ function isResultParameter8(key) {
26118
+ return key.startsWith("_");
26119
+ }
26120
+ function sendInvalidSearch4008(res, diagnostics) {
26121
+ return res.status(400).json({
26122
+ resourceType: "OperationOutcome",
26123
+ issue: [{ severity: "error", code: "invalid", diagnostics }]
25846
26124
  });
25847
26125
  }
26126
+ function extractSearchParamKeys8(query) {
26127
+ const out = [];
26128
+ for (const rawKey of Object.keys(query)) {
26129
+ if (isResultParameter8(rawKey)) {
26130
+ continue;
26131
+ }
26132
+ out.push({ rawKey, code: stripModifier8(rawKey) });
26133
+ }
26134
+ return out;
26135
+ }
26136
+ function buildUnknownParamDiagnostics8(unknownCodes) {
26137
+ const validCodes = getRegisteredSearchParameters(
26138
+ MEDICATIONSTATEMENT_RESOURCE_TYPE
26139
+ ).map((p) => p.code).sort().join(", ");
26140
+ const codes = unknownCodes.join(", ");
26141
+ const isPlural = unknownCodes.length !== 1;
26142
+ return [
26143
+ `Unknown search ${isPlural ? "parameters" : "parameter"} for MedicationStatement: ${codes}.`,
26144
+ `Valid codes: ${validCodes}.`
26145
+ ].join(" ");
26146
+ }
26147
+ function findMalformedReference8(query, searchParamKeys) {
26148
+ const referenceCodes = new Set(
26149
+ getRegisteredSearchParameters(MEDICATIONSTATEMENT_RESOURCE_TYPE).filter((p) => p.type === "reference").map((p) => p.code)
26150
+ );
26151
+ for (const { rawKey, code } of searchParamKeys) {
26152
+ if (!referenceCodes.has(code)) {
26153
+ continue;
26154
+ }
26155
+ const raw = query[rawKey];
26156
+ const values = typeof raw === "string" ? raw.split(",") : Array.isArray(raw) ? raw.flatMap((v) => v.split(",")) : [];
26157
+ for (const v of values) {
26158
+ const trimmed = v.trim();
26159
+ if (trimmed.length === 0) {
26160
+ continue;
26161
+ }
26162
+ if (parseTypedReference(trimmed) === void 0) {
26163
+ return { rawKey, value: trimmed };
26164
+ }
26165
+ }
26166
+ }
26167
+ return void 0;
26168
+ }
26169
+ async function listMedicationStatementsRoute(req, res) {
26170
+ const searchParamKeys = extractSearchParamKeys8(
26171
+ req.query
26172
+ );
26173
+ if (searchParamKeys.length === 0) {
26174
+ return handleListRoute({
26175
+ req,
26176
+ res,
26177
+ basePath: BASE_PATH.MEDICATIONSTATEMENT,
26178
+ listOperation: listMedicationStatementsOperation,
26179
+ errorLogContext: "GET /MedicationStatement list error:"
26180
+ });
26181
+ }
26182
+ const registered = getRegisteredSearchParameters(
26183
+ MEDICATIONSTATEMENT_RESOURCE_TYPE
26184
+ );
26185
+ const validCodes = new Set(registered.map((p) => p.code));
26186
+ const unknownCodes = searchParamKeys.map((k) => k.code).filter((code) => !validCodes.has(code));
26187
+ if (unknownCodes.length > 0) {
26188
+ return sendInvalidSearch4008(
26189
+ res,
26190
+ buildUnknownParamDiagnostics8([...new Set(unknownCodes)])
26191
+ );
26192
+ }
26193
+ const malformedRef = findMalformedReference8(
26194
+ req.query,
26195
+ searchParamKeys
26196
+ );
26197
+ if (malformedRef !== void 0) {
26198
+ return sendInvalidSearch4008(
26199
+ res,
26200
+ `?${malformedRef.rawKey} must be a typed reference like "Practitioner/<id>"; got "${malformedRef.value}".`
26201
+ );
26202
+ }
26203
+ const ctx = req.openhiContext;
26204
+ try {
26205
+ const result = await genericSearchOperation({
26206
+ resourceType: MEDICATIONSTATEMENT_RESOURCE_TYPE,
26207
+ tenantId: ctx.tenantId,
26208
+ workspaceId: ctx.workspaceId,
26209
+ query: req.query,
26210
+ resolver: defaultSearchParameterResolver
26211
+ });
26212
+ const bundle = buildSearchsetBundle(
26213
+ BASE_PATH.MEDICATIONSTATEMENT,
26214
+ result.entries
26215
+ );
26216
+ return res.json(bundle);
26217
+ } catch (err) {
26218
+ return sendOperationOutcome500(
26219
+ res,
26220
+ err,
26221
+ "GET /MedicationStatement search error:"
26222
+ );
26223
+ }
26224
+ }
25848
26225
 
25849
26226
  // src/data/operations/data/medicationstatement/medicationstatement-update-operation.ts
25850
26227
  async function updateMedicationStatementOperation(params) {
@@ -29235,30 +29612,30 @@ async function listObservationsOperation(params) {
29235
29612
 
29236
29613
  // src/data/rest-api/routes/data/observation/observation-list-route.ts
29237
29614
  var OBSERVATION_RESOURCE_TYPE = "Observation";
29238
- function stripModifier6(key) {
29615
+ function stripModifier9(key) {
29239
29616
  const idx = key.indexOf(":");
29240
29617
  return idx === -1 ? key : key.slice(0, idx);
29241
29618
  }
29242
- function isResultParameter6(key) {
29619
+ function isResultParameter9(key) {
29243
29620
  return key.startsWith("_");
29244
29621
  }
29245
- function sendInvalidSearch4006(res, diagnostics) {
29622
+ function sendInvalidSearch4009(res, diagnostics) {
29246
29623
  return res.status(400).json({
29247
29624
  resourceType: "OperationOutcome",
29248
29625
  issue: [{ severity: "error", code: "invalid", diagnostics }]
29249
29626
  });
29250
29627
  }
29251
- function extractSearchParamKeys6(query) {
29628
+ function extractSearchParamKeys9(query) {
29252
29629
  const out = [];
29253
29630
  for (const rawKey of Object.keys(query)) {
29254
- if (isResultParameter6(rawKey)) {
29631
+ if (isResultParameter9(rawKey)) {
29255
29632
  continue;
29256
29633
  }
29257
- out.push({ rawKey, code: stripModifier6(rawKey) });
29634
+ out.push({ rawKey, code: stripModifier9(rawKey) });
29258
29635
  }
29259
29636
  return out;
29260
29637
  }
29261
- function buildUnknownParamDiagnostics6(unknownCodes) {
29638
+ function buildUnknownParamDiagnostics9(unknownCodes) {
29262
29639
  const validCodes = getRegisteredSearchParameters(OBSERVATION_RESOURCE_TYPE).map((p) => p.code).sort().join(", ");
29263
29640
  const codes = unknownCodes.join(", ");
29264
29641
  const isPlural = unknownCodes.length !== 1;
@@ -29267,7 +29644,7 @@ function buildUnknownParamDiagnostics6(unknownCodes) {
29267
29644
  `Valid codes: ${validCodes}.`
29268
29645
  ].join(" ");
29269
29646
  }
29270
- function findMalformedReference6(query, searchParamKeys) {
29647
+ function findMalformedReference9(query, searchParamKeys) {
29271
29648
  const referenceCodes = new Set(
29272
29649
  getRegisteredSearchParameters(OBSERVATION_RESOURCE_TYPE).filter((p) => p.type === "reference").map((p) => p.code)
29273
29650
  );
@@ -29290,7 +29667,7 @@ function findMalformedReference6(query, searchParamKeys) {
29290
29667
  return void 0;
29291
29668
  }
29292
29669
  async function listObservationsRoute(req, res) {
29293
- const searchParamKeys = extractSearchParamKeys6(
29670
+ const searchParamKeys = extractSearchParamKeys9(
29294
29671
  req.query
29295
29672
  );
29296
29673
  if (searchParamKeys.length === 0) {
@@ -29306,17 +29683,17 @@ async function listObservationsRoute(req, res) {
29306
29683
  const validCodes = new Set(registered.map((p) => p.code));
29307
29684
  const unknownCodes = searchParamKeys.map((k) => k.code).filter((code) => !validCodes.has(code));
29308
29685
  if (unknownCodes.length > 0) {
29309
- return sendInvalidSearch4006(
29686
+ return sendInvalidSearch4009(
29310
29687
  res,
29311
- buildUnknownParamDiagnostics6([...new Set(unknownCodes)])
29688
+ buildUnknownParamDiagnostics9([...new Set(unknownCodes)])
29312
29689
  );
29313
29690
  }
29314
- const malformedRef = findMalformedReference6(
29691
+ const malformedRef = findMalformedReference9(
29315
29692
  req.query,
29316
29693
  searchParamKeys
29317
29694
  );
29318
29695
  if (malformedRef !== void 0) {
29319
- return sendInvalidSearch4006(
29696
+ return sendInvalidSearch4009(
29320
29697
  res,
29321
29698
  `?${malformedRef.rawKey} must be a typed reference like "Practitioner/<id>"; got "${malformedRef.value}".`
29322
29699
  );
@@ -30346,30 +30723,30 @@ async function listPatientsOperation(params) {
30346
30723
 
30347
30724
  // src/data/rest-api/routes/data/patient/patient-list-route.ts
30348
30725
  var PATIENT_RESOURCE_TYPE = "Patient";
30349
- function stripModifier7(key) {
30726
+ function stripModifier10(key) {
30350
30727
  const idx = key.indexOf(":");
30351
30728
  return idx === -1 ? key : key.slice(0, idx);
30352
30729
  }
30353
- function isResultParameter7(key) {
30730
+ function isResultParameter10(key) {
30354
30731
  return key.startsWith("_");
30355
30732
  }
30356
- function sendInvalidSearch4007(res, diagnostics) {
30733
+ function sendInvalidSearch40010(res, diagnostics) {
30357
30734
  return res.status(400).json({
30358
30735
  resourceType: "OperationOutcome",
30359
30736
  issue: [{ severity: "error", code: "invalid", diagnostics }]
30360
30737
  });
30361
30738
  }
30362
- function extractSearchParamKeys7(query) {
30739
+ function extractSearchParamKeys10(query) {
30363
30740
  const out = [];
30364
30741
  for (const rawKey of Object.keys(query)) {
30365
- if (isResultParameter7(rawKey)) {
30742
+ if (isResultParameter10(rawKey)) {
30366
30743
  continue;
30367
30744
  }
30368
- out.push({ rawKey, code: stripModifier7(rawKey) });
30745
+ out.push({ rawKey, code: stripModifier10(rawKey) });
30369
30746
  }
30370
30747
  return out;
30371
30748
  }
30372
- function buildUnknownParamDiagnostics7(unknownCodes) {
30749
+ function buildUnknownParamDiagnostics10(unknownCodes) {
30373
30750
  const validCodes = getRegisteredSearchParameters(PATIENT_RESOURCE_TYPE).map((p) => p.code).sort().join(", ");
30374
30751
  const codes = unknownCodes.join(", ");
30375
30752
  const isPlural = unknownCodes.length !== 1;
@@ -30378,7 +30755,7 @@ function buildUnknownParamDiagnostics7(unknownCodes) {
30378
30755
  `Valid codes: ${validCodes}.`
30379
30756
  ].join(" ");
30380
30757
  }
30381
- function findMalformedReference7(query, searchParamKeys) {
30758
+ function findMalformedReference10(query, searchParamKeys) {
30382
30759
  const referenceCodes = new Set(
30383
30760
  getRegisteredSearchParameters(PATIENT_RESOURCE_TYPE).filter((p) => p.type === "reference").map((p) => p.code)
30384
30761
  );
@@ -30401,7 +30778,7 @@ function findMalformedReference7(query, searchParamKeys) {
30401
30778
  return void 0;
30402
30779
  }
30403
30780
  async function listPatientsRoute(req, res) {
30404
- const searchParamKeys = extractSearchParamKeys7(
30781
+ const searchParamKeys = extractSearchParamKeys10(
30405
30782
  req.query
30406
30783
  );
30407
30784
  if (searchParamKeys.length === 0) {
@@ -30417,17 +30794,17 @@ async function listPatientsRoute(req, res) {
30417
30794
  const validCodes = new Set(registered.map((p) => p.code));
30418
30795
  const unknownCodes = searchParamKeys.map((k) => k.code).filter((code) => !validCodes.has(code));
30419
30796
  if (unknownCodes.length > 0) {
30420
- return sendInvalidSearch4007(
30797
+ return sendInvalidSearch40010(
30421
30798
  res,
30422
- buildUnknownParamDiagnostics7([...new Set(unknownCodes)])
30799
+ buildUnknownParamDiagnostics10([...new Set(unknownCodes)])
30423
30800
  );
30424
30801
  }
30425
- const malformedRef = findMalformedReference7(
30802
+ const malformedRef = findMalformedReference10(
30426
30803
  req.query,
30427
30804
  searchParamKeys
30428
30805
  );
30429
30806
  if (malformedRef !== void 0) {
30430
- return sendInvalidSearch4007(
30807
+ return sendInvalidSearch40010(
30431
30808
  res,
30432
30809
  `?${malformedRef.rawKey} must be a typed reference like "Practitioner/<id>"; got "${malformedRef.value}".`
30433
30810
  );
@@ -31802,30 +32179,30 @@ async function listProceduresOperation(params) {
31802
32179
 
31803
32180
  // src/data/rest-api/routes/data/procedure/procedure-list-route.ts
31804
32181
  var PROCEDURE_RESOURCE_TYPE = "Procedure";
31805
- function stripModifier8(key) {
32182
+ function stripModifier11(key) {
31806
32183
  const idx = key.indexOf(":");
31807
32184
  return idx === -1 ? key : key.slice(0, idx);
31808
32185
  }
31809
- function isResultParameter8(key) {
32186
+ function isResultParameter11(key) {
31810
32187
  return key.startsWith("_");
31811
32188
  }
31812
- function sendInvalidSearch4008(res, diagnostics) {
32189
+ function sendInvalidSearch40011(res, diagnostics) {
31813
32190
  return res.status(400).json({
31814
32191
  resourceType: "OperationOutcome",
31815
32192
  issue: [{ severity: "error", code: "invalid", diagnostics }]
31816
32193
  });
31817
32194
  }
31818
- function extractSearchParamKeys8(query) {
32195
+ function extractSearchParamKeys11(query) {
31819
32196
  const out = [];
31820
32197
  for (const rawKey of Object.keys(query)) {
31821
- if (isResultParameter8(rawKey)) {
32198
+ if (isResultParameter11(rawKey)) {
31822
32199
  continue;
31823
32200
  }
31824
- out.push({ rawKey, code: stripModifier8(rawKey) });
32201
+ out.push({ rawKey, code: stripModifier11(rawKey) });
31825
32202
  }
31826
32203
  return out;
31827
32204
  }
31828
- function buildUnknownParamDiagnostics8(unknownCodes) {
32205
+ function buildUnknownParamDiagnostics11(unknownCodes) {
31829
32206
  const validCodes = getRegisteredSearchParameters(PROCEDURE_RESOURCE_TYPE).map((p) => p.code).sort().join(", ");
31830
32207
  const codes = unknownCodes.join(", ");
31831
32208
  const isPlural = unknownCodes.length !== 1;
@@ -31834,7 +32211,7 @@ function buildUnknownParamDiagnostics8(unknownCodes) {
31834
32211
  `Valid codes: ${validCodes}.`
31835
32212
  ].join(" ");
31836
32213
  }
31837
- function findMalformedReference8(query, searchParamKeys) {
32214
+ function findMalformedReference11(query, searchParamKeys) {
31838
32215
  const referenceCodes = new Set(
31839
32216
  getRegisteredSearchParameters(PROCEDURE_RESOURCE_TYPE).filter((p) => p.type === "reference").map((p) => p.code)
31840
32217
  );
@@ -31857,7 +32234,7 @@ function findMalformedReference8(query, searchParamKeys) {
31857
32234
  return void 0;
31858
32235
  }
31859
32236
  async function listProceduresRoute(req, res) {
31860
- const searchParamKeys = extractSearchParamKeys8(
32237
+ const searchParamKeys = extractSearchParamKeys11(
31861
32238
  req.query
31862
32239
  );
31863
32240
  if (searchParamKeys.length === 0) {
@@ -31873,17 +32250,17 @@ async function listProceduresRoute(req, res) {
31873
32250
  const validCodes = new Set(registered.map((p) => p.code));
31874
32251
  const unknownCodes = searchParamKeys.map((k) => k.code).filter((code) => !validCodes.has(code));
31875
32252
  if (unknownCodes.length > 0) {
31876
- return sendInvalidSearch4008(
32253
+ return sendInvalidSearch40011(
31877
32254
  res,
31878
- buildUnknownParamDiagnostics8([...new Set(unknownCodes)])
32255
+ buildUnknownParamDiagnostics11([...new Set(unknownCodes)])
31879
32256
  );
31880
32257
  }
31881
- const malformedRef = findMalformedReference8(
32258
+ const malformedRef = findMalformedReference11(
31882
32259
  req.query,
31883
32260
  searchParamKeys
31884
32261
  );
31885
32262
  if (malformedRef !== void 0) {
31886
- return sendInvalidSearch4008(
32263
+ return sendInvalidSearch40011(
31887
32264
  res,
31888
32265
  `?${malformedRef.rawKey} must be a typed reference like "Practitioner/<id>"; got "${malformedRef.value}".`
31889
32266
  );
@@ -34410,7 +34787,7 @@ function singleStringQueryParam(req, name) {
34410
34787
  const trimmed = v.trim();
34411
34788
  return trimmed === "" ? void 0 : trimmed;
34412
34789
  }
34413
- function sendInvalidSearch4009(res, diagnostics) {
34790
+ function sendInvalidSearch40012(res, diagnostics) {
34414
34791
  return res.status(400).json({
34415
34792
  resourceType: "OperationOutcome",
34416
34793
  issue: [{ severity: "error", code: "invalid", diagnostics }]
@@ -34420,7 +34797,7 @@ async function listSchedulesRoute(req, res) {
34420
34797
  const actorRef = singleStringQueryParam(req, "actor");
34421
34798
  if (actorRef !== void 0) {
34422
34799
  if (parseTypedReference(actorRef) === void 0) {
34423
- return sendInvalidSearch4009(
34800
+ return sendInvalidSearch40012(
34424
34801
  res,
34425
34802
  `?actor must be a typed reference like "Practitioner/<id>"; got "${actorRef}".`
34426
34803
  );
@@ -38218,7 +38595,7 @@ function singleStringQueryParam2(req, name) {
38218
38595
  const trimmed = v.trim();
38219
38596
  return trimmed === "" ? void 0 : trimmed;
38220
38597
  }
38221
- function sendInvalidSearch40010(res, diagnostics) {
38598
+ function sendInvalidSearch40013(res, diagnostics) {
38222
38599
  return res.status(400).json({
38223
38600
  resourceType: "OperationOutcome",
38224
38601
  issue: [{ severity: "error", code: "invalid", diagnostics }]
@@ -38228,14 +38605,14 @@ async function listTasksRoute(req, res) {
38228
38605
  const ownerRef = singleStringQueryParam2(req, "owner");
38229
38606
  const requesterRef = singleStringQueryParam2(req, "requester");
38230
38607
  if (ownerRef !== void 0 && requesterRef !== void 0) {
38231
- return sendInvalidSearch40010(
38608
+ return sendInvalidSearch40013(
38232
38609
  res,
38233
38610
  "?owner= and ?requester= cannot be combined on the same request."
38234
38611
  );
38235
38612
  }
38236
38613
  if (ownerRef !== void 0) {
38237
38614
  if (parseTypedReference(ownerRef) === void 0) {
38238
- return sendInvalidSearch40010(
38615
+ return sendInvalidSearch40013(
38239
38616
  res,
38240
38617
  `?owner must be a typed reference like "Practitioner/<id>"; got "${ownerRef}".`
38241
38618
  );
@@ -38258,7 +38635,7 @@ async function listTasksRoute(req, res) {
38258
38635
  }
38259
38636
  if (requesterRef !== void 0) {
38260
38637
  if (parseTypedReference(requesterRef) === void 0) {
38261
- return sendInvalidSearch40010(
38638
+ return sendInvalidSearch40013(
38262
38639
  res,
38263
38640
  `?requester must be a typed reference like "Practitioner/<id>"; got "${requesterRef}".`
38264
38641
  );