Uploaded image for project: 'FHIR Module v2'
  1. FHIR Module v2
  2. FM2-357

Add an OpenMRS Service for getting a FHIR Client

    XMLWordPrintable

Details

    • Enhancement
    • Status: Closed
    • Should
    • Resolution: Fixed
    • FM2 1.2.0
    • FM2 1.2.0
    • None
    • None

    Description

      One of the things we need to support is allowing other modules to easily access a FHIR client that is appropriately configured. This shouldn't be too hard since a client mode is already building into the HAPI library. We also already define a client factory for our FHIR contexts.

      What we need to do is to package this up into an OpenMRS Service that be accessed using the OpenMRS ServiceContext.

      We should create a service interface and matching implementation for FhirClientService, which should have two methods, one to get an IGenericClient that corresponds to the FHIR STU3 version and one that corresponds to the FHIR R4 version. Something like this:

      public interface FhirClientService extends OpenmrsService {
      
          IGenericClient getClientForR3(String baseUrl);
      
          IGenericClient getClientForR4(String baseUrl);
      
      }
      

      The implementation would then look something like this:

      public class FhirClientServiceImpl implements FhirClientService {
      
          public IGenericClient getClientForR3(String baseUrl) {
              // get the client here
          }
         
          // similarly for the other method
      }
      

      The intended usage by another module would look something like this:

      IGenericClient myFhirClient = ServiceContext.getService(FhirClientService.class).getClientForR4("https://hapi.fhir.org/baseR4");
      
      myFhirClient.search().forResource(Patient.class).execute();
      

      Gliffy Diagrams

        Attachments

          Activity

            People

              ankerj Jessie Anker
              ibacher Ian Bacher
              Votes:
              0 Vote for this issue
              Watchers:
              2 Start watching this issue

              Dates

                Created:
                Updated:
                Resolved: