Extensions (Specifically Race Code)

Nov 19, 2013 at 11:08 PM

This SDK has literally been my savior, but there is one bit of functionality that I can't seem to find...

CDA R2 allows for extensions. For instance, I need to specify multiple races if the patient has declared more than one race within our system. The HL7SDK patient object only allows for one race code to be tied to it.

According to CDA R2 specifications, CDA allows for extension nodes to allow for multiple entries. The additional race nodes would have a format of the following:

<sdtc:raceCode code="12345" ... />

Does the SDK allow for this???

Thanks a ton in advance!
Nov 20, 2013 at 5:53 AM
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:
> "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 project

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):
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.
Sep 22, 2016 at 4:16 PM
Hello guys, is there any new version of this sdk with that feature for multiple racecodes included in it? If so, please, can you guys let me know where can I get it? Thank you so much in advance.