@cosyte/synth 0.1.6 → 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.
@@ -504,7 +504,9 @@ function mshScaffold(rng, type) {
504
504
  controlId,
505
505
  timestamp,
506
506
  version: "2.5",
507
- processingId: "P"
507
+ // MSH-11 processing ID `T` (HL7 table 0103: training), never `P` (production): every message
508
+ // says it is test data in the field the standard gives for it.
509
+ processingId: "T"
508
510
  });
509
511
  return { message, timestamp, controlId };
510
512
  }
@@ -974,8 +976,18 @@ function narrative(text) {
974
976
  prop("div", str(`<div xmlns="http://www.w3.org/1999/xhtml"><p>${escaped}</p></div>`))
975
977
  ]);
976
978
  }
979
+ var TEST_DATA_LABEL = Object.freeze({
980
+ system: "http://terminology.hl7.org/CodeSystem/v3-ActReason",
981
+ code: "HTEST",
982
+ display: "test health data"
983
+ });
977
984
  function meta(profiles) {
978
- return fhirPeer().complex([prop("profile", fhirPeer().list(profiles.map((p) => str(p))))]);
985
+ const props = [];
986
+ if (profiles.length > 0) {
987
+ props.push(prop("profile", fhirPeer().list(profiles.map((p) => str(p)))));
988
+ }
989
+ props.push(prop("security", fhirPeer().list([coding(TEST_DATA_LABEL)])));
990
+ return fhirPeer().complex(props);
979
991
  }
