REST module Concept Mapping error

Hi all,

With reference to this resolved issue : I am trying to use Concept mappings instead of uuids for posting data to OpenMRS via REST.

The post below works perfectly fine and submits data successfully


However, when I try to use Concept mappings as suggested in ticket the call fails


The error with complete stacktrace in tomcat catalina.out is here

The version of module is Rest Web Services - 2.9.39bd19.

Am I making any mistake in sending the post? Do I need to use any other version?

Thanks, Maimoona IHS (Interactive Health Solutions)

( @darius @ahabib )

What version of OpenMRS do you use? Referencing concepts by mappings is only supported for 1.9+.

@raff - its Version: 1.9.7 Build 60bd9b

The error in logs is NPE, which may imply that no concept with the CIEL:5087 or CIEL:5088 same-as mapping was found. Did you verify that concepts have those mappings?

@raff . Yes concepts with mappings exists. Also I am using the same request with just changed concept field value during data post. Thats how both concepts look like

Apparently get by mapping only works when fetching a concept but i see there is a bug in ObsResource where they only looking up a concept by uuid so the concept mapping fails, you can create a ticket to get it fixed so that it supports concept mappings too. We should probably get rid of the method with @PropertySetter annotation in to get it to work


Is there any chance that you can write a failing unit test that demonstrates this issue? I can probably help fix it.

Wyclif is right, ObsResource1_8.setConcept must be modified to replicate the behavior of ConceptResource1_9.getByUniqueId and possibly other resources using concepts.

To avoid code duplication we should probably move ConceptResource1_9.getByUniqueId to the Concept Service.

Hi @darius, I have reported the issue here with a test class which have two tests. One for passing case with concept uuid and other for failing test case with exception thrown. The class need to have openmrs url, user and password changed to work as expected. The test doesnot work with demo openmrs since it has REST version 2.6, while we need 2.9.

@raff , looking into the issue:

It appears that the issue has fixed but under final code review process. Could you please give any idea when we can have it available in any module release. Or is there any chance that we can get the code for the fix and update and compile module ourselves, because looking into the commits I was not able to track down the actual changes done to make the concept-mapping work.

I will release the module by the end of this week. You could also try building the master branch.

I thought this issue is already resolved but am getting the same error when try to use concept map in an obs payload.

Am testing this issue on Platform 1.11.5 and am running REST Web Services 2.14-SNAPSHOT.c28691 built from the master branch.

Any help or guidance will be very helpful.

@werick, can you please show what that POST is that’s failing?

Here is the payload

{"patient":"patient_uuid", "encounterType":"b24721a5-9e7a-4a51-8257-91af569fbc4a", "encounterDatetime":"2016-03-08","obs":[{"concept":"CIEL:1436", "value":"664AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA"}]

patient_uuid is a valid UUID ?

@lluismf: The submit work fine when using uuids. The patient uuid is ok.


Here is the stack trace

This error would be thrown if the concept is not found. Are you sure you have a non-required concept with that mapping?

Any chance you can run this under the debugger, with a breakpoint on ConceptResource1_9 line 42, and see what is happening in this case?

Apparently its not breaking on ConceptResource1_9 line 42> Not user why its calling 1_8 resource.

Hmm, try to put breakpoints at the first line of ConceptResource1_8.getByUniqueId and ConceptResource1_9.getByUniqueId, and see which is getting called.

(If it’s hitting the 1.8 resource but you’re on Platform 1.11, that’s a different issue to explore.)