I am obtaining the following 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"
}
}
]
}
}
This is an Appointment structure:
When I attempt to deserialize this into a FHIR Appointment class, the attempt fails:
Appointment a = JsonConvert.DeserializeObject<Appointment>(strAppt, jss);
There's no exception, but clearly, this has not been successful:
The Appointment class is instantiated, but all of its attributes are null or 0
Here are the FHIR packages which I have incorporated into my project:
The solution is not to use JsonConvert, but rather to use the specialized FhirJsonParser.
This works:
FhirJsonParser fjp = new FhirJsonParser();
Bundle bundle = fjp.Parse<Bundle>(Response);
foreach (var entry in bundle.Entry)
{
Appointment appt = (Appointment)entry.Resource;
}
A good documentation resource: https://docs.fire.ly/firelynetsdk/start.html