FHIR type generation from HL7 CDA on FHIR specification.
This example demonstrates how to generate TypeScript interfaces from the HL7 CDA UV Core (Clinical Document Architecture) FHIR package. It includes:
- Full C-CDA on FHIR type definitions
- Document structure and sections
- Clinical content models
- Export of TypeSchema and dependency tree for debugging
To generate TypeScript types for CDA:
bun run examples/typescript-ccda/generate.tsThis will output to ./examples/typescript-ccda/fhir-types/ and create debug files.
Edit generate.ts to customize:
.typescript({
withDebugComment: false // Include generation metadata
})import { ClinicalDocument } from './fhir-types/index.js';
const clinicalDoc: ClinicalDocument = {
resourceType: 'ClinicalDocument',
id: 'doc-1',
code: {
coding: [{
system: 'http://loinc.org',
code: '34133-9' // Summarization of Episode Note
}]
},
// ... additional fields
};if (clinicalDoc.section) {
clinicalDoc.section.forEach(section => {
console.log(`Section: ${section.code?.coding?.[0].display}`);
// Process section content
});
}