@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.
@@ -655,11 +655,14 @@ declare function reference(ref: string): FhirComplex;
655
655
  */
656
656
  declare function narrative(text: string): FhirComplex;
657
657
  /**
658
- * A `meta.profile` element pinning the resource to one or more canonical profile URLs (US Core
659
- * conformance is claimed via `meta.profile`). No version is pinned, so validating against any supplied
660
- * version of the named profile never raises a version-mismatch.
661
- *
662
- * @param profiles - The canonical profile URLs to claim.
658
+ * A resource's `meta`: the `HTEST` security label in `meta.security`, which says the resource is test
659
+ * data, on every resource this package generates, plus a `meta.profile` pinning the resource to one or
660
+ * more canonical profile URLs when any are given (US Core conformance is claimed via `meta.profile`).
661
+ * No version is pinned, so validating against any supplied version of the named profile never raises
662
+ * a version-mismatch.
663
+ *
664
+ * @param profiles - The canonical profile URLs to claim. Empty for none: `meta.profile` is then left
665
+ * out and `meta` carries only the security label.
663
666
  * @returns A `meta` `FhirComplex`.
664
667
  * @example
665
668
  * ```ts
@@ -655,11 +655,14 @@ declare function reference(ref: string): FhirComplex;
655
655
  */
656
656
  declare function narrative(text: string): FhirComplex;
