【问题标题】:Having trouble Deserializing json to FHIR Appointment Instance将 json 反序列化为 FHIR 约会实例时遇到问题
【发布时间】:2020-11-17 14:51:34
【问题描述】:

我正在获取以下 json:

{
  "fullUrl": "https://my.fhir-server.com:8181/multi-m2integrationtest/firm/xyz123/ema/fhir/v2/Appointment/7240",
  "resource": {
    "resourceType": "Appointment",
    "id": "7240",
    "meta": {
      "lastUpdated": "2020-11-16T15:00:40-05:00"
    },
    "status": "pending",
    "appointmentType": {
      "coding": [
        {
          "system": "https://my.fhir-server.com:8181/multi-m2integrationtest/firm/xyz123/ema/fhir/v2/ValueSet/appointment-type",
          "code": "599",
          "display": "New Patient"
        }
      ],
      "text": "New Patient"
    },
    "reasonCode": [
      {
        "coding": [
          {
            "system": "https://my.fhir-server.com:8181/multi-m2integrationtest/firm/xyz123/ema/fhir/v2/ValueSet/reportable-reason",
            "code": "Other",
            "display": "OTHER"
          }
        ],
        "text": "OTHER"
      }
    ],
    "supportingInformation": [
      {
        "identifier": {
          "system": "NEW_PATIENT",
          "value": "true"
        },
        "display": "New Patient: true"
      }
    ],
    "start": "2020-11-17T09:55:00-05:00",
    "end": "2020-11-17T10:10:00-05:00",
    "minutesDuration": 15,
    "created": "2020-11-16T15:00:40-05:00",
    "participant": [
      {
        "actor": {
          "reference": "https://my.fhir-server.com:8181/multi-m2integrationtest/firm/xyz123/ema/fhir/v2/Location/271",
          "display": "https://my.fhir-server.com:8181/multi-m2integrationtest/firm/xyz123/ema/fhir/v2/Location/271"
        }
      },
      {
        "actor": {
          "reference": "https://my.fhir-server.com:8181/multi-m2integrationtest/firm/xyz123/ema/fhir/v2/Practitioner/116249",
          "display": "https://my.fhir-server.com:8181/multi-m2integrationtest/firm/xyz123/ema/fhir/v2/Practitioner/116249"
        }
      },
      {
        "actor": {
          "reference": "https://my.fhir-server.com:8181/multi-m2integrationtest/firm/xyz123/ema/fhir/v2/Patient/116453",
          "display": "https://my.fhir-server.com:8181/multi-m2integrationtest/firm/xyz123/ema/fhir/v2/Patient/116453"
        }
      }
    ]
  }
}

这是一个约会结构:

当我尝试将其反序列化为 FHIR Appointment 类时,尝试失败:

Appointment a = JsonConvert.DeserializeObject<Appointment>(strAppt, jss);

也不例外,但显然,这并没有成功:

Appointment 类已实例化,但其所有属性均为 null 或 0

以下是我已合并到我的项目中的 FHIR 包:

【问题讨论】:

    标签: c# json deserialization json-deserialization hl7-fhir


    【解决方案1】:

    解决方法不是使用JsonConvert,而是使用专门的FhirJsonParser。

    这行得通:

    FhirJsonParser fjp = new FhirJsonParser();
    Bundle bundle = fjp.Parse<Bundle>(Response);
    foreach (var entry in bundle.Entry)
    {
        Appointment appt = (Appointment)entry.Resource;
    }
    

    一个很好的文档资源:https://docs.fire.ly/firelynetsdk/start.html

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2021-12-13
      • 2020-10-20
      • 2011-06-30
      • 2021-10-19
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多