Incorporating HTML Diagnostic Reports in NEHTA CDA Documents

Nov 18, 2012

A vendor asks how to include a report like the one in this OBX into a NEHTA CDA document (copied from a real report, with only names and the link URL changed): ```` OBX|1|FT|HTML^Display format in HTML^AUSPDI|1|<HTML><P>This report has been forwarded to "DUCK, Dr Daffy" from "MM" with the following comments:
"TEST REPORT IN HTML FORMAT"

</P>CLICK HERE TO VIEW THE IMAGES (6)

X-RAY LUMBOSACRAL SPINE

Findings : Frontal, lateral and cone-down lateral view of the lumbosacral
junction.

There has been posterior decompression and fusion using paired rod and
pedicular screw fixation at L4 and L5 with a disc spacer. The hardware is in
the expected position without hardware fracture or surrounding lucency to
suggest loosening. There is marked disc height loss at L5/S1 without
subluxation. There is right convexity curvature centered at L3/L4. No gross
vertebral fracture or osseous destructive lesion. Sacroiliac joints show
mild degenerative change.

CONCLUSION : Posterior decompression and fusion at L4/L5 with disc spacer. No
hardware complication seen. Right convexity lumbar curvature. No vertebral
subluxation.


X-RAYS RIGHT FOOT

Findings: Frontal, lateral and oblique views were obtained.

There is a transverse fracture minimally displaced involving the tuberosity
of the fifth metatarsal bone. The remaining osseous alignment is maintained.
There is flattening of the longitudinal plantar arch. No lesion or fracture
is evident. Small ankle joint effusion.

CONCLUSION : Acute transverse fracture of the fifth metatarsal base and
displacement is only 1 cortical-thickness width.

Kind regards,
[Image “Donald Duck 2”]
Dr Donald Duck  MBBS FRANZCR
</HTML>||||||C|||20110516133619+1000||243344EL^Duck^Donald^^^Dr^^AUSHICPR~ PBHNWMI^Duck^Donald^^^Dr^^LOC001


The answer might have been to simple add the html source as an attachment, following the same method as for a PDF, [as previously explained](/2012/06/28/add-pathology-report-attachments-to-nehta-clinical-documents.html):
Pathology Test Result      Original Pathology Report  

This method is valid for sending documents to other clinical systems that are tested against the Rendering specification – it will display correctly. Unfortunately, primarily for security reasons, the pcEHR does not allow html attachments, so this isn’t a valid method for the pcEHR. For the pcEHR, you must do one of two things:
* Convert the html to a PDF, and use the PDF method
* Convert the html to CDA Narrative, and insert this directly in CDA

This is not an easy choice – my experience with html to PDF converters has been disappointing. Converting the html to CDA narrative is a better choice for the users – the diagnostic report is no longer a click away. However, converting this html to CDA narrative isn’t particularly easy.

HTML --> PDF is a generic industry thing, and I’ll leave the reader to navigate through the unhappy choices on offer. The rest of this post explores the process of converting HTML to CDA narrative

