LinuxForHealth / FHIR

The LinuxForHealth FHIR® Server and related projects
https://linuxforhealth.github.io/FHIR
Apache License 2.0
330 stars 157 forks source link

Transaction Bundle persisted but the Resources are not created #4171

Closed jecihjoy closed 1 year ago

jecihjoy commented 1 year ago

Describe the bug When I do a POST request of a Transaction bundle, the bundle is persisted and I can do a get of the bundle, However the individual resources in the Bundle are not persisted. Eg I tried creating a Bundle consisting Encounters and Observations, I got a 201 created but when I fetch my encounters or observations nothing new was recorded in the database

Environment I used fhir-install-5.0.0.zip and fhir-persistence-schema-5.0.0-cli.jar to setup the server

To Reproduce Do a POST request of a Bundle containing and Fhir R4 Resources and check if additional records were created

Expected behavior I expect individual resources from the Bundle to be persisted in the database, which I can then verify via a GET request

Additional context N/A

lmsurpre commented 1 year ago

You probably POSTed to the Bundle endpoint [host]/fhir-server/api/v4/Bundle instead of the batch/transaction endpoint [host]/fhir-server/api/v4. This is a common mistake.

jecihjoy commented 1 year ago

When I post here fhir-server/api/v4/ am getting this error


    "resourceType": "OperationOutcome",
    "id": "7f-0-0-1-e1d4f5d1-77e7-4c10-8bc8-9a185b895da8",
    "issue": [
        {
            "severity": "fatal",
            "code": "not-found",
            "details": {
                "text": "Request URL for bundled create requests should have a path with exactly one token (<resourceType>)."
            }
        }
    ]
}
jecihjoy commented 1 year ago

Found the issue causing the error above. Posting the solution for future references. In the payload, instaed of using

 "request": {
                "method": "POST",
                "url": "/Observation"
            }

Use

        "request": {
            "method": "POST",
            "url": "Observation"
        } 

That forward slash was causing the issue above
lmsurpre commented 1 year ago

@jecihjoy thank you for sharing. The one without the leading "/" matches the POST example from the spec: https://www.hl7.org/fhir/bundle-transaction.json.html

But I feel like both should work. Mind opening a separate issue for getting bundle request urls with a leading "/" to work?

jecihjoy commented 1 year ago

I have opened an issue here