Skip to main content
Version: v0.1.11

Generator options, kinds and profiles

This page lists every option the generators, corpora, quirk generators and pairing loops take, with its default; every kind a corpus mix accepts; and every profile @cosyte/synth defines or names. The API reference holds the full signatures, generated from the source.

Options every format shares​

Seeds​

Whereseed
HL7 v2, FHIR and C-CDA generatorsoptional, defaults to 0
generateHl7(kind, seed)required, the second argument
X12, NCPDP and ASTM generatorsrequired
Quirk generatorsoptional, defaults to 0
@cosyte/synth/deid pairing loopsoptional, defaults to 0
Every corpus and quirk corpusrequired

The same seed gives the same bytes on the same versions of @cosyte/synth and the parser that builds the format.

Corpus options​

Every format's corpus (hl7Corpus, fhirCorpus, ccdaCorpus, x12Corpus, ncpdpCorpus, astmCorpus) takes these options:

OptionTypeDefaultMeaning
seednumberrequiredThe corpus seed. Each artifact gets its own seed, drawn in order from a generator seeded with it.
countnumbersee KindsHow many artifacts to generate.
mixkindsevery kind of the formatThe kinds to cycle through, in order: artifact i is mix[i % mix.length]. Each entry is checked before anything is generated.
verifybooleantrueRead each artifact back through its parser and record the codes it reports as the artifact's warnings. false skips the read, and every warnings is then empty without having been checked.

A mix entry outside the format's kinds throws SYNTH_UNSUPPORTED_KIND.

An empty mix (mix: []) throws SYNTH_EMPTY_POOL in every format, whatever the count, before anything is generated. It names no kind to cycle through, so it is never read as the default mix and never filled with a kind you did not ask for. Leave mix out for the default.

Quirk corpus options​

hl7QuirkCorpus, ccdaQuirkCorpus and astmQuirkCorpus take these options:

OptionTypeDefaultMeaning
seednumberrequiredThe corpus seed.
countnumberthe number of quirks in useHow many quirk artifacts to generate.
quirksquirk namesevery quirk in the format's registryThe quirks to cycle through.
profileSynthProfilenoneA profile whose quirks drive the corpus. When given, quirks is ignored.

hl7QuirkCorpus also takes kind (default "ORU^R01"), and ccdaQuirkCorpus takes documentType (default "ccd"): the clean base each quirk is put into. A quirk name outside the format's registry throws SYNTH_UNSUPPORTED_QUIRK.

An empty quirks list, or a profile whose quirks list is empty, throws SYNTH_EMPTY_POOL, whatever the count, before anything is generated. It is never read as every quirk: leave quirks and profile out for that.

Kinds​

The kinds each corpus accepts in mix, which are also the kind label on each artifact.

FormatCorpusKinds, in default orderDefault count
HL7 v2hl7CorpusADT^A01, ADT^A04, ADT^A08, ORU^R01, ORM^O01, SIU^S12, VXU^V041
FHIRfhirCorpusUSCorePatient, Condition, ObservationLab, VitalSign, MedicationRequest, Encounter, Immunization, AllergyIntolerance, Procedure, DiagnosticReport, Bundle1
C-CDAccdaCorpusccd, referralNote1
X12x12Corpus837P, 837I, 837D, 835, 271the length of mix
NCPDPncpdpCorpusNewRx, RxRenewalRequest, RxChangeRequest, B1, B2, B3the length of mix
ASTMastmCorpusResult, Orderthe length of mix

hl7Corpus also accepts ten kinds that are not in its default mix, so a seed's default corpus does not change as kinds are added: ACK, ADT^A02, ADT^A03, ADT^A11, ADT^A13, ADT^A28, ADT^A31, MDM^T02, DFT^P03 and OML^O21. HL7_MESSAGE_KINDS lists all seventeen; pass it as mix to cycle through every one.

fhirCorpus also accepts two kinds that are not in its default mix: Patient (a base R4 Patient with no US Core profile) and DocumentBundle (a document Bundle). Bundle is a collection Bundle.

hl7Corpus also takes triggers, a list of ADT trigger events (any trigger generateAdt accepts). When given, it takes the place of mix and the corpus holds only ADT messages. An empty triggers list throws SYNTH_EMPTY_POOL, as an empty mix does.

HL7 v2 options​

Subpath @cosyte/synth/hl7, built through @cosyte/hl7.

