2

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

Seth Rylan
  • 116
  • 1
  • 6
Ashish
  • 421
  • 9
  • 22
  • I don't know enough about Spring to know what you're trying to do here, but where does the URL get into the picture? You should use something like Fiddler to debug the network traffic, and then you'll be able to see why the request is bad. Btw, Your getResourceType() method is weird, but I don't see how that's relevant. – Grahame Grieve Apr 09 '14 at 14:16
  • I would suspect that the requesting client is not setting the `Accepts` header to indicate that it will accept JSON. As @GrahameGrieve suggested, Fiddler or some other traffic analyzer (Chrome's developer tools, FireFox's FireBug, etc) would be useful. – CodeChimp Apr 09 '14 at 16:43

0 Answers0