@openhi/constructs 0.0.142 → 0.0.144

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.
@@ -9399,206 +9399,6 @@ async function listAllergyIntolerancesOperation(params) {
9399
9399
  );
9400
9400
  }
9401
9401
 
9402
- // src/data/rest-api/routes/data/allergyintolerance/allergyintolerance-list-route.ts
9403
- async function listAllergyIntolerancesRoute(req, res) {
9404
- return handleListRoute({
9405
- req,
9406
- res,
9407
- basePath: BASE_PATH.ALLERGYINTOLERANCE,
9408
- listOperation: listAllergyIntolerancesOperation,
9409
- errorLogContext: "GET /AllergyIntolerance list error:"
9410
- });
9411
- }
9412
-
9413
- // src/data/operations/data/allergyintolerance/allergyintolerance-update-operation.ts
9414
- async function updateAllergyIntoleranceOperation(params) {
9415
- const { context, id, body, tableName } = params;
9416
- const { tenantId, workspaceId, date, actorId, actorName } = context;
9417
- const service = getDynamoDataService(tableName);
9418
- return updateDataEntityById(
9419
- service.entities.allergyintolerance,
9420
- tenantId,
9421
- workspaceId,
9422
- id,
9423
- "AllergyIntolerance",
9424
- context,
9425
- (existingResourceStr) => buildUpdatedResourceWithAudit(
9426
- body,
9427
- id,
9428
- date,
9429
- actorId,
9430
- actorName,
9431
- existingResourceStr,
9432
- "AllergyIntolerance"
9433
- )
9434
- );
9435
- }
9436
-
9437
- // src/data/rest-api/routes/data/allergyintolerance/allergyintolerance-update-route.ts
9438
- async function updateAllergyIntoleranceRoute(req, res) {
9439
- const bodyResult = requireJsonBodyAs(req, res);
9440
- if ("errorResponse" in bodyResult) return bodyResult.errorResponse;
9441
- const id = String(req.params.id);
9442
- const ctx = req.openhiContext;
9443
- const body = bodyResult.body;
9444
- const resource = {
9445
- ...body,
9446
- resourceType: "AllergyIntolerance",
9447
- id
9448
- };
9449
- try {
9450
- const result = await updateAllergyIntoleranceOperation({
9451
- context: ctx,
9452
- id,
9453
- body: resource
9454
- });
9455
- return res.json(result.resource);
9456
- } catch (err) {
9457
- const status = domainErrorToHttpStatus(err);
9458
- if (status === 404) {
9459
- const diagnostics = err instanceof NotFoundError ? err.message : `AllergyIntolerance ${id} not found`;
9460
- return sendOperationOutcome404(res, diagnostics);
9461
- }
9462
- return sendOperationOutcome500(res, err, "PUT AllergyIntolerance error:");
9463
- }
9464
- }
9465
-
9466
- // src/data/rest-api/routes/data/allergyintolerance/allergyintolerance.ts
9467
- var router13 = import_express13.default.Router();
9468
- router13.get("/", listAllergyIntolerancesRoute);
9469
- router13.get("/:id", getAllergyIntoleranceByIdRoute);
9470
- router13.post("/", createAllergyIntoleranceRoute);
9471
- router13.put("/:id", updateAllergyIntoleranceRoute);
9472
- router13.delete("/:id", deleteAllergyIntoleranceRoute);
9473
-
9474
- // src/data/rest-api/routes/data/appointment/appointment.ts
9475
- var import_express14 = __toESM(require("express"));
9476
-
9477
- // src/data/operations/data/appointment/appointment-create-operation.ts
9478
- var import_ulid6 = require("ulid");
9479
- async function createAppointmentOperation(params) {
9480
- const { context, body, tableName } = params;
9481
- const { tenantId, workspaceId, date, actorId, actorName } = context;
9482
- const id = body.id ?? (0, import_ulid6.ulid)();
9483
- const meta = {
9484
- ...body.meta ?? {},
9485
- lastUpdated: date,
9486
- versionId: "1"
9487
- };
9488
- const resourceWithAudit = {
9489
- ...body,
9490
- resourceType: "Appointment",
9491
- id,
9492
- meta: mergeAuditIntoMeta(meta, {
9493
- createdDate: date,
9494
- createdById: actorId,
9495
- createdByName: actorName,
9496
- modifiedDate: date,
9497
- modifiedById: actorId,
9498
- modifiedByName: actorName
9499
- })
9500
- };
9501
- const service = getDynamoDataService(tableName);
9502
- return createDataEntityRecord(
9503
- service.entities.appointment,
9504
- tenantId,
9505
- workspaceId,
9506
- id,
9507
- resourceWithAudit,
9508
- date
9509
- );
9510
- }
9511
-
9512
- // src/data/rest-api/routes/data/appointment/appointment-create-route.ts
9513
- async function createAppointmentRoute(req, res) {
9514
- const bodyResult = requireJsonBodyAs(req, res);
9515
- if ("errorResponse" in bodyResult) return bodyResult.errorResponse;
9516
- const ctx = req.openhiContext;
9517
- const body = bodyResult.body;
9518
- const resource = {
9519
- ...body,
9520
- resourceType: "Appointment"
9521
- };
9522
- try {
9523
- const result = await createAppointmentOperation({
9524
- context: ctx,
9525
- body: resource
9526
- });
9527
- return res.status(201).location(`${BASE_PATH.APPOINTMENT}/${result.id}`).json(result.resource);
9528
- } catch (err) {
9529
- return sendOperationOutcome500(res, err, "POST Appointment error:");
9530
- }
9531
- }
9532
-
9533
- // src/data/operations/data/appointment/appointment-delete-operation.ts
9534
- async function deleteAppointmentOperation(params) {
9535
- const { context, id, tableName } = params;
9536
- const { tenantId, workspaceId } = context;
9537
- const service = getDynamoDataService(tableName);
9538
- await deleteDataEntityById(
9539
- service.entities.appointment,
9540
- tenantId,
9541
- workspaceId,
9542
- id
9543
- );
9544
- }
9545
-
9546
- // src/data/rest-api/routes/data/appointment/appointment-delete-route.ts
9547
- async function deleteAppointmentRoute(req, res) {
9548
- const id = String(req.params.id);
9549
- const ctx = req.openhiContext;
9550
- try {
9551
- await deleteAppointmentOperation({ context: ctx, id });
9552
- return res.status(204).send();
9553
- } catch (err) {
9554
- return sendOperationOutcome500(res, err, "DELETE Appointment error:");
9555
- }
9556
- }
9557
-
9558
- // src/data/operations/data/appointment/appointment-get-by-id-operation.ts
9559
- async function getAppointmentByIdOperation(params) {
9560
- const { context, id, tableName } = params;
9561
- const { tenantId, workspaceId } = context;
9562
- const service = getDynamoDataService(tableName);
9563
- return getDataEntityById(
9564
- service.entities.appointment,
9565
- tenantId,
9566
- workspaceId,
9567
- id,
9568
- "Appointment"
9569
- );
9570
- }
9571
-
9572
- // src/data/rest-api/routes/data/appointment/appointment-get-by-id-route.ts
9573
- async function getAppointmentByIdRoute(req, res) {
9574
- const id = String(req.params.id);
9575
- const ctx = req.openhiContext;
9576
- try {
9577
- const result = await getAppointmentByIdOperation({ context: ctx, id });
9578
- return res.json(result.resource);
9579
- } catch (err) {
9580
- const status = domainErrorToHttpStatus(err);
9581
- if (status === 404) {
9582
- const diagnostics = err instanceof NotFoundError ? err.message : `Appointment ${id} not found`;
9583
- return sendOperationOutcome404(res, diagnostics);
9584
- }
9585
- return sendOperationOutcome500(res, err, "GET Appointment error:");
9586
- }
9587
- }
9588
-
9589
- // src/data/operations/data/appointment/appointment-list-operation.ts
9590
- async function listAppointmentsOperation(params) {
9591
- const { context, tableName, mode } = params;
9592
- const { tenantId, workspaceId } = context;
9593
- const service = getDynamoDataService(tableName);
9594
- return listDataEntitiesByWorkspace(
9595
- service.entities.appointment,
9596
- tenantId,
9597
- workspaceId,
9598
- mode
9599
- );
9600
- }
9601
-
9602
9402
  // src/data/search/engine/reference-predicate.ts