GeneratorOptionsDefaultsReturns
generateAdtseed, trigger, subject0, "A01", "person"Hl7Message
generateOruseed, subject0, "person"Hl7Message
generateOrmseed0Hl7Message
generateSiuseed0Hl7Message
generateVxuseed0Hl7Message
generateMdmseed0Hl7Message
generateDftseed0Hl7Message
generateOmlseed0Hl7Message
generateAckseed, inbound, code0, the ADT^A01 from seed, "AA"Hl7Message
generateHl7(kind, seed)noneHl7Message
generateHl7Quirkseed, quirk, kind0, required, "ORU^R01"QuirkArtifact

trigger is "A01", "A02", "A03", "A04", "A08", "A11", "A13", "A28" or "A31". subject is "person" or "animal" (Generate animal patients). code is "AA", "AE" or "AR". generateHl7's kind is any HL7 v2 kind in the Kinds table; generateHl7Quirk's is one of the seven in the default mix. Quirk names are in the quirk catalog.

FHIR options​

Subpath @cosyte/synth/fhir, built through @cosyte/fhir. Every generator returns @cosyte/fhir's resource model.

GeneratorOptionsDefaults
generatePatientseed, profile0, "base"
generateConditionseed, subject, usCore0, "Patient/syn-patient-1", true
generateObservationLabseed, subject, usCore0, "Patient/syn-patient-1", true
generateVitalSignseed, subject, usCore0, "Patient/syn-patient-1", true
generateMedicationRequestseed, subject, requester, usCore0, "Patient/syn-patient-1", "Practitioner/syn-practitioner-1", true
generateEncounterseed, subject, usCore0, "Patient/syn-patient-1", true
generateDiagnosticReportseed, subject, results, usCore0, "Patient/syn-patient-1", [], true
generateImmunizationseed, patient, usCore0, "Patient/syn-patient-1", true
generateAllergyIntoleranceseed, patient, usCore0, "Patient/syn-patient-1", true
generateProcedureseed, subject, usCore0, "Patient/syn-patient-1", true
generateProvenanceseed, target, usCore0, "Patient/syn-patient-1", true
generateBundleseed, type0, "collection"
generateUsCoreProfileprofile, seedrequired, 0
  • profile on generatePatient is "base" (a base R4 Patient) or "us-core" (adds the US Core meta.profile and the race, ethnicity and birth sex extensions).
  • usCore adds the resource's US Core profile to meta.profile when true.
  • subject, patient, requester and target are reference strings, such as "Patient/syn-patient-1" or a urn:uuid: full URL.
  • results is a list of references to the report's Observations; empty leaves result out.
  • type on generateBundle is "collection", "transaction" or "document".
  • roundTrip(resource, { profiles }) takes the StructureDefinitions to validate against. None is bundled.

C-CDA options​

Subpath @cosyte/synth/ccda, built through @cosyte/ccda. Every generator returns @cosyte/ccda's document model, except the quirk generator.

GeneratorOptionsDefaultsReturns
generateCcdseed0CcdaDocument
generateReferralNoteseed0CcdaDocument
generateCcdaseed, documentType0, "ccd"CcdaDocument
generateCcdaQuirkseed, quirk, documentType0, required, "ccd"QuirkArtifact

documentType is "ccd" or "referralNote". Quirk names are in the quirk catalog.

X12 options​

Subpath @cosyte/synth/x12, built through @cosyte/x12. Every generator returns @cosyte/x12's interchange model, and every option object holds only seed, which is required.

GeneratorTransaction
generate837P837 professional claim
generate837I837 institutional claim
generate837D837 dental claim
generate837(variant, …)the 837 named by variant: "P", "I" or "D"
generate835835 remittance
generate271271 eligibility response

NCPDP options​

Subpath @cosyte/synth/ncpdp, built through @cosyte/ncpdp. Every generator returns the serialized message as a string, and every option object holds only seed, which is required.

GeneratorMessage
generateNewRxSCRIPT NewRx
generateRxRenewalRequestSCRIPT RxRenewalRequest
generateRxChangeRequestSCRIPT RxChangeRequest
generateB1Telecom billing
generateB2Telecom reversal
generateB3Telecom rebill
generateTelecom(code, …)the Telecom transaction named by code: "B1", "B2" or "B3"

ASTM options​

Subpath @cosyte/synth/astm, built through @cosyte/astm.

