3

I am working on a medical application based on HL7 FHIR. I am trying to add new record using XML and JSON both. But all I get is the '500 Internal Server Error'. The XML I am trying to POST is:

<?xml version="1.0" encoding="UTF-8"?>
<feed xmlns="http://www.w3.org/2005/Atom">
   <title>Patient Data</title>
   <id>urn:uuid:20</id>
   <updated>2015-05-21T16:33:58.030533</updated>
   <entry>
      <title>Patient Dummy Data</title>
      <id>Other/p21-disease-activity-score-1439917023</id>
      <updated>2015-08-18T18:57:03</updated>
      <published>2015-08-18T18:57:03</published>
      <content type="text/xml">
         <Other xmlns="http://hl7.org/fhir">
            <identifier>
               <value value="p21-disease-activity-score-1439917023" />
            </identifier>
            <text>
               <status value="generated" />
            </text>
            <subject>
               <reference value="patient/21" />
               <display value="4" />
            </subject>
            <code>
               <coding>
                  <system value="http://hl7.org/fhir/other-resource-type" />
                  <code value="RA_DISEASE_ACTIVITY" />
               </coding>
            </code>
         </Other>
      </content>
   </entry>
</feed>

I am posting this XML to API Server using PHP-CURL but getting 500 Internal Server Error.

I tried with JSON too but no luck. Here is the JSON:

[
    {
        "resourceType": "Bundle",
        "title": "PatientData",
        "id": "urn:uuid:21",
        "updated": "2015-05-21T16:33:58.030533",
        "entry": [
            {
                "title": "MyTitle",
                "id": "Other/p007-shoulder-lt-1439220540",
                "updated": "2015-08-10T11:29:00",
                "published": "2015-08-10T11:29:00",
                "author": {
                    "name": "Medtak"
                },
                "content": {
                    "resourceType": "Other",
                    "identifier": "007",
                    "text": {
                        "status": "generated"
                    },
                    "subject": {
                        "reference": "patient/007",
                        "display": "true"
                    },
                    "code": {
                        "coding": [
                            {
                                "system": "http://hl7.org/fhir/other-resource-type",
                                "code": "RA_DISEASE_ACTIVITY"
                            }
                        ]
                    }
                }
            }
        ]
    }
]

I have spent almost 3 days to fix this issue but couldn't find any solution. Any help would be appreciated. Thanks!

2 Answers2

3

POST a resource via CURL

curl -X POST https://api.1uphealth.care/fhir/stu2/Patient \
  -H "Content-Type: application/json" \
  -H "Authorization: Bearer xxx_your_access_token_here_xxx" \
  -d '{"resourceType": "Patient","id": "helloiamatestpatient","gender": "female"}'

If you're posting xml, use the correct xml fhir doc and change the Content-Type.

Depending on the FHIR server you're working with, you may not be able to POST resources because many do not support write access yet.

Here's some more information on using oauth to query FHIR - https://1up.health/dev/intro-fhir-api-oauth-query

Ricky Sahu
  • 23,455
  • 4
  • 42
  • 32
0

You can get some idea if you following below link. http://hl7-fhir.github.io/overview-dev.html

Hariprasath
  • 539
  • 1
  • 9
  • 21