@cosyte/synth 0.1.7 → 0.1.9

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.
@@ -569,7 +569,12 @@ function isRequireEsmRefusal(error) {
569
569
  }
570
570
  function loadPeer(specifier, host) {
571
571
  if (host.resolve === void 0) return host.require(specifier);
572
- const entry = url.fileURLToPath(host.resolve(specifier));
572
+ let entry;
573
+ try {
574
+ entry = url.fileURLToPath(host.resolve(specifier));
575
+ } catch {
576
+ return host.require(specifier);
577
+ }
573
578
  try {
574
579
  return host.require(entry);
575
580
  } catch (error) {
@@ -616,8 +621,18 @@ function narrative(text) {
616
621
  prop("div", str(`<div xmlns="http://www.w3.org/1999/xhtml"><p>${escaped}</p></div>`))
617
622
  ]);
618
623
  }
624
+ var TEST_DATA_LABEL = Object.freeze({
625
+ system: "http://terminology.hl7.org/CodeSystem/v3-ActReason",
626
+ code: "HTEST",
627
+ display: "test health data"
628
+ });
619
629
  function meta(profiles) {
620
- return fhirPeer().complex([prop("profile", fhirPeer().list(profiles.map((p) => str(p))))]);
630
+ const props = [];
631
+ if (profiles.length > 0) {
632
+ props.push(prop("profile", fhirPeer().list(profiles.map((p) => str(p)))));
633
+ }
634
+ props.push(prop("security", fhirPeer().list([coding(TEST_DATA_LABEL)])));
635
+ return fhirPeer().complex(props);
621
636
  }
