npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2026 – Pkg Stats / Ryan Hefner

@opencharts/resources

v0.0.1

Published

Resource utilities for OpenCharts

Readme

@opencharts/resources

Canonical resource catalog, validator, and built-in FHIR-aligned resource types.

npm License: MIT

Overview

@opencharts/resources provides the resource type system used by the canonical data model. Every resource instance must have a registered type. The catalog cross-references @opencharts/parameters at registration time to ensure every parameter spec names a valid, registered parameter type.

  • CanonicalResourceCatalog — register, retrieve, and validate resource definitions.
  • CanonicalResourceValidator — validate resource instances and arrays.
  • baseResources / registerBaseResources — the built-in FHIR-aligned resource set (Patient, Encounter, Observation, DocumentReference, …).

Installation

npm install @opencharts/resources

Usage

Using the base resource set

import { createCanonicalSystem } from '@opencharts/sdk';

const { resources } = createCanonicalSystem();

const patientDef = resources.get('Patient');
console.log(patientDef.resolvable); // true

Manual setup (no SDK)

import { CanonicalResourceCatalog, registerBaseResources } from '@opencharts/resources';
import { CanonicalParameterCatalog, registerBaseParameters } from '@opencharts/parameters';

const parameters = new CanonicalParameterCatalog();
registerBaseParameters(parameters);

// Pass parameterCatalog for referential-integrity checks at registration time
const resources = new CanonicalResourceCatalog({ parameterCatalog: parameters });
registerBaseResources(resources);

Register a custom resource type

resources.register({
  type: 'Lab',
  version: 1,
  name: 'Lab Result',
  description: 'A laboratory observation result',
  parameters: {
    identifiers:  { parameter: 'IdentifierList' },
    code:         { parameter: 'CodeableConcept',     cardinality: '1..1' },
    subject_ref:  { parameter: 'ResourceReference',   cardinality: '1..1' },
    effective:    { parameter: 'DateOrDateTimeOrPeriod' },
    value:        { parameter: 'ObservationValue' },
  },
  resolvable: false,
});

Validate a resource instance

import { CanonicalResourceValidator } from '@opencharts/resources';
import { CanonicalExtensionRegistry } from '@opencharts/extension';

const extensions = new CanonicalExtensionRegistry();
const validator = new CanonicalResourceValidator({
  resourceCatalog:  resources,
  parameterCatalog: parameters,
  extensionRegistry: extensions,
});

const { valid, errors } = validator.validateResource({
  key:  'lab-1',
  type: 'Lab',
  parameters: {
    code:        { system: 'loinc', code: '718-7' },  // CodeableConcept
    subject_ref: { type: 'Patient', id: 'p-001' },
  },
});

if (!valid) console.error(errors);

Validate an array of resources

const report = validator.validateResourceArray([resource1, resource2]);
// report: { valid: boolean, errors: string[] }
// Also checks for duplicate keys across the array.

Built-in Resource Types

Identity / organization

Patient, Practitioner, PractitionerRole, Organization, Location, RelatedPerson, Coverage

Scheduling / clinical context

Appointment, Encounter, EpisodeOfCare, ServiceRequest

Clinical data

Observation, Condition, AllergyIntolerance, Procedure, DiagnosticReport, Immunization, CarePlan, Goal, Medication, MedicationRequest, MedicationAdministration, MedicationDispense, MedicationStatement

Documents

DocumentReference, ClinicalDocument, Binary

Operation outputs

DataPackage, ExportManifest, ValidationReport, TransformationResult, DeliveryReceipt

API Reference

CanonicalResourceCatalog

| Method | Description | |---|---| | register(definition) | Register a resource definition (immutable once published) | | get(type, version?) | Retrieve a definition (latest if no version) | | has(type, version?) | Check existence | | list() | All registered definitions | | validateDefinition(definition) | Structural validation (used internally) |

CanonicalResourceValidator

| Method | Description | |---|---| | validateResource(resource, context?) | Returns { valid, errors } | | validateResourceArray(resources) | Validates array including duplicate-key check |

License

MIT