Skip to content
LambogeniusDocs

HL7 v2 Schema Generator

Generated schemas

The file layout, naming and content of each generated schema, and how the conversion works.

VS Code extensionlambogenius.hl7-schemagenFree · MIT license. Works entirely locally.

What the generated schemas look like

Each schema holds the whole message: MSH followed by the body, groups included.

Example
File<output>/2.5/ADT_A01_25.xsd
RootADT_A01_25, in namespace http://lambogenius.com/HealthCare/HL7/2X; children unqualified
Segments, groupsPID, ADT_A01_PROCEDURE
Fields (1-based)PID_5_PatientName
Components (0-based)XPN_0_FamilyName
CardinalityRequired fields, repeats, required segments and groups, taken from v2.xml

A patient name in a message, as XML against the schema:

<ns0:ADT_A01_25 xmlns:ns0="http://lambogenius.com/HealthCare/HL7/2X">
  <MSH>...</MSH>
  <PID>
    <PID_5_PatientName>
      <XPN_0_FamilyName><FN_0_Surname>DOE</FN_0_Surname></XPN_0_FamilyName>
      <XPN_1_GivenName>JOHN</XPN_1_GivenName>
    </PID_5_PatientName>
  </PID>
</ns0:ADT_A01_25>

How the conversion works

  • Names: v2.xml names (PID.5, XPN.1, ADT_A01.PROCEDURE) become PID_5_PatientName, XPN_0_FamilyName and ADT_A01_PROCEDURE. The descriptive part is the v2.xml LongName in PascalCase (“Driver's License Number - Patient” → DriverSLicenseNumberPatient).
  • Types: primitive types and formatted text (FT, TX) are plain strings. varies (OBX-5) is a mixed wildcard type.
  • Any-segment positions: anyHL7Segment / anyZSegment (used by some MFN, PC*, QBP and RTB structures) become an optional xs:any namespace="##other". Adjacent ones are merged to keep the schema unambiguous.
  • Extension points: the xs:any extension points at the end of each v2.xml segment are left out.
  • Coded values aren't restricted, because v2.xml has no table enumerations.