6. Tools¶
6.1. rimdb2py.sql¶
Rim map dumper; outputs the dependency list and attribute list of an already present HL7 schema. This RIM map is typically generated once for each required normative edition.
In the example below, an excerpt of a project Makefile, the rim map is generated after the database has been prepared by loading the MGRID HDL and the HL7v3 Normative Edition 2005 RIM.
$(RIMPYDIR)/rim$(RIMVER).py: $(RIMPYDIR)/__init__.py $(ROOT)/generators/rimdb2py.sql
psql postgres -qc "DROP DATABASE IF EXISTS rimdb2py"
createdb rimdb2py
psql rimdb2py -qc "CREATE EXTENSION hl7basetable"
psql rimdb2py -qc "CREATE EXTENSION ucum"
psql rimdb2py -qc "CREATE EXTENSION hl7"
psql rimdb2py -qc "CREATE EXTENSION hl7v3vocab_edition2005"
psql rimdb2py -qc "CREATE EXTENSION hl7v3datatypes"
psql rimdb2py -qc "CREATE EXTENSION hl7v3rim_edition2005"
psql rimdb2py -qtAf $(ROOT)/generators/rimdb2py.sql > $@
psql postgres -qc "DROP DATABASE IF EXISTS rimdb2py"
6.2. mif12py.xsl¶
XSL transform that retrieves MIF1 attributes about a message needed for the conversion from XML to SQL from a MIF1 file.
Typical use in a project Makefile:
$(MIFPYDIR)/%.py: $(MIFDIR)/%.mif $(MIFPYDIR)/__init__.py $(ROOT)/generators/mif12py.xsl
xsltproc $(ROOT)/generators/mif12py.xsl $< > $@
6.3. mif22py.xsl¶
XSL transform that retrieves MIF2 attributes about a message needed for the conversion from XML to SQL from a MIF2 file.
Typical use in a project Makefile:
$(MIFPYDIR)/%.py: $(MIFDIR)/%.mif $(MIFPYDIR)/__init__.py $(ROOT)/generators/mif22py.xsl
xsltproc $(ROOT)/generators/mif22py.xsl $< > $@
6.4. inmif22py.xsl¶
XSL transform that retrieves MIF2 attributes from an interaction mif needed for the conversion from XML to SQL. Note that it is possible to use the interaction as defined using MIF2 while using MIF1 for the message types contained in the interaction.
Typical use in a project Makefile:
$(INTMIFPYDIR)/%.py: $(INTMIFDIR)/%.mif $(INTMIFPYDIR)/__init__.py $(ROOT)/generators/inmif22py.xsl
xsltproc $(ROOT)/generators/inmif22py.xsl $< > $@
6.5. process_includes.py¶
Rewrite an XSL document pointing to other XSL documents using import and include statements into a larger self-contained XSL.
Note
xsd2parser.py
uses this to rewrite the source xsd into one large xsd. If
parser generation fails, this tool may be used directly to determine what
the exact parser generator input is.
6.6. rimmifinh.sql¶
Dump the tables and their ancestors for a previous loaded HL7 database. Usage:
psql hl7database -f rimmifinh.sql
CREATE FUNCTION
relname | coalesce
------------------------------------+------------------------------------
Access | Role
Account | Act
Acknowledgement | Acknowledgement
AcknowledgementDetail | AcknowledgementDetail
Act | Act
ActRelationship | ActRelationship
Attachment | Attachment
AttentionLine | AttentionLine
Batch | Transmission
CommunicationFunction | CommunicationFunction
Container | Entity
ContextStructure | Act
ControlAct | Act
Device | Entity
DeviceTask | Act
DiagnosticImage | Act
Diet | Act
Document | Act
Employee | Role
Entity | Entity
Entity_CommunicationFunction | Entity_CommunicationFunction
Exposure | Act
FinancialContract | Act
FinancialTransaction | Act
InfrastructureRoot | InfrastructureRoot
InvoiceElement | Act
LanguageCommunication | LanguageCommunication
LicensedEntity | Role
LivingSubject | Entity
ManagedParticipation | Participation
ManufacturedMaterial | Entity
Material | Entity
Message | Transmission
NonPersonLivingSubject | Entity
Observation | Act
Organization | Entity
Parameter | Parameter
ParameterItem | Parameter
ParameterList | Parameter
Participation | Participation
Patient | Role
PatientEncounter | Act
Person | Entity
Place | Entity
Procedure | Act
PublicHealthCase | Act
QualifiedEntity | Role
QueryAck | QueryEvent
QueryByParameter | QueryEvent
QueryContinuation | QueryEvent
QueryEvent | QueryEvent
QuerySpec | QueryEvent
Role | Role
RoleLink | RoleLink
SortControl | SortControl
SubstanceAdministration | Act
Supply | Act
Transmission | Transmission
TransmissionRelationship | TransmissionRelationship
Transmission_CommunicationFunction | Transmission_CommunicationFunction
WorkingList | Act
(62 rows)
6.7. xml2dt.xsl¶
RIM datatype list generator.
Typical use in a project Makefile:
$(DTOBJ): $(DTSRC) $(RIMPYDIR)/__init__.py $(ROOT)/generators/xml2dt.xsl
echo "xml2dt = []" > $@
xsltproc $(ROOT)/generators/xml2dt.xsl $(DTSRC) >> $@
6.8. xsd2parser.py¶
The xsd2parser.py parser generator is used to create a DOM repository and parser from a HL7v3 message XML schema definition.
Typical use in a project Makefile:
$(PARSER) $(PARSERSUBS): $(XSDDIR)/$(TOPMIF).xsd $(ROOT)/generators/xsd2parser.py
$(ROOT)/generators/xsd2parser.py -o $(PARSER) -s \
$(PARSERSUBS) -f -m --no-dates --no-versions \
--silence --member-specs=list --super $(TOPMIF) $<
As it is based on GenerateDS, it still carries similar command line options:
python xsd2parser.py [ options ] <xsd_file>
python xsd2parser.py [ options ] -
Options:
-
-h
,
--help
¶
Display this information.
-
-o
<outfilename>
¶ Output file name for data representation classes
-
-s
<subclassfilename>
¶ Output file name for subclasses
-
-p
<prefix>
¶ Prefix string to be pre-pended to the class names
-
-f
¶
Force creation of output files. Do not ask.
-
-a
<namespaceabbrev>
¶ Namespace abbreviation, e.g. “xsd:”. Default = ‘xs:’.
-
-b
<behaviorfilename>
¶ Input file name for behaviors added to subclasses
-
-m
¶
Generate properties for member variables.
-
--subclass-suffix
="XXX"
¶ Append XXX to the generated subclass names. Default=”Sub”.
-
--root-element
="XXX"
¶ Assume XXX is root element of instance docs. Default is first element defined in schema.
-
--super
="XXX"
¶ Super module name in subclass module. Default=”???”
-
--validator-bodies
=path
¶ Path to a directory containing files that provide bodies (implementations) of validator methods.
-
--use-old-getter-setter
¶
Name getters and setters getVar() and setVar(), instead of get_var() and set_var().
-
--user-methods
= <module>
,
-u
<module>
¶ Optional module containing user methods. See section “User Methods” in the documentation.
-
--no-dates
¶
Do not include the current date in the generated files. This is useful if you want to minimize the amount of (no-operation) changes to the generated python code.
-
--no-versions
¶
Do not include the current version in the generated files. This is useful if you want to minimize the amount of (no-operation) changes to the generated python code.
-
--no-process-includes
¶
Do not process included XML Schema files. By default, xsd2parser.py will insert content from files referenced by <include ... />elements into the XML Schema to be processed.
-
--silence
¶
Normally, the code generated with xsd2parser echoes the information being parsed. To prevent the echo from occurring, use the –silence switch.
-
--namespacedef
='xmlns:abc="http://www.abc.com"'
¶ Namespace definition to be passed in as the value for the namespacedef_ parameter of the export() method by the generated parse() and parseString() functions. Default=’‘.
-
--external-encoding
=<encoding>
¶ Encode output written by the generated export methods using this encoding. Default, if omitted, is the value returned by sys.getdefaultencoding(). Example: –external-encoding=’utf-8’.
-
--member-specs
=list|dict
¶ Generate member (type) specifications in each class: a dictionary of instances of class MemberSpec_ containing member name, type, and array or not. Allowed values are “list” or “dict”. Default: do not generate.
-
-q
,
--no-questions
¶
Do not ask questions, for example, force overwrite.
6.9. enumerate_includes.py¶
Enumerate all schemas included in a xsd.
Used in message development to determine xsds of CMETs used by a top message xsd.
python enumerate_includes.py <xsd_file>