980
992
  function toFhirDate(ymd) {
981
993
  return `${ymd.slice(0, 4)}-${ymd.slice(4, 6)}-${ymd.slice(6, 8)}`;
@@ -1307,7 +1319,7 @@ function generatePatient(options = {}) {
1307
1319
  prop("resourceType", str("Patient")),
1308
1320
  prop("id", str(`syn-patient-${id.id}`))
1309
1321
  ];
1310
- if (usCore) props.push(prop("meta", meta([US_CORE_PROFILE.PATIENT])));
1322
+ props.push(prop("meta", meta(usCore ? [US_CORE_PROFILE.PATIENT] : [])));
1311
1323
  props.push(
1312
1324
  prop(
1313
1325
  "text",
@@ -1389,7 +1401,7 @@ function generateCondition(options = {}) {
1389
1401
  prop("resourceType", str("Condition")),
1390
1402
  prop("id", str(`syn-cond-${rng.digits(8)}`))
1391
1403
  ];
1392
- if (usCore) props.push(prop("meta", meta([US_CORE_PROFILE.CONDITION])));
1404
+ props.push(prop("meta", meta(usCore ? [US_CORE_PROFILE.CONDITION] : [])));
1393
1405
  props.push(prop("text", narrative(`Synthetic condition: ${code.display}.`)));
1394
1406
  props.push(
1395
1407
  prop(
@@ -1445,7 +1457,7 @@ function buildObservation(seed, subject, usCore, profileUrl, category, pool, eff
1445
1457
  prop("resourceType", str("Observation")),
1446
1458
  prop("id", str(`syn-obs-${rng.digits(8)}`))
1447
1459
  ];
1448
- if (usCore) props.push(prop("meta", meta([profileUrl])));
1460
+ props.push(prop("meta", meta(usCore ? [profileUrl] : [])));
1449
1461
  props.push(
1450
1462
  prop("text", narrative(`Synthetic ${category.display.toLowerCase()}: ${concept.display}.`))
1451
1463
  );
@@ -1513,7 +1525,7 @@ function generateMedicationRequest(options = {}) {
1513
1525
  prop("resourceType", str("MedicationRequest")),
1514
1526
  prop("id", str(`syn-medreq-${rng.digits(8)}`))
1515
1527
  ];
1516
- if (usCore) props.push(prop("meta", meta([US_CORE_PROFILE.MEDICATION_REQUEST])));
1528
+ props.push(prop("meta", meta(usCore ? [US_CORE_PROFILE.MEDICATION_REQUEST] : [])));
1517
1529
  props.push(prop("text", narrative(`Synthetic medication order: ${med.display}.`)));
1518
1530
  props.push(prop("status", str("active")));
1519
1531
  props.push(prop("intent", str("order")));
@@ -1536,7 +1548,7 @@ function generateEncounter(options = {}) {
1536
1548
  prop("resourceType", str("Encounter")),
1537
1549
  prop("id", str(`syn-enc-${rng.digits(8)}`))
1538
1550
  ];
1539
- if (usCore) props.push(prop("meta", meta([US_CORE_PROFILE.ENCOUNTER])));
1551
+ props.push(prop("meta", meta(usCore ? [US_CORE_PROFILE.ENCOUNTER] : [])));
1540
1552
  props.push(prop("text", narrative(`Synthetic encounter: ${type.display}.`)));
1541
1553
  props.push(
1542
1554
  prop(
@@ -1567,7 +1579,7 @@ function generateImmunization(options = {}) {
1567
1579
  prop("resourceType", str("Immunization")),
1568
1580
  prop("id", str(`syn-imm-${rng.digits(8)}`))
1569
1581
  ];
1570
- if (usCore) props.push(prop("meta", meta([US_CORE_PROFILE.IMMUNIZATION])));
1582
+ props.push(prop("meta", meta(usCore ? [US_CORE_PROFILE.IMMUNIZATION] : [])));
1571
1583
  props.push(prop("text", narrative(`Synthetic immunization: ${vaccine.display}.`)));
1572
1584
  props.push(prop("status", str("completed")));
1573
1585
  props.push(prop("vaccineCode", codeableConcept(vaccine)));
@@ -1587,7 +1599,7 @@ function generateAllergyIntolerance(options = {}) {
1587
1599
  prop("resourceType", str("AllergyIntolerance")),
1588
1600
  prop("id", str(`syn-allergy-${rng.digits(8)}`))
1589
1601
  ];
1590
- if (usCore) props.push(prop("meta", meta([US_CORE_PROFILE.ALLERGY_INTOLERANCE])));
1602
+ props.push(prop("meta", meta(usCore ? [US_CORE_PROFILE.ALLERGY_INTOLERANCE] : [])));
1591
1603
  props.push(prop("text", narrative(`Synthetic allergy: ${allergen.display}.`)));
1592
1604
  props.push(
1593
1605
  prop(
@@ -1630,7 +1642,7 @@ function generateProcedure(options = {}) {
1630
1642
  prop("resourceType", str("Procedure")),
1631
1643
  prop("id", str(`syn-proc-${rng.digits(8)}`))
1632
1644
  ];
1633
- if (usCore) props.push(prop("meta", meta([US_CORE_PROFILE.PROCEDURE])));
1645
+ props.push(prop("meta", meta(usCore ? [US_CORE_PROFILE.PROCEDURE] : [])));
1634
1646
  props.push(prop("text", narrative(`Synthetic procedure: ${code.display}.`)));
1635
1647
  props.push(prop("status", str("completed")));
1636
1648
  props.push(prop("code", codeableConcept(code)));
@@ -1649,7 +1661,7 @@ function generateDiagnosticReport(options = {}) {
1649
1661
  prop("resourceType", str("DiagnosticReport")),
1650
1662
  prop("id", str(`syn-dr-${rng.digits(8)}`))
1651
1663
  ];
1652
- if (usCore) props.push(prop("meta", meta([US_CORE_PROFILE.DIAGNOSTIC_REPORT_LAB])));
1664
+ props.push(prop("meta", meta(usCore ? [US_CORE_PROFILE.DIAGNOSTIC_REPORT_LAB] : [])));
1653
1665
  props.push(prop("text", narrative(`Synthetic laboratory report: ${code.display}.`)));
1654
1666
  props.push(prop("status", str("final")));
1655
1667
  props.push(
@@ -1686,6 +1698,7 @@ function buildComposition(rng, input) {
1686
1698
  const props = [
1687
1699
  prop("resourceType", str("Composition")),
1688
1700
  prop("id", str(`syn-comp-${rng.digits(8)}`)),
1701
+ prop("meta", meta([])),
1689
1702
  prop("text", narrative("Synthetic continuity-of-care document summary.")),
1690
1703
  prop("status", str("final")),
1691
1704
  prop(
@@ -1721,6 +1734,7 @@ function buildOrganization(rng) {
1721
1734
  return fhirPeer().complex([
1722
1735
  prop("resourceType", str("Organization")),
1723
1736
  prop("id", str(`syn-org-${rng.digits(8)}`)),
1737
+ prop("meta", meta([])),
1724
1738
  prop("text", narrative("Synthetic health organization.")),
1725
1739
  prop(
1726
1740
  "identifier",
@@ -1849,7 +1863,8 @@ function generateBundle(options = {}) {
1849
1863
  });
1850
1864
  const props = [
1851
1865
  prop("resourceType", str("Bundle")),
1852
- prop("id", str(`syn-bundle-${rng.digits(8)}`))
1866
+ prop("id", str(`syn-bundle-${rng.digits(8)}`)),
1867
+ prop("meta", meta([]))
1853
1868
  ];
1854
1869
  if (type === "document") {
1855
1870
  const id = safe.identifier(rng, "AN");
@@ -1954,12 +1969,12 @@ var PROCEDURE_MODIFIERS = Object.freeze(["25", "59", "76", "GT"]);
1954
1969
  var PLACES_OF_SERVICE = Object.freeze(["11", "22", "21", "12", "49"]);
1955
1970
  var DIAGNOSES = Object.freeze(
1956
1971
  [
1957
- { code: "J20.9", label: "acute bronchitis, unspecified" },
1958
- { code: "E11.9", label: "type 2 diabetes mellitus without complications" },
1972
+ { code: "J209", label: "acute bronchitis, unspecified" },
1973
+ { code: "E119", label: "type 2 diabetes mellitus without complications" },
1959
1974
  { code: "I10", label: "essential (primary) hypertension" },
1960
- { code: "M54.5", label: "low back pain" },
1961
- { code: "R07.9", label: "chest pain, unspecified" },
1962
- { code: "Z00.00", label: "general adult medical exam without abnormal findings" }
1975
+ { code: "M545", label: "low back pain" },
1976
+ { code: "R079", label: "chest pain, unspecified" },
1977
+ { code: "Z0000", label: "general adult medical exam without abnormal findings" }
1963
1978
  ].map((entry) => Object.freeze(entry))
1964
1979
  );
1965
1980
  var REVENUE_CODES = Object.freeze(
@@ -2367,7 +2382,8 @@ function generate271(options) {
2367
2382
  serviceTypeCodes: serviceTypes,
2368
2383
  inPlanNetwork: "Y",
2369
2384
  monetaryAmount: dec2(money(rng.int(500, 5e3))),
2370
- percent: dec2(String(rng.pick([80, 90, 100])))
2385
+ percent: dec2(rng.pick([".8", ".9", "1"]))
2386
+ // EB-08 is a decimal fraction
2371
2387
  }
2372
2388
  ]
2373
2389
  }
@@ -2518,7 +2534,8 @@ function claimSegment(rng, minimal) {
2518
2534
  field("E1", "03"),
2519
2535
  // 03 = NDC
2520
2536
  field("D7", drug.ndc),
2521
- field("E7", String(rng.int(30, 90))),
2537
+ field("E7", String(rng.int(30, 90) * 1e3)),
2538
+ // 442-E7 carries three implied decimals
2522
2539
  field("D5", String(rng.pick([30, 60, 90]))),
2523
2540
  field("D8", rng.pick(DAW_CODES))
2524
2541
  ]