GeneratorOptionsDefaultsReturns
generateAstmResultseed, resultCount, commentrequired, 1 to 4 from the seed, truestring
generateAstmOrderseedrequiredstring
generateAstmResultFramedseed, resultCount, commentrequired, 1 to 4 from the seed, trueUint8Array
generateAstmQuirkseed, quirk, kind0, required, "Result"QuirkArtifact
  • resultCount is the number of R records; comment adds a C record after them.
  • generateAstmOrder takes the same options type and ignores resultCount and comment: an order has no results and no comment.
  • kind on generateAstmQuirk admits only "Result": both ASTM quirks change records only a result report carries.

Quirk names are in the quirk catalog.

Pairing loop options​

Subpath @cosyte/synth/deid, run through @cosyte/deid.

LoopOptionsDefaultsValues
hl7DeidLoopseed, kind0, "ORU^R01"any HL7 v2 kind
fhirDeidLoopseed0
x12DeidLoopseed, variant0, "837P""837P", "837I", "837D", "271", "835"
ncpdpTelecomDeidLoopseed, transaction0, "B1""B1", "B2", "B3"
ccdaDeidLoopseed, documentType0, "ccd""ccd", "referral"

The loops do not check variant, transaction or documentType against their sets the way the generators do. What it does and does not do says what each does with a value outside its set.

Profiles​

Three different things are called a profile. Each is listed here.

Synth profiles​

A synth profile names a set of quirks once, for a quirk corpus. defineSynthProfile(spec) returns a frozen SynthProfile.

FieldTypeRequiredMeaning
namestringyesThe profile's name. A missing or blank name throws SYNTH_INVALID_PROFILE.
quirksstring[]noThe quirks a quirk corpus applies. Checked against the format's registry when a corpus uses the profile. Left out, the corpus uses its own quirks option or every quirk; an empty list throws SYNTH_EMPTY_POOL.
givenNamesstring[]noStored on the profile. No generator reads it in this release.
familyNamesstring[]noStored on the profile. No generator reads it in this release.

The built-in synth profiles, one per format with quirks, each naming every quirk in its registry:

ProfilenameSubpath
hl7QuirkProfilecosyte-hl7-quirks@cosyte/synth/hl7
ccdaQuirkProfilecosyte-ccda-quirks@cosyte/synth/ccda
astmQuirkProfilecosyte-astm-quirks@cosyte/synth/astm

Parser profiles​

A parser profile belongs to the parser, not to @cosyte/synth: it tells the parser which deviations to tolerate. A quirk round trip parses the fixture twice, once with no profile and once under the built-in public profile that tolerates the quirk, and reports both.

ParserProfileToleratesHow
@cosyte/hl7visageunknown-zsegmentsuppressed
@cosyte/ccdalegacyR11template-extension-absentre-badged
@cosyte/ccdasmartScorecarddeprecated-loinc, deprecated-code-systemre-badged
@cosyte/astmreferenceCorpusunknown-escapere-badged

Suppressed means the warning is dropped; re-badged means it is replaced by PROFILE_QUIRK_APPLIED. The HL7 v2 unknown-escape and ASTM unknown-record-type quirks have no tolerating profile.

US Core profiles​

The FHIR subpath generates 11 of the 49 resource profiles US Core 6.1.0 publishes. Ask for one by its id with generateUsCoreProfile({ profile, seed }); usCoreCoverage() lists all 49, each with its profile id, its canonical URL and whether this build has it generated.

Profile idGenerated by
us-core-allergyintolerancegenerateAllergyIntolerance
us-core-condition-problems-health-concernsgenerateCondition
us-core-diagnosticreport-labgenerateDiagnosticReport
us-core-encountergenerateEncounter
us-core-immunizationgenerateImmunization
us-core-medicationrequestgenerateMedicationRequest
us-core-observation-labgenerateObservationLab
us-core-patientgeneratePatient
us-core-proceduregenerateProcedure
us-core-provenancegenerateProvenance
us-core-vital-signsgenerateVitalSign

Another profile the guide publishes throws SYNTH_PROFILE_NOT_GENERATED; a name it does not publish throws SYNTH_UNSUPPORTED_KIND.

import { usCoreCoverage } from "@cosyte/synth/fhir";

const generated = usCoreCoverage().filter((entry) => entry.generated);

generated.map((entry) => entry.profile); // => ["us-core-allergyintolerance", "us-core-condition-problems-health-concerns", "us-core-diagnosticreport-lab", "us-core-encounter", "us-core-immunization", "us-core-medicationrequest", "us-core-observation-lab", "us-core-patient", "us-core-procedure", "us-core-provenance", "us-core-vital-signs"]