FHIR Chat · HAPI FHIR - Pass List<Observation> to create method · implementers

Stream: implementers

Topic: HAPI FHIR - Pass List<Observation> to create method


view this post on Zulip Valeriy Shtanko (Jan 31 2019 at 13:54):

Hi!
I am new with HAPI FHIR and asking for help in my task.

I need to pass a list of Observation to the method in my Observation resource provider.
When I have tried to do

@Create
public MethodOutcome createObservationResult(@ResourceParam List<Observation> results) {
...
}

I have faced a multiple issues with, such as incorrect resource type, wrong json.
Could you advise me a correct approach for that task?

Thank you

view this post on Zulip Lloyd McKenzie (Jan 31 2019 at 15:10):

You describe your issues in the past tense. What issue are you facing now? Also, you might want to raise this on the #hapi stream.

view this post on Zulip Valeriy Shtanko (Jan 31 2019 at 15:18):

Thank you for your answer. Unfortunately, I still fight with that issues.

view this post on Zulip Lloyd McKenzie (Jan 31 2019 at 15:41):

The portion you've shown isn't going to help much with diagnosing your issue as we can't see the resource type or the JSON

view this post on Zulip Valeriy Shtanko (Feb 01 2019 at 11:10):

Hi Lloyd
Thank you for your answer.

Resource type is Observation and as I mentioned above I want to implement method, which accepts list of observations. When I return list of observation from another method HAPI puts it into bundle, so I expect if I implement method

@Create
public MethodOutcome createObservationResult(@ResourceParam List<Observation> results) {...}

and will send the JSON (with bundle as payload) I'll get list of observation inside method.
The bundle JSON is

{
"resourceType": "Bundle",
"id": "cf288d1c-6828-4a63-a3c1-3d503a1e7759",
"meta": {
"lastUpdated": "2019-01-31T14:53:33.392+02:00"
},
"type": "message",
"total": 3,
"link": [
{
"relation": "self",
"url": "http://localhost:8089/fhir/Observation"
}
],
"entry": [
{
"fullUrl": "http://localhost:8089/fhir/Observation/333",
"resource": {
"resourceType": "Observation",
"id": "333",
"basedOn": [
{
"reference": "referral-id"
}
],
"performer": [
{
"reference": "referral-id"
}
],
"component": [
{
"code": {
"coding": [
{
"code": "name-of-analysis"
}
]
},
"valueString": "aaa"
},
{
"code": {
"coding": [
{
"code": "result-of-analysis"
}
]
},
"valueString": "bbb"
},
{
"code": {
"coding": [
{
"code": "unit-of-measurement"
}
]
},
"valueString": "ccc"
},
{
"code": {
"coding": [
{
"code": "reference-interval"
}
]
},
"valueString": "ddd"
}
]
}
},
{
"fullUrl": "http://localhost:8089/fhir/Observation/333",
"resource": {
"resourceType": "Observation",
"id": "333",
"basedOn": [
{
"reference": "referral-id"
}
],
"performer": [
{
"reference": "referral-id"
}
],
"component": [
{
"code": {
"coding": [
{
"code": "name-of-analysis"
}
]
},
"valueString": "aaa"
},
{
"code": {
"coding": [
{
"code": "result-of-analysis"
}
]
},
"valueString": "bbb"
},
{
"code": {
"coding": [
{
"code": "unit-of-measurement"
}
]
},
"valueString": "ccc"
},
{
"code": {
"coding": [
{
"code": "reference-interval"
}
]
},
"valueString": "ddd"
}
]
}
},
{
"fullUrl": "http://localhost:8089/fhir/Observation/333",
"resource": {
"resourceType": "Observation",
"id": "333",
"basedOn": [
{
"reference": "referral-id"
}
],
"performer": [
{
"reference": "referral-id"
}
],
"component": [
{
"code": {
"coding": [
{
"code": "name-of-analysis"
}
]
},
"valueString": "aaa"
},
{
"code": {
"coding": [
{
"code": "result-of-analysis"
}
]
},
"valueString": "bbb"
},
{
"code": {
"coding": [
{
"code": "unit-of-measurement"
}
]
},
"valueString": "ccc"
},
{
"code": {
"coding": [
{
"code": "reference-interval"
}
]
},
"valueString": "ddd"
}
]
}
}
]
}

The endpoint is localhost:8089/fhir/Observation

I get the error "Failed to parse request body as JSON resource. Error was: Incorrect resource type found, expected "Observation" but found "Bundle""

view this post on Zulip Lloyd McKenzie (Feb 01 2019 at 15:41):

@James Agnew


Last updated: Apr 12 2022 at 19:14 UTC