@openhi/constructs 0.0.143 → 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.
|
@@ -10173,6 +10173,72 @@ var FAMILYMEMBERHISTORY_SEARCH_PARAMETERS = [
|
|
|
10173
10173
|
{ code: "identifier", type: "token", jsonbPath: "$.identifier[*]" }
|
|
10174
10174
|
];
|
|
10175
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 = [
|
|
10204
|
+
{ code: "status", type: "token", jsonbPath: "$.status" },
|
|
10205
|
+
{ code: "intent", type: "token", jsonbPath: "$.intent" },
|
|
10206
|
+
{ code: "category", type: "token", jsonbPath: "$.category[*]" },
|
|
10207
|
+
{ code: "priority", type: "token", jsonbPath: "$.priority" },
|
|
10208
|
+
{ code: "code", type: "token", jsonbPath: "$.medicationCodeableConcept" },
|
|
10209
|
+
{ code: "subject", type: "reference", jsonbPath: "$.subject" },
|
|
10210
|
+
{ code: "patient", type: "reference", jsonbPath: "$.subject" },
|
|
10211
|
+
{ code: "encounter", type: "reference", jsonbPath: "$.encounter" },
|
|
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" },
|
|
10227
|
+
{
|
|
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
|
+
|
|
10176
10242
|
// src/data/search/registry/observation-search-parameters.ts
|
|
10177
10243
|
var OBSERVATION_SEARCH_PARAMETERS = [
|
|
10178
10244
|
{ code: "status", type: "token", jsonbPath: "$.status" },
|
|
@@ -10264,6 +10330,9 @@ var STATIC_SEARCH_PARAMETER_MAP = {
|
|
|
10264
10330
|
Condition: CONDITION_SEARCH_PARAMETERS,
|
|
10265
10331
|
Encounter: ENCOUNTER_SEARCH_PARAMETERS,
|
|
10266
10332
|
FamilyMemberHistory: FAMILYMEMBERHISTORY_SEARCH_PARAMETERS,
|
|
10333
|
+
Immunization: IMMUNIZATION_SEARCH_PARAMETERS,
|
|
10334
|
+
MedicationRequest: MEDICATIONREQUEST_SEARCH_PARAMETERS,
|
|
10335
|
+
MedicationStatement: MEDICATIONSTATEMENT_SEARCH_PARAMETERS,
|
|
10267
10336
|
Observation: OBSERVATION_SEARCH_PARAMETERS,
|
|
10268
10337
|
Patient: PATIENT_SEARCH_PARAMETERS,
|
|
10269
10338
|
Procedure: PROCEDURE_SEARCH_PARAMETERS
|
|
@@ -22148,15 +22217,108 @@ async function listImmunizationsOperation(params) {
|
|
|
22148
22217
|
}
|
|
22149
22218
|
|
|
22150
22219
|
// src/data/rest-api/routes/data/immunization/immunization-list-route.ts
|
|
22151
|
-
|
|
22152
|
-
|
|
22153
|
-
|
|
22154
|
-
|
|
22155
|
-
|
|
22156
|
-
|
|
22157
|
-
|
|
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 }]
|
|
22158
22232
|
});
|
|
22159
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);
|
|
22318
|
+
} catch (err) {
|
|
22319
|
+
return sendOperationOutcome500(res, err, "GET /Immunization search error:");
|
|
22320
|
+
}
|
|
22321
|
+
}
|
|
22160
22322
|
|
|
22161
22323
|
// src/data/operations/data/immunization/immunization-update-operation.ts
|
|
22162
22324
|
async function updateImmunizationOperation(params) {
|
|
@@ -25629,15 +25791,119 @@ async function listMedicationRequestsOperation(params) {
|
|
|
25629
25791
|
}
|
|
25630
25792
|
|
|
25631
25793
|
// src/data/rest-api/routes/data/medicationrequest/medicationrequest-list-route.ts
|
|
25632
|
-
|
|
25633
|
-
|
|
25634
|
-
|
|
25635
|
-
|
|
25636
|
-
|
|
25637
|
-
|
|
25638
|
-
|
|
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 }]
|
|
25639
25806
|
});
|
|
25640
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
|
+
}
|
|
25641
25907
|
|
|
25642
25908
|
// src/data/operations/data/medicationrequest/medicationrequest-update-operation.ts
|
|
25643
25909
|
async function updateMedicationRequestOperation(params) {
|
|
@@ -25836,15 +26102,119 @@ async function listMedicationStatementsOperation(params) {
|
|
|
25836
26102
|
}
|
|
25837
26103
|
|
|
25838
26104
|
// src/data/rest-api/routes/data/medicationstatement/medicationstatement-list-route.ts
|
|
25839
|
-
|
|
25840
|
-
|
|
25841
|
-
|
|
25842
|
-
|
|
25843
|
-
|
|
25844
|
-
|
|
25845
|
-
|
|
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 }]
|
|
25846
26117
|
});
|
|
25847
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
|
+
}
|
|
25848
26218
|
|
|
25849
26219
|
// src/data/operations/data/medicationstatement/medicationstatement-update-operation.ts
|
|
25850
26220
|
async function updateMedicationStatementOperation(params) {
|
|
@@ -29235,30 +29605,30 @@ async function listObservationsOperation(params) {
|
|
|
29235
29605
|
|
|
29236
29606
|
// src/data/rest-api/routes/data/observation/observation-list-route.ts
|
|
29237
29607
|
var OBSERVATION_RESOURCE_TYPE = "Observation";
|
|
29238
|
-
function
|
|
29608
|
+
function stripModifier9(key) {
|
|
29239
29609
|
const idx = key.indexOf(":");
|
|
29240
29610
|
return idx === -1 ? key : key.slice(0, idx);
|
|
29241
29611
|
}
|
|
29242
|
-
function
|
|
29612
|
+
function isResultParameter9(key) {
|
|
29243
29613
|
return key.startsWith("_");
|
|
29244
29614
|
}
|
|
29245
|
-
function
|
|
29615
|
+
function sendInvalidSearch4009(res, diagnostics) {
|
|
29246
29616
|
return res.status(400).json({
|
|
29247
29617
|
resourceType: "OperationOutcome",
|
|
29248
29618
|
issue: [{ severity: "error", code: "invalid", diagnostics }]
|
|
29249
29619
|
});
|
|
29250
29620
|
}
|
|
29251
|
-
function
|
|
29621
|
+
function extractSearchParamKeys9(query) {
|
|
29252
29622
|
const out = [];
|
|
29253
29623
|
for (const rawKey of Object.keys(query)) {
|
|
29254
|
-
if (
|
|
29624
|
+
if (isResultParameter9(rawKey)) {
|
|
29255
29625
|
continue;
|
|
29256
29626
|
}
|
|
29257
|
-
out.push({ rawKey, code:
|
|
29627
|
+
out.push({ rawKey, code: stripModifier9(rawKey) });
|
|
29258
29628
|
}
|
|
29259
29629
|
return out;
|
|
29260
29630
|
}
|
|
29261
|
-
function
|
|
29631
|
+
function buildUnknownParamDiagnostics9(unknownCodes) {
|
|
29262
29632
|
const validCodes = getRegisteredSearchParameters(OBSERVATION_RESOURCE_TYPE).map((p) => p.code).sort().join(", ");
|
|
29263
29633
|
const codes = unknownCodes.join(", ");
|
|
29264
29634
|
const isPlural = unknownCodes.length !== 1;
|
|
@@ -29267,7 +29637,7 @@ function buildUnknownParamDiagnostics6(unknownCodes) {
|
|
|
29267
29637
|
`Valid codes: ${validCodes}.`
|
|
29268
29638
|
].join(" ");
|
|
29269
29639
|
}
|
|
29270
|
-
function
|
|
29640
|
+
function findMalformedReference9(query, searchParamKeys) {
|
|
29271
29641
|
const referenceCodes = new Set(
|
|
29272
29642
|
getRegisteredSearchParameters(OBSERVATION_RESOURCE_TYPE).filter((p) => p.type === "reference").map((p) => p.code)
|
|
29273
29643
|
);
|
|
@@ -29290,7 +29660,7 @@ function findMalformedReference6(query, searchParamKeys) {
|
|
|
29290
29660
|
return void 0;
|
|
29291
29661
|
}
|
|
29292
29662
|
async function listObservationsRoute(req, res) {
|
|
29293
|
-
const searchParamKeys =
|
|
29663
|
+
const searchParamKeys = extractSearchParamKeys9(
|
|
29294
29664
|
req.query
|
|
29295
29665
|
);
|
|
29296
29666
|
if (searchParamKeys.length === 0) {
|
|
@@ -29306,17 +29676,17 @@ async function listObservationsRoute(req, res) {
|
|
|
29306
29676
|
const validCodes = new Set(registered.map((p) => p.code));
|
|
29307
29677
|
const unknownCodes = searchParamKeys.map((k) => k.code).filter((code) => !validCodes.has(code));
|
|
29308
29678
|
if (unknownCodes.length > 0) {
|
|
29309
|
-
return
|
|
29679
|
+
return sendInvalidSearch4009(
|
|
29310
29680
|
res,
|
|
29311
|
-
|
|
29681
|
+
buildUnknownParamDiagnostics9([...new Set(unknownCodes)])
|
|
29312
29682
|
);
|
|
29313
29683
|
}
|
|
29314
|
-
const malformedRef =
|
|
29684
|
+
const malformedRef = findMalformedReference9(
|
|
29315
29685
|
req.query,
|
|
29316
29686
|
searchParamKeys
|
|
29317
29687
|
);
|
|
29318
29688
|
if (malformedRef !== void 0) {
|
|
29319
|
-
return
|
|
29689
|
+
return sendInvalidSearch4009(
|
|
29320
29690
|
res,
|
|
29321
29691
|
`?${malformedRef.rawKey} must be a typed reference like "Practitioner/<id>"; got "${malformedRef.value}".`
|
|
29322
29692
|
);
|
|
@@ -30346,30 +30716,30 @@ async function listPatientsOperation(params) {
|
|
|
30346
30716
|
|
|
30347
30717
|
// src/data/rest-api/routes/data/patient/patient-list-route.ts
|
|
30348
30718
|
var PATIENT_RESOURCE_TYPE = "Patient";
|
|
30349
|
-
function
|
|
30719
|
+
function stripModifier10(key) {
|
|
30350
30720
|
const idx = key.indexOf(":");
|
|
30351
30721
|
return idx === -1 ? key : key.slice(0, idx);
|
|
30352
30722
|
}
|
|
30353
|
-
function
|
|
30723
|
+
function isResultParameter10(key) {
|
|
30354
30724
|
return key.startsWith("_");
|
|
30355
30725
|
}
|
|
30356
|
-
function
|
|
30726
|
+
function sendInvalidSearch40010(res, diagnostics) {
|
|
30357
30727
|
return res.status(400).json({
|
|
30358
30728
|
resourceType: "OperationOutcome",
|
|
30359
30729
|
issue: [{ severity: "error", code: "invalid", diagnostics }]
|
|
30360
30730
|
});
|
|
30361
30731
|
}
|
|
30362
|
-
function
|
|
30732
|
+
function extractSearchParamKeys10(query) {
|
|
30363
30733
|
const out = [];
|
|
30364
30734
|
for (const rawKey of Object.keys(query)) {
|
|
30365
|
-
if (
|
|
30735
|
+
if (isResultParameter10(rawKey)) {
|
|
30366
30736
|
continue;
|
|
30367
30737
|
}
|
|
30368
|
-
out.push({ rawKey, code:
|
|
30738
|
+
out.push({ rawKey, code: stripModifier10(rawKey) });
|
|
30369
30739
|
}
|
|
30370
30740
|
return out;
|
|
30371
30741
|
}
|
|
30372
|
-
function
|
|
30742
|
+
function buildUnknownParamDiagnostics10(unknownCodes) {
|
|
30373
30743
|
const validCodes = getRegisteredSearchParameters(PATIENT_RESOURCE_TYPE).map((p) => p.code).sort().join(", ");
|
|
30374
30744
|
const codes = unknownCodes.join(", ");
|
|
30375
30745
|
const isPlural = unknownCodes.length !== 1;
|
|
@@ -30378,7 +30748,7 @@ function buildUnknownParamDiagnostics7(unknownCodes) {
|
|
|
30378
30748
|
`Valid codes: ${validCodes}.`
|
|
30379
30749
|
].join(" ");
|
|
30380
30750
|
}
|
|
30381
|
-
function
|
|
30751
|
+
function findMalformedReference10(query, searchParamKeys) {
|
|
30382
30752
|
const referenceCodes = new Set(
|
|
30383
30753
|
getRegisteredSearchParameters(PATIENT_RESOURCE_TYPE).filter((p) => p.type === "reference").map((p) => p.code)
|
|
30384
30754
|
);
|
|
@@ -30401,7 +30771,7 @@ function findMalformedReference7(query, searchParamKeys) {
|
|
|
30401
30771
|
return void 0;
|
|
30402
30772
|
}
|
|
30403
30773
|
async function listPatientsRoute(req, res) {
|
|
30404
|
-
const searchParamKeys =
|
|
30774
|
+
const searchParamKeys = extractSearchParamKeys10(
|
|
30405
30775
|
req.query
|
|
30406
30776
|
);
|
|
30407
30777
|
if (searchParamKeys.length === 0) {
|
|
@@ -30417,17 +30787,17 @@ async function listPatientsRoute(req, res) {
|
|
|
30417
30787
|
const validCodes = new Set(registered.map((p) => p.code));
|
|
30418
30788
|
const unknownCodes = searchParamKeys.map((k) => k.code).filter((code) => !validCodes.has(code));
|
|
30419
30789
|
if (unknownCodes.length > 0) {
|
|
30420
|
-
return
|
|
30790
|
+
return sendInvalidSearch40010(
|
|
30421
30791
|
res,
|
|
30422
|
-
|
|
30792
|
+
buildUnknownParamDiagnostics10([...new Set(unknownCodes)])
|
|
30423
30793
|
);
|
|
30424
30794
|
}
|
|
30425
|
-
const malformedRef =
|
|
30795
|
+
const malformedRef = findMalformedReference10(
|
|
30426
30796
|
req.query,
|
|
30427
30797
|
searchParamKeys
|
|
30428
30798
|
);
|
|
30429
30799
|
if (malformedRef !== void 0) {
|
|
30430
|
-
return
|
|
30800
|
+
return sendInvalidSearch40010(
|
|
30431
30801
|
res,
|
|
30432
30802
|
`?${malformedRef.rawKey} must be a typed reference like "Practitioner/<id>"; got "${malformedRef.value}".`
|
|
30433
30803
|
);
|
|
@@ -31802,30 +32172,30 @@ async function listProceduresOperation(params) {
|
|
|
31802
32172
|
|
|
31803
32173
|
// src/data/rest-api/routes/data/procedure/procedure-list-route.ts
|
|
31804
32174
|
var PROCEDURE_RESOURCE_TYPE = "Procedure";
|
|
31805
|
-
function
|
|
32175
|
+
function stripModifier11(key) {
|
|
31806
32176
|
const idx = key.indexOf(":");
|
|
31807
32177
|
return idx === -1 ? key : key.slice(0, idx);
|
|
31808
32178
|
}
|
|
31809
|
-
function
|
|
32179
|
+
function isResultParameter11(key) {
|
|
31810
32180
|
return key.startsWith("_");
|
|
31811
32181
|
}
|
|
31812
|
-
function
|
|
32182
|
+
function sendInvalidSearch40011(res, diagnostics) {
|
|
31813
32183
|
return res.status(400).json({
|
|
31814
32184
|
resourceType: "OperationOutcome",
|
|
31815
32185
|
issue: [{ severity: "error", code: "invalid", diagnostics }]
|
|
31816
32186
|
});
|
|
31817
32187
|
}
|
|
31818
|
-
function
|
|
32188
|
+
function extractSearchParamKeys11(query) {
|
|
31819
32189
|
const out = [];
|
|
31820
32190
|
for (const rawKey of Object.keys(query)) {
|
|
31821
|
-
if (
|
|
32191
|
+
if (isResultParameter11(rawKey)) {
|
|
31822
32192
|
continue;
|
|
31823
32193
|
}
|
|
31824
|
-
out.push({ rawKey, code:
|
|
32194
|
+
out.push({ rawKey, code: stripModifier11(rawKey) });
|
|
31825
32195
|
}
|
|
31826
32196
|
return out;
|
|
31827
32197
|
}
|
|
31828
|
-
function
|
|
32198
|
+
function buildUnknownParamDiagnostics11(unknownCodes) {
|
|
31829
32199
|
const validCodes = getRegisteredSearchParameters(PROCEDURE_RESOURCE_TYPE).map((p) => p.code).sort().join(", ");
|
|
31830
32200
|
const codes = unknownCodes.join(", ");
|
|
31831
32201
|
const isPlural = unknownCodes.length !== 1;
|
|
@@ -31834,7 +32204,7 @@ function buildUnknownParamDiagnostics8(unknownCodes) {
|
|
|
31834
32204
|
`Valid codes: ${validCodes}.`
|
|
31835
32205
|
].join(" ");
|
|
31836
32206
|
}
|
|
31837
|
-
function
|
|
32207
|
+
function findMalformedReference11(query, searchParamKeys) {
|
|
31838
32208
|
const referenceCodes = new Set(
|
|
31839
32209
|
getRegisteredSearchParameters(PROCEDURE_RESOURCE_TYPE).filter((p) => p.type === "reference").map((p) => p.code)
|
|
31840
32210
|
);
|
|
@@ -31857,7 +32227,7 @@ function findMalformedReference8(query, searchParamKeys) {
|
|
|
31857
32227
|
return void 0;
|
|
31858
32228
|
}
|
|
31859
32229
|
async function listProceduresRoute(req, res) {
|
|
31860
|
-
const searchParamKeys =
|
|
32230
|
+
const searchParamKeys = extractSearchParamKeys11(
|
|
31861
32231
|
req.query
|
|
31862
32232
|
);
|
|
31863
32233
|
if (searchParamKeys.length === 0) {
|
|
@@ -31873,17 +32243,17 @@ async function listProceduresRoute(req, res) {
|
|
|
31873
32243
|
const validCodes = new Set(registered.map((p) => p.code));
|
|
31874
32244
|
const unknownCodes = searchParamKeys.map((k) => k.code).filter((code) => !validCodes.has(code));
|
|
31875
32245
|
if (unknownCodes.length > 0) {
|
|
31876
|
-
return
|
|
32246
|
+
return sendInvalidSearch40011(
|
|
31877
32247
|
res,
|
|
31878
|
-
|
|
32248
|
+
buildUnknownParamDiagnostics11([...new Set(unknownCodes)])
|
|
31879
32249
|
);
|
|
31880
32250
|
}
|
|
31881
|
-
const malformedRef =
|
|
32251
|
+
const malformedRef = findMalformedReference11(
|
|
31882
32252
|
req.query,
|
|
31883
32253
|
searchParamKeys
|
|
31884
32254
|
);
|
|
31885
32255
|
if (malformedRef !== void 0) {
|
|
31886
|
-
return
|
|
32256
|
+
return sendInvalidSearch40011(
|
|
31887
32257
|
res,
|
|
31888
32258
|
`?${malformedRef.rawKey} must be a typed reference like "Practitioner/<id>"; got "${malformedRef.value}".`
|
|
31889
32259
|
);
|
|
@@ -34410,7 +34780,7 @@ function singleStringQueryParam(req, name) {
|
|
|
34410
34780
|
const trimmed = v.trim();
|
|
34411
34781
|
return trimmed === "" ? void 0 : trimmed;
|
|
34412
34782
|
}
|
|
34413
|
-
function
|
|
34783
|
+
function sendInvalidSearch40012(res, diagnostics) {
|
|
34414
34784
|
return res.status(400).json({
|
|
34415
34785
|
resourceType: "OperationOutcome",
|
|
34416
34786
|
issue: [{ severity: "error", code: "invalid", diagnostics }]
|
|
@@ -34420,7 +34790,7 @@ async function listSchedulesRoute(req, res) {
|
|
|
34420
34790
|
const actorRef = singleStringQueryParam(req, "actor");
|
|
34421
34791
|
if (actorRef !== void 0) {
|
|
34422
34792
|
if (parseTypedReference(actorRef) === void 0) {
|
|
34423
|
-
return
|
|
34793
|
+
return sendInvalidSearch40012(
|
|
34424
34794
|
res,
|
|
34425
34795
|
`?actor must be a typed reference like "Practitioner/<id>"; got "${actorRef}".`
|
|
34426
34796
|
);
|
|
@@ -38218,7 +38588,7 @@ function singleStringQueryParam2(req, name) {
|
|
|
38218
38588
|
const trimmed = v.trim();
|
|
38219
38589
|
return trimmed === "" ? void 0 : trimmed;
|
|
38220
38590
|
}
|
|
38221
|
-
function
|
|
38591
|
+
function sendInvalidSearch40013(res, diagnostics) {
|
|
38222
38592
|
return res.status(400).json({
|
|
38223
38593
|
resourceType: "OperationOutcome",
|
|
38224
38594
|
issue: [{ severity: "error", code: "invalid", diagnostics }]
|
|
@@ -38228,14 +38598,14 @@ async function listTasksRoute(req, res) {
|
|
|
38228
38598
|
const ownerRef = singleStringQueryParam2(req, "owner");
|
|
38229
38599
|
const requesterRef = singleStringQueryParam2(req, "requester");
|
|
38230
38600
|
if (ownerRef !== void 0 && requesterRef !== void 0) {
|
|
38231
|
-
return
|
|
38601
|
+
return sendInvalidSearch40013(
|
|
38232
38602
|
res,
|
|
38233
38603
|
"?owner= and ?requester= cannot be combined on the same request."
|
|
38234
38604
|
);
|
|
38235
38605
|
}
|
|
38236
38606
|
if (ownerRef !== void 0) {
|
|
38237
38607
|
if (parseTypedReference(ownerRef) === void 0) {
|
|
38238
|
-
return
|
|
38608
|
+
return sendInvalidSearch40013(
|
|
38239
38609
|
res,
|
|
38240
38610
|
`?owner must be a typed reference like "Practitioner/<id>"; got "${ownerRef}".`
|
|
38241
38611
|
);
|
|
@@ -38258,7 +38628,7 @@ async function listTasksRoute(req, res) {
|
|
|
38258
38628
|
}
|
|
38259
38629
|
if (requesterRef !== void 0) {
|
|
38260
38630
|
if (parseTypedReference(requesterRef) === void 0) {
|
|
38261
|
-
return
|
|
38631
|
+
return sendInvalidSearch40013(
|
|
38262
38632
|
res,
|
|
38263
38633
|
`?requester must be a typed reference like "Practitioner/<id>"; got "${requesterRef}".`
|
|
38264
38634
|
);
|