1

I am planning a new desktop application. It will provide a WYSIWYG editor for HL7 files (OSS Project). HL7 is a structured file format often used by hospitals for exchanging data between systems.

The basic structure of the format comprises of records which are \r delimited. A record can have N fields which are | delimited. A field itself can be sub-devided into components ^ and sub-components & and fields can be repeated ~ (similar to an array). Every message type has a different number of fields/components and sub-components. Empty fields at the end of a record can be omitted.

Example of a simple record: OBX|14|NM|0050–5^Calcium||8.9|mg/dl|8.4–10.4||||F

I have already implemented an efficient parser which turns a whole file into a hirarchial data structure in C. I want to implement an application that allows editing these files like in a text editor. I want to keep the underlaying hirarchial datastructure at any point, so it is easy to validate structure and content of every field, upon user changes, quickly.

Also note worthy is, that I already implemented a viewer where the document strcuture is displayed in a QTreeView. The structure is using a QAbstractItemModel.

Now to my actual question: how would I approach the problem of having a text editor with a structured data model in Qt. I have done some research:

  • there is a QDomDocument, it seems to be made to work with xml data. I could convert my structure into XML but can the dom object be used with a text editor ?
  • Is there a way to bind a tree like document model to QTextEdit or QPlainTextEdit?
  • is it possible to bind a QAbstractItemModel to a document in QTextEdit or QPlainTextEdit?

What would be the best approach to tackle the problem of having a textual representation of a tree that gets updated once text and/or stricture is changed by editing in the text field?

Performance and cross platform capability is important, so this project will be implemented in C++.

Thanks for any advice and examples appreciated if you have any.

-S

Spliffster
  • 6,959
  • 2
  • 24
  • 19
  • 2
    HL7 should be burned by hellfire and forgotten about. Why an OSS project to support this abomination? It’s punched cards ported to text. It’s not needed for anything at all, and the poor sobs who are forced to use it should be freed from this awkward mainframe-mindset heresy. Qt should ban such use (joking, but really - don’t do it, it’s a waste of life and only gives the proponents ammo in discussions as to why should it be kept alive). I’ll do everything in my power to steer anyone, and their animals, away from HL7. It’s reinventing the wheel, 1960s-style. Barf. – Kuba hasn't forgotten Monica Aug 05 '20 at 05:24
  • 1
    And as a potential patient, I’d rather nothing about me was encoded in HL7. Ever. – Kuba hasn't forgotten Monica Aug 05 '20 at 05:26
  • And also: C data structures? If anything, I’d use a fast text transformation to turn it into valid json, and then use a library that will parse that json faster then your conversion code can produce it (I’m serious, it’s a fine deal at this point). – Kuba hasn't forgotten Monica Aug 05 '20 at 05:28
  • As for how to make text editors that work with structured data: look how the JetBrains folks have done it in their DSL tooling, called MPL. You’d be maybe better off prototyping some of the ideas in that environment and then writing a custom editor in Qt. It’s not hard to do from scratch. But at least don’t directly touch HL7 if you could use my help. Let the tool only ever deal with json, and have separate converters that don’t have to parse the numbers etc. – Kuba hasn't forgotten Monica Aug 05 '20 at 05:31
  • @ReinstateMonica: I can relate to your hate towards HL7. However, in reality it is used extensively and I am not living in dreamland. Also, when dealing with millions of messages per day, having a design goal to make the core of the tools cross-platform capable and performant I don't see a better language than C. The underlying libraries should also provide language bindings for several languages. My employer is nice enough to let me make part of the tool-set OSS. Your comments are not very helpful because they answer none of my questions. Still upvoted for comedic value. – Spliffster Aug 05 '20 at 06:40

0 Answers0