I am creating an bundle object and setting the Metadata property "LastUpdated" as DateTimeOffset.Now;
When the FHIR JSON is output to response, it is showing as
"resourceType": "Bundle",
"id": "40127cc7-20c1-4dfc-99bc-01c06f88ebe0",
"meta": {
"lastUpdated": "2018-05-06T17:58:14.43+03:00"
},
However, our expected format in JSON for lastUpdated/any datetime field is to be as "yyyy-MM-DDT:HH:mm:ssZ". But I get ms+UTCOff time instead of Z.
Please help us how we can achieve this lastUpdated to be of expected format while serializing the resource content to JSON.
I am using below code in customformatter class written to parse fhir+json data.
public override System.Threading.Tasks.Task WriteToStreamAsync(Type type, object value, Stream writeStream, HttpContent content, TransportContext transportContext)
{
return System.Threading.Tasks.Task.Factory.StartNew(() =>
{
StreamWriter writer = new StreamWriter(writeStream);
JsonWriter jsonwriter = SerializationUtil.CreateJsonTextWriter(writer); // This will use the BetterJsonWriter which handles precision correctly
if (type == typeof(OperationOutcome))
{
Resource resource = (Resource)value;
FhirSerializer.SerializeResource(resource, jsonwriter);
}
else if (typeof(Resource).IsAssignableFrom(type))
{
if (value != null)
{
Resource r = value as Resource;
SummaryType st = SummaryType.False;
if (r.HasAnnotation())
st = r.Annotation();
FhirSerializer.SerializeResource(r, jsonwriter, st);
}
}
writer.Flush();
});
Hi, I am facing an issue,
I am creating an bundle object and setting the Metadata property "LastUpdated" as DateTimeOffset.Now;
When the FHIR JSON is output to response, it is showing as "resourceType": "Bundle", "id": "40127cc7-20c1-4dfc-99bc-01c06f88ebe0", "meta": { "lastUpdated": "2018-05-06T17:58:14.43+03:00" },
However, our expected format in JSON for lastUpdated/any datetime field is to be as "yyyy-MM-DDT:HH:mm:ssZ". But I get ms+UTCOff time instead of Z.
Please help us how we can achieve this lastUpdated to be of expected format while serializing the resource content to JSON.
I am using below code in customformatter class written to parse fhir+json data.
public override System.Threading.Tasks.Task WriteToStreamAsync(Type type, object value, Stream writeStream, HttpContent content, TransportContext transportContext) { return System.Threading.Tasks.Task.Factory.StartNew(() => { StreamWriter writer = new StreamWriter(writeStream); JsonWriter jsonwriter = SerializationUtil.CreateJsonTextWriter(writer); // This will use the BetterJsonWriter which handles precision correctly if (type == typeof(OperationOutcome)) { Resource resource = (Resource)value; FhirSerializer.SerializeResource(resource, jsonwriter); } else if (typeof(Resource).IsAssignableFrom(type)) { if (value != null) { Resource r = value as Resource; SummaryType st = SummaryType.False; if (r.HasAnnotation())
st = r.Annotation();
FhirSerializer.SerializeResource(r, jsonwriter, st);
}
}
writer.Flush();
});
Your help is highly appreciated.