@rxbenefits/types
v1.0.0
Published
TypeScript type definitions for RxBenefits applications
Maintainers
Readme
@rxbenefits/types
TypeScript type definitions for RxBenefits healthcare benefits management applications.
Overview
This package provides comprehensive TypeScript type definitions for all domain entities used across RxBenefits applications, including:
- User Management: Users, roles, and permissions
- Organization Management: Organizations, groups, and locations
- Member Management: Employees, dependents, and coverage
- Clinical & Pharmacy: Drugs, conditions, and intervention lists
- Business Operations: Applications, files, invoices, and issues
- System Configuration: Validation rules, events, and module definitions
Installation
npm install @rxbenefits/typesor with Yarn:
yarn add @rxbenefits/typesRequirements
- TypeScript: >= 5.0.0
- Node.js: >= 20.0.0
Usage
Importing Types
import { Organization, UserProfile, Employee, Dependent, Drug, APIError } from '@rxbenefits/types';
// Use types in your code
const organization: Organization = {
organizationNo: 12345,
name: 'Example Healthcare',
effectiveDate: '2025-01-01',
eligibilityContact: '[email protected]',
eligibilityVendor: 'Vendor Name',
medicalVendorContact: '[email protected]',
invoiceContact: '[email protected]',
type: 'standard',
processStatus: 1,
exportPharmacyClaimsForAllGroups: true,
generateEmployeeSSN: false,
generateMemberUponClaimReconciliation: false,
};Using Type Guards
The package includes type guard functions to safely check types at runtime:
import { isOrganization, isApiError } from '@rxbenefits/types';
// Type guard for Organization
function processOrganization(data: unknown) {
if (isOrganization(data)) {
// TypeScript knows data is Organization here
console.log(`Processing: ${data.name}`);
return data.organizationNo;
}
throw new Error('Invalid organization data');
}
// Type guard for API errors
async function fetchData() {
try {
// API call
} catch (error) {
if (isApiError(error)) {
// TypeScript knows error is APIError here
console.error(`API Error: ${error.data.error}`);
console.error(`Status: ${error.status}`);
}
}
}Available Type Categories
API & Error Handling
APIError- API error response structureAPIErrorData- Error data payloadisApiError()- Type guard for API errors
User Management
UserProfile- User profile informationUsers- User entityRoles- User roles and permissions
Organization Management
Organization- Organization entity with all configurationAuthOrganization- Simplified organization for authenticationBenefitPackage- Benefit package configurationBenefitPlanHistory- Historical benefit plan dataMedDSubsidy- Medicare Part D subsidy informationGroup- Organization group entityLocations- Location entitiesisOrganization()- Type guard for Organization
Member Management
Employee- Employee informationEmployeeCoverage- Coverage detailsDependent- Dependent informationMemberSearch- Search criteria and resultsPlanCoverage- Plan coverage details
Clinical & Pharmacy
Drugs- Drug entity informationCondition- Clinical condition typesInterventionDrugList- Drug intervention listsTargetDrugList- Target drug listsPharmacies- Pharmacy entity information
Business Operations
Application- Application typesEligibilityImport- Eligibility import structuresFiles- File management typesInvoice- Invoice entitiesIssues- Issue tracking types
System & Configuration
Lists- List typesListType- List type definitionsEvents- System event typesValidationRules- Validation rule definitionsModuleDefinition- Module configurationWindow- Window/global type extensions
Development
Setup
# Clone the repository
git clone https://github.com/RxBenefits/rxbenefits-types.git
cd rxbenefits-types
# Install dependencies
npm installBuild
# Production build
npm run build
# Development build with source maps
npm run build:dev
# Watch mode
npm run build:watchTesting
# Run all tests
npm test
# Run tests in watch mode
npm run test:watch
# Run tests with coverage
npm run test:coverageLinting and Formatting
# Run ESLint
npm run lint
# Fix ESLint issues
npm run lint:fix
# Format code with Prettier
npm run format
# Check formatting
npm run format:checkValidation
Run all checks before committing:
npm run validateThis runs type checking, linting, and tests.
Contributing
We welcome contributions! Please follow these guidelines:
- Fork the repository and create your branch from
main - Add tests for any new types or type guards
- Ensure tests pass: Run
npm run validate - Follow code style: Use Prettier and ESLint configurations
- Write good commit messages: Use Conventional Commits
- Submit a pull request
Commit Message Format
type(scope): subject
body
footerTypes: feat, fix, docs, style, refactor, test, chore
Example:
feat(organization): add new BenefitPlan type
Added BenefitPlan interface to support new benefit plan structure
BREAKING CHANGE: Organization.benefitPlans is now an array of BenefitPlanVersioning
This package follows Semantic Versioning:
- Major version (X.0.0): Breaking changes to existing types
- Minor version (0.X.0): New types or non-breaking additions
- Patch version (0.0.X): Bug fixes and documentation updates
License
This project is licensed under the MIT License - see the LICENSE file for details.
Support
- Issues: GitHub Issues
- Documentation: GitHub Wiki
- Changelog: CHANGELOG.md
Related Packages
@rxbenefits/api- API client library@rxbenefits/utils- Utility functions@rxbenefits/constants- Application constants@rxbenefits/ui- UI component library
Acknowledgments
Built with ❤️ by the RxBenefits Engineering Team for the healthcare benefits management community.