9603
9403
  function buildOpenHiResourceUrn(opts) {
9604
9404
  return `urn:ohi:${opts.tenantId}:${opts.workspaceId}:${opts.resourceType}:${opts.resourceId}`;
@@ -10252,6 +10052,30 @@ async function genericSearchOperation(params) {
10252
10052
  return { entries, total: entries.length };
10253
10053
  }
10254
10054
 
10055
+ // src/data/search/registry/allergyintolerance-search-parameters.ts
10056
+ var ALLERGYINTOLERANCE_SEARCH_PARAMETERS = [
10057
+ {
10058
+ code: "clinical-status",
10059
+ type: "token",
10060
+ jsonbPath: "$.clinicalStatus"
10061
+ },
10062
+ {
10063
+ code: "verification-status",
10064
+ type: "token",
10065
+ jsonbPath: "$.verificationStatus"
10066
+ },
10067
+ { code: "type", type: "token", jsonbPath: "$.type" },
10068
+ { code: "category", type: "token", jsonbPath: "$.category[*]" },
10069
+ { code: "criticality", type: "token", jsonbPath: "$.criticality" },
10070
+ { code: "code", type: "token", jsonbPath: "$.code" },
10071
+ { code: "patient", type: "reference", jsonbPath: "$.patient" },
10072
+ { code: "recorder", type: "reference", jsonbPath: "$.recorder" },
10073
+ { code: "asserter", type: "reference", jsonbPath: "$.asserter" },
10074
+ { code: "date", type: "date", jsonbPath: "$.recordedDate" },
10075
+ { code: "last-date", type: "date", jsonbPath: "$.lastOccurrence" },
10076
+ { code: "identifier", type: "token", jsonbPath: "$.identifier[*]" }
10077
+ ];
10078
+
10255
10079
  // src/data/search/registry/appointment-search-parameters.ts
10256
10080
  var APPOINTMENT_SEARCH_PARAMETERS = [
10257
10081
  { code: "status", type: "token", jsonbPath: "$.status" },
@@ -10286,6 +10110,32 @@ var APPOINTMENT_SEARCH_PARAMETERS = [
10286
10110
  { code: "slot", type: "reference", jsonbPath: "$.slot[*]" }
10287
10111
  ];
10288
10112
 
10113
+ // src/data/search/registry/condition-search-parameters.ts
10114
+ var CONDITION_SEARCH_PARAMETERS = [
10115
+ {
10116
+ code: "clinical-status",
10117
+ type: "token",
10118
+ jsonbPath: "$.clinicalStatus"
10119
+ },
10120
+ {
10121
+ code: "verification-status",
10122
+ type: "token",
10123
+ jsonbPath: "$.verificationStatus"
10124
+ },
10125
+ { code: "category", type: "token", jsonbPath: "$.category[*]" },
10126
+ { code: "severity", type: "token", jsonbPath: "$.severity" },
10127
+ { code: "code", type: "token", jsonbPath: "$.code" },
10128
+ { code: "subject", type: "reference", jsonbPath: "$.subject" },
10129
+ { code: "patient", type: "reference", jsonbPath: "$.subject" },
10130
+ { code: "encounter", type: "reference", jsonbPath: "$.encounter" },
10131
+ { code: "asserter", type: "reference", jsonbPath: "$.asserter" },
10132
+ { code: "recorder", type: "reference", jsonbPath: "$.recorder" },
10133
+ { code: "onset-date", type: "date", jsonbPath: "$.onsetDateTime" },
10134
+ { code: "recorded-date", type: "date", jsonbPath: "$.recordedDate" },
10135
+ { code: "body-site", type: "token", jsonbPath: "$.bodySite[*]" },
10136
+ { code: "identifier", type: "token", jsonbPath: "$.identifier[*]" }
10137
+ ];
10138
+
10289
10139
  // src/data/search/registry/encounter-search-parameters.ts
10290
10140
  var ENCOUNTER_SEARCH_PARAMETERS = [
10291
10141
  { code: "status", type: "token", jsonbPath: "$.status" },
@@ -10312,129 +10162,516 @@ var ENCOUNTER_SEARCH_PARAMETERS = [
10312
10162
  }
10313
10163
  ];
10314
10164
 
10315
- // src/data/search/registry/observation-search-parameters.ts
10316
- var OBSERVATION_SEARCH_PARAMETERS = [
10165
+ // src/data/search/registry/familymemberhistory-search-parameters.ts
10166
+ var FAMILYMEMBERHISTORY_SEARCH_PARAMETERS = [
10167
+ { code: "status", type: "token", jsonbPath: "$.status" },
10168
+ { code: "relationship", type: "token", jsonbPath: "$.relationship" },
10169
+ { code: "sex", type: "token", jsonbPath: "$.sex" },
10170
+ { code: "patient", type: "reference", jsonbPath: "$.patient" },
10171
+ { code: "date", type: "date", jsonbPath: "$.date" },
10172
+ { code: "code", type: "token", jsonbPath: "$.condition[*]" },
10173
+ { code: "identifier", type: "token", jsonbPath: "$.identifier[*]" }
10174
+ ];
10175
+
10176
+ // src/data/search/registry/immunization-search-parameters.ts
10177
+ var IMMUNIZATION_SEARCH_PARAMETERS = [
10178
+ { code: "status", type: "token", jsonbPath: "$.status" },
10179
+ { code: "status-reason", type: "token", jsonbPath: "$.statusReason" },
10180
+ { code: "vaccine-code", type: "token", jsonbPath: "$.vaccineCode" },
10181
+ { code: "patient", type: "reference", jsonbPath: "$.patient" },
10182
+ { code: "date", type: "date", jsonbPath: "$.occurrenceDateTime" },
10183
+ { code: "performer", type: "reference", jsonbPath: "$.performer[*].actor" },
10184
+ { code: "location", type: "reference", jsonbPath: "$.location" },
10185
+ {
10186
+ code: "lot-number",
10187
+ type: "string",
10188
+ jsonbPath: "$.lotNumber",
10189
+ modifiers: ["exact", "contains", "missing", "not"]
10190
+ },
10191
+ { code: "manufacturer", type: "reference", jsonbPath: "$.manufacturer" },
10192
+ { code: "reaction", type: "reference", jsonbPath: "$.reaction[*].detail" },
10193
+ { code: "reason-code", type: "token", jsonbPath: "$.reasonCode[*]" },
10194
+ {
10195
+ code: "reason-reference",
10196
+ type: "reference",
10197
+ jsonbPath: "$.reasonReference[*]"
10198
+ },
10199
+ { code: "identifier", type: "token", jsonbPath: "$.identifier[*]" }
10200
+ ];
10201
+
10202
+ // src/data/search/registry/medicationrequest-search-parameters.ts
10203
+ var MEDICATIONREQUEST_SEARCH_PARAMETERS = [
10317
10204
  { code: "status", type: "token", jsonbPath: "$.status" },
10205
+ { code: "intent", type: "token", jsonbPath: "$.intent" },
10318
10206
  { code: "category", type: "token", jsonbPath: "$.category[*]" },
10319
- { code: "code", type: "token", jsonbPath: "$.code" },
10207
+ { code: "priority", type: "token", jsonbPath: "$.priority" },
10208
+ { code: "code", type: "token", jsonbPath: "$.medicationCodeableConcept" },
10320
10209
  { code: "subject", type: "reference", jsonbPath: "$.subject" },
10321
10210
  { code: "patient", type: "reference", jsonbPath: "$.subject" },
10322
10211
  { code: "encounter", type: "reference", jsonbPath: "$.encounter" },
10323
- { code: "performer", type: "reference", jsonbPath: "$.performer[*]" },
10324
- { code: "date", type: "date", jsonbPath: "$.effectiveDateTime" },
10212
+ { code: "authored-on", type: "date", jsonbPath: "$.authoredOn" },
10213
+ { code: "requester", type: "reference", jsonbPath: "$.requester" },
10214
+ { code: "performer", type: "reference", jsonbPath: "$.performer" },
10215
+ { code: "identifier", type: "token", jsonbPath: "$.identifier[*]" }
10216
+ ];
10217
+
10218
+ // src/data/search/registry/medicationstatement-search-parameters.ts
10219
+ var MEDICATIONSTATEMENT_SEARCH_PARAMETERS = [
10220
+ { code: "status", type: "token", jsonbPath: "$.status" },
10221
+ { code: "category", type: "token", jsonbPath: "$.category" },
10222
+ { code: "code", type: "token", jsonbPath: "$.medicationCodeableConcept" },
10223
+ { code: "subject", type: "reference", jsonbPath: "$.subject" },
10224
+ { code: "patient", type: "reference", jsonbPath: "$.subject" },
10225
+ { code: "context", type: "reference", jsonbPath: "$.context" },
10226
+ { code: "effective", type: "date", jsonbPath: "$.effectiveDateTime" },
10325
10227
  {
10326
- code: "value-string",
10327
- type: "string",
10328
- jsonbPath: "$.valueString",
10329
- modifiers: ["exact", "contains", "missing", "not"]
10228
+ code: "information-source",
10229
+ type: "reference",
10230
+ jsonbPath: "$.informationSource"
10231
+ },
10232
+ {
10233
+ code: "medication",
10234
+ type: "reference",
10235
+ jsonbPath: "$.medicationReference"
10236
+ },
10237
+ { code: "source", type: "reference", jsonbPath: "$.informationSource" },
10238
+ { code: "identifier", type: "token", jsonbPath: "$.identifier[*]" },
10239
+ { code: "part-of", type: "reference", jsonbPath: "$.partOf[*]" }
10240
+ ];
10241
+
10242
+ // src/data/search/registry/observation-search-parameters.ts
10243
+ var OBSERVATION_SEARCH_PARAMETERS = [
10244
+ { code: "status", type: "token", jsonbPath: "$.status" },
10245
+ { code: "category", type: "token", jsonbPath: "$.category[*]" },
10246
+ { code: "code", type: "token", jsonbPath: "$.code" },
10247
+ { code: "subject", type: "reference", jsonbPath: "$.subject" },
10248
+ { code: "patient", type: "reference", jsonbPath: "$.subject" },
10249
+ { code: "encounter", type: "reference", jsonbPath: "$.encounter" },
10250
+ { code: "performer", type: "reference", jsonbPath: "$.performer[*]" },
10251
+ { code: "date", type: "date", jsonbPath: "$.effectiveDateTime" },
10252
+ {
10253
+ code: "value-string",
10254
+ type: "string",
10255
+ jsonbPath: "$.valueString",
10256
+ modifiers: ["exact", "contains", "missing", "not"]
10330
10257
  },
10331
10258
  { code: "identifier", type: "token", jsonbPath: "$.identifier[*]" },
10332
10259
  { code: "based-on", type: "reference", jsonbPath: "$.basedOn[*]" },
10333
10260
  { code: "part-of", type: "reference", jsonbPath: "$.partOf[*]" }
10334
10261
  ];
10335
10262
 
10336
- // src/data/search/registry/patient-search-parameters.ts
10337
- var PATIENT_SEARCH_PARAMETERS = [
10338
- { code: "gender", type: "token", jsonbPath: "$.gender" },
10339
- { code: "identifier", type: "token", jsonbPath: "$.identifier[*].value" },
10340
- { code: "birthdate", type: "date", jsonbPath: "$.birthDate" },
10341
- {
10342
- code: "name",
10343
- type: "string",
10344
- jsonbPath: "$.name[*].text",
10345
- modifiers: ["exact", "contains", "missing", "not"]
10346
- },
10347
- {
10348
- code: "family",
10349
- type: "string",
10350
- jsonbPath: "$.name[*].family",
10351
- modifiers: ["exact", "contains", "missing", "not"]
10352
- },
10353
- {
10354
- code: "given",
10355
- type: "string",
10356
- jsonbPath: "$.name[*].given",
10357
- modifiers: ["exact", "contains", "missing", "not"]
10358
- },
10359
- { code: "active", type: "token", jsonbPath: "$.active" },
10360
- { code: "deceased", type: "token", jsonbPath: "$.deceasedBoolean" },
10361
- {
10362
- code: "general-practitioner",
10363
- type: "reference",
10364
- jsonbPath: "$.generalPractitioner[*]"
10365
- },
10366
- {
10367
- code: "organization",
10368
- type: "reference",
10369
- jsonbPath: "$.managingOrganization"
10263
+ // src/data/search/registry/patient-search-parameters.ts
10264
+ var PATIENT_SEARCH_PARAMETERS = [
10265
+ { code: "gender", type: "token", jsonbPath: "$.gender" },
10266
+ { code: "identifier", type: "token", jsonbPath: "$.identifier[*].value" },
10267
+ { code: "birthdate", type: "date", jsonbPath: "$.birthDate" },
10268
+ {
10269
+ code: "name",
10270
+ type: "string",
10271
+ jsonbPath: "$.name[*].text",
10272
+ modifiers: ["exact", "contains", "missing", "not"]
10273
+ },
10274
+ {
10275
+ code: "family",
10276
+ type: "string",
10277
+ jsonbPath: "$.name[*].family",
10278
+ modifiers: ["exact", "contains", "missing", "not"]
10279
+ },
10280
+ {
10281
+ code: "given",
10282
+ type: "string",
10283
+ jsonbPath: "$.name[*].given",
10284
+ modifiers: ["exact", "contains", "missing", "not"]
10285
+ },
10286
+ { code: "active", type: "token", jsonbPath: "$.active" },
10287
+ { code: "deceased", type: "token", jsonbPath: "$.deceasedBoolean" },
10288
+ {
10289
+ code: "general-practitioner",
10290
+ type: "reference",
10291
+ jsonbPath: "$.generalPractitioner[*]"
10292
+ },
10293
+ {
10294
+ code: "organization",
10295
+ type: "reference",
10296
+ jsonbPath: "$.managingOrganization"
10297
+ }
10298
+ ];
10299
+
10300
+ // src/data/search/registry/procedure-search-parameters.ts
10301
+ var PROCEDURE_SEARCH_PARAMETERS = [
10302
+ { code: "status", type: "token", jsonbPath: "$.status" },
10303
+ { code: "category", type: "token", jsonbPath: "$.category" },
10304
+ { code: "code", type: "token", jsonbPath: "$.code" },
10305
+ { code: "subject", type: "reference", jsonbPath: "$.subject" },
10306
+ { code: "patient", type: "reference", jsonbPath: "$.subject" },
10307
+ { code: "encounter", type: "reference", jsonbPath: "$.encounter" },
10308
+ {
10309
+ code: "performer",
10310
+ type: "reference",
10311
+ jsonbPath: "$.performer[*].actor"
10312
+ },
10313
+ { code: "date", type: "date", jsonbPath: "$.performedDateTime" },
10314
+ { code: "location", type: "reference", jsonbPath: "$.location" },
10315
+ { code: "identifier", type: "token", jsonbPath: "$.identifier[*]" },
10316
+ { code: "based-on", type: "reference", jsonbPath: "$.basedOn[*]" },
10317
+ { code: "part-of", type: "reference", jsonbPath: "$.partOf[*]" },
10318
+ { code: "reason-code", type: "token", jsonbPath: "$.reasonCode[*]" },
10319
+ {
10320
+ code: "reason-reference",
10321
+ type: "reference",
10322
+ jsonbPath: "$.reasonReference[*]"
10323
+ }
10324
+ ];
10325
+
10326
+ // src/data/search/registry/resolver.ts
10327
+ var STATIC_SEARCH_PARAMETER_MAP = {
10328
+ AllergyIntolerance: ALLERGYINTOLERANCE_SEARCH_PARAMETERS,
10329
+ Appointment: APPOINTMENT_SEARCH_PARAMETERS,
10330
+ Condition: CONDITION_SEARCH_PARAMETERS,
10331
+ Encounter: ENCOUNTER_SEARCH_PARAMETERS,
10332
+ FamilyMemberHistory: FAMILYMEMBERHISTORY_SEARCH_PARAMETERS,
10333
+ Immunization: IMMUNIZATION_SEARCH_PARAMETERS,
10334
+ MedicationRequest: MEDICATIONREQUEST_SEARCH_PARAMETERS,
10335
+ MedicationStatement: MEDICATIONSTATEMENT_SEARCH_PARAMETERS,
10336
+ Observation: OBSERVATION_SEARCH_PARAMETERS,
10337
+ Patient: PATIENT_SEARCH_PARAMETERS,
10338
+ Procedure: PROCEDURE_SEARCH_PARAMETERS
10339
+ };
10340
+ var defaultSearchParameterResolver = (resourceType, _tenantId) => STATIC_SEARCH_PARAMETER_MAP[resourceType] ?? [];
10341
+ function getRegisteredSearchParameters(resourceType) {
10342
+ return STATIC_SEARCH_PARAMETER_MAP[resourceType] ?? [];
10343
+ }
10344
+
10345
+ // src/data/rest-api/routes/data/allergyintolerance/allergyintolerance-list-route.ts
10346
+ var ALLERGYINTOLERANCE_RESOURCE_TYPE = "AllergyIntolerance";
10347
+ function stripModifier(key) {
10348
+ const idx = key.indexOf(":");
10349
+ return idx === -1 ? key : key.slice(0, idx);
10350
+ }
10351
+ function isResultParameter(key) {
10352
+ return key.startsWith("_");
10353
+ }
10354
+ function sendInvalidSearch400(res, diagnostics) {
10355
+ return res.status(400).json({
10356
+ resourceType: "OperationOutcome",
10357
+ issue: [{ severity: "error", code: "invalid", diagnostics }]
10358
+ });
10359
+ }
10360
+ function extractSearchParamKeys(query) {
10361
+ const out = [];
10362
+ for (const rawKey of Object.keys(query)) {
10363
+ if (isResultParameter(rawKey)) {
10364
+ continue;
10365
+ }
10366
+ out.push({ rawKey, code: stripModifier(rawKey) });
10367
+ }
10368
+ return out;
10369
+ }
10370
+ function buildUnknownParamDiagnostics(unknownCodes) {
10371
+ const validCodes = getRegisteredSearchParameters(
10372
+ ALLERGYINTOLERANCE_RESOURCE_TYPE
10373
+ ).map((p) => p.code).sort().join(", ");
10374
+ const codes = unknownCodes.join(", ");
10375
+ const isPlural = unknownCodes.length !== 1;
10376
+ return [
10377
+ `Unknown search ${isPlural ? "parameters" : "parameter"} for AllergyIntolerance: ${codes}.`,
10378
+ `Valid codes: ${validCodes}.`
10379
+ ].join(" ");
10380
+ }
10381
+ function findMalformedReference(query, searchParamKeys) {
10382
+ const referenceCodes = new Set(
10383
+ getRegisteredSearchParameters(ALLERGYINTOLERANCE_RESOURCE_TYPE).filter((p) => p.type === "reference").map((p) => p.code)
10384
+ );
10385
+ for (const { rawKey, code } of searchParamKeys) {
10386
+ if (!referenceCodes.has(code)) {
10387
+ continue;
10388
+ }
10389
+ const raw = query[rawKey];
10390
+ const values = typeof raw === "string" ? raw.split(",") : Array.isArray(raw) ? raw.flatMap((v) => v.split(",")) : [];
10391
+ for (const v of values) {
10392
+ const trimmed = v.trim();
10393
+ if (trimmed.length === 0) {
10394
+ continue;
10395
+ }
10396
+ if (parseTypedReference(trimmed) === void 0) {
10397
+ return { rawKey, value: trimmed };
10398
+ }
10399
+ }
10400
+ }
10401
+ return void 0;
10402
+ }
10403
+ async function listAllergyIntolerancesRoute(req, res) {
10404
+ const searchParamKeys = extractSearchParamKeys(
10405
+ req.query
10406
+ );
10407
+ if (searchParamKeys.length === 0) {
10408
+ return handleListRoute({
10409
+ req,
10410
+ res,
10411
+ basePath: BASE_PATH.ALLERGYINTOLERANCE,
10412
+ listOperation: listAllergyIntolerancesOperation,
10413
+ errorLogContext: "GET /AllergyIntolerance list error:"
10414
+ });
10415
+ }
10416
+ const registered = getRegisteredSearchParameters(
10417
+ ALLERGYINTOLERANCE_RESOURCE_TYPE
10418
+ );
10419
+ const validCodes = new Set(registered.map((p) => p.code));
10420
+ const unknownCodes = searchParamKeys.map((k) => k.code).filter((code) => !validCodes.has(code));
10421
+ if (unknownCodes.length > 0) {
10422
+ return sendInvalidSearch400(
10423
+ res,
10424
+ buildUnknownParamDiagnostics([...new Set(unknownCodes)])
10425
+ );
10426
+ }
10427
+ const malformedRef = findMalformedReference(
10428
+ req.query,
10429
+ searchParamKeys
10430
+ );
10431
+ if (malformedRef !== void 0) {
10432
+ return sendInvalidSearch400(
10433
+ res,
10434
+ `?${malformedRef.rawKey} must be a typed reference like "Practitioner/<id>"; got "${malformedRef.value}".`
10435
+ );
10436
+ }
10437
+ const ctx = req.openhiContext;
10438
+ try {
10439
+ const result = await genericSearchOperation({
10440
+ resourceType: ALLERGYINTOLERANCE_RESOURCE_TYPE,
10441
+ tenantId: ctx.tenantId,
10442
+ workspaceId: ctx.workspaceId,
10443
+ query: req.query,
10444
+ resolver: defaultSearchParameterResolver
10445
+ });
10446
+ const bundle = buildSearchsetBundle(
10447
+ BASE_PATH.ALLERGYINTOLERANCE,
10448
+ result.entries
10449
+ );
10450
+ return res.json(bundle);
10451
+ } catch (err) {
10452
+ return sendOperationOutcome500(
10453
+ res,
10454
+ err,
10455
+ "GET /AllergyIntolerance search error:"
10456
+ );
10457
+ }
10458
+ }
10459
+
10460
+ // src/data/operations/data/allergyintolerance/allergyintolerance-update-operation.ts
10461
+ async function updateAllergyIntoleranceOperation(params) {
10462
+ const { context, id, body, tableName } = params;
10463
+ const { tenantId, workspaceId, date, actorId, actorName } = context;
10464
+ const service = getDynamoDataService(tableName);
10465
+ return updateDataEntityById(
10466
+ service.entities.allergyintolerance,
10467
+ tenantId,
10468
+ workspaceId,
10469
+ id,
10470
+ "AllergyIntolerance",
10471
+ context,
10472
+ (existingResourceStr) => buildUpdatedResourceWithAudit(
10473
+ body,
10474
+ id,
10475
+ date,
10476
+ actorId,
10477
+ actorName,
10478
+ existingResourceStr,
10479
+ "AllergyIntolerance"
10480
+ )
10481
+ );
10482
+ }
10483
+
10484
+ // src/data/rest-api/routes/data/allergyintolerance/allergyintolerance-update-route.ts
10485
+ async function updateAllergyIntoleranceRoute(req, res) {
10486
+ const bodyResult = requireJsonBodyAs(req, res);
10487
+ if ("errorResponse" in bodyResult) return bodyResult.errorResponse;
10488
+ const id = String(req.params.id);
10489
+ const ctx = req.openhiContext;
10490
+ const body = bodyResult.body;
10491
+ const resource = {
10492
+ ...body,
10493
+ resourceType: "AllergyIntolerance",
10494
+ id
10495
+ };
10496
+ try {
10497
+ const result = await updateAllergyIntoleranceOperation({
10498
+ context: ctx,
10499
+ id,
10500
+ body: resource
10501
+ });
10502
+ return res.json(result.resource);
10503
+ } catch (err) {
10504
+ const status = domainErrorToHttpStatus(err);
10505
+ if (status === 404) {
10506
+ const diagnostics = err instanceof NotFoundError ? err.message : `AllergyIntolerance ${id} not found`;
10507
+ return sendOperationOutcome404(res, diagnostics);
10508
+ }
10509
+ return sendOperationOutcome500(res, err, "PUT AllergyIntolerance error:");
10510
+ }
10511
+ }
10512
+
10513
+ // src/data/rest-api/routes/data/allergyintolerance/allergyintolerance.ts
10514
+ var router13 = import_express13.default.Router();
10515
+ router13.get("/", listAllergyIntolerancesRoute);
10516
+ router13.get("/:id", getAllergyIntoleranceByIdRoute);
10517
+ router13.post("/", createAllergyIntoleranceRoute);
10518
+ router13.put("/:id", updateAllergyIntoleranceRoute);
10519
+ router13.delete("/:id", deleteAllergyIntoleranceRoute);
10520
+
10521
+ // src/data/rest-api/routes/data/appointment/appointment.ts
10522
+ var import_express14 = __toESM(require("express"));
10523
+
10524
+ // src/data/operations/data/appointment/appointment-create-operation.ts
10525
+ var import_ulid6 = require("ulid");
10526
+ async function createAppointmentOperation(params) {
10527
+ const { context, body, tableName } = params;
10528
+ const { tenantId, workspaceId, date, actorId, actorName } = context;
10529
+ const id = body.id ?? (0, import_ulid6.ulid)();
10530
+ const meta = {
10531
+ ...body.meta ?? {},
10532
+ lastUpdated: date,
10533
+ versionId: "1"
10534
+ };
10535
+ const resourceWithAudit = {
10536
+ ...body,
10537
+ resourceType: "Appointment",
10538
+ id,
10539
+ meta: mergeAuditIntoMeta(meta, {
10540
+ createdDate: date,
10541
+ createdById: actorId,
10542
+ createdByName: actorName,
10543
+ modifiedDate: date,
10544
+ modifiedById: actorId,
10545
+ modifiedByName: actorName
10546
+ })
10547
+ };
10548
+ const service = getDynamoDataService(tableName);
10549
+ return createDataEntityRecord(
10550
+ service.entities.appointment,
10551
+ tenantId,
10552
+ workspaceId,
10553
+ id,
10554
+ resourceWithAudit,
10555
+ date
10556
+ );
10557
+ }
10558
+
10559
+ // src/data/rest-api/routes/data/appointment/appointment-create-route.ts
10560
+ async function createAppointmentRoute(req, res) {
10561
+ const bodyResult = requireJsonBodyAs(req, res);
10562
+ if ("errorResponse" in bodyResult) return bodyResult.errorResponse;
10563
+ const ctx = req.openhiContext;
10564
+ const body = bodyResult.body;
10565
+ const resource = {
10566
+ ...body,
10567
+ resourceType: "Appointment"
10568
+ };
10569
+ try {
10570
+ const result = await createAppointmentOperation({
10571
+ context: ctx,
10572
+ body: resource
10573
+ });
10574
+ return res.status(201).location(`${BASE_PATH.APPOINTMENT}/${result.id}`).json(result.resource);
10575
+ } catch (err) {
10576
+ return sendOperationOutcome500(res, err, "POST Appointment error:");
10577
+ }
10578
+ }
10579
+
10580
+ // src/data/operations/data/appointment/appointment-delete-operation.ts
10581
+ async function deleteAppointmentOperation(params) {
10582
+ const { context, id, tableName } = params;
10583
+ const { tenantId, workspaceId } = context;
10584
+ const service = getDynamoDataService(tableName);
10585
+ await deleteDataEntityById(
10586
+ service.entities.appointment,
10587
+ tenantId,
10588
+ workspaceId,
10589
+ id
10590
+ );
10591
+ }
10592
+
10593
+ // src/data/rest-api/routes/data/appointment/appointment-delete-route.ts
10594
+ async function deleteAppointmentRoute(req, res) {
10595
+ const id = String(req.params.id);
10596
+ const ctx = req.openhiContext;
10597
+ try {
10598
+ await deleteAppointmentOperation({ context: ctx, id });
10599
+ return res.status(204).send();
10600
+ } catch (err) {
10601
+ return sendOperationOutcome500(res, err, "DELETE Appointment error:");
10370
10602
  }
10371
- ];
10603
+ }
10372
10604
 
10373
- // src/data/search/registry/procedure-search-parameters.ts
10374
- var PROCEDURE_SEARCH_PARAMETERS = [
10375
- { code: "status", type: "token", jsonbPath: "$.status" },
10376
- { code: "category", type: "token", jsonbPath: "$.category" },
10377
- { code: "code", type: "token", jsonbPath: "$.code" },
10378
- { code: "subject", type: "reference", jsonbPath: "$.subject" },
10379
- { code: "patient", type: "reference", jsonbPath: "$.subject" },
10380
- { code: "encounter", type: "reference", jsonbPath: "$.encounter" },
10381
- {
10382
- code: "performer",
10383
- type: "reference",
10384
- jsonbPath: "$.performer[*].actor"
10385
- },
10386
- { code: "date", type: "date", jsonbPath: "$.performedDateTime" },
10387
- { code: "location", type: "reference", jsonbPath: "$.location" },
10388
- { code: "identifier", type: "token", jsonbPath: "$.identifier[*]" },
10389
- { code: "based-on", type: "reference", jsonbPath: "$.basedOn[*]" },
10390
- { code: "part-of", type: "reference", jsonbPath: "$.partOf[*]" },
10391
- { code: "reason-code", type: "token", jsonbPath: "$.reasonCode[*]" },
10392
- {
10393
- code: "reason-reference",
10394
- type: "reference",
10395
- jsonbPath: "$.reasonReference[*]"
10605
+ // src/data/operations/data/appointment/appointment-get-by-id-operation.ts
10606
+ async function getAppointmentByIdOperation(params) {
10607
+ const { context, id, tableName } = params;
10608
+ const { tenantId, workspaceId } = context;
10609
+ const service = getDynamoDataService(tableName);
10610
+ return getDataEntityById(
10611
+ service.entities.appointment,
10612
+ tenantId,
10613
+ workspaceId,
10614
+ id,
10615
+ "Appointment"
10616
+ );
10617
+ }
10618
+
10619
+ // src/data/rest-api/routes/data/appointment/appointment-get-by-id-route.ts
10620
+ async function getAppointmentByIdRoute(req, res) {
10621
+ const id = String(req.params.id);
10622
+ const ctx = req.openhiContext;
10623
+ try {
10624
+ const result = await getAppointmentByIdOperation({ context: ctx, id });
10625
+ return res.json(result.resource);
10626
+ } catch (err) {
10627
+ const status = domainErrorToHttpStatus(err);
10628
+ if (status === 404) {
10629
+ const diagnostics = err instanceof NotFoundError ? err.message : `Appointment ${id} not found`;
10630
+ return sendOperationOutcome404(res, diagnostics);
10631
+ }
10632
+ return sendOperationOutcome500(res, err, "GET Appointment error:");
10396
10633
  }
10397
- ];
10634
+ }
10398
10635
 
10399
- // src/data/search/registry/resolver.ts
10400
- var STATIC_SEARCH_PARAMETER_MAP = {
10401
- Appointment: APPOINTMENT_SEARCH_PARAMETERS,
10402
- Encounter: ENCOUNTER_SEARCH_PARAMETERS,
10403
- Observation: OBSERVATION_SEARCH_PARAMETERS,
10404
- Patient: PATIENT_SEARCH_PARAMETERS,
10405
- Procedure: PROCEDURE_SEARCH_PARAMETERS
10406
- };
10407
- var defaultSearchParameterResolver = (resourceType, _tenantId) => STATIC_SEARCH_PARAMETER_MAP[resourceType] ?? [];
10408
- function getRegisteredSearchParameters(resourceType) {
10409
- return STATIC_SEARCH_PARAMETER_MAP[resourceType] ?? [];
10636
+ // src/data/operations/data/appointment/appointment-list-operation.ts
10637
+ async function listAppointmentsOperation(params) {
10638
+ const { context, tableName, mode } = params;
10639
+ const { tenantId, workspaceId } = context;
10640
+ const service = getDynamoDataService(tableName);
10641
+ return listDataEntitiesByWorkspace(
10642
+ service.entities.appointment,
10643
+ tenantId,
10644
+ workspaceId,
10645
+ mode
10646
+ );
10410
10647
  }
10411
10648
 
10412
10649
  // src/data/rest-api/routes/data/appointment/appointment-list-route.ts
10413
10650
  var APPOINTMENT_RESOURCE_TYPE = "Appointment";
10414
- function stripModifier(key) {
10651
+ function stripModifier2(key) {
10415
10652
  const idx = key.indexOf(":");
10416
10653
  return idx === -1 ? key : key.slice(0, idx);
10417
10654
  }
10418
- function isResultParameter(key) {
10655
+ function isResultParameter2(key) {
10419
10656
  return key.startsWith("_");
10420
10657
  }
10421
- function sendInvalidSearch400(res, diagnostics) {
10658
+ function sendInvalidSearch4002(res, diagnostics) {
10422
10659
  return res.status(400).json({
10423
10660
  resourceType: "OperationOutcome",
10424
10661
  issue: [{ severity: "error", code: "invalid", diagnostics }]
10425
10662
  });
10426
10663
  }
10427
- function extractSearchParamKeys(query) {
10664
+ function extractSearchParamKeys2(query) {
10428
10665
  const out = [];
10429
10666
  for (const rawKey of Object.keys(query)) {
10430
- if (isResultParameter(rawKey)) {
10667
+ if (isResultParameter2(rawKey)) {
10431
10668
  continue;
10432
10669
  }
10433
- out.push({ rawKey, code: stripModifier(rawKey) });
10670
+ out.push({ rawKey, code: stripModifier2(rawKey) });
10434
10671
  }
10435
10672
  return out;
10436
10673
  }
10437
- function buildUnknownParamDiagnostics(unknownCodes) {
10674
+ function buildUnknownParamDiagnostics2(unknownCodes) {
10438
10675
  const validCodes = getRegisteredSearchParameters(APPOINTMENT_RESOURCE_TYPE).map((p) => p.code).sort().join(", ");
10439
10676
  const codes = unknownCodes.join(", ");
10440
10677
  const isPlural = unknownCodes.length !== 1;
@@ -10443,7 +10680,7 @@ function buildUnknownParamDiagnostics(unknownCodes) {
10443
10680
  `Valid codes: ${validCodes}.`
10444
10681
  ].join(" ");
10445
10682
  }
10446
- function findMalformedReference(query, searchParamKeys) {
10683
+ function findMalformedReference2(query, searchParamKeys) {
10447
10684
  const referenceCodes = new Set(
10448
10685
  getRegisteredSearchParameters(APPOINTMENT_RESOURCE_TYPE).filter((p) => p.type === "reference").map((p) => p.code)
10449
10686
  );
@@ -10466,7 +10703,7 @@ function findMalformedReference(query, searchParamKeys) {
10466
10703
  return void 0;
10467
10704
  }
10468
10705
  async function listAppointmentsRoute(req, res) {
10469
- const searchParamKeys = extractSearchParamKeys(
10706
+ const searchParamKeys = extractSearchParamKeys2(
10470
10707
  req.query
10471
10708
  );
10472
10709
  if (searchParamKeys.length === 0) {
@@ -10482,17 +10719,17 @@ async function listAppointmentsRoute(req, res) {
10482
10719
  const validCodes = new Set(registered.map((p) => p.code));
10483
10720
  const unknownCodes = searchParamKeys.map((k) => k.code).filter((code) => !validCodes.has(code));
10484
10721
  if (unknownCodes.length > 0) {
10485
- return sendInvalidSearch400(
10722
+ return sendInvalidSearch4002(
10486
10723
  res,
10487
- buildUnknownParamDiagnostics([...new Set(unknownCodes)])
10724
+ buildUnknownParamDiagnostics2([...new Set(unknownCodes)])
10488
10725
  );
10489
10726
  }
10490
- const malformedRef = findMalformedReference(
10727
+ const malformedRef = findMalformedReference2(
10491
10728
  req.query,
10492
10729
  searchParamKeys
10493
10730
  );
10494
10731
  if (malformedRef !== void 0) {
10495
- return sendInvalidSearch400(
10732
+ return sendInvalidSearch4002(
10496
10733
  res,
10497
10734
  `?${malformedRef.rawKey} must be a typed reference like "Practitioner/<id>"; got "${malformedRef.value}".`
10498
10735
  );
@@ -14758,42 +14995,135 @@ async function getConditionByIdRoute(req, res) {
14758
14995
  const id = String(req.params.id);
14759
14996
  const ctx = req.openhiContext;
14760
14997
  try {
14761
- const result = await getConditionByIdOperation({ context: ctx, id });
14762
- return res.json(result.resource);
14998
+ const result = await getConditionByIdOperation({ context: ctx, id });
14999
+ return res.json(result.resource);
15000
+ } catch (err) {
15001
+ const status = domainErrorToHttpStatus(err);
15002
+ if (status === 404) {
15003
+ const diagnostics = err instanceof NotFoundError ? err.message : `Condition ${id} not found`;
15004
+ return sendOperationOutcome404(res, diagnostics);
15005
+ }
15006
+ return sendOperationOutcome500(res, err, "GET Condition error:");
15007
+ }
15008
+ }
15009
+
15010
+ // src/data/operations/data/condition/condition-list-operation.ts
15011
+ async function listConditionsOperation(params) {
15012
+ const { context, tableName, mode } = params;
15013
+ const { tenantId, workspaceId } = context;
15014
+ const service = getDynamoDataService(tableName);
15015
+ return listDataEntitiesByWorkspace(
15016
+ service.entities.condition,
15017
+ tenantId,
15018
+ workspaceId,
15019
+ mode
15020
+ );
15021
+ }
15022
+
15023
+ // src/data/rest-api/routes/data/condition/condition-list-route.ts
15024
+ var CONDITION_RESOURCE_TYPE = "Condition";
15025
+ function stripModifier3(key) {
15026
+ const idx = key.indexOf(":");
15027
+ return idx === -1 ? key : key.slice(0, idx);
15028
+ }
15029
+ function isResultParameter3(key) {
15030
+ return key.startsWith("_");
15031
+ }
15032
+ function sendInvalidSearch4003(res, diagnostics) {
15033
+ return res.status(400).json({
15034
+ resourceType: "OperationOutcome",
15035
+ issue: [{ severity: "error", code: "invalid", diagnostics }]
15036
+ });
15037
+ }
15038
+ function extractSearchParamKeys3(query) {
15039
+ const out = [];
15040
+ for (const rawKey of Object.keys(query)) {
15041
+ if (isResultParameter3(rawKey)) {
15042
+ continue;
15043
+ }
15044
+ out.push({ rawKey, code: stripModifier3(rawKey) });
15045
+ }
15046
+ return out;
15047
+ }
15048
+ function buildUnknownParamDiagnostics3(unknownCodes) {
15049
+ const validCodes = getRegisteredSearchParameters(CONDITION_RESOURCE_TYPE).map((p) => p.code).sort().join(", ");
15050
+ const codes = unknownCodes.join(", ");
15051
+ const isPlural = unknownCodes.length !== 1;
15052
+ return [
15053
+ `Unknown search ${isPlural ? "parameters" : "parameter"} for Condition: ${codes}.`,
15054
+ `Valid codes: ${validCodes}.`
15055
+ ].join(" ");
15056
+ }
15057
+ function findMalformedReference3(query, searchParamKeys) {
15058
+ const referenceCodes = new Set(
15059
+ getRegisteredSearchParameters(CONDITION_RESOURCE_TYPE).filter((p) => p.type === "reference").map((p) => p.code)
15060
+ );
15061
+ for (const { rawKey, code } of searchParamKeys) {
15062
+ if (!referenceCodes.has(code)) {
15063
+ continue;
15064
+ }
15065
+ const raw = query[rawKey];
15066
+ const values = typeof raw === "string" ? raw.split(",") : Array.isArray(raw) ? raw.flatMap((v) => v.split(",")) : [];
15067
+ for (const v of values) {
15068
+ const trimmed = v.trim();
15069
+ if (trimmed.length === 0) {
15070
+ continue;
15071
+ }
15072
+ if (parseTypedReference(trimmed) === void 0) {
15073
+ return { rawKey, value: trimmed };
15074
+ }
15075
+ }
15076
+ }
15077
+ return void 0;
15078
+ }
15079
+ async function listConditionsRoute(req, res) {
15080
+ const searchParamKeys = extractSearchParamKeys3(
15081
+ req.query
15082
+ );
15083
+ if (searchParamKeys.length === 0) {
15084
+ return handleListRoute({
15085
+ req,
15086
+ res,
15087
+ basePath: BASE_PATH.CONDITION,
15088
+ listOperation: listConditionsOperation,
15089
+ errorLogContext: "GET /Condition list error:"
15090
+ });
15091
+ }
15092
+ const registered = getRegisteredSearchParameters(CONDITION_RESOURCE_TYPE);
15093
+ const validCodes = new Set(registered.map((p) => p.code));
15094
+ const unknownCodes = searchParamKeys.map((k) => k.code).filter((code) => !validCodes.has(code));
15095
+ if (unknownCodes.length > 0) {
15096
+ return sendInvalidSearch4003(
15097
+ res,
15098
+ buildUnknownParamDiagnostics3([...new Set(unknownCodes)])
15099
+ );
15100
+ }
15101
+ const malformedRef = findMalformedReference3(
15102
+ req.query,
15103
+ searchParamKeys
15104
+ );
15105
+ if (malformedRef !== void 0) {
15106
+ return sendInvalidSearch4003(
15107
+ res,
15108
+ `?${malformedRef.rawKey} must be a typed reference like "Practitioner/<id>"; got "${malformedRef.value}".`
15109
+ );
15110
+ }
15111
+ const ctx = req.openhiContext;
15112
+ try {
15113
+ const result = await genericSearchOperation({
15114
+ resourceType: CONDITION_RESOURCE_TYPE,
15115
+ tenantId: ctx.tenantId,
15116
+ workspaceId: ctx.workspaceId,
15117
+ query: req.query,
15118
+ resolver: defaultSearchParameterResolver
15119
+ });
15120
+ const bundle = buildSearchsetBundle(BASE_PATH.CONDITION, result.entries);
15121
+ return res.json(bundle);
14763
15122
  } catch (err) {
14764
- const status = domainErrorToHttpStatus(err);
14765
- if (status === 404) {
14766
- const diagnostics = err instanceof NotFoundError ? err.message : `Condition ${id} not found`;
14767
- return sendOperationOutcome404(res, diagnostics);
14768
- }
14769
- return sendOperationOutcome500(res, err, "GET Condition error:");
15123
+ return sendOperationOutcome500(res, err, "GET /Condition search error:");
14770
15124
  }
14771
15125
  }
14772
15126
 
14773
- // src/data/operations/data/condition/condition-list-operation.ts
14774
- async function listConditionsOperation(params) {
14775
- const { context, tableName, mode } = params;
14776
- const { tenantId, workspaceId } = context;
14777
- const service = getDynamoDataService(tableName);
14778
- return listDataEntitiesByWorkspace(
14779
- service.entities.condition,
14780
- tenantId,
14781
- workspaceId,
14782
- mode
14783
- );
14784
- }
14785
-
14786
- // src/data/rest-api/routes/data/condition/condition-list-route.ts
14787
- async function listConditionsRoute(req, res) {
14788
- return handleListRoute({
14789
- req,
14790
- res,
14791
- basePath: BASE_PATH.CONDITION,
14792
- listOperation: listConditionsOperation,
14793
- errorLogContext: "GET /Condition list error:"
14794
- });
14795
- }
14796
-
14797
15127
  // src/data/operations/data/condition/condition-update-operation.ts
14798
15128
  async function updateConditionOperation(params) {
14799
15129
  const { context, id, body, tableName } = params;
@@ -18055,30 +18385,30 @@ async function listEncountersOperation(params) {
18055
18385
 
18056
18386
  // src/data/rest-api/routes/data/encounter/encounter-list-route.ts
18057
18387
  var ENCOUNTER_RESOURCE_TYPE = "Encounter";
18058
- function stripModifier2(key) {
18388
+ function stripModifier4(key) {
18059
18389
  const idx = key.indexOf(":");
18060
18390
  return idx === -1 ? key : key.slice(0, idx);
18061
18391
  }
18062
- function isResultParameter2(key) {
18392
+ function isResultParameter4(key) {
18063
18393
  return key.startsWith("_");
18064
18394
  }
18065
- function sendInvalidSearch4002(res, diagnostics) {
18395
+ function sendInvalidSearch4004(res, diagnostics) {
18066
18396
  return res.status(400).json({
18067
18397
  resourceType: "OperationOutcome",
18068
18398
  issue: [{ severity: "error", code: "invalid", diagnostics }]
18069
18399
  });
18070
18400
  }
18071
- function extractSearchParamKeys2(query) {
18401
+ function extractSearchParamKeys4(query) {
18072
18402
  const out = [];
18073
18403
  for (const rawKey of Object.keys(query)) {
18074
- if (isResultParameter2(rawKey)) {
18404
+ if (isResultParameter4(rawKey)) {
18075
18405
  continue;
18076
18406
  }
18077
- out.push({ rawKey, code: stripModifier2(rawKey) });
18407
+ out.push({ rawKey, code: stripModifier4(rawKey) });
18078
18408
  }
18079
18409
  return out;
18080
18410
  }
18081
- function buildUnknownParamDiagnostics2(unknownCodes) {
18411
+ function buildUnknownParamDiagnostics4(unknownCodes) {
18082
18412
  const validCodes = getRegisteredSearchParameters(ENCOUNTER_RESOURCE_TYPE).map((p) => p.code).sort().join(", ");
18083
18413
  const codes = unknownCodes.join(", ");
18084
18414
  const isPlural = unknownCodes.length !== 1;
@@ -18087,7 +18417,7 @@ function buildUnknownParamDiagnostics2(unknownCodes) {
18087
18417
  `Valid codes: ${validCodes}.`
18088
18418
  ].join(" ");
18089
18419
  }
18090
- function findMalformedReference2(query, searchParamKeys) {
18420
+ function findMalformedReference4(query, searchParamKeys) {
18091
18421
  const referenceCodes = new Set(
18092
18422
  getRegisteredSearchParameters(ENCOUNTER_RESOURCE_TYPE).filter((p) => p.type === "reference").map((p) => p.code)
18093
18423
  );
@@ -18110,7 +18440,7 @@ function findMalformedReference2(query, searchParamKeys) {
18110
18440
  return void 0;
18111
18441
  }
18112
18442
  async function listEncountersRoute(req, res) {
18113
- const searchParamKeys = extractSearchParamKeys2(
18443
+ const searchParamKeys = extractSearchParamKeys4(
18114
18444
  req.query
18115
18445
  );
18116
18446
  if (searchParamKeys.length === 0) {
@@ -18126,17 +18456,17 @@ async function listEncountersRoute(req, res) {
18126
18456
  const validCodes = new Set(registered.map((p) => p.code));
18127
18457
  const unknownCodes = searchParamKeys.map((k) => k.code).filter((code) => !validCodes.has(code));
18128
18458
  if (unknownCodes.length > 0) {
18129
- return sendInvalidSearch4002(
18459
+ return sendInvalidSearch4004(
18130
18460
  res,
18131
- buildUnknownParamDiagnostics2([...new Set(unknownCodes)])
18461
+ buildUnknownParamDiagnostics4([...new Set(unknownCodes)])
18132
18462
  );
18133
18463
  }
18134
- const malformedRef = findMalformedReference2(
18464
+ const malformedRef = findMalformedReference4(
18135
18465
  req.query,
18136
18466
  searchParamKeys
18137
18467
  );
18138
18468
  if (malformedRef !== void 0) {
18139
- return sendInvalidSearch4002(
18469
+ return sendInvalidSearch4004(
18140
18470
  res,
18141
18471
  `?${malformedRef.rawKey} must be a typed reference like "Practitioner/<id>"; got "${malformedRef.value}".`
18142
18472
  );
@@ -20180,15 +20510,119 @@ async function listFamilyMemberHistorysOperation(params) {
20180
20510
  }
20181
20511
 
20182
20512
  // src/data/rest-api/routes/data/familymemberhistory/familymemberhistory-list-route.ts
20183
- async function listFamilyMemberHistorysRoute(req, res) {
20184
- return handleListRoute({
20185
- req,
20186
- res,
20187
- basePath: BASE_PATH.FAMILYMEMBERHISTORY,
20188
- listOperation: listFamilyMemberHistorysOperation,
20189
- errorLogContext: "GET /FamilyMemberHistory list error:"
20513
+ var FAMILYMEMBERHISTORY_RESOURCE_TYPE = "FamilyMemberHistory";
20514
+ function stripModifier5(key) {
20515
+ const idx = key.indexOf(":");
20516
+ return idx === -1 ? key : key.slice(0, idx);
20517
+ }
20518
+ function isResultParameter5(key) {
20519
+ return key.startsWith("_");
20520
+ }
20521
+ function sendInvalidSearch4005(res, diagnostics) {
20522
+ return res.status(400).json({
20523
+ resourceType: "OperationOutcome",
20524
+ issue: [{ severity: "error", code: "invalid", diagnostics }]
20190
20525
  });
20191
20526
  }
20527
+ function extractSearchParamKeys5(query) {
20528
+ const out = [];
20529
+ for (const rawKey of Object.keys(query)) {
20530
+ if (isResultParameter5(rawKey)) {
20531
+ continue;
20532
+ }
20533
+ out.push({ rawKey, code: stripModifier5(rawKey) });
20534
+ }
20535
+ return out;
20536
+ }
20537
+ function buildUnknownParamDiagnostics5(unknownCodes) {
20538
+ const validCodes = getRegisteredSearchParameters(
20539
+ FAMILYMEMBERHISTORY_RESOURCE_TYPE
20540
+ ).map((p) => p.code).sort().join(", ");
20541
+ const codes = unknownCodes.join(", ");
20542
+ const isPlural = unknownCodes.length !== 1;
20543
+ return [
20544
+ `Unknown search ${isPlural ? "parameters" : "parameter"} for FamilyMemberHistory: ${codes}.`,
20545
+ `Valid codes: ${validCodes}.`
20546
+ ].join(" ");
20547
+ }
20548
+ function findMalformedReference5(query, searchParamKeys) {
20549
+ const referenceCodes = new Set(
20550
+ getRegisteredSearchParameters(FAMILYMEMBERHISTORY_RESOURCE_TYPE).filter((p) => p.type === "reference").map((p) => p.code)
20551
+ );
20552
+ for (const { rawKey, code } of searchParamKeys) {
20553
+ if (!referenceCodes.has(code)) {
20554
+ continue;
20555
+ }
20556
+ const raw = query[rawKey];
20557
+ const values = typeof raw === "string" ? raw.split(",") : Array.isArray(raw) ? raw.flatMap((v) => v.split(",")) : [];
20558
+ for (const v of values) {
20559
+ const trimmed = v.trim();
20560
+ if (trimmed.length === 0) {
20561
+ continue;
20562
+ }
20563
+ if (parseTypedReference(trimmed) === void 0) {
20564
+ return { rawKey, value: trimmed };
20565
+ }
20566
+ }
20567
+ }
20568
+ return void 0;
20569
+ }
20570
+ async function listFamilyMemberHistorysRoute(req, res) {
20571
+ const searchParamKeys = extractSearchParamKeys5(
20572
+ req.query
20573
+ );
20574
+ if (searchParamKeys.length === 0) {
20575
+ return handleListRoute({
20576
+ req,
20577
+ res,
20578
+ basePath: BASE_PATH.FAMILYMEMBERHISTORY,
20579
+ listOperation: listFamilyMemberHistorysOperation,
20580
+ errorLogContext: "GET /FamilyMemberHistory list error:"
20581
+ });
20582
+ }
20583
+ const registered = getRegisteredSearchParameters(
20584
+ FAMILYMEMBERHISTORY_RESOURCE_TYPE
20585
+ );
20586
+ const validCodes = new Set(registered.map((p) => p.code));
20587
+ const unknownCodes = searchParamKeys.map((k) => k.code).filter((code) => !validCodes.has(code));
20588
+ if (unknownCodes.length > 0) {
20589
+ return sendInvalidSearch4005(
20590
+ res,
20591
+ buildUnknownParamDiagnostics5([...new Set(unknownCodes)])
20592
+ );
20593
+ }
20594
+ const malformedRef = findMalformedReference5(
20595
+ req.query,
20596
+ searchParamKeys
20597
+ );
20598
+ if (malformedRef !== void 0) {
20599
+ return sendInvalidSearch4005(
20600
+ res,
20601
+ `?${malformedRef.rawKey} must be a typed reference like "Patient/<id>"; got "${malformedRef.value}".`
20602
+ );
20603
+ }
20604
+ const ctx = req.openhiContext;
20605
+ try {
20606
+ const result = await genericSearchOperation({
20607
+ resourceType: FAMILYMEMBERHISTORY_RESOURCE_TYPE,
20608
+ tenantId: ctx.tenantId,
20609
+ workspaceId: ctx.workspaceId,
20610
+ query: req.query,
20611
+ resolver: defaultSearchParameterResolver
20612
+ });
20613
+ const bundle = buildSearchsetBundle(
20614
+ BASE_PATH.FAMILYMEMBERHISTORY,
20615
+ result.entries
20616
+ );
20617
+ return res.json(bundle);
20618
+ } catch (err) {
20619
+ return sendOperationOutcome500(
20620
+ res,
20621
+ err,
20622
+ "GET /FamilyMemberHistory search error:"
20623
+ );
20624
+ }
20625
+ }
20192
20626
 
20193
20627
  // src/data/operations/data/familymemberhistory/familymemberhistory-update-operation.ts
20194
20628
  async function updateFamilyMemberHistoryOperation(params) {
@@ -21757,42 +22191,135 @@ async function getImmunizationByIdRoute(req, res) {
21757
22191
  const id = String(req.params.id);
21758
22192
  const ctx = req.openhiContext;
21759
22193
  try {
21760
- const result = await getImmunizationByIdOperation({ context: ctx, id });
21761
- return res.json(result.resource);
22194
+ const result = await getImmunizationByIdOperation({ context: ctx, id });
22195
+ return res.json(result.resource);
22196
+ } catch (err) {
22197
+ const status = domainErrorToHttpStatus(err);
22198
+ if (status === 404) {
22199
+ const diagnostics = err instanceof NotFoundError ? err.message : `Immunization ${id} not found`;
22200
+ return sendOperationOutcome404(res, diagnostics);
22201
+ }
22202
+ return sendOperationOutcome500(res, err, "GET Immunization error:");
22203
+ }
22204
+ }
22205
+
22206
+ // src/data/operations/data/immunization/immunization-list-operation.ts
22207
+ async function listImmunizationsOperation(params) {
22208
+ const { context, tableName, mode } = params;
22209
+ const { tenantId, workspaceId } = context;
22210
+ const service = getDynamoDataService(tableName);
22211
+ return listDataEntitiesByWorkspace(
22212
+ service.entities.immunization,
22213
+ tenantId,
22214
+ workspaceId,
22215
+ mode
22216
+ );
22217
+ }
22218
+
22219
+ // src/data/rest-api/routes/data/immunization/immunization-list-route.ts
22220
+ var IMMUNIZATION_RESOURCE_TYPE = "Immunization";
22221
+ function stripModifier6(key) {
22222
+ const idx = key.indexOf(":");
22223
+ return idx === -1 ? key : key.slice(0, idx);
22224
+ }
22225
+ function isResultParameter6(key) {
22226
+ return key.startsWith("_");
22227
+ }
22228
+ function sendInvalidSearch4006(res, diagnostics) {
22229
+ return res.status(400).json({
22230
+ resourceType: "OperationOutcome",
22231
+ issue: [{ severity: "error", code: "invalid", diagnostics }]
22232
+ });
22233
+ }
22234
+ function extractSearchParamKeys6(query) {
22235
+ const out = [];
22236
+ for (const rawKey of Object.keys(query)) {
22237
+ if (isResultParameter6(rawKey)) {
22238
+ continue;
22239
+ }
22240
+ out.push({ rawKey, code: stripModifier6(rawKey) });
22241
+ }
22242
+ return out;
22243
+ }
22244
+ function buildUnknownParamDiagnostics6(unknownCodes) {
22245
+ const validCodes = getRegisteredSearchParameters(IMMUNIZATION_RESOURCE_TYPE).map((p) => p.code).sort().join(", ");
22246
+ const codes = unknownCodes.join(", ");
22247
+ const isPlural = unknownCodes.length !== 1;
22248
+ return [
22249
+ `Unknown search ${isPlural ? "parameters" : "parameter"} for Immunization: ${codes}.`,
22250
+ `Valid codes: ${validCodes}.`
22251
+ ].join(" ");
22252
+ }
22253
+ function findMalformedReference6(query, searchParamKeys) {
22254
+ const referenceCodes = new Set(
22255
+ getRegisteredSearchParameters(IMMUNIZATION_RESOURCE_TYPE).filter((p) => p.type === "reference").map((p) => p.code)
22256
+ );
22257
+ for (const { rawKey, code } of searchParamKeys) {
22258
+ if (!referenceCodes.has(code)) {
22259
+ continue;
22260
+ }
22261
+ const raw = query[rawKey];
22262
+ const values = typeof raw === "string" ? raw.split(",") : Array.isArray(raw) ? raw.flatMap((v) => v.split(",")) : [];
22263
+ for (const v of values) {
22264
+ const trimmed = v.trim();
22265
+ if (trimmed.length === 0) {
22266
+ continue;
22267
+ }
22268
+ if (parseTypedReference(trimmed) === void 0) {
22269
+ return { rawKey, value: trimmed };
22270
+ }
22271
+ }
22272
+ }
22273
+ return void 0;
22274
+ }
22275
+ async function listImmunizationsRoute(req, res) {
22276
+ const searchParamKeys = extractSearchParamKeys6(
22277
+ req.query
22278
+ );
22279
+ if (searchParamKeys.length === 0) {
22280
+ return handleListRoute({
22281
+ req,
22282
+ res,
22283
+ basePath: BASE_PATH.IMMUNIZATION,
22284
+ listOperation: listImmunizationsOperation,
22285
+ errorLogContext: "GET /Immunization list error:"
22286
+ });
22287
+ }
22288
+ const registered = getRegisteredSearchParameters(IMMUNIZATION_RESOURCE_TYPE);
22289
+ const validCodes = new Set(registered.map((p) => p.code));
22290
+ const unknownCodes = searchParamKeys.map((k) => k.code).filter((code) => !validCodes.has(code));
22291
+ if (unknownCodes.length > 0) {
22292
+ return sendInvalidSearch4006(
22293
+ res,
22294
+ buildUnknownParamDiagnostics6([...new Set(unknownCodes)])
22295
+ );
22296
+ }
22297
+ const malformedRef = findMalformedReference6(
22298
+ req.query,
22299
+ searchParamKeys
22300
+ );
22301
+ if (malformedRef !== void 0) {
22302
+ return sendInvalidSearch4006(
22303
+ res,
22304
+ `?${malformedRef.rawKey} must be a typed reference like "Practitioner/<id>"; got "${malformedRef.value}".`
22305
+ );
22306
+ }
22307
+ const ctx = req.openhiContext;
22308
+ try {
22309
+ const result = await genericSearchOperation({
22310
+ resourceType: IMMUNIZATION_RESOURCE_TYPE,
22311
+ tenantId: ctx.tenantId,
22312
+ workspaceId: ctx.workspaceId,
22313
+ query: req.query,
22314
+ resolver: defaultSearchParameterResolver
22315
+ });
22316
+ const bundle = buildSearchsetBundle(BASE_PATH.IMMUNIZATION, result.entries);
22317
+ return res.json(bundle);
21762
22318
  } catch (err) {
21763
- const status = domainErrorToHttpStatus(err);
21764
- if (status === 404) {
21765
- const diagnostics = err instanceof NotFoundError ? err.message : `Immunization ${id} not found`;
21766
- return sendOperationOutcome404(res, diagnostics);
21767
- }
21768
- return sendOperationOutcome500(res, err, "GET Immunization error:");
22319
+ return sendOperationOutcome500(res, err, "GET /Immunization search error:");
21769
22320
  }
21770
22321
  }
21771
22322
 
21772
- // src/data/operations/data/immunization/immunization-list-operation.ts
21773
- async function listImmunizationsOperation(params) {
21774
- const { context, tableName, mode } = params;
21775
- const { tenantId, workspaceId } = context;
21776
- const service = getDynamoDataService(tableName);
21777
- return listDataEntitiesByWorkspace(
21778
- service.entities.immunization,
21779
- tenantId,
21780
- workspaceId,
21781
- mode
21782
- );
21783
- }
21784
-
21785
- // src/data/rest-api/routes/data/immunization/immunization-list-route.ts
21786
- async function listImmunizationsRoute(req, res) {
21787
- return handleListRoute({
21788
- req,
21789
- res,
21790
- basePath: BASE_PATH.IMMUNIZATION,
21791
- listOperation: listImmunizationsOperation,
21792
- errorLogContext: "GET /Immunization list error:"
21793
- });
21794
- }
21795
-
21796
22323
  // src/data/operations/data/immunization/immunization-update-operation.ts
21797
22324
  async function updateImmunizationOperation(params) {
21798
22325
  const { context, id, body, tableName } = params;
@@ -25264,15 +25791,119 @@ async function listMedicationRequestsOperation(params) {
25264
25791
  }
25265
25792
 
25266
25793
  // src/data/rest-api/routes/data/medicationrequest/medicationrequest-list-route.ts
25267
- async function listMedicationRequestsRoute(req, res) {
25268
- return handleListRoute({
25269
- req,
25270
- res,
25271
- basePath: BASE_PATH.MEDICATIONREQUEST,
25272
- listOperation: listMedicationRequestsOperation,
25273
- errorLogContext: "GET /MedicationRequest list error:"
25794
+ var MEDICATIONREQUEST_RESOURCE_TYPE = "MedicationRequest";
25795
+ function stripModifier7(key) {
25796
+ const idx = key.indexOf(":");
25797
+ return idx === -1 ? key : key.slice(0, idx);
25798
+ }
25799
+ function isResultParameter7(key) {
25800
+ return key.startsWith("_");
25801
+ }
25802
+ function sendInvalidSearch4007(res, diagnostics) {
25803
+ return res.status(400).json({
25804
+ resourceType: "OperationOutcome",
25805
+ issue: [{ severity: "error", code: "invalid", diagnostics }]
25274
25806
  });
25275
25807
  }
25808
+ function extractSearchParamKeys7(query) {
25809
+ const out = [];
25810
+ for (const rawKey of Object.keys(query)) {
25811
+ if (isResultParameter7(rawKey)) {
25812
+ continue;
25813
+ }
25814
+ out.push({ rawKey, code: stripModifier7(rawKey) });
25815
+ }
25816
+ return out;
25817
+ }
25818
+ function buildUnknownParamDiagnostics7(unknownCodes) {
25819
+ const validCodes = getRegisteredSearchParameters(
25820
+ MEDICATIONREQUEST_RESOURCE_TYPE
25821
+ ).map((p) => p.code).sort().join(", ");
25822
+ const codes = unknownCodes.join(", ");
25823
+ const isPlural = unknownCodes.length !== 1;
25824
+ return [
25825
+ `Unknown search ${isPlural ? "parameters" : "parameter"} for MedicationRequest: ${codes}.`,
25826
+ `Valid codes: ${validCodes}.`
25827
+ ].join(" ");
25828
+ }
25829
+ function findMalformedReference7(query, searchParamKeys) {
25830
+ const referenceCodes = new Set(
25831
+ getRegisteredSearchParameters(MEDICATIONREQUEST_RESOURCE_TYPE).filter((p) => p.type === "reference").map((p) => p.code)
25832
+ );
25833
+ for (const { rawKey, code } of searchParamKeys) {
25834
+ if (!referenceCodes.has(code)) {
25835
+ continue;
25836
+ }
25837
+ const raw = query[rawKey];
25838
+ const values = typeof raw === "string" ? raw.split(",") : Array.isArray(raw) ? raw.flatMap((v) => v.split(",")) : [];
25839
+ for (const v of values) {
25840
+ const trimmed = v.trim();
25841
+ if (trimmed.length === 0) {
25842
+ continue;
25843
+ }
25844
+ if (parseTypedReference(trimmed) === void 0) {
25845
+ return { rawKey, value: trimmed };
25846
+ }
25847
+ }
25848
+ }
25849
+ return void 0;
25850
+ }
25851
+ async function listMedicationRequestsRoute(req, res) {
25852
+ const searchParamKeys = extractSearchParamKeys7(
25853
+ req.query
25854
+ );
25855
+ if (searchParamKeys.length === 0) {
25856
+ return handleListRoute({
25857
+ req,
25858
+ res,
25859
+ basePath: BASE_PATH.MEDICATIONREQUEST,
25860
+ listOperation: listMedicationRequestsOperation,
25861
+ errorLogContext: "GET /MedicationRequest list error:"
25862
+ });
25863
+ }
25864
+ const registered = getRegisteredSearchParameters(
25865
+ MEDICATIONREQUEST_RESOURCE_TYPE
25866
+ );
25867
+ const validCodes = new Set(registered.map((p) => p.code));
25868
+ const unknownCodes = searchParamKeys.map((k) => k.code).filter((code) => !validCodes.has(code));
25869
+ if (unknownCodes.length > 0) {
25870
+ return sendInvalidSearch4007(
25871
+ res,
25872
+ buildUnknownParamDiagnostics7([...new Set(unknownCodes)])
25873
+ );
25874
+ }
25875
+ const malformedRef = findMalformedReference7(
25876
+ req.query,
25877
+ searchParamKeys
25878
+ );
25879
+ if (malformedRef !== void 0) {
25880
+ return sendInvalidSearch4007(
25881
+ res,
25882
+ `?${malformedRef.rawKey} must be a typed reference like "Practitioner/<id>"; got "${malformedRef.value}".`
25883
+ );
25884
+ }
25885
+ const ctx = req.openhiContext;
25886
+ try {
25887
+ const result = await genericSearchOperation({
25888
+ resourceType: MEDICATIONREQUEST_RESOURCE_TYPE,
25889
+ tenantId: ctx.tenantId,
25890
+ workspaceId: ctx.workspaceId,
25891
+ query: req.query,
25892
+ resolver: defaultSearchParameterResolver
25893
+ });
25894
+ const bundle = buildSearchsetBundle(
25895
+ BASE_PATH.MEDICATIONREQUEST,
25896
+ result.entries
25897
+ );
25898
+ return res.json(bundle);
25899
+ } catch (err) {
25900
+ return sendOperationOutcome500(
25901
+ res,
25902
+ err,
25903
+ "GET /MedicationRequest search error:"
25904
+ );
25905
+ }
25906
+ }
25276
25907
 
25277
25908
  // src/data/operations/data/medicationrequest/medicationrequest-update-operation.ts
25278
25909
  async function updateMedicationRequestOperation(params) {
@@ -25471,15 +26102,119 @@ async function listMedicationStatementsOperation(params) {
25471
26102
  }
25472
26103
 
25473
26104
  // src/data/rest-api/routes/data/medicationstatement/medicationstatement-list-route.ts
25474
- async function listMedicationStatementsRoute(req, res) {
25475
- return handleListRoute({
25476
- req,
25477
- res,
25478
- basePath: BASE_PATH.MEDICATIONSTATEMENT,
25479
- listOperation: listMedicationStatementsOperation,
25480
- errorLogContext: "GET /MedicationStatement list error:"
26105
+ var MEDICATIONSTATEMENT_RESOURCE_TYPE = "MedicationStatement";
26106
+ function stripModifier8(key) {
26107
+ const idx = key.indexOf(":");
26108
+ return idx === -1 ? key : key.slice(0, idx);
26109
+ }
26110
+ function isResultParameter8(key) {
26111
+ return key.startsWith("_");
26112
+ }
26113
+ function sendInvalidSearch4008(res, diagnostics) {
26114
+ return res.status(400).json({
26115
+ resourceType: "OperationOutcome",
26116
+ issue: [{ severity: "error", code: "invalid", diagnostics }]
25481
26117
  });
25482
26118
  }
26119
+ function extractSearchParamKeys8(query) {
26120
+ const out = [];
26121
+ for (const rawKey of Object.keys(query)) {
26122
+ if (isResultParameter8(rawKey)) {
26123
+ continue;
26124
+ }
26125
+ out.push({ rawKey, code: stripModifier8(rawKey) });
26126
+ }
26127
+ return out;
26128
+ }
26129
+ function buildUnknownParamDiagnostics8(unknownCodes) {
26130
+ const validCodes = getRegisteredSearchParameters(
26131
+ MEDICATIONSTATEMENT_RESOURCE_TYPE
26132
+ ).map((p) => p.code).sort().join(", ");
26133
+ const codes = unknownCodes.join(", ");
26134
+ const isPlural = unknownCodes.length !== 1;
26135
+ return [
26136
+ `Unknown search ${isPlural ? "parameters" : "parameter"} for MedicationStatement: ${codes}.`,
26137
+ `Valid codes: ${validCodes}.`
26138
+ ].join(" ");
26139
+ }
26140
+ function findMalformedReference8(query, searchParamKeys) {
26141
+ const referenceCodes = new Set(
26142
+ getRegisteredSearchParameters(MEDICATIONSTATEMENT_RESOURCE_TYPE).filter((p) => p.type === "reference").map((p) => p.code)
26143
+ );
26144
+ for (const { rawKey, code } of searchParamKeys) {
26145
+ if (!referenceCodes.has(code)) {
26146
+ continue;
26147
+ }
26148
+ const raw = query[rawKey];
26149
+ const values = typeof raw === "string" ? raw.split(",") : Array.isArray(raw) ? raw.flatMap((v) => v.split(",")) : [];
26150
+ for (const v of values) {
26151
+ const trimmed = v.trim();
26152
+ if (trimmed.length === 0) {
26153
+ continue;
26154
+ }
26155
+ if (parseTypedReference(trimmed) === void 0) {
26156
+ return { rawKey, value: trimmed };
26157
+ }
26158
+ }
26159
+ }
26160
+ return void 0;
26161
+ }
26162
+ async function listMedicationStatementsRoute(req, res) {
26163
+ const searchParamKeys = extractSearchParamKeys8(
26164
+ req.query
26165
+ );
26166
+ if (searchParamKeys.length === 0) {
26167
+ return handleListRoute({
26168
+ req,
26169
+ res,
26170
+ basePath: BASE_PATH.MEDICATIONSTATEMENT,
26171
+ listOperation: listMedicationStatementsOperation,
26172
+ errorLogContext: "GET /MedicationStatement list error:"
26173
+ });
26174
+ }
26175
+ const registered = getRegisteredSearchParameters(
26176
+ MEDICATIONSTATEMENT_RESOURCE_TYPE
26177
+ );
26178
+ const validCodes = new Set(registered.map((p) => p.code));
26179
+ const unknownCodes = searchParamKeys.map((k) => k.code).filter((code) => !validCodes.has(code));
26180
+ if (unknownCodes.length > 0) {
26181
+ return sendInvalidSearch4008(
26182
+ res,
26183
+ buildUnknownParamDiagnostics8([...new Set(unknownCodes)])
26184
+ );
26185
+ }
26186
+ const malformedRef = findMalformedReference8(
26187
+ req.query,
26188
+ searchParamKeys
26189
+ );
26190
+ if (malformedRef !== void 0) {
26191
+ return sendInvalidSearch4008(
26192
+ res,
26193
+ `?${malformedRef.rawKey} must be a typed reference like "Practitioner/<id>"; got "${malformedRef.value}".`
26194
+ );
26195
+ }
26196
+ const ctx = req.openhiContext;
26197
+ try {
26198
+ const result = await genericSearchOperation({
26199
+ resourceType: MEDICATIONSTATEMENT_RESOURCE_TYPE,
26200
+ tenantId: ctx.tenantId,
26201
+ workspaceId: ctx.workspaceId,
26202
+ query: req.query,
26203
+ resolver: defaultSearchParameterResolver
26204
+ });
26205
+ const bundle = buildSearchsetBundle(
26206
+ BASE_PATH.MEDICATIONSTATEMENT,
26207
+ result.entries
26208
+ );
26209
+ return res.json(bundle);
26210
+ } catch (err) {
26211
+ return sendOperationOutcome500(
26212
+ res,
26213
+ err,
26214
+ "GET /MedicationStatement search error:"
26215
+ );
26216
+ }
26217
+ }
25483
26218
 
25484
26219
  // src/data/operations/data/medicationstatement/medicationstatement-update-operation.ts
25485
26220
  async function updateMedicationStatementOperation(params) {
@@ -28870,30 +29605,30 @@ async function listObservationsOperation(params) {
28870
29605
 
28871
29606
  // src/data/rest-api/routes/data/observation/observation-list-route.ts
28872
29607
  var OBSERVATION_RESOURCE_TYPE = "Observation";
28873
- function stripModifier3(key) {
29608
+ function stripModifier9(key) {
28874
29609
  const idx = key.indexOf(":");
28875
29610
  return idx === -1 ? key : key.slice(0, idx);
28876
29611
  }
28877
- function isResultParameter3(key) {
29612
+ function isResultParameter9(key) {
28878
29613
  return key.startsWith("_");
28879
29614
  }
28880
- function sendInvalidSearch4003(res, diagnostics) {
29615
+ function sendInvalidSearch4009(res, diagnostics) {
28881
29616
  return res.status(400).json({
28882
29617
  resourceType: "OperationOutcome",
28883
29618
  issue: [{ severity: "error", code: "invalid", diagnostics }]
28884
29619
  });
28885
29620
  }
28886
- function extractSearchParamKeys3(query) {
29621
+ function extractSearchParamKeys9(query) {
28887
29622
  const out = [];
28888
29623
  for (const rawKey of Object.keys(query)) {
28889
- if (isResultParameter3(rawKey)) {
29624
+ if (isResultParameter9(rawKey)) {
28890
29625
  continue;
28891
29626
  }
28892
- out.push({ rawKey, code: stripModifier3(rawKey) });
29627
+ out.push({ rawKey, code: stripModifier9(rawKey) });
28893
29628
  }
28894
29629
  return out;
28895
29630
  }
28896
- function buildUnknownParamDiagnostics3(unknownCodes) {
29631
+ function buildUnknownParamDiagnostics9(unknownCodes) {
28897
29632
  const validCodes = getRegisteredSearchParameters(OBSERVATION_RESOURCE_TYPE).map((p) => p.code).sort().join(", ");
28898
29633
  const codes = unknownCodes.join(", ");
28899
29634
  const isPlural = unknownCodes.length !== 1;
@@ -28902,7 +29637,7 @@ function buildUnknownParamDiagnostics3(unknownCodes) {
28902
29637
  `Valid codes: ${validCodes}.`
28903
29638
  ].join(" ");
28904
29639
  }
28905
- function findMalformedReference3(query, searchParamKeys) {
29640
+ function findMalformedReference9(query, searchParamKeys) {
28906
29641
  const referenceCodes = new Set(
28907
29642
  getRegisteredSearchParameters(OBSERVATION_RESOURCE_TYPE).filter((p) => p.type === "reference").map((p) => p.code)
28908
29643
  );
@@ -28925,7 +29660,7 @@ function findMalformedReference3(query, searchParamKeys) {
28925
29660
  return void 0;
28926
29661
  }
28927
29662
  async function listObservationsRoute(req, res) {
28928
- const searchParamKeys = extractSearchParamKeys3(
29663
+ const searchParamKeys = extractSearchParamKeys9(
28929
29664
  req.query
28930
29665
  );
28931
29666
  if (searchParamKeys.length === 0) {
@@ -28941,17 +29676,17 @@ async function listObservationsRoute(req, res) {
28941
29676
  const validCodes = new Set(registered.map((p) => p.code));
28942
29677
  const unknownCodes = searchParamKeys.map((k) => k.code).filter((code) => !validCodes.has(code));
28943
29678
  if (unknownCodes.length > 0) {
28944
- return sendInvalidSearch4003(
29679
+ return sendInvalidSearch4009(
28945
29680
  res,
28946
- buildUnknownParamDiagnostics3([...new Set(unknownCodes)])
29681
+ buildUnknownParamDiagnostics9([...new Set(unknownCodes)])
28947
29682
  );
28948
29683
  }
28949
- const malformedRef = findMalformedReference3(
29684
+ const malformedRef = findMalformedReference9(
28950
29685
  req.query,
28951
29686
  searchParamKeys
28952
29687
  );
28953
29688
  if (malformedRef !== void 0) {
28954
- return sendInvalidSearch4003(
29689
+ return sendInvalidSearch4009(
28955
29690
  res,
28956
29691
  `?${malformedRef.rawKey} must be a typed reference like "Practitioner/<id>"; got "${malformedRef.value}".`
28957
29692
  );
@@ -29981,30 +30716,30 @@ async function listPatientsOperation(params) {
29981
30716
 
29982
30717
  // src/data/rest-api/routes/data/patient/patient-list-route.ts
29983
30718
  var PATIENT_RESOURCE_TYPE = "Patient";
29984
- function stripModifier4(key) {
30719
+ function stripModifier10(key) {
29985
30720
  const idx = key.indexOf(":");
29986
30721
  return idx === -1 ? key : key.slice(0, idx);
29987
30722
  }
29988
- function isResultParameter4(key) {
30723
+ function isResultParameter10(key) {
29989
30724
  return key.startsWith("_");
29990
30725
  }
29991
- function sendInvalidSearch4004(res, diagnostics) {
30726
+ function sendInvalidSearch40010(res, diagnostics) {
29992
30727
  return res.status(400).json({
29993
30728
  resourceType: "OperationOutcome",
29994
30729
  issue: [{ severity: "error", code: "invalid", diagnostics }]
29995
30730
  });
29996
30731
  }
29997
- function extractSearchParamKeys4(query) {
30732
+ function extractSearchParamKeys10(query) {
29998
30733
  const out = [];
29999
30734
  for (const rawKey of Object.keys(query)) {
30000
- if (isResultParameter4(rawKey)) {
30735
+ if (isResultParameter10(rawKey)) {
30001
30736
  continue;
30002
30737
  }
30003
- out.push({ rawKey, code: stripModifier4(rawKey) });
30738
+ out.push({ rawKey, code: stripModifier10(rawKey) });
30004
30739
  }
30005
30740
  return out;
30006
30741
  }
30007
- function buildUnknownParamDiagnostics4(unknownCodes) {
30742
+ function buildUnknownParamDiagnostics10(unknownCodes) {
30008
30743
  const validCodes = getRegisteredSearchParameters(PATIENT_RESOURCE_TYPE).map((p) => p.code).sort().join(", ");
30009
30744
  const codes = unknownCodes.join(", ");
30010
30745
  const isPlural = unknownCodes.length !== 1;
@@ -30013,7 +30748,7 @@ function buildUnknownParamDiagnostics4(unknownCodes) {
30013
30748
  `Valid codes: ${validCodes}.`
30014
30749
  ].join(" ");
30015
30750
  }
30016
- function findMalformedReference4(query, searchParamKeys) {
30751
+ function findMalformedReference10(query, searchParamKeys) {
30017
30752
  const referenceCodes = new Set(
30018
30753
  getRegisteredSearchParameters(PATIENT_RESOURCE_TYPE).filter((p) => p.type === "reference").map((p) => p.code)
30019
30754
  );
@@ -30036,7 +30771,7 @@ function findMalformedReference4(query, searchParamKeys) {
30036
30771
  return void 0;
30037
30772
  }
30038
30773
  async function listPatientsRoute(req, res) {
30039
- const searchParamKeys = extractSearchParamKeys4(
30774
+ const searchParamKeys = extractSearchParamKeys10(
30040
30775
  req.query
30041
30776
  );
30042
30777
  if (searchParamKeys.length === 0) {
@@ -30052,17 +30787,17 @@ async function listPatientsRoute(req, res) {
30052
30787
  const validCodes = new Set(registered.map((p) => p.code));
30053
30788
  const unknownCodes = searchParamKeys.map((k) => k.code).filter((code) => !validCodes.has(code));
30054
30789
  if (unknownCodes.length > 0) {
30055
- return sendInvalidSearch4004(
30790
+ return sendInvalidSearch40010(
30056
30791
  res,
30057
- buildUnknownParamDiagnostics4([...new Set(unknownCodes)])
30792
+ buildUnknownParamDiagnostics10([...new Set(unknownCodes)])
30058
30793
  );
30059
30794
  }
30060
- const malformedRef = findMalformedReference4(
30795
+ const malformedRef = findMalformedReference10(
30061
30796
  req.query,
30062
30797
  searchParamKeys
30063
30798
  );
30064
30799
  if (malformedRef !== void 0) {
30065
- return sendInvalidSearch4004(
30800
+ return sendInvalidSearch40010(
30066
30801
  res,
30067
30802
  `?${malformedRef.rawKey} must be a typed reference like "Practitioner/<id>"; got "${malformedRef.value}".`
30068
30803
  );
@@ -31437,30 +32172,30 @@ async function listProceduresOperation(params) {
31437
32172
 
31438
32173
  // src/data/rest-api/routes/data/procedure/procedure-list-route.ts
31439
32174
  var PROCEDURE_RESOURCE_TYPE = "Procedure";
31440
- function stripModifier5(key) {
32175
+ function stripModifier11(key) {
31441
32176
  const idx = key.indexOf(":");
31442
32177
  return idx === -1 ? key : key.slice(0, idx);
31443
32178
  }
31444
- function isResultParameter5(key) {
32179
+ function isResultParameter11(key) {
31445
32180
  return key.startsWith("_");
31446
32181
  }
31447
- function sendInvalidSearch4005(res, diagnostics) {
32182
+ function sendInvalidSearch40011(res, diagnostics) {
31448
32183
  return res.status(400).json({
31449
32184
  resourceType: "OperationOutcome",
31450
32185
  issue: [{ severity: "error", code: "invalid", diagnostics }]
31451
32186
  });
31452
32187
  }
31453
- function extractSearchParamKeys5(query) {
32188
+ function extractSearchParamKeys11(query) {
31454
32189
  const out = [];
31455
32190
  for (const rawKey of Object.keys(query)) {
31456
- if (isResultParameter5(rawKey)) {
32191
+ if (isResultParameter11(rawKey)) {
31457
32192
  continue;
31458
32193
  }
31459
- out.push({ rawKey, code: stripModifier5(rawKey) });
32194
+ out.push({ rawKey, code: stripModifier11(rawKey) });
31460
32195
  }
31461
32196
  return out;
31462
32197
  }
31463
- function buildUnknownParamDiagnostics5(unknownCodes) {
32198
+ function buildUnknownParamDiagnostics11(unknownCodes) {
31464
32199
  const validCodes = getRegisteredSearchParameters(PROCEDURE_RESOURCE_TYPE).map((p) => p.code).sort().join(", ");
31465
32200
  const codes = unknownCodes.join(", ");
31466
32201
  const isPlural = unknownCodes.length !== 1;
@@ -31469,7 +32204,7 @@ function buildUnknownParamDiagnostics5(unknownCodes) {
31469
32204
  `Valid codes: ${validCodes}.`
31470
32205
  ].join(" ");
31471
32206
  }
31472
- function findMalformedReference5(query, searchParamKeys) {
32207
+ function findMalformedReference11(query, searchParamKeys) {
31473
32208
  const referenceCodes = new Set(
31474
32209
  getRegisteredSearchParameters(PROCEDURE_RESOURCE_TYPE).filter((p) => p.type === "reference").map((p) => p.code)
31475
32210
  );
@@ -31492,7 +32227,7 @@ function findMalformedReference5(query, searchParamKeys) {
31492
32227
  return void 0;
31493
32228
  }
31494
32229
  async function listProceduresRoute(req, res) {
31495
- const searchParamKeys = extractSearchParamKeys5(
32230
+ const searchParamKeys = extractSearchParamKeys11(
31496
32231
  req.query
31497
32232
  );
31498
32233
  if (searchParamKeys.length === 0) {
@@ -31508,17 +32243,17 @@ async function listProceduresRoute(req, res) {
31508
32243
  const validCodes = new Set(registered.map((p) => p.code));
31509
32244
  const unknownCodes = searchParamKeys.map((k) => k.code).filter((code) => !validCodes.has(code));
31510
32245
  if (unknownCodes.length > 0) {
31511
- return sendInvalidSearch4005(
32246
+ return sendInvalidSearch40011(
31512
32247
  res,
31513
- buildUnknownParamDiagnostics5([...new Set(unknownCodes)])
32248
+ buildUnknownParamDiagnostics11([...new Set(unknownCodes)])
31514
32249
  );
31515
32250
  }
31516
- const malformedRef = findMalformedReference5(
32251
+ const malformedRef = findMalformedReference11(
31517
32252
  req.query,
31518
32253
  searchParamKeys
31519
32254
  );
31520
32255
  if (malformedRef !== void 0) {
31521
- return sendInvalidSearch4005(
32256
+ return sendInvalidSearch40011(
31522
32257
  res,
31523
32258
  `?${malformedRef.rawKey} must be a typed reference like "Practitioner/<id>"; got "${malformedRef.value}".`
31524
32259
  );
@@ -34045,7 +34780,7 @@ function singleStringQueryParam(req, name) {
34045
34780
  const trimmed = v.trim();
34046
34781
  return trimmed === "" ? void 0 : trimmed;
34047
34782
  }
34048
- function sendInvalidSearch4006(res, diagnostics) {
34783
+ function sendInvalidSearch40012(res, diagnostics) {
34049
34784
  return res.status(400).json({
34050
34785
  resourceType: "OperationOutcome",
34051
34786
  issue: [{ severity: "error", code: "invalid", diagnostics }]
@@ -34055,7 +34790,7 @@ async function listSchedulesRoute(req, res) {
34055
34790
  const actorRef = singleStringQueryParam(req, "actor");
34056
34791
  if (actorRef !== void 0) {
34057
34792
  if (parseTypedReference(actorRef) === void 0) {
34058
- return sendInvalidSearch4006(
34793
+ return sendInvalidSearch40012(
34059
34794
  res,
34060
34795
  `?actor must be a typed reference like "Practitioner/<id>"; got "${actorRef}".`
34061
34796
  );
@@ -37853,7 +38588,7 @@ function singleStringQueryParam2(req, name) {
37853
38588
  const trimmed = v.trim();
37854
38589
  return trimmed === "" ? void 0 : trimmed;
37855
38590
  }
37856
- function sendInvalidSearch4007(res, diagnostics) {
38591
+ function sendInvalidSearch40013(res, diagnostics) {
37857
38592
  return res.status(400).json({
37858
38593
  resourceType: "OperationOutcome",
37859
38594
  issue: [{ severity: "error", code: "invalid", diagnostics }]
@@ -37863,14 +38598,14 @@ async function listTasksRoute(req, res) {
37863
38598
  const ownerRef = singleStringQueryParam2(req, "owner");
37864
38599
  const requesterRef = singleStringQueryParam2(req, "requester");
37865
38600
  if (ownerRef !== void 0 && requesterRef !== void 0) {
37866
- return sendInvalidSearch4007(
38601
+ return sendInvalidSearch40013(
37867
38602
  res,
37868
38603
  "?owner= and ?requester= cannot be combined on the same request."
37869
38604
  );
37870
38605
  }
37871
38606
  if (ownerRef !== void 0) {
37872
38607
  if (parseTypedReference(ownerRef) === void 0) {
37873
- return sendInvalidSearch4007(
38608
+ return sendInvalidSearch40013(
37874
38609
  res,
37875
38610
  `?owner must be a typed reference like "Practitioner/<id>"; got "${ownerRef}".`
37876
38611
  );
@@ -37893,7 +38628,7 @@ async function listTasksRoute(req, res) {
37893
38628
  }
37894
38629
  if (requesterRef !== void 0) {
37895
38630
  if (parseTypedReference(requesterRef) === void 0) {
37896
- return sendInvalidSearch4007(
38631
+ return sendInvalidSearch40013(
37897
38632
  res,
37898
38633
  `?requester must be a typed reference like "Practitioner/<id>"; got "${requesterRef}".`
37899
38634
  );