Displaying XML in human readable format

8.6k views Asked by At

I have some medical records files which have this in the header:

ClinicalDocument xsi:schemaLocation="urn:hl7-org:v3 CDA.xsd" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:voc="urn:hl7-org:v3/voc" xmlns:sdtc="urn:hl7-org:sdtc" xmlns="urn:hl7-org:v3">

I would like to view them in a human readable format, in any of PDF, Word, or even in Excel.

I can't figure out how to get the appropriate "stylesheet", assuming this is what I am missing.

This is what I have tried:

1) If I open the file in a browser, I get the formatted XML with a message that says "This XML file does not appear to have any style information associated with it. The document tree is shown below."

2) I have tried googling for the file CDA.xsd and I went through this page http://motorcycleguy.blogspot.com/2010/07/where-is-xsd-for-ccd.html which had a couple of links which gave me some large tar files which I couldn't figure out how to use. One of them had a C32_CDA.xsd but when I rename that to CDA.xsd and put it in the same folder as my XML and then try to open it via Excel I cannot get it to display properly.

Any assistance would be most appreciated.

3

There are 3 answers

0
Michael Kay On

To display an XML document in human-readable format you need (typically) an XSLT stylesheet. It seems your XML is in a vocabulary called HL7 (health level 7?). I don't know much about HL7 except that it has a reputation for being very complex, so it's quite likely that the stylesheets needed will also be very complex.

A quick google showed a project for creating HL7 stylesheets here:

https://wiki.hl7.org/index.php?title=CDA_R2.1_Stylesheet_Project

You might find something there that is useful to you.

0
Bryn Lewis On

The XML files you have are C-CDA documents, which are used to communicate information between clinical systems. They are defined according to an HL7 standard.

There are many XSLT stylesheets that you could use to display them—search for C-CDA stylesheets.

Alternatively, I have created a C-CDA viewer you can use: https://github.com/brynlewis/C-CDA_Viewer

A demo of it is here: http://backbeachsoftware.com.au/challenge/index.htm

0
Cwinds On

Is the <ClinicalDocument> tag the first thing in this CCDA document file? Or are there one or two xml instructions at the very top like this (or maybe both on the same line):

<?xml version="1.0" encoding="UTF-8" standalone="yes"?>
<?xml-stylesheet type="text/xsl" href="_CDA_Stylesheet.xsl"?\>

In order for the CCDA Document to function as a valid "well-formed" xml document, it needs to have this xml instruction as the first thing in the file,

  <?xml version="1.0" encoding="UTF-8" standalone="yes"?>

above the root or Document Element, which is the <ClinicalDocument > tag in the CCDA.

The second xml instruction should indicate what xsl stylesheet is used to display the document in a web browser like Chrome, Edge, IE whatever.

If the 2nd xml instruction in your file looks something like this:

 <?xml-stylesheet type="text/xsl" href="_CDA_Stylesheet.xsl"?\>

Then you would know that the stylesheet that the CCDA needs is an xsl stylesheet file with the name:

 _CDA_Stylesheet.xsl

and it needs to be located in the same folder as the ccda xml document.

Or, the xsl stylesheet could be located in a folder that all ccda.xml users have access to, then the relative path to that xsl file can be included in the "href" attribute's value in the ccda.xml document's 2nd XML Instruction, something like:

 <?xml-stylesheet type="text/xsl" href=".\..\xslLibrary\_CDA_Stylesheet.xsl"?\>

If you have edited the ccda.xml file in Notepad, and made sure that the 2 xml instructions are at the top of the document, and you have put both the CCDA document and its required stylesheet (*.xsl) file into the same folder, you should be able to browse to the ccda.xml document and display it in your web browser.

This will allow you to read the document in a coherent, inexpensive and relatively easy manner like so:

CCDA with stylesheet viewed in web browser

  If, however, you are not looking for a clerical/clinical use of the document, you 
 can use Microsoft Access 2012 or 2016 and "import" the "external" xml file with 
 "Structure and Data" - and I think this will load it into a database with tables that  
 are named after each xml element in the document.  I don't recommend this, as it 
 loads the xml data elements as unrelated tables in MS Access.  If, however, you could
 transform the standard ccda into a specially designed xml/xslt document with 
 appropriate relational attributes added into the xml, you may be able to come up with 
 an xml document that imports easily into MS Access - then you could export each table  
 as an Excel csv or tab-delimited file. 

by the way, I found my example xslt stylesheet by searching HL7.org website looking for testing information. If you do find a suitable xsl stylesheet for ccda, you will have to edit the 2nd XML instruction to enter the appropriate stylesheet name.