@openhi/constructs 0.0.177 → 0.0.178

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.
@@ -10964,6 +10964,16 @@ function jsonbPathToStringShape(jsonbPath) {
10964
10964
  if (arrayOfScalars) {
10965
10965
  return { kind: "array-of-scalars", field: arrayOfScalars[1] };
10966
10966
  }
10967
+ const arrayOfArrays = /^\$\.([A-Za-z_][A-Za-z0-9_]*)\[\*\]\.([A-Za-z_][A-Za-z0-9_]*)\[\*\]$/.exec(
10968
+ jsonbPath
10969
+ );
10970
+ if (arrayOfArrays) {
10971
+ return {
10972
+ kind: "array-of-arrays",
10973
+ field: arrayOfArrays[1],
10974
+ subfield: arrayOfArrays[2]
10975
+ };
10976
+ }
10967
10977
  const arrayOfObjs = /^\$\.([A-Za-z_][A-Za-z0-9_]*)\[\*\]\.([A-Za-z_][A-Za-z0-9_]*)$/.exec(
10968
10978
  jsonbPath
10969
10979
  );
@@ -10975,7 +10985,7 @@ function jsonbPathToStringShape(jsonbPath) {
10975
10985
  };
10976
10986
  }
10977
10987
  throw new Error(
10978
- `String predicate cannot translate JSONPath "${jsonbPath}". Supported shapes: "$.field", "$.field[*]", "$.field[*].subfield".`
10988
+ `String predicate cannot translate JSONPath "${jsonbPath}". Supported shapes: "$.field", "$.field[*]", "$.field[*].subfield", "$.field[*].subfield[*]".`
10979
10989
  );
10980
10990
  }
10981
10991
  function escapeLikePattern(value) {
@@ -11008,6 +11018,13 @@ function buildIlikeExtractSql(shape, paramName) {
11008
11018
  `jsonb_array_elements(resource->'${shape.field}') AS s_obj(obj)`,
11009
11019
  `WHERE s_obj.obj->>'${shape.subfield}' ILIKE :${paramName})`
11010
11020
  ].join(" ");
11021
+ case "array-of-arrays":
11022
+ return [
11023
+ "EXISTS (SELECT 1 FROM",
11024
+ `jsonb_array_elements(resource->'${shape.field}') AS s_obj(obj),`,
11025
+ `jsonb_array_elements_text(s_obj.obj->'${shape.subfield}') AS s_elem(text_val)`,
11026
+ `WHERE s_elem.text_val ILIKE :${paramName})`
11027
+ ].join(" ");
11011
11028
  }
11012
11029
  }
11013
11030
  function emitStringPredicate(opts) {
@@ -11280,12 +11297,23 @@ async function genericSearchOperation(params) {
11280
11297
  ...combined.params
11281
11298
  ];
11282
11299
  const rows = await runner.query(sql, queryParams);
11283
- const entries = rows.map((row) => ({
11284
- id: row.id,
11285
- resource: { ...row.resource, id: row.id }
11286
- }));
11300
+ const entries = rows.map((row) => {
11301
+ const parsed = parseResourceColumn(row.resource);
11302
+ const bodyId = typeof parsed.id === "string" ? parsed.id : void 0;
11303
+ const id = bodyId ?? row.id;
11304
+ return {
11305
+ id,
11306
+ resource: { ...parsed, id }
11307
+ };
11308
+ });
11287
11309
  return { entries, total: entries.length };
11288
11310
  }
11311
+ function parseResourceColumn(raw) {
11312
+ if (typeof raw === "string") {
11313
+ return JSON.parse(raw);
11314
+ }
11315
+ return raw;
11316
+ }
11289
11317
 
11290
11318
  // src/data/search/registry/allergyintolerance-search-parameters.ts
11291
11319
  var ALLERGYINTOLERANCE_SEARCH_PARAMETERS = [
@@ -11886,7 +11914,7 @@ var PATIENT_SEARCH_PARAMETERS = [
11886
11914
  {
11887
11915
  code: "given",
11888
11916
  type: "string",
11889
- jsonbPath: "$.name[*].given",
11917
+ jsonbPath: "$.name[*].given[*]",
11890
11918
  modifiers: ["exact", "contains", "missing", "not"]
11891
11919
  },
11892
11920
  { code: "active", type: "token", jsonbPath: "$.active" },
@@ -11936,7 +11964,7 @@ var PRACTITIONER_SEARCH_PARAMETERS = [
11936
11964
  {
11937
11965
  code: "given",
11938
11966
  type: "string",
11939
- jsonbPath: "$.name[*].given",
11967
+ jsonbPath: "$.name[*].given[*]",
11940
11968
  modifiers: ["exact", "contains", "missing", "not"]
11941
11969
  },
11942
11970
  { code: "active", type: "token", jsonbPath: "$.active" },