I am trying to make an observation post request using the fhir module. I am using fhir version 0.9 and it is installed properly (as it allows me to make get requests). Therefore I think I am doing something wrong in my body request which looks like this:
I’m always getting error 400 so it must be something wrong with the request body I’m making but can’t figure out what the problem is, Any help would be greatly appreciated!
@dkayiwa thank you for your reply!
I tried cloning and compiling the version from github and didn’t work so I changed my platform version to the latest 2.0.0, installed the legacy UI to test the FHIR module using the rest client interface and now i get error 422. The only thing that I changed in my post request body is the patient uuid
I solved my problem. I was getting No matching concept found for the given codings. in my log because i wasn’t actually linking my observation to any openmrs concept. This is the JSON I send now and it works.
But is there a way to make a FHIR request without having to give the uuid of the concept? It’s inconvenient since the request is going to be made by a mobile application that doesn’t know the uuids of the concepts.
Thank you all for your help! I really appreciate it!
I would not recommend you to use anything other than the concept uuid. This is what is recommended going forwards. My advice is that when the mobile client is fetching concepts, make it also include the concept uuids.
Sorry for the trouble but I have another question. How can I store a value that is not numerical? For example if I want to make an observation for the patient’s skin type? Sending it as
"valueQuantity":{
"value":"type IV"
}
wouldn’t work as openmrs would wait for a numerical value.
This is what my log shows:
ERROR - ExceptionHandlingInterceptor.createOperationOutcome(141) |2016-08-16 09:08:43,098| Failure during REST processing: java.lang.NumberFormatException
java.lang.NumberFormatException
at java.math.BigDecimal.(Unknown Source)
at java.math.BigDecimal.(Unknown Source)
at java.math.BigDecimal.(Unknown Source)
at ca.uhn.fhir.model.primitive.DecimalDt.parse(DecimalDt.java:108)
at ca.uhn.fhir.model.primitive.DecimalDt.parse(DecimalDt.java:33)
at ca.uhn.fhir.model.api.BasePrimitive.setValueAsString(BasePrimitive.java:112)
at ca.uhn.fhir.parser.ParserState$PrimitiveState.attributeValue(ParserState.java:2257)
at ca.uhn.fhir.parser.ParserState.attributeValue(ParserState.java:105)
at ca.uhn.fhir.parser.JsonParser.parseChildren(JsonParser.java:1220)
at ca.uhn.fhir.parser.JsonParser.parseChildren(JsonParser.java:1157)
at ca.uhn.fhir.parser.JsonParser.parseChildren(JsonParser.java:1210)
at ca.uhn.fhir.parser.JsonParser.parseChildren(JsonParser.java:1157)
at ca.uhn.fhir.parser.JsonParser.doParseResource(JsonParser.java:214)
at ca.uhn.fhir.parser.BaseParser.parseResource(BaseParser.java:484)
at ca.uhn.fhir.rest.param.ResourceParameter.loadResourceFromRequest(ResourceParameter.java:190)
at ca.uhn.fhir.rest.param.ResourceParameter.parseResourceFromRequest(ResourceParameter.java:222)
at ca.uhn.fhir.rest.param.ResourceParameter.translateQueryParametersIntoServerArgument(ResourceParameter.java:116)
The concept data type was numerical (my mistake), I created a new concept with text data type and tried posting a request but now I’m getting:
Caused by: java.lang.RuntimeException: concept is null for obs id is null
at org.openmrs.Obs.setValueAsString(Obs.java:1095)
at org.openmrs.module.fhir.api.util.FHIRObsUtil.generateOpenMRSObs(FHIRObsUtil.java:337)
at org.openmrs.module.fhir.api.impl.ObsServiceImpl.createFHIRObservation(ObsServiceImpl.java:236)
at sun.reflect.GeneratedMethodAccessor373.invoke(Unknown Source)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source)
at java.lang.reflect.Method.invoke(Unknown Source)
at org.springframework.aop.support.AopUtils.invokeJoinpointUsingReflection(AopUtils.java:317)
at org.springframework.aop.framework.ReflectiveMethodInvocation.invokeJoinpoint(ReflectiveMethodInvocation.java:190)
at org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:157)