DEV Community

jy95
jy95

Posted on

FHIR Dosage Support - Turn HAPI FHIR Dosage into human readable text in your desired language and much more

TD;LR

import io.github.jy95.fds.common.types.DisplayOrder;
import io.github.jy95.fds.r4.DosageAPIR4;
import io.github.jy95.fds.r4.config.FDSConfigR4;
import org.hl7.fhir.r4.model.Dosage;
import java.util.List;

public class Main {
    public static void main(String[] args) {
        // Create a configuration to be used by the library
        FDSConfigR4 configR4 = FDSConfigR4
                .builder()
                .build();

        // Create the library with that configuration
        DosageAPIR4 lib = new DosageAPIR4(configR4);

        // TODO Your HAPI FHIR Dosage instance you would like to deal with ;)
        Dosage dosage = new Dosage();

        // Converts the dosage object into human-readable text
        String asText = lib.asHumanReadableText(dosage).get();

        // Extract specific existing field(s) to meet your requirements
        String singleField = lib.getFields(dosage, DisplayOrder.DOSE_QUANTITY).get();
        String multipleFields = lib.getFields(dosage, DisplayOrder.TEXT, DisplayOrder.PATIENT_INSTRUCTION).get();

        // Converts the dosage object into human-readable text
        String multipleAsText = lib.asHumanReadableText(List.of(dosage)).get();

        // And much more ...
    }
}
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 thanks to ICU4J
  • Integration Ease Works effortlessly in various environments like server, client, ...

Read more on: https://jy95.github.io/fds/

( Github : https://github.com/jy95/fds )

Top comments (0)