@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.
- package/CHANGELOG.md +34 -0
- package/README.md +8 -2
- package/dist/astm/index.cjs +4 -1
- package/dist/astm/index.cjs.map +1 -1
- package/dist/astm/index.mjs +4 -1
- package/dist/astm/index.mjs.map +1 -1
- package/dist/ccda/index.cjs.map +1 -1
- package/dist/ccda/index.mjs.map +1 -1
- package/dist/deid/index.cjs +36 -19
- package/dist/deid/index.cjs.map +1 -1
- package/dist/deid/index.mjs +36 -19
- package/dist/deid/index.mjs.map +1 -1
- package/dist/fhir/index.cjs +25 -12
- package/dist/fhir/index.cjs.map +1 -1
- package/dist/fhir/index.d.cts +8 -5
- package/dist/fhir/index.d.ts +8 -5
- package/dist/fhir/index.mjs +25 -12
- package/dist/fhir/index.mjs.map +1 -1
- package/dist/hl7/index.cjs +3 -1
- package/dist/hl7/index.cjs.map +1 -1
- package/dist/hl7/index.mjs +3 -1
- package/dist/hl7/index.mjs.map +1 -1
- package/dist/index.cjs +1 -1
- package/dist/index.cjs.map +1 -1
- package/dist/index.mjs +1 -1
- package/dist/index.mjs.map +1 -1
- package/dist/ncpdp/index.cjs +2 -1
- package/dist/ncpdp/index.cjs.map +1 -1
- package/dist/ncpdp/index.mjs +2 -1
- package/dist/ncpdp/index.mjs.map +1 -1
- package/dist/x12/index.cjs +7 -6
- package/dist/x12/index.cjs.map +1 -1
- package/dist/x12/index.d.cts +2 -1
- package/dist/x12/index.d.ts +2 -1
- package/dist/x12/index.mjs +7 -6
- package/dist/x12/index.mjs.map +1 -1
- package/package.json +4 -4
package/dist/deid/index.mjs
CHANGED
|
@@ -501,7 +501,9 @@ function mshScaffold(rng, type) {
|
|
|
501
501
|
controlId,
|
|
502
502
|
timestamp,
|
|
503
503
|
version: "2.5",
|
|
504
|
-
|
|
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
|
-
|
|
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
|
-
|
|
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
|
-
|
|
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
|
-
|
|
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
|
-
|
|
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
|
-
|
|
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
|
-
|
|
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
|
-
|
|
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
|
-
|
|
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
|
-
|
|
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");
|
|
@@ -1951,12 +1966,12 @@ var PROCEDURE_MODIFIERS = Object.freeze(["25", "59", "76", "GT"]);
|
|
|
1951
1966
|
var PLACES_OF_SERVICE = Object.freeze(["11", "22", "21", "12", "49"]);
|
|
1952
1967
|
var DIAGNOSES = Object.freeze(
|
|
1953
1968
|
[
|
|
1954
|
-
{ code: "
|
|
1955
|
-
{ code: "
|
|
1969
|
+
{ code: "J209", label: "acute bronchitis, unspecified" },
|
|
1970
|
+
{ code: "E119", label: "type 2 diabetes mellitus without complications" },
|
|
1956
1971
|
{ code: "I10", label: "essential (primary) hypertension" },
|
|
1957
|
-
{ code: "
|
|
1958
|
-
{ code: "
|
|
1959
|
-
{ code: "
|
|
1972
|
+
{ code: "M545", label: "low back pain" },
|
|
1973
|
+
{ code: "R079", label: "chest pain, unspecified" },
|
|
1974
|
+
{ code: "Z0000", label: "general adult medical exam without abnormal findings" }
|
|
1960
1975
|
].map((entry) => Object.freeze(entry))
|
|
1961
1976
|
);
|
|
1962
1977
|
var REVENUE_CODES = Object.freeze(
|
|
@@ -2364,7 +2379,8 @@ function generate271(options) {
|
|
|
2364
2379
|
serviceTypeCodes: serviceTypes,
|
|
2365
2380
|
inPlanNetwork: "Y",
|
|
2366
2381
|
monetaryAmount: dec2(money(rng.int(500, 5e3))),
|
|
2367
|
-
percent: dec2(
|
|
2382
|
+
percent: dec2(rng.pick([".8", ".9", "1"]))
|
|
2383
|
+
// EB-08 is a decimal fraction
|
|
2368
2384
|
}
|
|
2369
2385
|
]
|
|
2370
2386
|
}
|
|
@@ -2515,7 +2531,8 @@ function claimSegment(rng, minimal) {
|
|
|
2515
2531
|
field("E1", "03"),
|
|
2516
2532
|
// 03 = NDC
|
|
2517
2533
|
field("D7", drug.ndc),
|
|
2518
|
-
field("E7", String(rng.int(30, 90))),
|
|
2534
|
+
field("E7", String(rng.int(30, 90) * 1e3)),
|
|
2535
|
+
// 442-E7 carries three implied decimals
|
|
2519
2536
|
field("D5", String(rng.pick([30, 60, 90]))),
|
|
2520
2537
|
field("D8", rng.pick(DAW_CODES))
|
|
2521
2538
|
]
|