@fhirfly-io/terminology 0.10.1 → 0.12.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/index.cjs CHANGED
@@ -1364,6 +1364,232 @@ var SmaEndpoint = class {
1364
1364
  }
1365
1365
  };
1366
1366
 
1367
+ // src/endpoints/hcc.ts
1368
+ var HccEndpoint = class {
1369
+ constructor(http) {
1370
+ this.http = http;
1371
+ }
1372
+ /**
1373
+ * Look up HCC mappings for a single ICD-10 code.
1374
+ *
1375
+ * Returns all HCC category mappings for the given diagnosis code.
1376
+ *
1377
+ * @param icd10Code - ICD-10-CM diagnosis code (e.g., "E11.9")
1378
+ * @param options - Response shape and include options
1379
+ * @returns HCC mapping data (may contain multiple mappings)
1380
+ *
1381
+ * @example
1382
+ * ```ts
1383
+ * const result = await client.hcc.lookup("E11.9");
1384
+ * console.log(result.data); // HCC mapping(s) for Type 2 diabetes
1385
+ * ```
1386
+ */
1387
+ async lookup(icd10Code, options) {
1388
+ return this.http.get(`/v1/hcc/${encodeURIComponent(icd10Code)}`, options);
1389
+ }
1390
+ /**
1391
+ * Look up HCC mappings for multiple ICD-10 codes in a single request.
1392
+ *
1393
+ * @param codes - Array of ICD-10-CM codes (max 100)
1394
+ * @param options - Response shape, include, and batch options
1395
+ * @returns Batch response with HCC mappings for each code
1396
+ */
1397
+ async lookupMany(codes, options) {
1398
+ if (codes.length === 0) throw new ValidationError("codes array must not be empty");
1399
+ if (codes.length > 100) throw new ValidationError(`HCC batch lookup supports max 100 codes, got ${codes.length}`);
1400
+ return this.http.post(
1401
+ "/v1/hcc/_batch",
1402
+ { codes },
1403
+ options
1404
+ );
1405
+ }
1406
+ /**
1407
+ * Reverse lookup: find ICD-10 codes that map to a given HCC category.
1408
+ *
1409
+ * @param ccNumber - HCC condition category number
1410
+ * @param options - Response shape, include, and model filter options
1411
+ * @returns Reverse lookup result with array of ICD-10 codes
1412
+ *
1413
+ * @example
1414
+ * ```ts
1415
+ * // Find all ICD-10 codes that map to HCC 19 (Diabetes)
1416
+ * const result = await client.hcc.reverse(19);
1417
+ * console.log(result.data.icd10_codes);
1418
+ *
1419
+ * // Filter by model
1420
+ * const result = await client.hcc.reverse(19, { model: "CMS-HCC" });
1421
+ * ```
1422
+ */
1423
+ async reverse(ccNumber, options) {
1424
+ const { model, ...lookupOptions } = options ?? {};
1425
+ const endpoint = `/v1/hcc/reverse/${encodeURIComponent(String(ccNumber))}`;
1426
+ if (model) {
1427
+ return this.http.search(endpoint, {
1428
+ model,
1429
+ shape: lookupOptions.shape,
1430
+ include: lookupOptions.include?.join(",")
1431
+ });
1432
+ }
1433
+ return this.http.get(endpoint, lookupOptions);
1434
+ }
1435
+ /**
1436
+ * Search for HCC crosswalk mappings.
1437
+ *
1438
+ * @param params - Search parameters (q, model_version, model_type, cc_number, payment_year)
1439
+ * @param options - Pagination and response shape options
1440
+ * @returns Search results with facets
1441
+ *
1442
+ * @example
1443
+ * ```ts
1444
+ * // Search by ICD-10 code text
1445
+ * const results = await client.hcc.search({ q: "diabetes" });
1446
+ *
1447
+ * // Filter by model version
1448
+ * const results = await client.hcc.search({
1449
+ * model_version: "V28",
1450
+ * cc_number: 19
1451
+ * });
1452
+ * ```
1453
+ */
1454
+ async search(params, options) {
1455
+ return this.http.search("/v1/hcc/search", {
1456
+ ...params,
1457
+ ...options,
1458
+ include: options?.include?.join(",")
1459
+ });
1460
+ }
1461
+ };
1462
+
1463
+ // src/endpoints/opcs4.ts
1464
+ var Opcs4Endpoint = class {
1465
+ constructor(http) {
1466
+ this.http = http;
1467
+ }
1468
+ /**
1469
+ * Look up a single OPCS-4 procedure code.
1470
+ *
1471
+ * @param code - OPCS-4 procedure code (e.g., "W37.1")
1472
+ * @param options - Response shape and include options
1473
+ * @returns OPCS-4 data
1474
+ *
1475
+ * @example
1476
+ * ```ts
1477
+ * const result = await client.opcs4.lookup("W37.1");
1478
+ * console.log(result.data.display); // Procedure description
1479
+ * ```
1480
+ */
1481
+ async lookup(code, options) {
1482
+ return this.http.get(`/v1/opcs4/${encodeURIComponent(code)}`, options);
1483
+ }
1484
+ /**
1485
+ * Look up multiple OPCS-4 codes in a single request.
1486
+ *
1487
+ * @param codes - Array of OPCS-4 codes (max 100)
1488
+ * @param options - Response shape, include, and batch options
1489
+ * @returns Batch response with results for each code
1490
+ */
1491
+ async lookupMany(codes, options) {
1492
+ if (codes.length === 0) throw new ValidationError("codes array must not be empty");
1493
+ if (codes.length > 100) throw new ValidationError(`OPCS-4 batch lookup supports max 100 codes, got ${codes.length}`);
1494
+ return this.http.post(
1495
+ "/v1/opcs4/_batch",
1496
+ { codes },
1497
+ options
1498
+ );
1499
+ }
1500
+ /**
1501
+ * Search for OPCS-4 procedure codes.
1502
+ *
1503
+ * @param params - Search parameters (q, chapter, category)
1504
+ * @param options - Pagination and response shape options
1505
+ * @returns Search results with facets
1506
+ *
1507
+ * @example
1508
+ * ```ts
1509
+ * // Search for knee procedures
1510
+ * const results = await client.opcs4.search({ q: "knee replacement" });
1511
+ *
1512
+ * // Filter by chapter
1513
+ * const results = await client.opcs4.search({
1514
+ * chapter: "W",
1515
+ * q: "joint"
1516
+ * });
1517
+ * ```
1518
+ */
1519
+ async search(params, options) {
1520
+ return this.http.search("/v1/opcs4/search", {
1521
+ ...params,
1522
+ ...options,
1523
+ include: options?.include?.join(",")
1524
+ });
1525
+ }
1526
+ };
1527
+
1528
+ // src/endpoints/dmd.ts
1529
+ var DmdEndpoint = class {
1530
+ constructor(http) {
1531
+ this.http = http;
1532
+ }
1533
+ /**
1534
+ * Look up a single dm+d concept by code.
1535
+ *
1536
+ * @param code - dm+d code (SNOMED-style numeric identifier, 6-18 digits)
1537
+ * @param options - Response shape and include options
1538
+ * @returns dm+d concept data
1539
+ *
1540
+ * @example
1541
+ * ```ts
1542
+ * const result = await client.dmd.lookup("39732311000001104");
1543
+ * console.log(result.data.name); // "Paracetamol 500mg tablets"
1544
+ * ```
1545
+ */
1546
+ async lookup(code, options) {
1547
+ return this.http.get(`/v1/dmd/${encodeURIComponent(code)}`, options);
1548
+ }
1549
+ /**
1550
+ * Look up multiple dm+d codes in a single request.
1551
+ *
1552
+ * @param codes - Array of dm+d codes (max 100)
1553
+ * @param options - Response shape, include, and batch options
1554
+ * @returns Batch response with results for each code
1555
+ */
1556
+ async lookupMany(codes, options) {
1557
+ if (codes.length === 0) throw new ValidationError("codes array must not be empty");
1558
+ if (codes.length > 100) throw new ValidationError(`dm+d batch lookup supports max 100 codes, got ${codes.length}`);
1559
+ return this.http.post(
1560
+ "/v1/dmd/_batch",
1561
+ { codes },
1562
+ options
1563
+ );
1564
+ }
1565
+ /**
1566
+ * Search for dm+d concepts.
1567
+ *
1568
+ * @param params - Search parameters (q, concept_type, status)
1569
+ * @param options - Pagination and response shape options
1570
+ * @returns Search results with facets
1571
+ *
1572
+ * @example
1573
+ * ```ts
1574
+ * // Search for paracetamol products
1575
+ * const results = await client.dmd.search({ q: "paracetamol" });
1576
+ *
1577
+ * // Filter by concept type
1578
+ * const results = await client.dmd.search({
1579
+ * q: "amoxicillin",
1580
+ * concept_type: "VMP"
1581
+ * });
1582
+ * ```
1583
+ */
1584
+ async search(params, options) {
1585
+ return this.http.search("/v1/dmd/search", {
1586
+ ...params,
1587
+ ...options,
1588
+ include: options?.include?.join(",")
1589
+ });
1590
+ }
1591
+ };
1592
+
1367
1593
  // src/client.ts