The first issue is that the html is not well formed xhtml. This is a pretty common case – the source programmer tests in the major browsers, HTML doesn’t have to be well formed. Whether this is a problem or not for conversion depends on how you intend to implement – but lets assume, for the sake of this post, that it is (we’re going to use an xml transform based on this description here, sowe need the content to be wellformed). So the first thing we do is fix that. There’s a number of libraries and web services to do that. This is the output from [HTML tidy project](http://tidy.sourceforge.net/) (online at [http://validator.aborla.net/](http://validator.aborla.net/)):

```<?xml version="1.0" encoding="iso-8859-1"?>```**<?xml version="1.0" encoding="iso-8859-1"?>**
```<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"```**<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"**
```   "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">```**   "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">**
```<html xmlns="http://www.w3.org/1999/xhtml">```**<html xmlns="http://www.w3.org/1999/xhtml">**
```<head>```**<head>**
```<title></title>```**<title></title>**
```</head>```**</head>**
```<body>```**<body>**
```<p>This report has been forwarded to "Duck, Dr Daffy" from "Acme Diagnostics" with the following comments:<br />```**<p>This report has been forwarded to "Duck, Dr Daffy" from "Acme Diagnostics" with the following comments:<br />**
```"TEST REPORT IN HTML FORMAT"<br />```**"TEST REPORT IN HTML FORMAT"<br />**
```<br /></p>```**<br /></p>**
```<b><a href="http://acme.com/something">CLICK HERE TO VIEW THE IMAGES (6)</a></b><br />```**<b><a href="http://acme.com/something">CLICK HERE TO VIEW THE IMAGES (6)</a></b><br />**
```<br />```**<br />**
```<u><strong>X-RAY LUMBOSACRAL SPINE</strong></u><br />```**<u><strong>X-RAY LUMBOSACRAL SPINE</strong></u><br />**
```<br />```**<br />**
```<u><strong>Findings</strong></u>: Frontal, lateral and cone-down lateral view of the lumbosacral<br />```**<u><strong>Findings</strong></u>: Frontal, lateral and cone-down lateral view of the lumbosacral<br />**
```junction.<br />```**junction.<br />**
```<br />```**<br />**
```There has been posterior decompression and fusion using paired rod and<br />```**There has been posterior decompression and fusion using paired rod and<br />**
```pedicular screw fixation at L4 and L5 with a disc spacer. The hardware is in<br />```**pedicular screw fixation at L4 and L5 with a disc spacer. The hardware is in<br />**
```the expected position without hardware fracture or surrounding lucency to<br />```**the expected position without hardware fracture or surrounding lucency to<br />**
```suggest loosening. There is marked disc height loss at L5/S1 without<br />```**suggest loosening. There is marked disc height loss at L5/S1 without<br />**
```subluxation. There is right convexity curvature centered at L3/L4. No gross<br />```**subluxation. There is right convexity curvature centered at L3/L4. No gross<br />**
```vertebral fracture or osseous destructive lesion. Sacroiliac joints show<br />```**vertebral fracture or osseous destructive lesion. Sacroiliac joints show<br />**
```mild degenerative change.<br />```**mild degenerative change.<br />**
```<br />```**<br />**
```<u><strong>CONCLUSION</strong></u>: Posterior decompression and fusion at L4/L5 with disc spacer. No<br />```**<u><strong>CONCLUSION</strong></u>: Posterior decompression and fusion at L4/L5 with disc spacer. No<br />**
```hardware complication seen. Right convexity lumbar curvature. No vertebral<br />```**hardware complication seen. Right convexity lumbar curvature. No vertebral<br />**
```subluxation.<br />```**subluxation.<br />**
```<br />```**<br />**
```<br />```**<br />**
```<u><strong>X-RAYS RIGHT FOOT</strong></u><br />```**<u><strong>X-RAYS RIGHT FOOT</strong></u><br />**
```<br />```**<br />**
```<u><strong>Findings</strong></u>: Frontal, lateral and oblique views were obtained.<br />```**<u><strong>Findings</strong></u>: Frontal, lateral and oblique views were obtained.<br />**
```<br />```**<br />**
```There is a transverse fracture minimally displaced involving the tuberosity<br />```**There is a transverse fracture minimally displaced involving the tuberosity<br />**
```of the fifth metatarsal bone. The remaining osseous alignment is maintained.<br />```**of the fifth metatarsal bone. The remaining osseous alignment is maintained.<br />**
```There is flattening of the longitudinal plantar arch. No lesion or fracture<br />```**There is flattening of the longitudinal plantar arch. No lesion or fracture<br />**
```is evident. Small ankle joint effusion.<br />```**is evident. Small ankle joint effusion.<br />**
```<br />```**<br />**
```<u><strong>CONCLUSION</strong></u>: Acute transverse fracture of the fifth metatarsal base and<br />```**<u><strong>CONCLUSION</strong></u>: Acute transverse fracture of the fifth metatarsal base and<br />**
```displacement is only 1 cortical-thickness width.<br />```**displacement is only 1 cortical-thickness width.<br />**
```<br />```**<br />**
```Kind regards,<br />```**Kind regards,<br />**
```[Image "Donald Duck 2"]<br />```**[Image "Donald Duck 2"]<br />**
```<u><strong>Dr Donald Duck MBBS FRANZCR</strong></u><br />```**<u><strong>Dr Donald Duck MBBS FRANZCR</strong></u><br />**
```</body>```**</body>**
```</html>```**</html>**

So that’s bashed it into shape for running a transform. To convert this to CDA narrative, we need to:
* Strip off the <html>, <head> and <body> tags
* Rename <p> to <paragraph>
* Rename <a> to <linkHtml>
* Replace <u> with <content styleCode="Underline">
* Replace <strong> with <content styleCode="Bold">
* Put all the elements in the namespace urn:hl7-org:v3

Bingo: valid CDA Narrative:
  This report has been forwarded to "Duck, Dr Daffy" from "Acme Diagnostics" with the following comments:
"TEST REPORT IN HTML FORMAT"
   
 
      CLICK HERE TO VIEW THE IMAGES (6)    
 
      X-RAY LUMBOSACRAL SPINE    
 
      Findings   : Frontal, lateral and cone-down lateral view of the lumbosacral
junction.
 
There has been posterior decompression and fusion using paired rod and
pedicular screw fixation at L4 and L5 with a disc spacer. The hardware is in
the expected position without hardware fracture or surrounding lucency to
suggest loosening. There is marked disc height loss at L5/S1 without
subluxation. There is right convexity curvature centered at L3/L4. No gross
vertebral fracture or osseous destructive lesion. Sacroiliac joints show
mild degenerative change.
 
      CONCLUSION   : Posterior decompression and fusion at L4/L5 with disc spacer. No
hardware complication seen. Right convexity lumbar curvature. No vertebral
subluxation.
 
 
      X-RAYS RIGHT FOOT    
 
      Findings   : Frontal, lateral and oblique views were obtained.
 
There is a transverse fracture minimally displaced involving the tuberosity
of the fifth metatarsal bone. The remaining osseous alignment is maintained.
There is flattening of the longitudinal plantar arch. No lesion or fracture
is evident. Small ankle joint effusion.
 
      CONCLUSION   : Acute transverse fracture of the fifth metatarsal base and
displacement is only 1 cortical-thickness width.
 
Kind regards,
[Image "Donald Duck 2"]
      Dr Donald Duck MBBS FRANZCR    

````

Additional NEHTA constraints

However there is one more problem – a significant one. The NEHTA Rendering specification says (CDA-RS 43):

Authoring Systems SHALL NOT populate the narrative block with free text that is not contained in an allowed narrative block element e.g. or .

This narrative above has only one around the first paragraph, as provided into the source html. So it falls to the CDA builder to wrap any content – text, , ,
- in a . There’s no need to try and figure out where the paragraphs start and end when doing this - just wrap them all in a single . Concerning this, the rendering specification says (CDA-RS 44):

Authoring Systems SHOULD use separate narrative block elements to separate paragraphs of text

This is a SHOULD not a SHALL for exactly this situation - it’s a compromise between proper rendering – have to have the and pragmatics – don’t want to force people to guess at paragraph boundaries. Hopefully over time the source systems will migrate towards valid xhtml, but that’s not something we can rely on any time soon.