C# 无法将json反序列化到FHIR约会实例
我正在获取以下json:C# 无法将json反序列化到FHIR约会实例,c#,json,deserialization,json-deserialization,hl7-fhir,C#,Json,Deserialization,Json Deserialization,Hl7 Fhir,我正在获取以下json: { "fullUrl": "https://my.fhir-server.com:8181/multi-m2integrationtest/firm/xyz123/ema/fhir/v2/Appointment/7240", "resource": { "resourceType": "Appointment", "id": &
{
"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 a = JsonConvert.DeserializeObject<Appointment>(strAppt, jss);
约会a=JsonConvert.DeserializeObject
Appointment类已实例化,但其所有属性均为null或0
以下是我已纳入我的项目的FHIR包:
解决方案不是使用JsonConvert,而是使用专门的FhirJsonParser
这项工作:
FhirJsonParser fjp = new FhirJsonParser();
Bundle bundle = fjp.Parse<Bundle>(Response);
foreach (var entry in bundle.Entry)
{
Appointment appt = (Appointment)entry.Resource;
}
FhirJsonParser fjp=新的FhirJsonParser();
Bundle=fjp.Parse(响应);
foreach(bundle.entry中的var条目)
{
约会appt=(约会)entry.Resource;
}
好的文档资源: