@centricare/registry-manager
v1.0.0
Published
The Registry Manager is the official tool for managing and validating interoperability standards within the CentriCare ecosystem. This package acts as the Single Source of Truth (SSOT) and enforcer to ensure all data complies with the established registry
Readme
CentriCare Registry Manager
The Registry Manager is the official tool for managing and validating interoperability standards within the CentriCare ecosystem. This package acts as the Single Source of Truth (SSOT) and enforcer to ensure all data complies with the established registry rules.
Key Features
- Zero Setup (Plug & Play): Default registry JSON files are bundled directly within the package.
- Strict Code-Set Validation: Validates data using complete URNs (e.g.,
crn:code-set:common-status:active). - Data Structure Validation: Validates data schemas and blueprints using
valibotbased on designated schema URNs. - Tenant Extension: Supports registry extensions (adding new values only) for tenant-specific requirements under strict governance rules.
Installation
Ensure your GitHub Packages or NPM registry is properly configured. This package requires valibot as a peer dependency for schema validation.
npm install @centricare/registry-manager valibotUsage Guide
Use getInstance() to initialize the manager, then select the target registry handler: codeSet, schema, or external.
1. Initialization
There is no need to manually load the base JSON files. Upon initialization, the manager automatically loads the default registry data.
import { RegistryManager } from "@centricare/registry-manager";
const manager = RegistryManager.getInstance();2. Value Validation (Code-Set)
Use the manager.codeSet.validate method by providing the complete URN.
try {
manager.codeSet.validate("crn:code-set:common-status:active");
console.log("Value is valid!");
} catch (error) {
console.error(error.message); // Throws a RegistryError if invalid
}3. Data Schema Validation
Use the manager.schema.validate method by providing the schema URN and the target data payload.
const emergencyContactData = {
name: "Budi",
relation: "crn:code-set:family-relation:father",
contact: { phone: "0812345678" }
};
try {
manager.schema.validate("crn:schema:patient:emergency-contact", emergencyContactData);
console.log("Data structure is valid!");
} catch (error) {
console.error("Invalid data:", error.message);
}4. Registry Extension (Tenant-Specific)
If you need to introduce custom values for a specific tenant, target the appropriate registry type to extend it.
Extension Rules:
- Custom files must specify an edition that inherits from the base edition with an appended identifier (e.g.,
1.1.0-tenantA). - Base values from the original edition cannot be removed or modified; they can only be appended.
- Adding new registry subdomains or renaming existing ones is strictly prohibited.
import tenantCodeSetRegistry from "./data/code-set_1.1.0-tenantA.json";
try {
manager.codeSet.extend(tenantCodeSetRegistry);
// Tenant-specific values can now be validated
manager.codeSet.validate("crn:code-set:common-status:under-review");
} catch (error) {
console.error("Extension failed:", error.message);
}