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="http://www.w3.org/1999/xhtml"><%@
 taglib uri="http://java.sun.com/jsp/jstl/sql" prefix="sql" %><%@ 
 taglib uri="http://java.sun.com/jsp/jstl/core" prefix="c" %><%@ 
 taglib uri="http://java.sun.com/jsp/jstl/xml" prefix="x" 
%><sql:setDataSource var="snapshot" driver="com.mysql.jdbc.Driver"
 url="jdbc:mysql://localhost:3306/templatedb"
 user="user"  password="password"
/><sql:query dataSource="${snapshot}" var="valueset"
>SELECT valueSetName, description, ID from valueset WHERE OID = ?;
   <sql:param>${param.id}</sql:param>
</sql:query>     
<svs:ValueSet version="" displayName="${valueset.rowsByIndex[0][0]}" id="${param.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 = ?;
   <sql:param>${param.id}</sql:param>
</sql:query
>
<c:forEach var="row" items="${members.rows}">
<svs:Concept code="${row.code}" displayName="${row.displayName}" codeSystem="${row.codeSystemOID}" codeSystemName="${row.codeSystemName}" />
</c:forEach>
</svs:ConceptList>
</svs:ValueSet>
</svs:RetrieveValueSetResponse>


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:
<servlet>
<description>A Servlet conforming to the IHE SVS Profile</description>
<display-name>IHE SVS Servlet</display-name>
<servlet-name>RetrieveValueSet</servlet-name>
<jsp-file>/RetrieveValueSet.jsp</jsp-file>
</servlet>
<servlet-mapping>
<servlet-name>RetrieveValueSet</servlet-name>
<url-pattern>/RetrieveValueSet</url-pattern>
</servlet-mapping>

Try it out.


1 comment:

  1. Keith -- this is a great, concise example and immediately helped me get a sense of where your head was at with SVS. Well done.

    ReplyDelete