I am calling
string fhirString = FhirSerializer.SerializeResourceToXml(fhirBundle, Hl7.Fhir.Rest.SummaryType.True);
in the `fhirBundle` object, there is a Communication resource entry which I have added extensions to, like so:
communication.AddExtension(Constants.ThxExtReplyTo,
new ResourceReference()
{
Reference = Constants.CdxPractitionerUrl + senderPractId,
Extension = new List<Extension>()
{
// this is the on-behalf-of sub extension
new Extension()
{
Url = Constants.ThxExtOnBehalfof,
Value = new ResourceReference()
{
Reference = Constants.CdxOrganizationUrl + senderOrgId
}
}
}
}
);
When debugging, I can see the fhirBundle/Communication entry.Resource does contain the extensions, but after serialization, they are not in the resulting XML.
In contrast, in the Communication/recipient element, I am able to add and extension and it works -- for example:
var recipRef = new ResourceReference();
if (recip.providerType.Equals("Primary"))
{
recipRef.AddExtension(Constants.ThxExtPrimaryRecipient, new FhirBoolean(true));
}
recipRef.AddExtension(Constants.ThxExtOnBehalfof, new ResourceReference()
{
//Url = new Uri(Constants.ThxExtOnBehalfof),
Reference = Constants.CdxOrganizationUrl + recip.providerLocation.GetLocationKey()
//Value = new FhirString(Constants.CdxOrganizationUrl + recip.providerLocation.GetLocationKey())
});
communication.Recipient.Add(recipRef);
This is an OLD version of the .Net library, so I realize it's done a little differently now, but is there some knowledge out there to indicate what I might be doing wrong. Extensions ARE working in other places, but in many I cannot get them to work. I have no choice in teh version that we are using since this is beyond my control.
Here is the complete Communication XML that results from using the code above:
<Communication>
<id value="495e2bc8-3d9f-47c2-a4c8-a59650dd9d0a" />
<meta>
<security>
<code value="R" />
<display value="restricted" />
</security>
<tag>
<code value="SUBSETTED" />
</tag>
</meta>
<identifier>
<system value="urn:ietf:rfc3986" />
<value value="urn:uuid:495e2bc8-3d9f-47c2-a4c8-a59650dd9d0a" />
</identifier>
<category>
<coding>
<code value="consult" />
</coding>
</category>
<recipient>
<valueBoolean value="true" />
</extension>
<valueReference>
</valueReference>
</extension>
</recipient>
<payload>
<contentAttachment>
<contentType value="application/pdf" />
<url value="f634504b-79a2-e911-a96d-0050568c55a6" />
<size value="84110" />
<title value=".pdf" />
</contentAttachment>
</payload>
<status value="in-progress" />
<sent value="2019-07-10T15:14:46-07:00" />
<subject>
<reference value="Patient/1a49fa2d-6a76-4862-9cb9-694d173276df" />
</subject>
</Communication>