Convert your FHIR JSON -> XML and back here. The CDA Book is sometimes listed for Kindle here and it is also SHIPPING from Amazon! See here for Errata.

Friday, March 9, 2012

Implementing IHE SVS Over the Trifolia Consolidated CDA Database

This 32 line program is for a JSP Page to create an IHE SVS Value Set implementation over the Trifolia Workbench database that I've been playing around with.  It's got absolutely NO error handling, it just gets the material out of the valueset, valuesetmember and dictionarycodesystem tables if the parameter matches.

It was inspired by a brief e-mail exchange with Jacob Reider on the value of ONC creating a proof of concept repository.  Trifolia had most of what I needed in it for the database structure.  It either needs a version column added to the valueset and valueset member table, or some other minor restructuring so a valuesetmember can appear in multiple valueset versions (e.g., via an association table) to support version management, but is good enough for now for Consolidated CDA Implementors.

Since I need a working SVS repository for my QueryHealth work, I decided to throw this together and see how fast I could do it.  It took me about an hour to reconfigure my Eclipse install (I just got a new system and migrated all the software over using laplink, some of the configuration parameters needed debugging because file system locations had change).  The rest of the time was spend refreshing myself on JSTL.  It was done in less than two hours.

Here's the code:

<?xml version="1.0" encoding="ISO-8859-1" ?>
<svs:RetrieveValueSetResponse xmlns:svs="urn:ihe:iti:svs:2008" xmlns:html=""><%@
 taglib uri="" prefix="sql" %><%@ 
 taglib uri="" prefix="c" %><%@ 
 taglib uri="" prefix="x" 
%><sql:setDataSource var="snapshot" driver="com.mysql.jdbc.Driver"
 user="user"  password="password"
/><sql:query dataSource="${snapshot}" var="valueset"
>SELECT valueSetName, description, ID from valueset WHERE OID = ?;
<svs:ValueSet version="" displayName="${valueset.rowsByIndex[0][0]}" id="${}">
<svs:ConceptList xml:lang="en-US">
<sql:query dataSource="${snapshot}" var="members"
>SELECT m.code code, m.displayName displayname, m.codeSystemOID codeSystemOID, cs.codeSystemName codeSystemName
FROM valuesetmember m 
LEFT JOIN dictionarycodesystem cs 
ON m.codeSystemOID = cs.OID 
WHERE m.valueSetOId = ?;
<c:forEach var="row" items="${members.rows}">
<svs:Concept code="${row.code}" displayName="${row.displayName}" codeSystem="${row.codeSystemOID}" codeSystemName="${row.codeSystemName}" />

How to use it:
  1. Install MySQL Community Edition and JDBC Drivers
  2. Install The Trifolia Workbench (zip)
  3. Install the JSTL Libraries and MySQL JDBC Drivers into your Web Application
  4. Copy the above into RetrieveValueSet.jsp
  5. Change the user and password parameters above to match what is needed for your MySQL installation.
  6. Add the following lines to web.xml in your WEB-INF folder:
<description>A Servlet conforming to the IHE SVS Profile</description>
<display-name>IHE SVS Servlet</display-name>

Try it out.