530 likes | 676 Views
HL7 version 3. In-memory object processing. Scope: object based onformance/validation testing, class generators, M2M transoformations. Slide contents published under the Creative Commons / Attribute-Share Alike license Source: www.ringholm.de/download/HL7v3_implementation.zip. Agenda.
E N D
HL7 version 3 In-memory object processing Scope: object based onformance/validation testing, class generators, M2M transoformations Slide contents published under the Creative Commons / Attribute-Share Alike license Source: www.ringholm.de/download/HL7v3_implementation.zip
Agenda • Class generators • MDE principles • MIF/Schema based generators • M2M transformations • Model versioning • OO-based conformance/validation • Implementation experiences
RIMBAA Technology Matrix Persistent Representation Object Representation Serialized Representation RIM (generic) Model RIM Constrained Information Model Application specific Model
In-memory object processing Class Generators Slide contents published under the Creative Commons / Attribute-Share Alike license Source: www.ringholm.de/download/implementation_mechanics.ppt
Traditional Software Development Gather requirements Build Image credits: Johan den Haan, Mendix.nl
Model Driven Software Development (MDD) Model Generate Image credits: Johan den Haan, Mendix.nl
MDD - Application Generation Generic Software Components -Terminology -Data types Software application RIM Persistence Database
MDD –Prescription Example • RIM based model for Prescription • Business workflow • Exchange Pattern Software application
Class-based Parsing Class generators – XML Schema driven Every major development platform provides tools to generate classes from XML Schemas E.g. JAXB, .NET Framework/Mono (XSD.EXE), XML Beans… Class Generators – Model driven Model Driven Software development environments allow classes to be generated from (UML-) models E.g. MARC Everest API Generator (XML ITS/RIM ITS)
Model based code generation • Full (abstract) model specification is stored in a model repository (RoseTree) • Abstract model is expressed as a MIF (Model Interchange Format) file • MIF can be transformed to less expressive XML Schema • Code generation • MIF (to alternate model representation, e.g. UML) to code (e.g. MDHT) • XML Schema to code (e.g. JAXB xjc)
Note: Automatic Code Generation Schema-based code generation CDA R-MIM XML ITS Schema HL7v3 Model Repository MIF-based code generation CDA R-MIM MIF Template MIF Template XML Schema
Code Generation MIF Based Code Generation
MIF Based Code Generator • Full (abstract) model specification is stored in a model repository (RoseTree) • Abstract model is expressed as a MIF file – including GELLO/OCL expressions and (DCM derived) Template definitions • Code (class) generation • MIF - the code generator has to be aware of the structure of the MIF • UML/EMF (derived from the MIF) - the code generator has to know UML/EMF, including the v3 specific extensions
MIF v. Derived model MIF Derived (e.g. UML, Schema) Derived (lossy) specification of v3 model Cross-industry tools for code generation • Normative (full) specification of a v3 model, inclusive of documentation • Full validation support • No cross-industry tools for class generation • MIF based class generators are being created: MRC-HI Everest, OHT
Programming Components Target Model DSL Target Model MIF code Terminology server API + data Vocab MIF Serialization Reusable components XML encoding/decoding CMET MIF Datatypes Custom code Wrapper MIFs Code generation Model transform
Target Model / code • Target Model = payload/focal model • Based on MIF or DSL • Use either MIF or DSL, mixing the two doesn’t tend to work too well • Preserve all information during code generation, inclusive of all documentation
Vocabulary / Term. Server API • The management of vocabulary definitions and terminology services. • CTS API, Terminology Server (persisting vocabulary is the subject of an upcoming module)
Reusable Components • Common model components: • E.g. CMETs, message wrappers • Generate code for [universal] CMETs • All other CMET flavors (e.g. [identified], [identified-confirmable]) can be processed by the generated code.
Data Types – custom code • Custom library with support for v3 data types • Mostly: ISO data types, patched to support data types R1 as well • Relationship with Terminology Server (C* data types) • Needs custom coding: data types MIF is abstract. • Mohawk (.net) and OHT (Java) contain such libraries • Or use datatypes.xsd as the basis for development
Serialization – XML En/DeCoding • Serialization engine • Serialize RIM structures according to HL7 rules • XML En/DeCoding • Encoding of a serialized graph • Rules as specified by the ITS (e.g. XML ITS, RIM ITS)
Code Generation Schema Based Code Generation
Schema based code generation • Advantage: wide availability of tools • Serious disadvantage: XMl schema language isn’t powerful enough to express all model requirements • Disadvantage when validating templates (in-memory, not on serialized format): Templates are expressed in MIF, there is no Schema version.
Schema's serve multiple masters • Schema’s serve more than one purpose • design • validation • contract • code generation • those purposes often need different Schema’s • For code generation: + simplicity, readability - reuseability, composability Slide courtesy of: Marc de Graauw
The HL7v3 Schema’s XML ITS XML ITS Example: QUPA_IN101102UV01 Get Person Demographics Query • MCCI_MT000300UV01 • COCT_MT040203UV01 • COCT_MT150003UV03 • COCT_MT030203UV02 • MFMI_MT700711 • COCT_MT090300UV01 • COCT_MT150000UV02 • COCT_MT070000UV01 • COCT_MT710000UV01 • COCT_MT150003UV03 • COCT_MT070000UV01 • COCT_MT710000UV01 • COCT_MT090100 • COCT_MT150000UV02 • COCT_MT070000UV01 • COCT_MT710000UV01 • COCT_MT150003UV03 • COCT_MT070000UV01 • COCT_MT710000UV01 • COCT_MT090003 • COCT_MT150003UV03 • MCAI_MT900001 • QUPA_MT101102_V01 • QUPA_MT101101_V01 ..and: voc, datatypes, infrastructureRoot Slide courtesy of: Marc de Graauw
Remove ‘includes’ from v3 Schema’s XML ITS • Schema’s should be readable • tools can solve this • but they make you dependent on the tool • Therefore: flatten the Schema’s • remove all includes • put included schema’s where they belong • For readability: make the Schema resemble the instance • Readable Schema’s generate readable code! Slide courtesy of: Marc de Graauw
Datatype schema transformation XML ITS • Constrain data type definitions in XSD (data type flavors used by realm or an implementation) • Transform HL7 datatypes to XSD datatypes • e.g. TS: datetime, CS,ST: string • With a lot of HL7 datatypes, nothing happens except translation to XSD datatypes. • Some mappings (e.g. TS to datetime) have issues associated with them. • Mostly gets rid of nullFlavour support • Do this in the source, generates much more readable code Slide courtesy of: Marc de Graauw
Creative Commons Attribute-Share Alike Data Type schema Transformation XML ITS <xs:complexType name="QUPA_IN101102MdG.MCCI_MT000300UV01.Message"> <xs:sequence> <xs:element name="id" type="II"/> <xs:element name="creationTime" type="xs:date"/> <xs:element name="securityText" type="xs:string" minOccurs="0"/> <xs:element name="versionCode" type="xs:string" minOccurs="0"/> <xs:element name="interactionId" type="II"/> <xs:element name="profileId" type="II" minOccurs="0" maxOccurs="unbounded"/> <xs:element name="processingCode" type="xs:string"/> <xs:element name="processingModeCode" type="xs:string"/> <xs:element name="acceptAckCode" type="xs:string"/> <xs:element name="attachmentText" type="xs:string" minOccurs="0" maxOccurs="unbounded"/> <xs:element name="receiver" type="MCCI_MT000300UV01.Receiver" maxOccurs="unbounded"/> <xs:element name="sender" type="MCCI_MT000300UV01.Sender"/> </xs:sequence> </xs:complexType> <xs:complexType name="II"> <xs:simpleContent> <xs:extension base="xs:string"> <xs:attribute name="root" type="oid" use="optional"> </xs:attribute> <xs:attribute name="extension" type="xs:string" use="optional"> </xs:attribute> <xs:attribute name="assigningAuthorityName" type="xs:string" use="optional"> </xs:attribute> <xs:attribute name="displayable" type="xs:boolean" use="optional"> </xs:attribute> </xs:extension> </xs:simpleContent> </xs:complexType> TS ST CS CS CS CS ED
VB Code XML ITS Partial Public Class QUPA_IN101102MdGMCCI_MT000300UV01Message Private idField As II Private creationTimeField As Date Private securityTextField As String Private versionCodeField As String Private interactionIdField As II Private profileIdField() As II Private processingCodeField As String Private processingModeCodeField As String Private acceptAckCodeField As String Private attachmentTextField() As String Private receiverField() As MCCI_MT000300UV01Receiver Private senderField As MCCI_MT000300UV01Sender ''' Public Property id() As II Get Return Me.idField End Get Set Me.idField = value End Set End Property ''' <System.Xml.Serialization. XmlElementAttribute(DataType:="date")> _ Public Property creationTime() As Date Get Return Me.creationTimeField End Get Set Me.creationTimeField = value End Set End Property • VB code generated for the example query interaction decreased in size from 540 kb to 164 kb – with the exact same functionality • [Marc de Graauw, BC CA project].
XML ITS HL7 Medical Application HL7v3 Medical Content HL7 Control Query Processing Application HL7v3 Acts HL7 Transmission Wrapper Adapter HL7v3 Messages HL7 web services Messaging Adapter SOAP Messages HTTP Client / Server Slide courtesy of: Marc de Graauw
The HL7v3 Schema’s XML ITS • layer the Schema’s • anonimyze with xs:any • <xs:any namespace="##any" processContents="skip" minOccurs="0" maxOccurs="unbounded"/> • SOAP Headers, soap:Body anon • HL7 Transmission Wrapper, Act anon • HL7 Act Wrapper, medical payload anon Slide courtesy of: Marc de Graauw
XML ITS SOAP Transmission Wrapper Control Wrapper Payload Data Slide courtesy of: Marc de Graauw
XML ITS SOAP ANY Transmission Wrapper ANY Control Wrapper ANY Payload Data Slide courtesy of: Marc de Graauw
The XML ITS HL7v3 Schema’s XML ITS • Not very readable • without Schema editor not practically feasible • Generated from database • Fix them with XSLT or other: • Flatten the Schema’s • Remove unneeded datatype hierarchies • Layer the Schema’s • Replace all CMET flavors by a generic CMET flavor • Makes the Schema’s much more readable • Generates simpler code Slide (modified) courtesy of: Marc de Graauw
Code re-use: Post code generation XML ITS .. .. .. Interaction Schema #1 .. Interaction Schema #2 . . Virtual frontend Interaction Schema #n
RIM ITS Schema RIM ITS • Essentially 1 core schema with 50 classes • Generated classes will process any RIM ITS instance • Content validation to be done within application, not at the XML level • Additional MIF based code generation probably required • Processing of RIM-based object trees almost always requires knowledge of the structure of templates (SIM, LIM)
In-memory object processing Implementation Experiences Slide contents published under the Creative Commons / Attribute-Share Alike license Source: www.ringholm.de/download/implementation_mechanics.ppt
Use-case: E-Novation • Serialized messages mapped to in-memory message objects (JAXB, code generation) • Application (business-) objects mapped to relational database (Hibernate ORM) • Custom code: mapping of message objects to application objects
Use-case: E-Novation JAXB • There is no direct link between • Payload • ControlAct • Message • From Object(s) to DOM in 3 separate steps • From DOM to Object in 3 steps (in reverse order)
Use-case: JavaSIG • RIM based objects at core of application • Direct (MIF-based) mapping to/from serialized messages • Direct mapping to relational database See http://aurora.regenstrief.org/javasig for source code
Use-case: JavaSIG MIF based • The direct transition from RO to CS (CS uses the XML ITS) is the most complex part of the API and at every step it is guided by the parsed MIF file. • <Person>..</Person> may have been sent, with defaults omitted. Only by looking at the MIF does one know this equates to <Person classCode=“PSN”>..</Person> and how to map it to a RIM class.
Example Usage • National Cancer Registry HL7 v3 SDK • DRV Bund (Germany – amongst other things a hospital group) • Use RIMBAA Java API and JBoss to create & parse CDA documents. • PHI Technology toolset (Austrian HIS vendor) • Use RIMBAA Java API and JBoss
Use-case: Philips Research • Object model of MIF was generated from the MIF schemas, including read and write methods. • MIF files are read as instances of the MIF model and mapped to object models. • Applications are built using C# classes generated from the object models.
Philips Research: MIF usage Object models generated from MIF:
Use-case: phi-Solution Design Process Choose or Create RMIM Bind RMIM to Process Design FORMs Solution MODEL is READY Bind FORMs to Process Bind FORMs to RMIM Generate & Deploy Onto PHI RE RUN Build a “SOLUTION” to collect patient data (family name, given name, ...).
phi Designer Architecture ECLIPSE PHI JET TEMPLATE PHI DESIGNER PHI Eclipse Plug-ins MIF File (RIM) RIM GMF JET Template OHF JET EMITTER GEF EMF PHI Solution Model XML From OPEN MODEL to RE
MARC Everest Framework • Mohawk College (a Canadian university) has created a .net API-generator based on MIF. • Available on their website: http://everest.marc-hi.ca/