@cosyte/synth 0.1.7 → 0.1.8

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.
@@ -616,8 +616,18 @@ function narrative(text) {
616
616
  prop("div", str(`<div xmlns="http://www.w3.org/1999/xhtml"><p>${escaped}</p></div>`))
617
617
  ]);
618
618
  }
619
+ var TEST_DATA_LABEL = Object.freeze({
620
+ system: "http://terminology.hl7.org/CodeSystem/v3-ActReason",
621
+ code: "HTEST",
622
+ display: "test health data"
623
+ });
619
624
  function meta(profiles) {
620
- return fhirPeer().complex([prop("profile", fhirPeer().list(profiles.map((p) => str(p))))]);
625
+ const props = [];
626
+ if (profiles.length > 0) {
627
+ props.push(prop("profile", fhirPeer().list(profiles.map((p) => str(p)))));
628
+ }
629
+ props.push(prop("security", fhirPeer().list([coding(TEST_DATA_LABEL)])));
630
+ return fhirPeer().complex(props);
621
631
  }
622
632
  function toFhirDate(ymd) {
623
633
  return `${ymd.slice(0, 4)}-${ymd.slice(4, 6)}-${ymd.slice(6, 8)}`;
@@ -960,7 +970,7 @@ function generatePatient(options = {}) {
960
970
  prop("resourceType", str("Patient")),
961
971
  prop("id", str(`syn-patient-${id.id}`))
962
972
  ];
963
- if (usCore) props.push(prop("meta", meta([US_CORE_PROFILE.PATIENT])));
973
+ props.push(prop("meta", meta(usCore ? [US_CORE_PROFILE.PATIENT] : [])));
964
974
  props.push(
965
975
  prop(
966
976
  "text",
@@ -1042,7 +1052,7 @@ function generateCondition(options = {}) {
1042
1052
  prop("resourceType", str("Condition")),
1043
1053
  prop("id", str(`syn-cond-${rng.digits(8)}`))
1044
1054
  ];
1045
- if (usCore) props.push(prop("meta", meta([US_CORE_PROFILE.CONDITION])));
1055
+ props.push(prop("meta", meta(usCore ? [US_CORE_PROFILE.CONDITION] : [])));
1046
1056
  props.push(prop("text", narrative(`Synthetic condition: ${code.display}.`)));
1047
1057
  props.push(
1048
1058
  prop(
@@ -1098,7 +1108,7 @@ function buildObservation(seed, subject, usCore, profileUrl, category, pool, eff
1098
1108
  prop("resourceType", str("Observation")),
1099
1109
  prop("id", str(`syn-obs-${rng.digits(8)}`))
1100
1110
  ];
1101
- if (usCore) props.push(prop("meta", meta([profileUrl])));
1111
+ props.push(prop("meta", meta(usCore ? [profileUrl] : [])));
1102
1112
  props.push(
1103
1113
  prop("text", narrative(`Synthetic ${category.display.toLowerCase()}: ${concept.display}.`))
1104
1114
  );
@@ -1166,7 +1176,7 @@ function generateMedicationRequest(options = {}) {
1166
1176
  prop("resourceType", str("MedicationRequest")),
1167
1177
  prop("id", str(`syn-medreq-${rng.digits(8)}`))
1168
1178
  ];
1169
- if (usCore) props.push(prop("meta", meta([US_CORE_PROFILE.MEDICATION_REQUEST])));
1179
+ props.push(prop("meta", meta(usCore ? [US_CORE_PROFILE.MEDICATION_REQUEST] : [])));
1170
1180
  props.push(prop("text", narrative(`Synthetic medication order: ${med.display}.`)));
1171
1181
  props.push(prop("status", str("active")));
1172
1182
  props.push(prop("intent", str("order")));
@@ -1189,7 +1199,7 @@ function generateEncounter(options = {}) {
1189
1199
  prop("resourceType", str("Encounter")),
1190
1200
  prop("id", str(`syn-enc-${rng.digits(8)}`))
1191
1201
  ];
1192
- if (usCore) props.push(prop("meta", meta([US_CORE_PROFILE.ENCOUNTER])));
1202
+ props.push(prop("meta", meta(usCore ? [US_CORE_PROFILE.ENCOUNTER] : [])));
1193
1203
  props.push(prop("text", narrative(`Synthetic encounter: ${type.display}.`)));
1194
1204
  props.push(
1195
1205
  prop(
@@ -1220,7 +1230,7 @@ function generateImmunization(options = {}) {
1220
1230
  prop("resourceType", str("Immunization")),
1221
1231
  prop("id", str(`syn-imm-${rng.digits(8)}`))
1222
1232
  ];
1223
- if (usCore) props.push(prop("meta", meta([US_CORE_PROFILE.IMMUNIZATION])));
1233
+ props.push(prop("meta", meta(usCore ? [US_CORE_PROFILE.IMMUNIZATION] : [])));
1224
1234
  props.push(prop("text", narrative(`Synthetic immunization: ${vaccine.display}.`)));
1225
1235
  props.push(prop("status", str("completed")));
1226
1236
  props.push(prop("vaccineCode", codeableConcept(vaccine)));
@@ -1240,7 +1250,7 @@ function generateAllergyIntolerance(options = {}) {
1240
1250
  prop("resourceType", str("AllergyIntolerance")),
1241
1251
  prop("id", str(`syn-allergy-${rng.digits(8)}`))
1242
1252
  ];
1243
- if (usCore) props.push(prop("meta", meta([US_CORE_PROFILE.ALLERGY_INTOLERANCE])));
1253
+ props.push(prop("meta", meta(usCore ? [US_CORE_PROFILE.ALLERGY_INTOLERANCE] : [])));
1244
1254
  props.push(prop("text", narrative(`Synthetic allergy: ${allergen.display}.`)));
1245
1255
  props.push(
1246
1256
  prop(
@@ -1283,7 +1293,7 @@ function generateProcedure(options = {}) {
1283
1293
  prop("resourceType", str("Procedure")),
1284
1294
  prop("id", str(`syn-proc-${rng.digits(8)}`))
1285
1295
  ];
1286
- if (usCore) props.push(prop("meta", meta([US_CORE_PROFILE.PROCEDURE])));
1296
+ props.push(prop("meta", meta(usCore ? [US_CORE_PROFILE.PROCEDURE] : [])));
1287
1297
  props.push(prop("text", narrative(`Synthetic procedure: ${code.display}.`)));
1288
1298
  props.push(prop("status", str("completed")));
1289
1299
  props.push(prop("code", codeableConcept(code)));
@@ -1303,7 +1313,7 @@ function generateProvenance(options = {}) {
1303
1313
  prop("resourceType", str("Provenance")),
1304
1314
  prop("id", str(`syn-prov-${rng.digits(8)}`))
1305
1315
  ];
1306
- if (usCore) props.push(prop("meta", meta([US_CORE_PROFILE.PROVENANCE])));
1316
+ props.push(prop("meta", meta(usCore ? [US_CORE_PROFILE.PROVENANCE] : [])));
1307
1317
  props.push(prop("text", narrative("Synthetic provenance for a generated fixture.")));
1308
1318
  props.push(prop("target", fhirPeer().list([reference(target)])));
1309
1319
  props.push(prop("recorded", str(`${recorded}T10:00:00Z`)));
@@ -1351,7 +1361,7 @@ function generateDiagnosticReport(options = {}) {
1351
1361
  prop("resourceType", str("DiagnosticReport")),
1352
1362
  prop("id", str(`syn-dr-${rng.digits(8)}`))
1353
1363
  ];
1354
- if (usCore) props.push(prop("meta", meta([US_CORE_PROFILE.DIAGNOSTIC_REPORT_LAB])));
1364
+ props.push(prop("meta", meta(usCore ? [US_CORE_PROFILE.DIAGNOSTIC_REPORT_LAB] : [])));
1355
1365
  props.push(prop("text", narrative(`Synthetic laboratory report: ${code.display}.`)));
1356
1366
  props.push(prop("status", str("final")));
1357
1367
  props.push(
@@ -1410,6 +1420,7 @@ function buildComposition(rng, input) {
1410
1420
  const props = [
1411
1421
  prop("resourceType", str("Composition")),
1412
1422
  prop("id", str(`syn-comp-${rng.digits(8)}`)),
1423
+ prop("meta", meta([])),
1413
1424
  prop("text", narrative("Synthetic continuity-of-care document summary.")),
1414
1425
  prop("status", str("final")),
1415
1426
  prop(
@@ -1467,6 +1478,7 @@ function buildOrganization(rng) {
1467
1478
  return fhirPeer().complex([
1468
1479
  prop("resourceType", str("Organization")),
1469
1480
  prop("id", str(`syn-org-${rng.digits(8)}`)),
1481
+ prop("meta", meta([])),
1470
1482
  prop("text", narrative("Synthetic health organization.")),
1471
1483
  prop(
1472
1484
  "identifier",
@@ -1595,7 +1607,8 @@ function generateBundle(options = {}) {
1595
1607
  });
1596
1608
  const props = [
1597
1609
  prop("resourceType", str("Bundle")),
1598
- prop("id", str(`syn-bundle-${rng.digits(8)}`))
1610
+ prop("id", str(`syn-bundle-${rng.digits(8)}`)),
1611
+ prop("meta", meta([]))
1599
1612
  ];
1600
1613
  if (type === "document") {
1601
1614
  const id = safe.identifier(rng, "AN");