0.1.0 β€’ Published 10 months ago

@healthcare-interoperability/fhir-query-store v0.1.0

Weekly downloads
-
License
MIT
Repository
-
Last release
10 months ago

@healthcare-interoperability/fhir-query-store

Lightweight, extensible framework for generating data store–agnostic queries from FHIR resources.


✨ Features

  • πŸ₯ Supports core FHIR resource types (e.g., Patient, Appointment, Encounter)
  • πŸ”Œ Backend-agnostic: works with any storage engine (MongoDB, SQL, memory, etc.)
  • βš™οΈ Query generation logic encapsulated in a pluggable FHIRQuery class
  • πŸ” Built-in validation, normalization, and integration ID support
  • πŸ”„ Easily extendable for custom business logic or resource types

πŸ“¦ Installation

npm install @healthcare-interoperability/fhir-query-store

πŸš€ Usage

import { FHIRQuery } from '@healthcare-interoperability/fhir-query-store';

// Sample FHIR resource
const resource = {
  resourceType: 'Patient',
  id: '123',
  name: [{ family: 'Doe', given: ['John'] }],
};

// Create a FHIRQuery instance
const query = new FHIRQuery(resource);

// Optionally set integration ID
query.setIntegrationId('your-integration-id');

// Generate database-ready query structure
const updates = query.query();

console.log(updates);
/*
[
  {
    resourceType: 'Patient',
    query: {
      updateOne: {
        filter: { id: '123' },
        update: { $set: { ... } },
        upsert: true
      }
    }
  }
]
*/

🧱 Class Overview

FHIRQuery

  • constructor(resource: object)
  • .setIntegrationId(id: string)
  • .query() β†’ Array<{ resourceType, query }>

🧩 Extending

To add custom logic or support new backends, extend the base class:

class CustomQuery extends FHIRQuery {
  query() {
    const base = super.query();
    // Add custom logic here
    return base;
  }
}

πŸ“š Related Packages


πŸ“„ License

MIT