I am new to FHIR. I am trying to expose an REST url in Spring MVC which will expose the JSON data model of FHIR and will work on it. Using the sample requests available on FHIR website, I am not able to map it back to the data objects as I am not able to Figure out the Top level data object to map.
FhirModelWrapper.java
private Resource resourceType;
public Resource getResourceType() {
if(resourceType.getResourceType() == ResourceType.Encounter) {
return new Encounter();
}
return new Patient();
}
public void setResourceType(Resource resourceType) {
this.resourceType = resourceType;
}
Sample Request
{
"resourceType": "Encounter",
"identifier": [
{
"value": "id-12345"
}
],
"location": [
{
"location": {
"display": "Soliz House"
},
"period": {
"start": "2013-11-29",
"end": "2013-12-01"
}
}
]
}
Spring Controller
@RequestMapping(method = RequestMethod.POST, produces = "application/json", consumes = "application/json")
public @ResponseBody String[] getPatientDetails(@RequestBody FhirResource fhirModelWrapper) {
LOGGER.debug("POST Request Received for getPatientDetails " + fhirModelWrapper);
FhirModelWrapper gg = new FhirModelWrapper();
String returnT[] = rulesProcessor.process(gg);
LOGGER.debug("Request Processed.");
return returnT ;
}
I am getting error 400 Bad Request