@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.
@@ -501,7 +501,9 @@ function mshScaffold(rng, type) {
501
501
  controlId,
502
502
  timestamp,
503
503
  version: "2.5",
504
- processingId: "P"
504
+ // MSH-11 processing ID `T` (HL7 table 0103: training), never `P` (production): every message
505
+ // says it is test data in the field the standard gives for it.
506
+ processingId: "T"
505
507
  });
506
508
  return { message, timestamp, controlId };
507
509
  }
@@ -971,8 +973,18 @@ function narrative(text) {
971
973
  prop("div", str(`<div xmlns="http://www.w3.org/1999/xhtml"><p>${escaped}</p></div>`))
972
974
  ]);
973
975
  }
976
+ var TEST_DATA_LABEL = Object.freeze({
977
+ system: "http://terminology.hl7.org/CodeSystem/v3-ActReason",
978
+ code: "HTEST",
979
+ display: "test health data"
980
+ });
974
981
  function meta(profiles) {
975
- return fhirPeer().complex([prop("profile", fhirPeer().list(profiles.map((p) => str(p))))]);
982
+ const props = [];
983
+ if (profiles.length > 0) {
984
+ props.push(prop("profile", fhirPeer().list(profiles.map((p) => str(p)))));
985
+ }
986
+ props.push(prop("security", fhirPeer().list([coding(TEST_DATA_LABEL)])));
987
+ return fhirPeer().complex(props);
976
988
  }
