Versions Compared

Key

  • This line was added.
  • This line was removed.
  • Formatting was changed.

...

NoOpenMRS EntityFHIR ResourceFHIR Maturity
Level
Notes
1Patienthttps://www.hl7.org/fhir/patient.html5 
2Obshttps://www.hl7.org/fhir/observation.html5 
3Encounterhttps://www.hl7.org/fhir/encounter.html2 
4VisitList of encounters can be considered: https://www.hl7.org/fhir/list.html 

FHIR's Encounter resource can serve either as an OpenMRS Encounter or OpenMRS Visit. OpenMRS Encounter is a point in time.

  • If a FHIR Encounter spans a period of time (e.g., days), it would be an OpenMRS Visit.
  • If a FHIR Encounter has observations linked to it, it's an OpenMRS Encounter
5Providerhttps://www.hl7.org/fhir/practitioner.html3 
6Allergyhttps://www.hl7.org/fhir/allergyintolerance.html3 
7Drughttps://www.hl7.org/fhir/medication.html3 
8Locationhttps://www.hl7.org/fhir/location.html3 
9Order https://www.hl7.org/fhir/medicationrequest.html 

FHIR Nutrition Order and MedicationRequest can be considered, but orders have a broader sense in OpenMRS.

Priority would be MedicationRequest (Drug Order) and ProcedureRequest (Test Order)

10PatientProgramhttps://www.hl7.org/fhir/episodeofcare.html2 
11PatientStatehttps://www.hl7.org/fhir/condition.html3 
12Personhttps://www.hl7.org/fhir/person.html2 
13Relationshiphttps://www.hl7.org/fhir/relatedperson.html2 
14Cohorthttps://www.hl7.org/fhir/group.html1 

Synchronizing objects via FHIR

To add another object to FHIR synchronization, you must implement the FHIR Strategy Pattern

...

Code Block
package org.openmrs.module.fhir.api.strategies.objectname;

import org.hl7.fhir.dstu3.model.Objectname;

public interface GenericObjectnameStrategy {

   Objectname getObjectname(String uuid);

   void deleteObjectname(String uuid);

   Objectname updateObjectname(String uuid, Objectname objectname);

   Objectname createObjectname(Objectname objectname);
}


...

Code Block
package org.openmrs.module.fhir.api.strategies.objectname;

import org.openmrs.api.context.Context;
import org.openmrs.module.fhir.api.util.FHIRUtils;

public class ObjectNameStrategyUtil {

   public static GenericObjectNameStrategy getObjectNameStrategy() {
      String strategy = FHIRUtils.getObjectNameStrategy();

      return strategy == null ? new ObjectNameStrategy() :
            Context.getRegisteredComponent(strategy, GenericObjectNameStrategy.class);
   }
}



Strategy Util class will be called in ObjectNameServiceImpl class

Code Block
package org.openmrs.module.fhir.api.impl;

import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
import org.hl7.fhir.dstu3.model.ObjectName;
import org.openmrs.api.impl.BaseOpenmrsService;
import org.openmrs.module.fhir.api.ObjectNameService;
import org.openmrs.module.fhir.api.db.FHIRDAO;
import org.openmrs.module.fhir.api.strategies.objectname.ObjectNameStrategyUtil;

public class ObjectNameServiceImpl extends BaseOpenmrsService implements ObjectNameService {

   protected final Log log = LogFactory.getLog(this.getClass());

   private FHIRDAO dao;

   /**
    * @return the dao
    */
   public FHIRDAO getDao() {
      return dao;
   }

   /**
    * @param dao the dao to set
    */
   public void setDao(FHIRDAO dao) {
      this.dao = dao;
   }

   @Override
   public ObjectName getObjectName(String uuid) {
      return ObjectNameStrageryUtil.getObjectNameStrategy().getObjectName(uuid);
   }

   @Override
   public void deleteObjectName(String uuid) {
      ObjectNameStrageryUtil.getObjectNameStrategy().deleteObjectName(uuid);
   }

   @Override
   public ObjectName updateObjectName(String uuid, ObjectName objectName) {
      return ObjectNameStrategyUtil.getObjectName().updateObjectName(uuid, objectName);
   }

   @Override
   public ObjectName createObjectName(ObjectName objectName) {
      return ObjectNameStrategyUtil.getObjectNameStrategy().createObjectName(ObjectName);
   }
}



Which should implement an ObjectNameService interface

Code Block

package org.openmrs.module.fhir.api;

import org.hl7.fhir.dstu3.model.ObjectName;
import org.openmrs.api.OpenmrsService;
import org.springframework.transaction.annotation.Transactional;

@Transactional
public interface ObjectNameService extends OpenmrsService {

   /**
    * Get object by id
    *
    * @param uuid The uuid of object
    * @return ObjectName fhir resource
    */
   ObjectName getObjectName(String uuid);

   /**
    * Delete object by id
    *
    * @param uuid The uuid of object
    */
   void deleteObjectName(String uuid);

   /**
    * Update object
    *
    * @param uuid          The uuid of object
    * @param objectName representation of object fhir resource
    */
   ObjectName updateObjectName(String uuid, ObjectName objectName);

   /**
    * Create object
    *
    * @param objectName the object to create
    */
   ObjectName createObjectName(ObjectName objectName);
}