1368
1594
  var Fhirfly = class {
1369
1595
  http;
@@ -1419,6 +1645,21 @@ var Fhirfly = class {
1419
1645
  * State FHIR endpoint implementation status, patient access, and provider directories.
1420
1646
  */
1421
1647
  sma;
1648
+ /**
1649
+ * HCC (Hierarchical Condition Categories) crosswalk lookups.
1650
+ * Map ICD-10 diagnosis codes to CMS risk adjustment categories.
1651
+ */
1652
+ hcc;
1653
+ /**
1654
+ * OPCS-4 (Office of Population Censuses and Surveys) procedure code lookups.
1655
+ * UK NHS procedural coding system.
1656
+ */
1657
+ opcs4;
1658
+ /**
1659
+ * dm+d (Dictionary of Medicines and Devices) lookups.
1660
+ * UK NHS medicines reference data standard covering VTM/VMP/AMP/VMPP/AMPP.
1661
+ */
1662
+ dmd;
1422
1663
  /**
1423
1664
  * Create a new FHIRfly client.
1424
1665
  *
@@ -1468,15 +1709,21 @@ var Fhirfly = class {
1468
1709
  this.snomed = new SnomedEndpoint(this.http);
1469
1710
  this.claims = new ClaimsEndpoint(this.http);
1470
1711
  this.sma = new SmaEndpoint(this.http);
1712
+ this.hcc = new HccEndpoint(this.http);
1713
+ this.opcs4 = new Opcs4Endpoint(this.http);
1714
+ this.dmd = new DmdEndpoint(this.http);
1471
1715
  }
1472
1716
  };
1473
1717
 
1474
1718
  exports.ApiError = ApiError;
1475
1719
  exports.AuthenticationError = AuthenticationError;
1720
+ exports.DmdEndpoint = DmdEndpoint;
1476
1721
  exports.Fhirfly = Fhirfly;
1477
1722
  exports.FhirflyError = FhirflyError;
1723
+ exports.HccEndpoint = HccEndpoint;
1478
1724
  exports.NetworkError = NetworkError;
1479
1725
  exports.NotFoundError = NotFoundError;
1726
+ exports.Opcs4Endpoint = Opcs4Endpoint;
1480
1727
  exports.QuotaExceededError = QuotaExceededError;
1481
1728
  exports.RateLimitError = RateLimitError;
1482
1729
  exports.ServerError = ServerError;