977
989
  function toFhirDate(ymd) {
978
990
  return `${ymd.slice(0, 4)}-${ymd.slice(4, 6)}-${ymd.slice(6, 8)}`;
@@ -1304,7 +1316,7 @@ function generatePatient(options = {}) {
1304
1316
  prop("resourceType", str("Patient")),
1305
1317
  prop("id", str(`syn-patient-${id.id}`))
1306
1318
  ];
1307
- if (usCore) props.push(prop("meta", meta([US_CORE_PROFILE.PATIENT])));
1319
+ props.push(prop("meta", meta(usCore ? [US_CORE_PROFILE.PATIENT] : [])));
1308
1320
  props.push(
1309
1321
  prop(
1310
1322
  "text",
@@ -1386,7 +1398,7 @@ function generateCondition(options = {}) {
1386
1398
  prop("resourceType", str("Condition")),
1387
1399
  prop("id", str(`syn-cond-${rng.digits(8)}`))
1388
1400
  ];
1389
- if (usCore) props.push(prop("meta", meta([US_CORE_PROFILE.CONDITION])));
1401
+ props.push(prop("meta", meta(usCore ? [US_CORE_PROFILE.CONDITION] : [])));
1390
1402
  props.push(prop("text", narrative(`Synthetic condition: ${code.display}.`)));
1391
1403
  props.push(
1392
1404
  prop(
@@ -1442,7 +1454,7 @@ function buildObservation(seed, subject, usCore, profileUrl, category, pool, eff
1442
1454
  prop("resourceType", str("Observation")),
1443
1455
  prop("id", str(`syn-obs-${rng.digits(8)}`))
1444
1456
  ];
1445
- if (usCore) props.push(prop("meta", meta([profileUrl])));
1457
+ props.push(prop("meta", meta(usCore ? [profileUrl] : [])));
1446
1458
  props.push(
1447
1459
  prop("text", narrative(`Synthetic ${category.display.toLowerCase()}: ${concept.display}.`))
1448
1460
  );
@@ -1510,7 +1522,7 @@ function generateMedicationRequest(options = {}) {
1510
1522
  prop("resourceType", str("MedicationRequest")),
1511
1523
  prop("id", str(`syn-medreq-${rng.digits(8)}`))
1512
1524
  ];
1513
- if (usCore) props.push(prop("meta", meta([US_CORE_PROFILE.MEDICATION_REQUEST])));
1525
+ props.push(prop("meta", meta(usCore ? [US_CORE_PROFILE.MEDICATION_REQUEST] : [])));
1514
1526
  props.push(prop("text", narrative(`Synthetic medication order: ${med.display}.`)));
1515
1527
  props.push(prop("status", str("active")));
1516
1528
  props.push(prop("intent", str("order")));
@@ -1533,7 +1545,7 @@ function generateEncounter(options = {}) {
1533
1545
  prop("resourceType", str("Encounter")),
1534
1546
  prop("id", str(`syn-enc-${rng.digits(8)}`))
1535
1547
  ];
1536
- if (usCore) props.push(prop("meta", meta([US_CORE_PROFILE.ENCOUNTER])));
1548
+ props.push(prop("meta", meta(usCore ? [US_CORE_PROFILE.ENCOUNTER] : [])));
1537
1549
  props.push(prop("text", narrative(`Synthetic encounter: ${type.display}.`)));
1538
1550
  props.push(
1539
1551
  prop(
@@ -1564,7 +1576,7 @@ function generateImmunization(options = {}) {
1564
1576
  prop("resourceType", str("Immunization")),
1565
1577
  prop("id", str(`syn-imm-${rng.digits(8)}`))
1566
1578
  ];
1567
- if (usCore) props.push(prop("meta", meta([US_CORE_PROFILE.IMMUNIZATION])));
1579
+ props.push(prop("meta", meta(usCore ? [US_CORE_PROFILE.IMMUNIZATION] : [])));
1568
1580
  props.push(prop("text", narrative(`Synthetic immunization: ${vaccine.display}.`)));
1569
1581
  props.push(prop("status", str("completed")));
1570
1582
  props.push(prop("vaccineCode", codeableConcept(vaccine)));
@@ -1584,7 +1596,7 @@ function generateAllergyIntolerance(options = {}) {
1584
1596
  prop("resourceType", str("AllergyIntolerance")),
1585
1597
  prop("id", str(`syn-allergy-${rng.digits(8)}`))
1586
1598
  ];
1587
- if (usCore) props.push(prop("meta", meta([US_CORE_PROFILE.ALLERGY_INTOLERANCE])));
1599
+ props.push(prop("meta", meta(usCore ? [US_CORE_PROFILE.ALLERGY_INTOLERANCE] : [])));
1588
1600
  props.push(prop("text", narrative(`Synthetic allergy: ${allergen.display}.`)));
1589
1601
  props.push(
1590
1602
  prop(
@@ -1627,7 +1639,7 @@ function generateProcedure(options = {}) {
1627
1639
  prop("resourceType", str("Procedure")),
1628
1640
  prop("id", str(`syn-proc-${rng.digits(8)}`))
1629
1641
  ];
1630
- if (usCore) props.push(prop("meta", meta([US_CORE_PROFILE.PROCEDURE])));
1642
+ props.push(prop("meta", meta(usCore ? [US_CORE_PROFILE.PROCEDURE] : [])));
1631
1643
  props.push(prop("text", narrative(`Synthetic procedure: ${code.display}.`)));
1632
1644
  props.push(prop("status", str("completed")));
1633
1645
  props.push(prop("code", codeableConcept(code)));
@@ -1646,7 +1658,7 @@ function generateDiagnosticReport(options = {}) {
1646
1658
  prop("resourceType", str("DiagnosticReport")),
1647
1659
  prop("id", str(`syn-dr-${rng.digits(8)}`))
1648
1660
  ];
1649
- if (usCore) props.push(prop("meta", meta([US_CORE_PROFILE.DIAGNOSTIC_REPORT_LAB])));
1661
+ props.push(prop("meta", meta(usCore ? [US_CORE_PROFILE.DIAGNOSTIC_REPORT_LAB] : [])));
1650
1662
  props.push(prop("text", narrative(`Synthetic laboratory report: ${code.display}.`)));
1651
1663
  props.push(prop("status", str("final")));
1652
1664
  props.push(
@@ -1683,6 +1695,7 @@ function buildComposition(rng, input) {
1683
1695
  const props = [
1684
1696
  prop("resourceType", str("Composition")),
1685
1697
  prop("id", str(`syn-comp-${rng.digits(8)}`)),
1698
+ prop("meta", meta([])),
1686
1699
  prop("text", narrative("Synthetic continuity-of-care document summary.")),
1687
1700
  prop("status", str("final")),
1688
1701
  prop(
@@ -1718,6 +1731,7 @@ function buildOrganization(rng) {
1718
1731
  return fhirPeer().complex([
1719
1732
  prop("resourceType", str("Organization")),
1720
1733
  prop("id", str(`syn-org-${rng.digits(8)}`)),
1734
+ prop("meta", meta([])),
1721
1735
  prop("text", narrative("Synthetic health organization.")),
1722
1736
  prop(
1723
1737
  "identifier",
@@ -1846,7 +1860,8 @@ function generateBundle(options = {}) {
1846
1860
  });
1847
1861
  const props = [
1848
1862
  prop("resourceType", str("Bundle")),
1849
- prop("id", str(`syn-bundle-${rng.digits(8)}`))
1863
+ prop("id", str(`syn-bundle-${rng.digits(8)}`)),
1864
+ prop("meta", meta([]))
1850
1865
  ];
1851
1866
  if (type === "document") {
1852
1867
  const id = safe.identifier(rng, "AN");