DEV Community

jy95
jy95

Posted on

Turn FHIR Dosage into human readable text in your wanted language and much more with fhir-dosage-utils

TD;LR

import FhirDosageUtils from "fhir-dosage-utils"; // See https://jy95.github.io/fhir-dosage-utils/api/interface/Params for more info about config const config = { language: "en", }; // A FHIR Dosage example const dosage = { timing: { repeat: { frequency: 1, period: 8, periodUnit: "h", }, }, }; // Prepare utility class let dosageUtils = await FhirDosageUtils.build(config); // 1. You can turn dosage(s) to text // display "1 time every 8 hours" console.log(dosageUtils.fromDosageToText(dosage)); console.log(dosageUtils.fromMultipleDosageToText([dosage])); // 2. You can extract part(s) of dosage, to your liking // display "every 8 hours" console.log( dosageUtils.getFields(dosage, "periodPeriodMax" /*, other parameters*/), ); // 3. You can detect if Dosage objects contains only "sequential" instructions // display "true" console.log(dosageUtils.containsOnlySequentialInstructions([dosage])); // 4. Turn this array of Dosage objects into a data structure useful to handle "sequential" and "concurrent" instructions (cf. "sequence" property). // Display "[ [dosage] ]" console.log(dosageUtils.groupBySequence([dosage])); // ... And many things // Read https://jy95.github.io/fhir-dosage-utils/api/class/default for more info 
Enter fullscreen mode Exit fullscreen mode

Key Features

  • Compatible: Works with Dosage R4 and Dosage R5
  • Extensibility Easily adaptable and extendable to accommodate your requirements
  • Internationalization Seamlessly extendable to other languages with i18next
  • Integration Ease Works effortlessly in various environments like the browser, Node.js, ...

Read more on : https://jy95.github.io/fhir-dosage-utils/

Top comments (0)