FHIRSchema

TypeScript implementation of FHIRSchema converter and validator.
Overview
This project provides:
- Converter: Transforms FHIR StructureDefinitions into FHIRSchema format
- Validator: Validates FHIR resources against FHIRSchema definitions
Installation
npm install @atomic-ehr/fhirschema
Or install the latest canary version:
npm install @atomic-ehr/fhirschema@canary
Usage
Converting StructureDefinition to FHIRSchema
import { translate } from '@atomic-ehr/fhirschema';
const structureDefinition = {
resourceType: 'StructureDefinition',
name: 'Patient',
};
const fhirSchema = translate(structureDefinition);
Validating FHIR Resources
import { validate } from '@atomic-ehr/fhirschema';
const resource = {
resourceType: 'Patient',
};
const schema = { };
const context = { schemas: { Patient: schema } };
const result = validate(context, [], resource);
if (result.valid) {
console.log('Resource is valid');
} else {
console.log('Validation errors:', result.errors);
}
Development
Running Tests
bun test
Type Checking
bun run typecheck
Building
bun run build
Project Structure
├── src/
│ ├── converter/ # StructureDefinition to FHIRSchema converter
│ ├── validator/ # FHIRSchema validator
│ └── types.ts # Shared TypeScript types
├── test/
│ ├── unit/ # Unit tests
│ └── golden/ # Golden tests with expected outputs
├── spec/ # Specifications and documentation
├── adr/ # Architecture Decision Records
└── tasks/ # Task management
Development
This project uses:
- Bun as the runtime and test runner
- TypeScript for type safety
- GitHub Actions for CI/CD
Contributing
- Fork the repository
- Create your feature branch (
git checkout -b feature/amazing-feature
)
- Commit your changes (
git commit -m 'Add some amazing feature'
)
- Push to the branch (
git push origin feature/amazing-feature
)
- Open a Pull Request
License
[License information to be added]