It's possible but not easy and requires some source code modification :-/
Let me explain of how the library core works.
Internally it uses serializable classes generated by the xsd.exe tool. As far as you know, .NET serialization mechanism ignores all unknown elements/attributes and eliminates them from in-memory representation of XML document.
How to let .NET serializer know about your custom extensions?
1) You should take your extended CDA schema and re-generate serialization classes as follows:
2) Next, you have to regenerate Xml serializers source code. This can be done with the sgen.exe tool (look at the serasm.cmd batch file that comes with the HL7SDK.Xml.Cda project):
3) Rebuild HL7SDK.Xml project
4) Add properties/methods to an interface and a class in the HLSDK project, then rebuild:
Keep in mind that such approach is not applicable if you deal with a variety of extended CDA schemas and MUST keep original documents that come from another healthcare provider unchanged.
Let me explain of how the library core works.
Internally it uses serializable classes generated by the xsd.exe tool. As far as you know, .NET serialization mechanism ignores all unknown elements/attributes and eliminates them from in-memory representation of XML document.
How to let .NET serializer know about your custom extensions?
1) You should take your extended CDA schema and re-generate serialization classes as follows:
> "xsd.exe" "path-to-your-CDA.xsd" /classes /eld /edb /language:cs /namespace:HL7SDK.Xml.Cda.
Replace the CDA.cs file in the HL7.Xml.CDA project with the regenerated one. Recompile the HL7SDK.Xml.Cda project2) Next, you have to regenerate Xml serializers source code. This can be done with the sgen.exe tool (look at the serasm.cmd batch file that comes with the HL7SDK.Xml.Cda project):
sgen /assembly:..\Out\HL7SDK.Xml.Cda.dll /compiler:/keyfile:.\HL7SDK.Xml.Cda.snk /force /keep /out:.
The sgen.exe /keep option produces an ugly named file (something like "hlnkabdg.0.cs") that contains serializers. Replace the Serializers.cs file in the HL7.Xml.CDA project with the generated one.3) Rebuild HL7SDK.Xml project
4) Add properties/methods to an interface and a class in the HLSDK project, then rebuild:
// CDADocument.Partial.cs
partial interface IPatientRole
{
new string RaceCode {get;set;}
}
partial class PatientRole
{
public string RaceCode
{
get { return Element.raceCode; }
set { Element.raceCode = value; }
}
}
Keep in mind that such approach is not applicable if you deal with a variety of extended CDA schemas and MUST keep original documents that come from another healthcare provider unchanged.