Support for STU3 FHIR module

Hello,

I am working on a module implementing an extension of the FHIR STU3 api. I am heavily relying on the original fhir module https://github.com/openmrs/openmrs-module-fhir - this is specifically because it supports the STU3 FHIR api. My understanding is that the new FHIR module (https://github.com/openmrs/openmrs-module-fhir2) is implementing only the R4 (newer) version of FHIR.

While developing my module, I have noticed some bugs in the current FHIR STU3 module - and I want to fix them. I am not sure though what is the support for the module. Is it still to be worked on? Is the current team working on fhir2 module (supporting the R4 version) looking at the fhir module also?

Thanks

From the look of things FHIR2 module is supporting both as you can see here(support for dstu3) though a senior person such as @ibacher can confirm.

The original FHIR module had enough design & extensibility issues the decision was made to start from scratch with a new module (fhir2).

We also discussed whether to build for DSTU3 and support R4 where needed vs build for R4 and support DSTU3 where needed and the FHIR Squad chose the latter, since most new development is now using R4.

It would be preferable for you to help add DSTU3 support to fhir2 rather than building on the original fhir module.

@ibacher, we might want to edit the FHIR module wiki page and/or the README for the original FHIR module to make it easier for people to see the strategy for R4 and DSTU3 support.

1 Like

+ :100: to that.

Furthermore, as I was studying the module ahead of the work on immunizations, I was given the impression that most resources supported both R4 and DSTU3.

1 Like

Currently, the FHIR2 module has support for both R4 and DSTU3. However, the way we are supporting this is to generate the necessary resources in R4 and convert them to DSTU3 equivalents. Depending on the needs of your module, the FHIR2 module may already need them or you may need the support proposed as part of FM2-163.

The FHIR squad is currently not doing anything to update or maintain the old FHIR module.

Yes, I need to do that. And a whole bunch of other documentation.

1 Like

Didn’t see the support until now! Thanks for pointing it out.

Will mainly need to extend current profiles - for example the Patient profile. FM2-163 seems to be talking about new resources, will it cover the case of extending current profiles? Or is there another mechanism through which that would happen?

Good point! I will look into switching to the fhir2 module.

If you don’t need to add resources that don’t exist, it’s pretty simple to override existing resources. You’d most likely just need something like:

@Primary
@Component
public MyPatientTranslatorImpl extends org.openmrs.module.fhir2.api.translators.impl.PatientTranslatorImpl {
	@Override
	public Patient toFhirResource(org.openmrs.Patient openmrsPatient) {
		Patient patient =  super.toFhirResource(openmrsPatient);
		// enriching Patient model goes here
		return patient;
	}

	@Override
	public org.openmrs.Patient toOpenmrsType(org.openmrs.Patient currentPatient, Patient patient) {
		currentPatient = super.toOpenmrsType(currentPatient, patient);
		// enriching currentPatient goes here
		return currentPatient;
	}
}

Note, though, that this is operating on the R4 model of patient. If you really need to confine your changes to only DSTU3, you might go about things differently:

@Component("patientFhirR3ResourceProvider")
@Qualifier("fhirR3Resources")
@Primary
public class MyPatientFhirResourceProvider extends org.openmrs.module.fhir2.providers.r3.PatientFhirResourceProvider {
	@Read
	@SuppressWarnings("unused")
	public Patient getPatientById(@IdParam @NotNull IdType id) {
		org.hl7.fhir.r4.model.Patient patient = patientService.get(id.getIdPart());
		if (patient == null) {
			throw new ResourceNotFoundException("Could not find patient with Id " + id.getIdPart());
		}
		
		Patient patient = Patient30_40.convertPatient(patient);
		// do something to patient here
		return patient;
}

It really depends on what you’re trying to accomplish.

2 Likes

Thanks! Very helpful! I will give it a try.

Looks simple enough and would be quite easy to migrate the work I have done so far.