toOpenmrsType translator for ServiceRequest should be implemented

I am currently working on [FM2-591] toOpenmrsType translator for ServiceRequest should be implemented - OpenMRS Issues which ensures to implement the toOpenmrsType method for the ServiceRequest resource. This ticket is depended on by [FM2-584] Add support for Json Merge Patch operations - ServiceRequest Resource - OpenMRS Issues.

I have translated concept, subject, encounter and orderer with a snippet like shown below;-

	public TestOrder toOpenmrsType(@Nonnull TestOrder currentTestOrder, @Nonnull ServiceRequest serviceRequest) {
		notNull(currentTestOrder, "The existing Openmrs TestOrder object should not be null");
		notNull(serviceRequest, "The ServiceRequest object should not be null");
		if (serviceRequest.hasId()) {
		return currentTestOrder;

I however realise according to the toFhirResource, there are elements like occurence, performer that don’t really have direct elements in the TestOrder object. How do i go about that? or is it that not every element has got to be translated? An overview of how these translations should be done maybe?

cc: @ibacher @abertnamanya @mozzy

Hi @mherman22, Please refer to the Implementation Guide resource Mappings section at the bottom


Thanks @abertnamanya , I didn’t realize the mappings were documented too. I guess I should explore the IG further.

Cheers :wink:

Hey @abertnamanya , thanks for the pointer above. However, i find the mappings at the bottom of the page a little confusing. When i look into the ServiceRequestTranslatorImpl class, the table below is what i come up with.

Note: The question marks indicate there is no direct element in the TestOrder class to map that specific fhir element with. And thats where my question was initially, in the attempt to translate ServiceRequest to OMRS.

Qn: When translating back to OMRS, do i only concentrate on those elements in the ServiceRequest resource that have direct mappings in the TestOrder model? e.g id, code, subject,encounter, requester.

ServiceRequest OMRS TestOrder
id TestOrder.uuid
status ??
intent ??
code TestOrder.concept
subject TestOrder.patient
encounter TestOrder.encounter
occurence[x] TestOrder.effectiveStartDate, TestOrder.effectiveEndDate
requester TestOrder.orderer
performer ??

cc: @ibacher @dkayiwa @sharif