0

When I try to update an observation resource with an encounter reference to link the observation to a specific encounter using CRUD, it fails with the following error:

"Object with id: null was not of the specified subclass: edu.gatech.i3l.fhir.dstu2.entities.Person (class of the given object did not match class of persistent copy)"

I can't tell which object it is claiming is null, because every attribute in the JSON for the request has a corresponding value.

I'm using the following JSON syntax for the update:

{
    "resourceType":"Observation",
        "code":{
        "coding":[
            {
                "system":"http://loinc.org",
                "code":"8302-2"
            }
        ]
    },
    "valueQuantity":{
        "value":175.3,
        "units":"cm",
        "system":"http://unitsofmeasure.org",
        "code":"cm"
    },
    "appliesDateTime":"2015-10-26T23:59:00-04:00",
    "status":"final",
    "reliability":"ok",
    "subject":{
        "reference":"Patient/468"
    },
    "encounter":{ "reference":"336" }
}

I'm doing this on a test instance of FHIR. I created a new patient, a new encounter, and a new observation, and I now want to link the observation to the encounter. How is this done? Why wouldn't that JSON syntax work when that is the format returned when I search for the observation? I only added one attribute, the encounter reference.

Teksysta
  • 25
  • 3
  • Here is what was failing for the update attempts: { "resourceType":"Observation", "id":"40912", "code":{ "coding":[ { "system":"http://loinc.org", "code":"8302-2" } ] }, "valueQuantity":{ "value":173.5, "units":"cm", "system":"http://unitsofmeasure.org", "code":"cm" }, "appliesDateTime":"2015-10-26T23:59:00-04:00", "status":"final", "subject":{ "reference":"Patient568" }, "encounter":{ "reference":"7360" } } – Teksysta Oct 27 '15 at 20:08

2 Answers2

0

It looks like you're missing the resource id - you don't need that for an add, but you do for an update.

If you still have the problem when that's present, can you indicate what server you're trying to send to? (If not a public server, knowing what reference library/open source implementation it uses as its base would be helpful too.)

Lloyd McKenzie
  • 6,345
  • 1
  • 13
  • 10
  • Yes I pasted the wrong json for the upate attempts. – Teksysta Oct 27 '15 at 20:07
  • I finally got it to work though. I'm not sure if this is really the reason the update/create attempts were failing, but I changed the values for the body height and body weight measured to values with a zero fractional component (i.e. 50.0 vs 53.5) and the link to the encounter request succeeded. Weird. But it worked. I'll probably experiment with this some more to try to find the real reason why my earlier attempts failed. Thank you for that suggestion. – Teksysta Oct 27 '15 at 20:12
  • If the server will take 50.0 but not 53.5 with no other differences, then something weird is definitely going on :> – Lloyd McKenzie Oct 28 '15 at 00:24
0

This bug is fixed on version 2.0 on TechOnFhir, you should try again. https://github.com/i3l/GT-FHIR/issues/93

Ismael Sarmento
  • 844
  • 1
  • 11
  • 22