Creating C # Classes from FHIR Schemas

I'm trying to create C # classes from the schemas provided by the FHIR project: http://hl7.org/implement/standards/fhir/ I downloaded the schemas: http://hl7.org/documentcenter/public/standards/FHIR/fhir-all -xsd.zip I have a "Unblocked" zip file and unpacked xsd files into a folder. When I try to use xsd.exe to create C # classes, I keep getting errors indicating a problem with the schemas. Sequentially obtaining an xhtml: div element is not declared in addition to the others. The fhir-all.xsd file seems to display top-level objects. I managed to get a simple tombstone.xsd scheme to work with xsd.exe, but a more complex element like valueset.xsd or alert.xsdfails. I do not see what is wrong with these files. Any help on how to fix these schemes would be greatly appreciated.

+3
source share
4 answers

So far, I have managed to generate classes and de-serialize many of the * .xml patient samples provided for both raw classes generated as described and classes generated from raw classes by SOAP.

xhtml1-strict.xsd . xsd.exe , . . div, HTML . . . ( - , ).

XSD\xhtml1-strict.xsd(413):      <!--<xs:group ref="inline"/>-->
XSD\xhtml1-strict.xsd(441):      <!--<xs:element ref="pre"/>-->
XSD\xhtml1-strict.xsd(443):      <!--<xs:element ref="blockquote"/>-->
XSD\xhtml1-strict.xsd(462):      <!--<xs:group ref="misc"/>-->
XSD\xhtml1-strict.xsd(519):      <!--<xs:group ref="block"/>-->
XSD\xhtml1-strict.xsd(520):      <!--<xs:group ref="misc"/>-->
XSD\xhtml1-strict.xsd(539):      <!--<xs:group ref="misc"/>-->
XSD\xhtml1-strict.xsd(1349):        <!--<xs:group ref="block"/>-->
XSD\xhtml1-strict.xsd(1351):        <!--<xs:group ref="inline"/>-->
XSD\xhtml1-strict.xsd(1352):        <!--<xs:group ref="misc"/>-->
XSD\xhtml1-strict.xsd(1450):          <!--<xs:group ref="block"/>-->
XSD\xhtml1-strict.xsd(1452):          <!--<xs:group ref="misc"/>-->
XSD\xhtml1-strict.xsd(1718):          <!--<xs:group ref="block"/>-->
XSD\xhtml1-strict.xsd(1720):          <!--<xs:group ref="inline"/>-->
XSD\xhtml1-strict.xsd(1721):          <!--<xs:group ref="misc"/>-->

, .

Generate entities with Xsd2Code add-in from www.codeplex.com\Xsd2Code

Use fhir-atom-single.xsd as the source XSD
Use Parms:
    Serilization.GenerateXMLAttributes = true
    Code.Namespace = Hl7.Fhir.Validation.SchematronOutput
    Collection.CollectionObjectType=Array

!!! Do not open Schema in Designer, or classes will change.

Manual updates:

    public partial class boolean : Element
    ...
        [System.Xml.Serialization.XmlAttributeAttribute("value")]
        public bool Value
        {


    [System.Xml.Serialization.XmlTypeAttribute(AnonymousType = false, Namespace = "http://www.w3.org/1999/xhtml")]
    public partial class div : Flow


    Refactor:
    public partial class FeedType
    to
    public partial class feed
+2

POCO XSD . FHIR , , (, Observation.value), XSD (valueNumber, valueString, valueCodeableConcept .. ..).

, POCO json.

.NET NuGet FHIR FHIR, , . , Validation, json xsd REST .

WebAPI, : HL7 FHIR json asp.net web api

+4

-, , FHIR XSD XML-: "", ( < xsd: include > ), "", include, .. XSD.

, . :

enter image description here

... " ":

enter image description here

, "". XSD, "" .

, , , , , undefined.

, xsd.exe, . Microsoft , ( ); XSD 1.0 spec XSD 1.1 spec ,

. {} - , {} .

, xsd.exe, . xhtml1-strict.xsd " ". xsd.exe, ( ) xhtml , FHIR, , HTML. , HTML - , ( , ) , .NET.

@GrahameGrieve, , .NET, XSD-, XHTML. , .NET XSD, .NET, xsd.exe( , xsd.exe , XmlSchemaImporter.ImportTypeMapping, )

, , , , , , .

+1

: xsd.exe fhir-atom-single.xsd tombstone.xsd fhir-single.xsd opensearch.xsd opensearchscore.xsd xmldsig-core-schema.xsd xhtml1-strict.xsd xml.xsd/c

and classes are created after circular links are commented out from xhtml1-strict.xsd

However, as Ewout points out, this is not a complete fix because the schemas themselves are designed to be unfriendly to POCO classes.

In the patient class, this element:

  <xs:choice minOccurs="0" maxOccurs="1" >
    <xs:annotation>
      <xs:documentation>Indicates if the individual is deceased or not.</xs:documentation>
    </xs:annotation>
    <xs:element name="deceasedBoolean" type="boolean"/>
    <xs:element name="deceasedDateTime" type="dateTime"/>
  </xs:choice>

Productivity:

/// <remarks/>
[System.Xml.Serialization.XmlElementAttribute("deceasedBoolean", typeof(boolean))]
[System.Xml.Serialization.XmlElementAttribute("deceasedDateTime", typeof(dateTime))]
public Element Item {
    get {
        return this.itemField;
    }
    set {
        this.itemField = value;
    }
}

I reported these findings in the comments of the FHIR and I hope that they will be considered. In the meantime, I can continue my original intention. The SOAP implementation of the API using these definitions.

0
source

All Articles