2

I want to create a (graphical) representation for a custom HL7 v2 message structure. In this scenario, I'm only concerned with the high-level message structure - the arrangement and usage of the segments of a message. The official documents (which are not available unless you pay for them, AFAIK) use a table notation like this:

example structure

In this structure, the different brackets denote optional [] and repeatable {} segments as well as alternatives <x|y|z>. Our custom structure is built upon this standard and basically appends a few segments and declares that we'll never use certain other segments. So far, we have simply mimicked the table-like structure, but I find that this is hard to read, especially with multiple nestend levels of conditional groups. I was thinking about converting the TikZ file tree example to represent the data structure, but with all the child [missing] entries and other peculiarities, I was wondering whether there are other (better?) options.

5
  • This is the sort of thing I've seen used - I think they are called railroad diagrams.
    – Thruston
    Dec 15, 2014 at 14:16
  • @Thruston: This might be an interesting idea - however, I haven't found a viable alternative to produce these diagrams yet. The syntax package causes the entire build process to fail with missing \endcsnames, and the TikZ approach is way too complicated to be maintained by anyone else. An external tool would not be a great idea for maintenance reasons either...
    – vwegert
    Dec 16, 2014 at 10:32
  • How about transforming it to json? Then it is easy with LuaLaTeX Dec 17, 2014 at 16:50
  • @YiannisLazarides, can you explain how it would be easy with Lua? Or perhaps point to some other answer?
    – Thruston
    Dec 17, 2014 at 22:32
  • @Thruston Lua tables, are the datastructure, you can represent anything with them, similarly is json, which I prefer as it is now almost universal. Once you have the structure in a Lua Table, the formatting can then be programmed. I will post an answer tomorrow, as it is hectic today. See hl7.org/implement/standards/fhir/patient-examples.json.html Dec 18, 2014 at 2:50

2 Answers 2

2

I wholeheartily agree that the current format you are using is awkard and possibly it casts a light as to the many reasons that health software projects fail; which IMHO is due to bureaucratic complexification. Having to pay for the formats adds insult to injury.

I would recommend to use Lua. If you generating the data for typesetting programatically, I would use Lua tables directly. If they are generated from a db, either export them as XML or preferably json. Here is a simplified program to demonstrate this. No need for any railroads or boxes, you can read the data like a paragraph from a book.

enter image description here

  \documentclass{article}
    \usepackage{fontspec,luacode, xcolor}
    \newfontfamily{\arial}{Arial} 
    \begin{document}
    \arial

    \begin{luacode}
    if type(tex)=='table' then local print = tex.print  end

    local patientVisit = {
        patientClass = "CON",
        assignedPatientLocation = {
            pointOfCare = "8152879"
        },
        visitNumber = {
            idNumber = 16164813
        }
     }

    function inspect_table (tab, offset)
        offset = offset or "\\mbox{~~}"
        for k, v in pairs (tab) do
            local newoffset = offset .. offset
            if type(v) == "table" then
               print(offset..k .. " = \\{\\par ")
               inspect_table(v, newoffset)
               print(offset.."\\}\\par")
            else
             if k=="patientClass" then print(offset .. '{\\color{red}'.. k .. "} = " .. tostring(v), "\\par") 
               else
                  print(offset..k.."="..v.."\\par")
               end
           end
        end
    end

    inspect_table(patientVisit)
    \end{luacode}

The routine above is very simple, however it can easily be modified to color code better, sort the fields and add notes etc. As a bonus no need of any catcodes. If you interested in a json solution drop a message and I will post one.

1

An Example: find it at http://ddi.uni-wuppertal.de/material/materialsammlung/

package is on CTAN: http://ctan.org/pkg/schule

Railroad-diagram – introduced by Niklaus Wirth with programming language Pascal

\documentclass{schulein}
\usepackage[utf8]{inputenc}
\usepackage{schulinf}

\begin{document}

\begin{tikzpicture}[syntaxdiagramm]
\node [] {};
\node [terminal] {public};
\node [terminal] {class};
\node [nonterminal] {Klassenname};
\node [terminal] {\{};
\node (endstart) [point] {};
\node [point, below=of endstart] {};
\node [point, xshift=-75mm] {};
\node (endAttribute) [endpoint, continue chain=going below] {};
\node (startAttribute) [point] {};
{[start chain=attribute going right]
    \chainin (startAttribute);
    \node [point, xshift=25mm] {};
    \node [point, continue chain=going above] {};
    \node [nonterminal, continue chain=going left] {Attribut};
    \node [point, join,join=with endAttribute] {};
}

\node (startKonstruktor) [point] {};
\node (endKonstruktor) [endpoint] {};
{[start chain=konstruktor going right]
    \chainin (startKonstruktor);
    \node [point, xshift=30mm] {};
    \node [point, continue chain=going below] {};
    \node [nonterminal, continue chain=going left] {Konstruktor};
    \node [point, join,join=with endKonstruktor] {};
}

\node (endMethode) [endpoint] {};
\node (startMethode) [point] {};
{[start chain=methode going right]
    \chainin (startMethode);
    \node [point, xshift=25mm] {};
    \node [point, continue chain=going above] {};
    \node [nonterminal, continue chain=going left] {Methode};
    \node [point, join,join=with endMethode] {};
}

\node [point] {};
\node [terminal, continue chain=going left] {\}};

\end{tikzpicture}
\end{document}
2
  • There's a lot hidden away in that German "school" package - is there any documentation in English, I wonder?
    – Thruston
    Dec 17, 2014 at 22:34
  • at this very moment, there is no English documentation, so you've to read the source-code. But most is documented in the pgfmanual as well – including the railroad-diagramm-construction as an example
    – L. Humbert
    Dec 18, 2014 at 8:33

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .