FHIR HAPI Rest Server integration of OpenMRS FHIR module

Hi All,

We have manage to integrate the HAPI Restful Server with OpenMRS FHIR module. The reasons behind the integration is due to get the already implemented functionality of FHIR Specification without going to reinvent the wheel. HAPi FHIR Restful Servlet provide the skeleton of serving the Http requests according to FHIR specification. HAPi provide interface which allows us to write our own resource implementations on a annotation driven way which is more extensible and standardize. Below image shows the overview of serving FHIR request. First the FHIR request comes to OpenMRS FHIR Servelet which extend the HAPi restful server servelet class. There servelet will determine the request resource based on the request url which then forward to specified resource implementation. Initially there was a issue with the OpenMRS module servelets where it consider the top level module servelet which is the “ms/moduleServelet” as root servelet which leads HAPI to not splitting up the request URL from the resource. We have made a pull request to HAPI base to fix this issue by having own extending method.

Below is a sample PatientResource implementation which shows the extensible and usefulness of this integration. There are set of annotations which we can use in different purposes.

public class RestfulPatientResourceProvider implements IResourceProvider {
	private static final Log log = LogFactory.getLog(RestfulPatientResourceProvider.class);
	@Override
	public Class<? extends IResource> getResourceType() {
		return Patient.class;
	}

@Read()
public Patient getResourceById(@IdParam IdDt theId) {
	FHIRPatientResource patientResource = new FHIRPatientResource();
	Patient result = null;
	try {
		result = patientResource.getByUniqueId(theId);
	}  catch (FHIRValidationException e) {
		String msg = "Patient resource validation failed for patient" + theId.getIdPart();
		log.debug(msg, e);
	}
	return result;
}

@Search()
public List<Patient> findPatientsByFamilyName(@RequiredParam(name = Patient.SP_FAMILY) StringDt theFamilyName) {
	return null;
}

@Search()
public List<Patient> findPatientsByName(@RequiredParam(name = Patient.SP_NAME) StringDt name) {
	return null;
}

@Search()
public List<Patient> searchByIdentifier(@RequiredParam(name=Patient.SP_IDENTIFIER) TokenParam theId) {
	return null;
}

@surangak please add if I missed anything.

Thanks, Harsha

2 Likes

Discussed on 2015-01-21 Design Forum.