Skip to content

Implement extendable architecture for atomic system#2

Merged
octoshikari merged 2 commits intomainfrom
feature/hook-system
Oct 12, 2025
Merged

Implement extendable architecture for atomic system#2
octoshikari merged 2 commits intomainfrom
feature/hook-system

Conversation

@octoshikari
Copy link
Copy Markdown
Contributor

Add Type-Safe Generic System with Extensible Interfaces

Summary

Implements a comprehensive type system that provides full TypeScript type safety while maintaining 100% backward compatibility.

Key Features

  • Generic Resource Schemas: Define custom resource types with full type inference
  • Extensible Interfaces: Extend any service via TypeScript declaration merging
  • FHIR Version Agnostic: Works with R4, R5, or custom resource types
  • Full IDE Support: Autocomplete for resource types, search parameters, and custom methods

What's Changed

  • Added src/types/ with generic schema system
  • Updated all service interfaces with <Schema> generic parameter
  • Created comprehensive examples and documentation
  • Added manual release GitHub workflow with version selector

Example Usage

// Define your schema
declare module '@atomic-ehr/core' {
  interface CustomSchema {
    Patient: {
      resource: R4.IPatient;
      searchParams: { name?: string };
    };
  }

  interface Validator {
    validateWithAI(resource: any): Promise<ValidationResult>;
  }
}

// Get full type safety
const patient = await context.repository.create({
  resourceType: "Patient", // ✅ Autocomplete
  resource: { /* ✅ Typed as R4.IPatient */ }
});

await context.validator.validateWithAI(patient); // ✅ Custom method available

@octoshikari octoshikari merged commit 3c9bd8c into main Oct 12, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant