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/case

v0.0.1

Published

Case management models and utilities for OpenCharts

Readme

@opencharts/case

Assembles a pure mapper's canonical output into a structured operation case seed.

npm License: MIT

Overview

@opencharts/case turns the output of @opencharts/mapper's PureResourceMapper.map() into a deterministic case seed — a plain object that identifies the case, its resources, identity-resolution inputs, and business key.

  • Source-agnostic: consumes only canonical resource output, never raw source records.
  • Pure & deterministic: same input → same output every time. Case id and business key hash are derived via SHA-256 (Node.js built-in node:crypto).
  • No persistence coupling: emits a plain object, not a domain aggregate.

Installation

npm install @opencharts/case

Usage

Basic assembly

import { CaseAssembler } from '@opencharts/case';
import { PureResourceMapper, dsl as d } from '@opencharts/mapper';

const mapper = new PureResourceMapper();
const assembler = new CaseAssembler();

const mapped = mapper.map(mappingDefinition, sourceRecord);

const seed = assembler.assemble({
  mapped,
  workflow:       { id: 'chart-chase-v1', version: 1 },
  tenant_id:      'tenant-001',
  integration_id: 'integration-001',
});

console.log(seed);
/*
{
  id:             'OperationCase/ab12cd...',
  tenant_id:      'tenant-001',
  integration_id: 'integration-001',
  workflow:       { id: 'chart-chase-v1', version: 1 },
  business_key:   { category: 'Patient', canonical_hash: { algorithm: 'sha256', value: '...' } },
  resource_parameters: { patient: { identifiers: [...] } },
  resolutions: [{ key: 'patient', resource_type: 'Patient', profile: {...}, identity_parameters: {...}, is_subject: true }],
  state:      'open',
  generation: 1,
  priority:   0,
}
*/

With catalog validation

import { CaseAssembler } from '@opencharts/case';

// resourceValidator from @opencharts/resources
const assembler = new CaseAssembler({ resourceValidator });

const seed = assembler.assemble({ mapped, workflow, tenant_id, integration_id });
// Throws if any mapped resource is not catalog-valid (default onInvalidResource: 'throw')

Skip invalid resources

const assembler = new CaseAssembler({
  resourceValidator,
  onInvalidResource: 'skip',  // drop invalid resources, report them in seed.dropped_resources
});

const seed = assembler.assemble({ ... });
console.log(seed.dropped_resources);
// [{ key: 'encounter', errors: ['Unknown resource type: "UnknownType"'] }]

Optional inputs

const seed = assembler.assemble({
  mapped,
  workflow,
  tenant_id:      'tenant-001',
  integration_id: 'integration-001',
  correlation_id: 'corr-abc123',       // optional: external correlation id
  demand:         demandRef,           // optional: demand reference
  source_records: [{ id: 'rec-1' }],  // optional: provenance
  subject_type:   'Patient',           // which resource type is the subject (default: 'Patient')
  generation:     2,
  priority:       5,
  requireDemand:  true,                // enforce that demand is present
});

canonicalize(value) utility

import { canonicalize } from '@opencharts/case';

const canonical = canonicalize({ b: 2, a: 1 });
// '{"a":1,"b":2}'  — deterministic, key-sorted JSON

CaseAssembler options

| Option | Type | Default | Description | |---|---|---|---| | resourceValidator | object | null | CanonicalResourceValidator — enables catalog validation | | hashPolicyVersion | string | 'case-identity-v1' | Recorded on the business key hash | | onInvalidResource | 'throw'\|'skip' | 'throw' | Policy when catalog validation fails |

assemble(input) inputs

| Field | Required | Description | |---|---|---| | mapped | ✓ | PureResourceMapper.map() output | | workflow | ✓ | { id: string, version?: number } | | tenant_id | ✓ | Tenant identifier | | integration_id | ✓ | Integration identifier | | correlation_id | — | External correlation id | | demand | — | Demand reference (passed through) | | source_records | — | Provenance records (passed through) | | subject_type | — | Resource type treated as the case subject (default: 'Patient') | | subject_ref | — | Pre-resolved subject reference | | category | — | Business category (defaults to business_key.namespace) | | id | — | Override the derived case id | | generation | — | Default: 1 | | priority | — | Default: 0 | | state | — | Default: 'open' | | requireDemand | — | Throws if demand is absent. Default: false |

License

MIT