【问题标题】:Post XML or JSON to FHIR API Server将 XML 或 JSON 发布到 FHIR API 服务器
【发布时间】:2015-08-18 09:09:04
【问题描述】:

我正在开发基于 HL7 FHIR 的医疗应用程序。我正在尝试使用 XML 和 JSON 添加新记录。但我得到的只是“500 内部服务器错误”。 我要发布的 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 天的时间来解决这个问题,但找不到任何解决方案。任何帮助,将不胜感激。谢谢!

【问题讨论】:

  • 你累了什么,3天我们可以拿些样品
  • 为什么需要将 XML 转换为 JSON?
  • 我尝试使用 Curl 将 XML 文件发布到 API 服务器。我也尝试过使用 JSON。
  • 您发帖到哪个服务器,地址是什么?请尝试使用其中一台公共服务器

标签: json xml curl hl7-fhir


【解决方案1】:

通过 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 doc 并更改 Content-Type

根据您使用的 FHIR 服务器,您可能无法发布资源,因为许多资源还不支持写入访问。

这里有更多关于using oauth to query FHIR - https://1up.health/dev/intro-fhir-api-oauth-query的信息

【讨论】:

    【解决方案2】:

    如果您点击下面的链接,您会有所了解。 http://hl7-fhir.github.io/overview-dev.html

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2011-04-22
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2011-01-19
      • 2018-12-12
      相关资源
      最近更新 更多