657
657
  /**
658
- * A `meta.profile` element pinning the resource to one or more canonical profile URLs (US Core
659
- * conformance is claimed via `meta.profile`). No version is pinned, so validating against any supplied
660
- * version of the named profile never raises a version-mismatch.
661
- *
662
- * @param profiles - The canonical profile URLs to claim.
658
+ * A resource's `meta`: the `HTEST` security label in `meta.security`, which says the resource is test
659
+ * data, on every resource this package generates, plus a `meta.profile` pinning the resource to one or
660
+ * more canonical profile URLs when any are given (US Core conformance is claimed via `meta.profile`).
661
+ * No version is pinned, so validating against any supplied version of the named profile never raises
662
+ * a version-mismatch.
663
+ *
664
+ * @param profiles - The canonical profile URLs to claim. Empty for none: `meta.profile` is then left
665
+ * out and `meta` carries only the security label.
663
666
  * @returns A `meta` `FhirComplex`.
664
667
  * @example
665
668
  * ```ts
@@ -613,8 +613,18 @@ function narrative(text) {
613
613
  prop("div", str(`<div xmlns="http://www.w3.org/1999/xhtml"><p>${escaped}</p></div>`))
614
614
  ]);
615
615
  }
616
+ var TEST_DATA_LABEL = Object.freeze({
617
+ system: "http://terminology.hl7.org/CodeSystem/v3-ActReason",
618
+ code: "HTEST",
619
+ display: "test health data"
620
+ });
616
621
  function meta(profiles) {
617
- return fhirPeer().complex([prop("profile", fhirPeer().list(profiles.map((p) => str(p))))]);
622
+ const props = [];
623
+ if (profiles.length > 0) {
624
+ props.push(prop("profile", fhirPeer().list(profiles.map((p) => str(p)))));
625
+ }
626
+ props.push(prop("security", fhirPeer().list([coding(TEST_DATA_LABEL)])));
627
+ return fhirPeer().complex(props);
618
628
  }
619
629
  function toFhirDate(ymd) {
620
630
  return `${ymd.slice(0, 4)}-${ymd.slice(4, 6)}-${ymd.slice(6, 8)}`;
@@ -957,7 +967,7 @@ function generatePatient(options = {}) {
957
967
  prop("resourceType", str("Patient")),
958
968
  prop("id", str(`syn-patient-${id.id}`))
959
969
  ];
960
- if (usCore) props.push(prop("meta", meta([US_CORE_PROFILE.PATIENT])));
970
+ props.push(prop("meta", meta(usCore ? [US_CORE_PROFILE.PATIENT] : [])));
961
971
  props.push(
962
972
  prop(
963
973
  "text",
@@ -1039,7 +1049,7 @@ function generateCondition(options = {}) {
1039
1049
  prop("resourceType", str("Condition")),
1040
1050
  prop("id", str(`syn-cond-${rng.digits(8)}`))
1041
1051
  ];
1042
- if (usCore) props.push(prop("meta", meta([US_CORE_PROFILE.CONDITION])));
1052
+ props.push(prop("meta", meta(usCore ? [US_CORE_PROFILE.CONDITION] : [])));
1043
1053
  props.push(prop("text", narrative(`Synthetic condition: ${code.display}.`)));
1044
1054
  props.push(
1045
1055
  prop(
@@ -1095,7 +1105,7 @@ function buildObservation(seed, subject, usCore, profileUrl, category, pool, eff
1095
1105
  prop("resourceType", str("Observation")),
1096
1106
  prop("id", str(`syn-obs-${rng.digits(8)}`))
1097
1107
  ];
1098
- if (usCore) props.push(prop("meta", meta([profileUrl])));
1108
+ props.push(prop("meta", meta(usCore ? [profileUrl] : [])));
1099
1109
  props.push(
1100
1110
  prop("text", narrative(`Synthetic ${category.display.toLowerCase()}: ${concept.display}.`))
1101
1111
  );
@@ -1163,7 +1173,7 @@ function generateMedicationRequest(options = {}) {
1163
1173
  prop("resourceType", str("MedicationRequest")),
1164
1174
  prop("id", str(`syn-medreq-${rng.digits(8)}`))
1165
1175
  ];
1166
- if (usCore) props.push(prop("meta", meta([US_CORE_PROFILE.MEDICATION_REQUEST])));
1176
+ props.push(prop("meta", meta(usCore ? [US_CORE_PROFILE.MEDICATION_REQUEST] : [])));
1167
1177
  props.push(prop("text", narrative(`Synthetic medication order: ${med.display}.`)));
1168
1178
  props.push(prop("status", str("active")));
1169
1179
  props.push(prop("intent", str("order")));
@@ -1186,7 +1196,7 @@ function generateEncounter(options = {}) {
1186
1196
  prop("resourceType", str("Encounter")),
1187
1197
  prop("id", str(`syn-enc-${rng.digits(8)}`))
1188
1198
  ];
1189
- if (usCore) props.push(prop("meta", meta([US_CORE_PROFILE.ENCOUNTER])));
1199
+ props.push(prop("meta", meta(usCore ? [US_CORE_PROFILE.ENCOUNTER] : [])));
1190
1200
  props.push(prop("text", narrative(`Synthetic encounter: ${type.display}.`)));
1191
1201
  props.push(
1192
1202
  prop(
@@ -1217,7 +1227,7 @@ function generateImmunization(options = {}) {
1217
1227
  prop("resourceType", str("Immunization")),
1218
1228
  prop("id", str(`syn-imm-${rng.digits(8)}`))
1219
1229
  ];
1220
- if (usCore) props.push(prop("meta", meta([US_CORE_PROFILE.IMMUNIZATION])));
1230
+ props.push(prop("meta", meta(usCore ? [US_CORE_PROFILE.IMMUNIZATION] : [])));
1221
1231
  props.push(prop("text", narrative(`Synthetic immunization: ${vaccine.display}.`)));
1222
1232
  props.push(prop("status", str("completed")));
1223
1233
  props.push(prop("vaccineCode", codeableConcept(vaccine)));
@@ -1237,7 +1247,7 @@ function generateAllergyIntolerance(options = {}) {
1237
1247
  prop("resourceType", str("AllergyIntolerance")),
1238
1248
  prop("id", str(`syn-allergy-${rng.digits(8)}`))
1239
1249
  ];
1240
- if (usCore) props.push(prop("meta", meta([US_CORE_PROFILE.ALLERGY_INTOLERANCE])));
1250
+ props.push(prop("meta", meta(usCore ? [US_CORE_PROFILE.ALLERGY_INTOLERANCE] : [])));
1241
1251
  props.push(prop("text", narrative(`Synthetic allergy: ${allergen.display}.`)));
1242
1252
  props.push(
1243
1253
  prop(
@@ -1280,7 +1290,7 @@ function generateProcedure(options = {}) {
1280
1290
  prop("resourceType", str("Procedure")),
1281
1291
  prop("id", str(`syn-proc-${rng.digits(8)}`))
1282
1292
  ];
1283
- if (usCore) props.push(prop("meta", meta([US_CORE_PROFILE.PROCEDURE])));
1293
+ props.push(prop("meta", meta(usCore ? [US_CORE_PROFILE.PROCEDURE] : [])));
1284
1294
  props.push(prop("text", narrative(`Synthetic procedure: ${code.display}.`)));
1285
1295
  props.push(prop("status", str("completed")));
1286
1296
  props.push(prop("code", codeableConcept(code)));
@@ -1300,7 +1310,7 @@ function generateProvenance(options = {}) {
1300
1310
  prop("resourceType", str("Provenance")),
1301
1311
  prop("id", str(`syn-prov-${rng.digits(8)}`))
1302
1312
  ];
1303
- if (usCore) props.push(prop("meta", meta([US_CORE_PROFILE.PROVENANCE])));
1313
+ props.push(prop("meta", meta(usCore ? [US_CORE_PROFILE.PROVENANCE] : [])));
1304
1314
  props.push(prop("text", narrative("Synthetic provenance for a generated fixture.")));
1305
1315
  props.push(prop("target", fhirPeer().list([reference(target)])));
1306
1316
  props.push(prop("recorded", str(`${recorded}T10:00:00Z`)));
@@ -1348,7 +1358,7 @@ function generateDiagnosticReport(options = {}) {
1348
1358
  prop("resourceType", str("DiagnosticReport")),
1349
1359
  prop("id", str(`syn-dr-${rng.digits(8)}`))
1350
1360
  ];
1351
- if (usCore) props.push(prop("meta", meta([US_CORE_PROFILE.DIAGNOSTIC_REPORT_LAB])));
1361
+ props.push(prop("meta", meta(usCore ? [US_CORE_PROFILE.DIAGNOSTIC_REPORT_LAB] : [])));
1352
1362
  props.push(prop("text", narrative(`Synthetic laboratory report: ${code.display}.`)));
1353
1363
  props.push(prop("status", str("final")));
1354
1364
  props.push(
@@ -1407,6 +1417,7 @@ function buildComposition(rng, input) {
1407
1417
  const props = [
1408
1418
  prop("resourceType", str("Composition")),
1409
1419
  prop("id", str(`syn-comp-${rng.digits(8)}`)),
1420
+ prop("meta", meta([])),
1410
1421
  prop("text", narrative("Synthetic continuity-of-care document summary.")),
1411
1422
  prop("status", str("final")),
1412
1423
  prop(
@@ -1464,6 +1475,7 @@ function buildOrganization(rng) {
1464
1475
  return fhirPeer().complex([
1465
1476
  prop("resourceType", str("Organization")),
1466
1477
  prop("id", str(`syn-org-${rng.digits(8)}`)),
1478
+ prop("meta", meta([])),
1467
1479
  prop("text", narrative("Synthetic health organization.")),
1468
1480
  prop(
1469
1481
  "identifier",
@@ -1592,7 +1604,8 @@ function generateBundle(options = {}) {
1592
1604
  });
1593
1605
  const props = [
1594
1606
  prop("resourceType", str("Bundle")),
1595
- prop("id", str(`syn-bundle-${rng.digits(8)}`))
1607
+ prop("id", str(`syn-bundle-${rng.digits(8)}`)),
1608
+ prop("meta", meta([]))
1596
1609
  ];
1597
1610
  if (type === "document") {
1598
1611
  const id = safe.identifier(rng, "AN");