Post XML or JSON to FHIR API Server



我正在开发一个基于HL7 FHIR的医疗应用程序。我正试图使用XML和JSON添加新记录。但我得到的是'500内部服务器错误'。我要POST的XML是:

<?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>

我使用PHP-CURL将此XML发布到API服务器,但得到500内部服务器错误。

我也尝试过JSON,但没有运气。以下是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"
                            }
                        ]
                    }
                }
            }
        ]
    }
]

我花了将近3天的时间来解决这个问题,但没有找到任何解决方案。任何帮助都会很感激。谢谢!

通过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"}'

如果你发布的是xml,请使用正确的xml fhir文档并更改Content-Type .

根据你正在使用的FHIR服务器,你可能无法POST资源,因为许多服务器还不支持写访问。

这里有一些关于使用oauth查询FHIR的更多信息- https://1up.health/dev/intro-fhir-api-oauth-query

如果你跟随下面的链接,你会得到一些想法。http://hl7-fhir.github.io/overview-dev.html

最新更新