|
| 1 | +import { APIBuilder, mkCodegenLogger, prettyReport } from "../../src"; |
| 2 | + |
| 3 | +console.log("📦 Generating FHIR R4 Core Types..."); |
| 4 | + |
| 5 | +const logger = mkCodegenLogger({ |
| 6 | + prefix: "API", |
| 7 | + suppressTags: ["#fieldTypeNotFound", "#largeValueSet"], |
| 8 | +}); |
| 9 | + |
| 10 | +const builder = new APIBuilder({ logger }) |
| 11 | + .throwException() |
| 12 | + .fromPackage("hl7.fhir.r4.core", "4.0.1") |
| 13 | + .python({ |
| 14 | + allowExtraFields: false, |
| 15 | + primitiveTypeExtension: true, |
| 16 | + generateProfile: true, |
| 17 | + fhirpyClient: false, |
| 18 | + fieldFormat: "snake_case", |
| 19 | + }) |
| 20 | + .typeSchema({ |
| 21 | + treeShake: { |
| 22 | + "hl7.fhir.r4.core": { |
| 23 | + "http://hl7.org/fhir/StructureDefinition/Bundle": {}, |
| 24 | + "http://hl7.org/fhir/StructureDefinition/OperationOutcome": {}, |
| 25 | + "http://hl7.org/fhir/StructureDefinition/DomainResource": {}, |
| 26 | + "http://hl7.org/fhir/StructureDefinition/BackboneElement": {}, |
| 27 | + "http://hl7.org/fhir/StructureDefinition/Element": {}, |
| 28 | + "http://hl7.org/fhir/StructureDefinition/Patient": {}, |
| 29 | + "http://hl7.org/fhir/StructureDefinition/Observation": {}, |
| 30 | + "http://hl7.org/fhir/StructureDefinition/bodyweight": {}, |
| 31 | + // Extensions |
| 32 | + "http://hl7.org/fhir/StructureDefinition/patient-birthPlace": {}, |
| 33 | + "http://hl7.org/fhir/StructureDefinition/patient-nationality": {}, |
| 34 | + "http://hl7.org/fhir/StructureDefinition/humanname-own-prefix": {}, |
| 35 | + "http://hl7.org/fhir/StructureDefinition/patient-birthTime": {}, |
| 36 | + }, |
| 37 | + }, |
| 38 | + }) |
| 39 | + .outputTo("./examples/python-extension-example/fhir_types") |
| 40 | + .cleanOutput(true); |
| 41 | + |
| 42 | +const report = await builder.generate(); |
| 43 | + |
| 44 | +console.log(prettyReport(report)); |
| 45 | + |
| 46 | +if (!report.success) { |
| 47 | + process.exit(1); |
| 48 | +} |
0 commit comments