622
637
  function toFhirDate(ymd) {
623
638
  return `${ymd.slice(0, 4)}-${ymd.slice(4, 6)}-${ymd.slice(6, 8)}`;
@@ -960,7 +975,7 @@ function generatePatient(options = {}) {
960
975
  prop("resourceType", str("Patient")),
961
976
  prop("id", str(`syn-patient-${id.id}`))
962
977
  ];
963
- if (usCore) props.push(prop("meta", meta([US_CORE_PROFILE.PATIENT])));
978
+ props.push(prop("meta", meta(usCore ? [US_CORE_PROFILE.PATIENT] : [])));
964
979
  props.push(
965
980
  prop(
966
981
  "text",
@@ -1042,7 +1057,7 @@ function generateCondition(options = {}) {
1042
1057
  prop("resourceType", str("Condition")),
1043
1058
  prop("id", str(`syn-cond-${rng.digits(8)}`))
1044
1059
  ];
1045
- if (usCore) props.push(prop("meta", meta([US_CORE_PROFILE.CONDITION])));
1060
+ props.push(prop("meta", meta(usCore ? [US_CORE_PROFILE.CONDITION] : [])));
1046
1061
  props.push(prop("text", narrative(`Synthetic condition: ${code.display}.`)));
1047
1062
  props.push(
1048
1063
  prop(
@@ -1098,7 +1113,7 @@ function buildObservation(seed, subject, usCore, profileUrl, category, pool, eff
1098
1113
  prop("resourceType", str("Observation")),
1099
1114
  prop("id", str(`syn-obs-${rng.digits(8)}`))
1100
1115
  ];
1101
- if (usCore) props.push(prop("meta", meta([profileUrl])));
1116
+ props.push(prop("meta", meta(usCore ? [profileUrl] : [])));
1102
1117
  props.push(
1103
1118
  prop("text", narrative(`Synthetic ${category.display.toLowerCase()}: ${concept.display}.`))
1104
1119
  );
@@ -1166,7 +1181,7 @@ function generateMedicationRequest(options = {}) {
1166
1181
  prop("resourceType", str("MedicationRequest")),
1167
1182
  prop("id", str(`syn-medreq-${rng.digits(8)}`))
1168
1183
  ];
1169
- if (usCore) props.push(prop("meta", meta([US_CORE_PROFILE.MEDICATION_REQUEST])));
1184
+ props.push(prop("meta", meta(usCore ? [US_CORE_PROFILE.MEDICATION_REQUEST] : [])));
1170
1185
  props.push(prop("text", narrative(`Synthetic medication order: ${med.display}.`)));
1171
1186
  props.push(prop("status", str("active")));
1172
1187
  props.push(prop("intent", str("order")));
@@ -1189,7 +1204,7 @@ function generateEncounter(options = {}) {
1189
1204
  prop("resourceType", str("Encounter")),
1190
1205
  prop("id", str(`syn-enc-${rng.digits(8)}`))
1191
1206
  ];
1192
- if (usCore) props.push(prop("meta", meta([US_CORE_PROFILE.ENCOUNTER])));
1207
+ props.push(prop("meta", meta(usCore ? [US_CORE_PROFILE.ENCOUNTER] : [])));
1193
1208
  props.push(prop("text", narrative(`Synthetic encounter: ${type.display}.`)));
1194
1209
  props.push(
1195
1210
  prop(
@@ -1220,7 +1235,7 @@ function generateImmunization(options = {}) {
1220
1235
  prop("resourceType", str("Immunization")),
1221
1236
  prop("id", str(`syn-imm-${rng.digits(8)}`))
1222
1237
  ];
1223
- if (usCore) props.push(prop("meta", meta([US_CORE_PROFILE.IMMUNIZATION])));
1238
+ props.push(prop("meta", meta(usCore ? [US_CORE_PROFILE.IMMUNIZATION] : [])));
1224
1239
  props.push(prop("text", narrative(`Synthetic immunization: ${vaccine.display}.`)));
1225
1240
  props.push(prop("status", str("completed")));
1226
1241
  props.push(prop("vaccineCode", codeableConcept(vaccine)));
@@ -1240,7 +1255,7 @@ function generateAllergyIntolerance(options = {}) {
1240
1255
  prop("resourceType", str("AllergyIntolerance")),
1241
1256
  prop("id", str(`syn-allergy-${rng.digits(8)}`))
1242
1257
  ];
1243
- if (usCore) props.push(prop("meta", meta([US_CORE_PROFILE.ALLERGY_INTOLERANCE])));
1258
+ props.push(prop("meta", meta(usCore ? [US_CORE_PROFILE.ALLERGY_INTOLERANCE] : [])));
1244
1259
  props.push(prop("text", narrative(`Synthetic allergy: ${allergen.display}.`)));
1245
1260
  props.push(
1246
1261
  prop(
@@ -1283,7 +1298,7 @@ function generateProcedure(options = {}) {
1283
1298
  prop("resourceType", str("Procedure")),
1284
1299
  prop("id", str(`syn-proc-${rng.digits(8)}`))
1285
1300
  ];
1286
- if (usCore) props.push(prop("meta", meta([US_CORE_PROFILE.PROCEDURE])));
1301
+ props.push(prop("meta", meta(usCore ? [US_CORE_PROFILE.PROCEDURE] : [])));
1287
1302
  props.push(prop("text", narrative(`Synthetic procedure: ${code.display}.`)));
1288
1303
  props.push(prop("status", str("completed")));
1289
1304
  props.push(prop("code", codeableConcept(code)));
@@ -1303,7 +1318,7 @@ function generateProvenance(options = {}) {
1303
1318
  prop("resourceType", str("Provenance")),
1304
1319
  prop("id", str(`syn-prov-${rng.digits(8)}`))
1305
1320
  ];
1306
- if (usCore) props.push(prop("meta", meta([US_CORE_PROFILE.PROVENANCE])));
1321
+ props.push(prop("meta", meta(usCore ? [US_CORE_PROFILE.PROVENANCE] : [])));
1307
1322
  props.push(prop("text", narrative("Synthetic provenance for a generated fixture.")));
1308
1323
  props.push(prop("target", fhirPeer().list([reference(target)])));
1309
1324
  props.push(prop("recorded", str(`${recorded}T10:00:00Z`)));
@@ -1351,7 +1366,7 @@ function generateDiagnosticReport(options = {}) {
1351
1366
  prop("resourceType", str("DiagnosticReport")),
1352
1367
  prop("id", str(`syn-dr-${rng.digits(8)}`))
1353
1368
  ];
1354
- if (usCore) props.push(prop("meta", meta([US_CORE_PROFILE.DIAGNOSTIC_REPORT_LAB])));
1369
+ props.push(prop("meta", meta(usCore ? [US_CORE_PROFILE.DIAGNOSTIC_REPORT_LAB] : [])));
1355
1370
  props.push(prop("text", narrative(`Synthetic laboratory report: ${code.display}.`)));
1356
1371
  props.push(prop("status", str("final")));
1357
1372
  props.push(
@@ -1410,6 +1425,7 @@ function buildComposition(rng, input) {
1410
1425
  const props = [
1411
1426
  prop("resourceType", str("Composition")),
1412
1427
  prop("id", str(`syn-comp-${rng.digits(8)}`)),
1428
+ prop("meta", meta([])),
1413
1429
  prop("text", narrative("Synthetic continuity-of-care document summary.")),
1414
1430
  prop("status", str("final")),
1415
1431
  prop(
@@ -1467,6 +1483,7 @@ function buildOrganization(rng) {
1467
1483
  return fhirPeer().complex([
1468
1484
  prop("resourceType", str("Organization")),
1469
1485
  prop("id", str(`syn-org-${rng.digits(8)}`)),
1486
+ prop("meta", meta([])),
1470
1487
  prop("text", narrative("Synthetic health organization.")),
1471
1488
  prop(
1472
1489
  "identifier",
@@ -1595,7 +1612,8 @@ function generateBundle(options = {}) {
1595
1612
  });
1596
1613
  const props = [
1597
1614
  prop("resourceType", str("Bundle")),
1598
- prop("id", str(`syn-bundle-${rng.digits(8)}`))
1615
+ prop("id", str(`syn-bundle-${rng.digits(8)}`)),
1616
+ prop("meta", meta([]))
1599
1617
  ];
1600
1618
  if (type === "document") {
1601
1619
  const id = safe.identifier(rng, "AN");