[prev in list] [next in list] [prev in thread] [next in thread]
List: openmrs-svn
Subject: [30901] openmrs-modules/chica/tags: Version 1.60. 6 removes validation when parsing hl7 messages fro
From: svn-noreply () openmrs ! org
Date: 2014-09-10 3:48:58
Message-ID: 20140910034859.0FB9540231 () openmrs ! osuosl ! org
[Download RAW message or body]
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.1//EN"
"http://www.w3.org/TR/xhtml11/DTD/xhtml11.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head><meta http-equiv="content-type" content="text/html; charset=utf-8" />
<title>[30901] openmrs-modules/chica/tags: Version 1.60.6 removes validation when \
parsing hl7 messages from CHIRP</title> </head>
<body>
<style type="text/css"><!--
#msg dl.meta { border: 1px #006 solid; background: #369; padding: 6px; color: #fff; }
#msg dl.meta dt { float: left; width: 6em; font-weight: bold; }
#msg dt:after { content:':';}
#msg dl, #msg dt, #msg ul, #msg li, #header, #footer, #logmsg { font-family: \
verdana,arial,helvetica,sans-serif; font-size: 10pt; } #msg dl a { font-weight: \
bold} #msg dl a:link { color:#fc3; }
#msg dl a:active { color:#ff0; }
#msg dl a:visited { color:#cc6; }
h3 { font-family: verdana,arial,helvetica,sans-serif; font-size: 10pt; font-weight: \
bold; } #msg pre { overflow: auto; background: #ffc; border: 1px #fa0 solid; padding: \
6px; } #logmsg { background: #ffc; border: 1px #fa0 solid; padding: 1em 1em 0 1em; }
#logmsg p, #logmsg pre, #logmsg blockquote { margin: 0 0 1em 0; }
#logmsg p, #logmsg li, #logmsg dt, #logmsg dd { line-height: 14pt; }
#logmsg h1, #logmsg h2, #logmsg h3, #logmsg h4, #logmsg h5, #logmsg h6 { margin: .5em \
0; } #logmsg h1:first-child, #logmsg h2:first-child, #logmsg h3:first-child, #logmsg \
h4:first-child, #logmsg h5:first-child, #logmsg h6:first-child { margin-top: 0; } \
#logmsg ul, #logmsg ol { padding: 0; list-style-position: inside; margin: 0 0 0 1em; \
} #logmsg ul { text-indent: -1em; padding-left: 1em; }#logmsg ol { text-indent: \
-1.5em; padding-left: 1.5em; } #logmsg > ul, #logmsg > ol { margin: 0 0 1em 0; }
#logmsg pre { background: #eee; padding: 1em; }
#logmsg blockquote { border: 1px solid #fa0; border-left-width: 10px; padding: 1em \
1em 0 1em; background: white;} #logmsg dl { margin: 0; }
#logmsg dt { font-weight: bold; }
#logmsg dd { margin: 0; padding: 0 0 0.5em 0; }
#logmsg dd:before { content:'\00bb';}
#logmsg table { border-spacing: 0px; border-collapse: collapse; border-top: 4px solid \
#fa0; border-bottom: 1px solid #fa0; background: #fff; } #logmsg table th { \
text-align: left; font-weight: normal; padding: 0.2em 0.5em; border-top: 1px dotted \
#fa0; } #logmsg table td { text-align: right; border-top: 1px dotted #fa0; padding: \
0.2em 0.5em; } #logmsg table thead th { text-align: center; border-bottom: 1px solid \
#fa0; } #logmsg table th.Corner { text-align: left; }
#logmsg hr { border: none 0; border-top: 2px dashed #fa0; height: 1px; }
#header, #footer { color: #fff; background: #636; border: 1px #300 solid; padding: \
6px; } #patch { width: 100%; }
#patch h4 {font-family: \
verdana,arial,helvetica,sans-serif;font-size:10pt;padding:8px;background:#369;color:#fff;margin:0;}
#patch .propset h4, #patch .binary h4 {margin:0;}
#patch pre {padding:0;line-height:1.2em;margin:0;}
#patch .diff {width:100%;background:#eee;padding: 0 0 10px 0;overflow:auto;}
#patch .propset .diff, #patch .binary .diff {padding:10px 0;}
#patch span {display:block;padding:0 10px;}
#patch .modfile, #patch .addfile, #patch .delfile, #patch .propset, #patch .binary, \
#patch .copfile {border:1px solid #ccc;margin:10px 0;} #patch ins \
{background:#dfd;text-decoration:none;display:block;padding:0 10px;} #patch del \
{background:#fdd;text-decoration:none;display:block;padding:0 10px;} #patch .lines, \
.info {color:#888;background:#fff;}
--></style>
<div id="msg">
<dl class="meta">
<dt>Revision</dt> <dd>30901</dd>
<dt>Author</dt> <dd>msheley</dd>
<dt>Date</dt> <dd>2014-09-10 03:48:58 +0000 (Wed, 10 Sep 2014)</dd>
</dl>
<h3>Log Message</h3>
<pre>Version 1.60.6 removes validation when parsing hl7 messages from CHIRP</pre>
<h3>Added Paths</h3>
<ul>
<li>openmrs-modules/chica/tags/Release 1.60.6/</li>
<li><a href="#openmrsmoduleschicatagsRelease1606metadataconfigxml">openmrs-modules/chica/tags/Release \
1.60.6/metadata/config.xml</a></li> <li>openmrs-modules/chica/tags/Release \
1.60.6/ruleLibrary/ADHD/</li> <li>openmrs-modules/chica/tags/Release \
1.60.6/ruleLibrary/Asthma/</li> <li>openmrs-modules/chica/tags/Release \
1.60.6/ruleLibrary/adolescent alcohol/</li> <li>openmrs-modules/chica/tags/Release \
1.60.6/ruleLibrary/adolescent depression_suicide/</li> \
<li>openmrs-modules/chica/tags/Release 1.60.6/ruleLibrary/adolescent drugs/</li> \
<li>openmrs-modules/chica/tags/Release 1.60.6/ruleLibrary/adolescent sexuality/</li> \
<li>openmrs-modules/chica/tags/Release 1.60.6/ruleLibrary/developmental study/</li> \
<li>openmrs-modules/chica/tags/Release 1.60.6/ruleLibrary/maternal depression/</li> \
<li><a href="#openmrsmoduleschicatagsRelease1606srcorgopenmrsmodulechicahl7immunizationImmunizationRegistryQueryjava">openmrs-modules/chica/tags/Release \
1.60.6/src/org/openmrs/module/chica/hl7/immunization/ImmunizationRegistryQuery.java</a></li>
</ul>
<h3>Removed Paths</h3>
<ul>
<li><a href="#openmrsmoduleschicatagsRelease1606metadataconfigxml">openmrs-modules/chica/tags/Release \
1.60.6/metadata/config.xml</a></li> <li>openmrs-modules/chica/tags/Release \
1.60.6/ruleLibrary/ADHD/</li> <li>openmrs-modules/chica/tags/Release \
1.60.6/ruleLibrary/Asthma/</li> <li>openmrs-modules/chica/tags/Release \
1.60.6/ruleLibrary/adolescent alcohol/</li> <li>openmrs-modules/chica/tags/Release \
1.60.6/ruleLibrary/adolescent depression_suicide/</li> \
<li>openmrs-modules/chica/tags/Release 1.60.6/ruleLibrary/adolescent drugs/</li> \
<li>openmrs-modules/chica/tags/Release 1.60.6/ruleLibrary/adolescent sexuality/</li> \
<li>openmrs-modules/chica/tags/Release 1.60.6/ruleLibrary/developmental study/</li> \
<li>openmrs-modules/chica/tags/Release 1.60.6/ruleLibrary/maternal depression/</li> \
<li><a href="#openmrsmoduleschicatagsRelease1606srcorgopenmrsmodulechicahl7immunizationImmunizationRegistryQueryjava">openmrs-modules/chica/tags/Release \
1.60.6/src/org/openmrs/module/chica/hl7/immunization/ImmunizationRegistryQuery.java</a></li>
</ul>
</div>
<div id="patch">
<h3>Diff</h3>
<a id="openmrsmoduleschicatagsRelease1606"></a>
<div class="propset"><h4>Property changes: openmrs-modules/chica/tags/Release \
1.60.6</h4> <pre class="diff"><span>
</span></pre></div>
<a id="svnignore"></a>
<div class="addfile"><h4>Added: svn:ignore</h4></div>
<a id="svnmergeinfo"></a>
<div class="addfile"><h4>Added: svn:mergeinfo</h4></div>
<span class="cx">/openmrs-modules/chica/branches/chica 1.7.x compatible \
gis:26923-29251 </span><span class="cx">/openmrs-modules/chica/branches/chica 1.7.x \
compatible immunization:29719-30406 </span><span \
class="cx">/openmrs-modules/chica/branches/openmrs 1.6.1 compatible:15010-20687 \
</span><a id="openmrsmoduleschicatagsRelease1606metadataconfigxml"></a> <div \
class="delfile"><h4>Deleted: openmrs-modules/chica/tags/Release \
1.60.6/metadata/config.xml (30883 => 30901)</h4> <pre class="diff"><span>
<span class="info">--- openmrs-modules/chica/trunk/metadata/config.xml 2014-09-03 \
03:00:09 UTC (rev 30883)
+++ openmrs-modules/chica/tags/Release 1.60.6/metadata/config.xml 2014-09-10 03:48:58 \
UTC (rev 30901) </span><span class="lines">@@ -1,357 +0,0 @@
</span><del>-<?xml version="1.0" encoding="UTF-8"?>
-<!DOCTYPE module PUBLIC "-//OpenMRS//DTD OpenMRS Config 1.0//EN" \
"http://resources.openmrs.org/doctype/config-1.0.dtd">
-
-<module configVersion="1.0">
-
- <!-- Chica Module Properties -->
- <id>chica</id>
- <name>Chica</name>
- <version>1.60.5</version>
- <package>org.openmrs.module.@MODULE_ID@</package>
- <author>Vibha Anand and Tammy Dugan</author>
- <description>
- Runs CHICA specific tasks.
- </description>
-
- <activator>@MODULE_PACKAGE@.ChicaActivator</activator>
-
- <!-- /Chica Module Properties -->
-
- <require_version>1.1.10.2283</require_version>
- <require_modules>
- <require_module \
version="2.29.0">org.openmrs.module.dss</require_module>
- <require_module \
version="2.0.0">org.openmrs.module.atd</require_module>
- <require_module \
version="1.3.30">org.openmrs.module.sockethl7listener</require_module>
- <require_module \
version="1.0.4">org.openmrs.module.rgccd</require_module>
- <require_module \
version="1.7.1">org.openmrs.module.chirdlutil</require_module>
- <require_module \
version="2.0.0">org.openmrs.module.chirdlutilbackports</require_module> \
</require_modules>
- <extension>
- <point>org.openmrs.admin.list</point>
- <class>org.openmrs.module.chica.extension.html.AdminList</class>
- </extension>
-
- <advice>
- <point>org.openmrs.module.sockethl7listener.service.SocketHL7ListenerService</point>
- <class>@MODULE_PACKAGE@.advice.TriggerPatientAfterAdvice</class>
- </advice>
- <advice>
- <point>org.openmrs.module.atd.service.ATDService</point>
- <class>@MODULE_PACKAGE@.advice.TriggerPatientAfterAdvice</class>
- </advice>
- <globalProperty>
- <property>chica.statsConfigFile</property>
- <description>This file contains configuration for chica statistics.
- This file can be found at metadata/stats_config.xml
- </description>
- </globalProperty>
- <globalProperty>
- <property>chica.kiteHost</property>
- <defaultValue>134.68.32.31</defaultValue>
- <description>Host address to query for mrf dump and aliases.
- </description>
- </globalProperty>
- <globalProperty>
- <property>chica.kitePort</property>
- <defaultValue>17094</defaultValue>
- <description>Port to query for mrf dump and aliases.
- </description>
- </globalProperty>
- <globalProperty>
- <property>chica.kiteTimeout</property>
- <defaultValue>5</defaultValue>
- <description>Timeout for mrf dump and alias queries (in seconds).
- </description>
- </globalProperty>
- <globalProperty>
- <property>chica.mrfArchiveDirectory</property>
- <description>Directory where a copy of the mrf dump is stored.
- </description>
- </globalProperty>
- <globalProperty>
- <property>chica.aliasArchiveDirectory</property>
- <description>Directory where a copy of the alias query result is \
stored.
- </description>
- </globalProperty>
- <globalProperty>
- <property>chica.greaseBoardRefresh</property>
- <defaultValue>15</defaultValue>
- <description>Refresh period is seconds for the grease board refresh.
- </description>
- </globalProperty>
- <globalProperty>
- <property>chica.mrfParseErrorDirectory</property>
- <description>Directory where a copy of an mrf query result that \
couldn't be parsed is stored.
- </description>
- </globalProperty>
- <globalProperty>
- <property>chica.smsParseErrorDirectory</property>
- <description>Directory where a copy of an sms checkin hl7 message that \
couldn't be parsed is stored.
- </description>
- </globalProperty>
- <globalProperty>
- <property>chica.mckessonParseErrorDirectory</property>
- <description>Directory where a copy of an mckesson checkin hl7 message \
that couldn't be parsed is stored.
- </description>
- </globalProperty>
- <globalProperty>
- <property>chica.outboundHl7ArchiveDirectory</property>
- <description>Location to archive constructed outbound hl7 messages
- </description>
- </globalProperty>
- <globalProperty>
- <property>chica.pagerBaseURL</property>
- <defaultValue>http://www.ipnpaging.com/page.html</defaultValue>
- <description>Base URL of the pager service
- </description>
- </globalProperty>
- <globalProperty>
- <property>chica.pagerNumber</property>
- <defaultValue>3175431631</defaultValue>
- <description>Number for support pager for CHICA clinic.
- </description>
- </globalProperty>
- <globalProperty>
- <property>chica.pagerUrlMessageParam</property>
- <defaultValue>message</defaultValue>
- <description>Name for the URL parameter containing the message text.
- </description>
- </globalProperty>
- <globalProperty>
- <property>chica.pagerUrlNumberParam</property>
- <defaultValue>pin</defaultValue>
- <description>Name for the URL parameter containing the pager number.
- </description>
- </globalProperty>
- <globalProperty>
- <property>chica.retireProvidersPeriod</property>
- <defaultValue>90</defaultValue>
- <description>Time period in days before inactive providers (no \
encounters) are voided by a cron job</description>
- </globalProperty>
- <globalProperty>
- <property>chica.greaseboardCheckoutState</property>
- <defaultValue>FINISHED</defaultValue>
- <description>State that tells us to remove the patient from the \
greaseboard</description>
- </globalProperty>
- <globalProperty>
- <property>chica.pagerWaitTimeBeforeRepage</property>
- <defaultValue>15</defaultValue>
- <description>How long to wait before the GET HELP NOW sends another \
page request from Greaseboard</description>
- </globalProperty>
- <globalProperty>
- <property>chica.medicationListTimeout</property>
- <defaultValue>5</defaultValue>
- <description>Timeout for medication list queries (in seconds).
- </description>
- </globalProperty>
- <globalProperty>
- <property>chica.genericProviderId</property>
- <description>Generic provider id to use for medication query when no \
other provider id.
- </description>
- </globalProperty>
- <globalProperty>
- <property>chica.immunizationInputDirectory</property>
- <description>Directory containing results of immunization queries of \
mrf dump. Becomes input to immunization forecasting.
- </description>
- </globalProperty>
- <globalProperty>
- <property>chica.immunizationOutputDirectory</property>
- <description>Directory containing results of the immunization \
forecasting.
- </description>
- </globalProperty>
- <globalProperty>
- <property>chica.immunXSLT</property>
- <description>Directory containing xslt transform needed for \
immunization query result xml.
- </description>
- </globalProperty>
- <globalProperty>
- <property>chica.immunizationListTimeout</property>
- <defaultValue>1</defaultValue>
- <description>Timeout for immunization list queries (in seconds).
- </description>
- </globalProperty>
- <globalProperty>
- <property>chica.stylesheetDirectory</property>
- <description>Directory where XSLT stylesheets are contained.
- </description>
- </globalProperty>
- <globalProperty>
- <property>chica.growthChartConfigFile</property>
- <description>Location of the growth chart configuration file.
- </description>
- </globalProperty>
- <globalProperty>
- <property>chica.growthChartPlotImage</property>
- <description>Location of the image used to make plots on the growth \
charts.
- </description>
- </globalProperty>
- <globalProperty>
- <property>chica.gisMapUrl</property>
- <description>The base URL to generate a CHICA GIS map.
- </description>
- </globalProperty>
- <globalProperty>
- <property>chica.gisDataUrl</property>
- <description>The base URL to generate a CHICA GIS data.
- </description>
- </globalProperty>
- <globalProperty>
- <property>chica.gisTutorRadius</property>
- <defaultValue>3</defaultValue>
- <description>The map radius (in miles)of the tutoring resources for \
the CHICA GIS map generation.
- </description>
- </globalProperty>
- <globalProperty>
- <property>chica.gisExerciseRadius</property>
- <defaultValue>3</defaultValue>
- <description>The map radius (in miles)of the exercise resources for \
the CHICA GIS map generation.
- </description>
- </globalProperty>
- <globalProperty>
- <property>chica.gisDentalRadius</property>
- <defaultValue>3</defaultValue>
- <description>The map radius (in miles)of the dental resources for the \
CHICA GIS map generation.
- </description>
- </globalProperty>
- <globalProperty>
- <property>chica.gisToppingFilter</property>
- <defaultValue>6</defaultValue>
- <description>The maximum number of search result giving by the CHICA \
GIS service.
- </description>
- </globalProperty>
- <globalProperty>
- <property>chica.gisTimeout</property>
- <defaultValue>10</defaultValue>
- <description>The timeout for CHICA GIS queries (in seconds).
- </description>
- </globalProperty>
- <globalProperty>
- <property>chica.gisMaxRadius</property>
- <defaultValue>10</defaultValue>
- <description>The maximum radius to search for GIS data.
- </description>
- </globalProperty>
- <globalProperty>
- <property>chica.gisConnectionTimeout</property>
- <defaultValue>3</defaultValue>
- <description>The connection timeout for CHICA GIS queries (in \
seconds).
- </description>
- </globalProperty>
- <globalProperty>
- <property>chica.gisMinAge</property>
- <defaultValue>1</defaultValue>
- <description>The minimum age (in years) for the GIS query.
- </description>
- </globalProperty>
- <globalProperty>
- <property>chica.presnetConnectionTimeout</property>
- <defaultValue>5</defaultValue>
- <description>The connection timeout for Presnet connections (in \
seconds).
- </description>
- </globalProperty>
- <globalProperty>
- <property>chica.presnetReadTimeout</property>
- <defaultValue>5</defaultValue>
- <description>The read timeout for Presnet connections (in seconds).
- </description>
- </globalProperty>
- <globalProperty>
- <property>chica.gisMinimumSearchResults</property>
- <defaultValue>3</defaultValue>
- <description>The minimum number of search results to be met before \
results are displayed on the forms.
- </description>
- </globalProperty>
- <globalProperty>
- <property>chica.passcode</property>
- <description>Passcode used by mobile products to view CHICA data.
- </description>
- </globalProperty>
- <globalProperty>
- <property>chica.allowableHL7MessageSources</property>
- <defaultValue>ECW</defaultValue>
- <description>Comma delimited list of allowable sources for hl7 ADT \
messages.
- </description>
- </globalProperty>
- <globalProperty>
- <property>chica.ImmunizationQueryActivated</property>
- <defaultValue>true</defaultValue>
- <description>Activate query to CHIRP registry
- </description>
- </globalProperty>
- <globalProperty>
- <property>chica.ImmunizationQueryConfigFile</property>
- <description>Location the configuration file for the hl7 immunization \
query.
- </description>
- </globalProperty>
- <globalProperty>
- <property>chica.ImmunizationQueryPassword</property>
- <description>Password to CHIRP registry.
- </description>
- </globalProperty>
- <globalProperty>
- <property>chica.ImmunizationQueryURL</property>
- <description>CHIRP URL
- </description>
- </globalProperty>
- <globalProperty>
- <property>chica.ImmunizationQueryUserId</property>
- <description>Userid for access to CHIRP.
- </description>
- </globalProperty>
- <globalProperty>
- <property>chica.chica.activateVXU</property>
- <defaultValue>false</defaultValue>
- <description>Allow hl7 VXU update to CHIRP immunization \
registry</description>
- </globalProperty>
- <globalProperty>
- <property>chica.ImmunizationOutputDirectory</property>
- <description>CHIRP hl7 query and response file directory
- </description>
- </globalProperty>
- <globalProperty>
- <property>chica.activateVXUToCreatePatient</property>
- <description>Activate VXU to create a patient in the CHIRP registry.
- </description>
- </globalProperty>
-
-
-
- <!-- Internationalization -->
- <!-- All message codes should start with @MODULE_ID@.* -->
- <messages>
- <lang>en</lang>
- <file>messages.properties</file>
- </messages>
- <!-- /Internationalization -->
-
- <mappingFiles>
- hcageinf.hbm.xml
- lenageinf.hbm.xml
- wtageinf.hbm.xml
- bmiage.hbm.xml
- encounter.hbm.xml
- study.hbm.xml
- study_attribute.hbm.xml
- study_attribute_value.hbm.xml
- old_rule.hbm.xml
- chica1_patient.hbm.xml
- chica1_patient_obsv.hbm.xml
- chica1_appointments.hbm.xml
- insurance_category.hbm.xml
- family.hbm.xml
- patient_family.hbm.xml
- chica_hl7_export.hbm.xml
- ddst.hbm.xml
- high_bp.hbm.xml
- chica_hl7_export_map.hbm.xml
- chica_hl7_export_status.hbm.xml
- </mappingFiles>
-
- <!-- Servlets -->
- <!-- Accessed through the url \
/pageContext()/moduleServlet/<moduleId>/<servlet-name> \
-->
- <servlet>
- <servlet-name>chicaMobile</servlet-name>
- <servlet-class>@MODULE_PACKAGE@.web.ChicaMobileServlet</servlet-class>
- </servlet>
-
-</module>
-
</del></span></pre></div>
<a id="openmrsmoduleschicatagsRelease1606metadataconfigxmlfromrev30900openmrsmoduleschicatrunkmetadataconfigxml"></a>
<div class="copfile"><h4>Copied: openmrs-modules/chica/tags/Release \
1.60.6/metadata/config.xml (from rev 30900, \
openmrs-modules/chica/trunk/metadata/config.xml) (0 => 30901)</h4> <pre \
class="diff"><span> <span class="info">--- openmrs-modules/chica/tags/Release \
1.60.6/metadata/config.xml (rev 0)
+++ openmrs-modules/chica/tags/Release 1.60.6/metadata/config.xml 2014-09-10 03:48:58 \
UTC (rev 30901) </span><span class="lines">@@ -0,0 +1,357 @@
</span><ins>+<?xml version="1.0" encoding="UTF-8"?>
+<!DOCTYPE module PUBLIC "-//OpenMRS//DTD OpenMRS Config 1.0//EN" \
"http://resources.openmrs.org/doctype/config-1.0.dtd"> +
+<module configVersion="1.0">
+
+ <!-- Chica Module Properties -->
+ <id>chica</id>
+ <name>Chica</name>
+ <version>1.60.6</version>
+ <package>org.openmrs.module.@MODULE_ID@</package>
+ <author>Vibha Anand and Tammy Dugan</author>
+ <description>
+ Runs CHICA specific tasks.
+ </description>
+
+ <activator>@MODULE_PACKAGE@.ChicaActivator</activator>
+
+ <!-- /Chica Module Properties -->
+
+ <require_version>1.1.10.2283</require_version>
+ <require_modules>
+ <require_module \
version="2.29.0">org.openmrs.module.dss</require_module> + \
<require_module version="2.0.0">org.openmrs.module.atd</require_module>
+ <require_module \
version="1.3.30">org.openmrs.module.sockethl7listener</require_module>
+ <require_module \
version="1.0.4">org.openmrs.module.rgccd</require_module> + \
<require_module version="1.7.1">org.openmrs.module.chirdlutil</require_module>
+ <require_module \
version="2.0.0">org.openmrs.module.chirdlutilbackports</require_module> \
</require_modules> + <extension>
+ <point>org.openmrs.admin.list</point>
+ <class>org.openmrs.module.chica.extension.html.AdminList</class>
+ </extension>
+
+ <advice>
+ <point>org.openmrs.module.sockethl7listener.service.SocketHL7ListenerService</point>
+ <class>@MODULE_PACKAGE@.advice.TriggerPatientAfterAdvice</class>
+ </advice>
+ <advice>
+ <point>org.openmrs.module.atd.service.ATDService</point>
+ <class>@MODULE_PACKAGE@.advice.TriggerPatientAfterAdvice</class>
+ </advice>
+ <globalProperty>
+ <property>chica.statsConfigFile</property>
+ <description>This file contains configuration for chica statistics.
+ This file can be found at metadata/stats_config.xml
+ </description>
+ </globalProperty>
+ <globalProperty>
+ <property>chica.kiteHost</property>
+ <defaultValue>134.68.32.31</defaultValue>
+ <description>Host address to query for mrf dump and aliases.
+ </description>
+ </globalProperty>
+ <globalProperty>
+ <property>chica.kitePort</property>
+ <defaultValue>17094</defaultValue>
+ <description>Port to query for mrf dump and aliases.
+ </description>
+ </globalProperty>
+ <globalProperty>
+ <property>chica.kiteTimeout</property>
+ <defaultValue>5</defaultValue>
+ <description>Timeout for mrf dump and alias queries (in seconds).
+ </description>
+ </globalProperty>
+ <globalProperty>
+ <property>chica.mrfArchiveDirectory</property>
+ <description>Directory where a copy of the mrf dump is stored.
+ </description>
+ </globalProperty>
+ <globalProperty>
+ <property>chica.aliasArchiveDirectory</property>
+ <description>Directory where a copy of the alias query result is \
stored. + </description>
+ </globalProperty>
+ <globalProperty>
+ <property>chica.greaseBoardRefresh</property>
+ <defaultValue>15</defaultValue>
+ <description>Refresh period is seconds for the grease board refresh.
+ </description>
+ </globalProperty>
+ <globalProperty>
+ <property>chica.mrfParseErrorDirectory</property>
+ <description>Directory where a copy of an mrf query result that \
couldn't be parsed is stored. + </description>
+ </globalProperty>
+ <globalProperty>
+ <property>chica.smsParseErrorDirectory</property>
+ <description>Directory where a copy of an sms checkin hl7 message that \
couldn't be parsed is stored. + </description>
+ </globalProperty>
+ <globalProperty>
+ <property>chica.mckessonParseErrorDirectory</property>
+ <description>Directory where a copy of an mckesson checkin hl7 message \
that couldn't be parsed is stored. + </description>
+ </globalProperty>
+ <globalProperty>
+ <property>chica.outboundHl7ArchiveDirectory</property>
+ <description>Location to archive constructed outbound hl7 messages
+ </description>
+ </globalProperty>
+ <globalProperty>
+ <property>chica.pagerBaseURL</property>
+ <defaultValue>http://www.ipnpaging.com/page.html</defaultValue>
+ <description>Base URL of the pager service
+ </description>
+ </globalProperty>
+ <globalProperty>
+ <property>chica.pagerNumber</property>
+ <defaultValue>3175431631</defaultValue>
+ <description>Number for support pager for CHICA clinic.
+ </description>
+ </globalProperty>
+ <globalProperty>
+ <property>chica.pagerUrlMessageParam</property>
+ <defaultValue>message</defaultValue>
+ <description>Name for the URL parameter containing the message text.
+ </description>
+ </globalProperty>
+ <globalProperty>
+ <property>chica.pagerUrlNumberParam</property>
+ <defaultValue>pin</defaultValue>
+ <description>Name for the URL parameter containing the pager number.
+ </description>
+ </globalProperty>
+ <globalProperty>
+ <property>chica.retireProvidersPeriod</property>
+ <defaultValue>90</defaultValue>
+ <description>Time period in days before inactive providers (no \
encounters) are voided by a cron job</description> + </globalProperty>
+ <globalProperty>
+ <property>chica.greaseboardCheckoutState</property>
+ <defaultValue>FINISHED</defaultValue>
+ <description>State that tells us to remove the patient from the \
greaseboard</description> + </globalProperty>
+ <globalProperty>
+ <property>chica.pagerWaitTimeBeforeRepage</property>
+ <defaultValue>15</defaultValue>
+ <description>How long to wait before the GET HELP NOW sends another \
page request from Greaseboard</description> + </globalProperty>
+ <globalProperty>
+ <property>chica.medicationListTimeout</property>
+ <defaultValue>5</defaultValue>
+ <description>Timeout for medication list queries (in seconds).
+ </description>
+ </globalProperty>
+ <globalProperty>
+ <property>chica.genericProviderId</property>
+ <description>Generic provider id to use for medication query when no \
other provider id. + </description>
+ </globalProperty>
+ <globalProperty>
+ <property>chica.immunizationInputDirectory</property>
+ <description>Directory containing results of immunization queries of \
mrf dump. Becomes input to immunization forecasting. + </description>
+ </globalProperty>
+ <globalProperty>
+ <property>chica.immunizationOutputDirectory</property>
+ <description>Directory containing results of the immunization \
forecasting. + </description>
+ </globalProperty>
+ <globalProperty>
+ <property>chica.immunXSLT</property>
+ <description>Directory containing xslt transform needed for \
immunization query result xml. + </description>
+ </globalProperty>
+ <globalProperty>
+ <property>chica.immunizationListTimeout</property>
+ <defaultValue>1</defaultValue>
+ <description>Timeout for immunization list queries (in seconds).
+ </description>
+ </globalProperty>
+ <globalProperty>
+ <property>chica.stylesheetDirectory</property>
+ <description>Directory where XSLT stylesheets are contained.
+ </description>
+ </globalProperty>
+ <globalProperty>
+ <property>chica.growthChartConfigFile</property>
+ <description>Location of the growth chart configuration file.
+ </description>
+ </globalProperty>
+ <globalProperty>
+ <property>chica.growthChartPlotImage</property>
+ <description>Location of the image used to make plots on the growth \
charts. + </description>
+ </globalProperty>
+ <globalProperty>
+ <property>chica.gisMapUrl</property>
+ <description>The base URL to generate a CHICA GIS map.
+ </description>
+ </globalProperty>
+ <globalProperty>
+ <property>chica.gisDataUrl</property>
+ <description>The base URL to generate a CHICA GIS data.
+ </description>
+ </globalProperty>
+ <globalProperty>
+ <property>chica.gisTutorRadius</property>
+ <defaultValue>3</defaultValue>
+ <description>The map radius (in miles)of the tutoring resources for \
the CHICA GIS map generation. + </description>
+ </globalProperty>
+ <globalProperty>
+ <property>chica.gisExerciseRadius</property>
+ <defaultValue>3</defaultValue>
+ <description>The map radius (in miles)of the exercise resources for \
the CHICA GIS map generation. + </description>
+ </globalProperty>
+ <globalProperty>
+ <property>chica.gisDentalRadius</property>
+ <defaultValue>3</defaultValue>
+ <description>The map radius (in miles)of the dental resources for the \
CHICA GIS map generation. + </description>
+ </globalProperty>
+ <globalProperty>
+ <property>chica.gisToppingFilter</property>
+ <defaultValue>6</defaultValue>
+ <description>The maximum number of search result giving by the CHICA \
GIS service. + </description>
+ </globalProperty>
+ <globalProperty>
+ <property>chica.gisTimeout</property>
+ <defaultValue>10</defaultValue>
+ <description>The timeout for CHICA GIS queries (in seconds).
+ </description>
+ </globalProperty>
+ <globalProperty>
+ <property>chica.gisMaxRadius</property>
+ <defaultValue>10</defaultValue>
+ <description>The maximum radius to search for GIS data.
+ </description>
+ </globalProperty>
+ <globalProperty>
+ <property>chica.gisConnectionTimeout</property>
+ <defaultValue>3</defaultValue>
+ <description>The connection timeout for CHICA GIS queries (in \
seconds). + </description>
+ </globalProperty>
+ <globalProperty>
+ <property>chica.gisMinAge</property>
+ <defaultValue>1</defaultValue>
+ <description>The minimum age (in years) for the GIS query.
+ </description>
+ </globalProperty>
+ <globalProperty>
+ <property>chica.presnetConnectionTimeout</property>
+ <defaultValue>5</defaultValue>
+ <description>The connection timeout for Presnet connections (in \
seconds). + </description>
+ </globalProperty>
+ <globalProperty>
+ <property>chica.presnetReadTimeout</property>
+ <defaultValue>5</defaultValue>
+ <description>The read timeout for Presnet connections (in seconds).
+ </description>
+ </globalProperty>
+ <globalProperty>
+ <property>chica.gisMinimumSearchResults</property>
+ <defaultValue>3</defaultValue>
+ <description>The minimum number of search results to be met before \
results are displayed on the forms. + </description>
+ </globalProperty>
+ <globalProperty>
+ <property>chica.passcode</property>
+ <description>Passcode used by mobile products to view CHICA data.
+ </description>
+ </globalProperty>
+ <globalProperty>
+ <property>chica.allowableHL7MessageSources</property>
+ <defaultValue>ECW</defaultValue>
+ <description>Comma delimited list of allowable sources for hl7 ADT \
messages. + </description>
+ </globalProperty>
+ <globalProperty>
+ <property>chica.ImmunizationQueryActivated</property>
+ <defaultValue>true</defaultValue>
+ <description>Activate query to CHIRP registry
+ </description>
+ </globalProperty>
+ <globalProperty>
+ <property>chica.ImmunizationQueryConfigFile</property>
+ <description>Location the configuration file for the hl7 immunization \
query. + </description>
+ </globalProperty>
+ <globalProperty>
+ <property>chica.ImmunizationQueryPassword</property>
+ <description>Password to CHIRP registry.
+ </description>
+ </globalProperty>
+ <globalProperty>
+ <property>chica.ImmunizationQueryURL</property>
+ <description>CHIRP URL
+ </description>
+ </globalProperty>
+ <globalProperty>
+ <property>chica.ImmunizationQueryUserId</property>
+ <description>Userid for access to CHIRP.
+ </description>
+ </globalProperty>
+ <globalProperty>
+ <property>chica.chica.activateVXU</property>
+ <defaultValue>false</defaultValue>
+ <description>Allow hl7 VXU update to CHIRP immunization \
registry</description> + </globalProperty>
+ <globalProperty>
+ <property>chica.ImmunizationOutputDirectory</property>
+ <description>CHIRP hl7 query and response file directory
+ </description>
+ </globalProperty>
+ <globalProperty>
+ <property>chica.activateVXUToCreatePatient</property>
+ <description>Activate VXU to create a patient in the CHIRP registry.
+ </description>
+ </globalProperty>
+
+
+
+ <!-- Internationalization -->
+ <!-- All message codes should start with @MODULE_ID@.* -->
+ <messages>
+ <lang>en</lang>
+ <file>messages.properties</file>
+ </messages>
+ <!-- /Internationalization -->
+
+ <mappingFiles>
+ hcageinf.hbm.xml
+ lenageinf.hbm.xml
+ wtageinf.hbm.xml
+ bmiage.hbm.xml
+ encounter.hbm.xml
+ study.hbm.xml
+ study_attribute.hbm.xml
+ study_attribute_value.hbm.xml
+ old_rule.hbm.xml
+ chica1_patient.hbm.xml
+ chica1_patient_obsv.hbm.xml
+ chica1_appointments.hbm.xml
+ insurance_category.hbm.xml
+ family.hbm.xml
+ patient_family.hbm.xml
+ chica_hl7_export.hbm.xml
+ ddst.hbm.xml
+ high_bp.hbm.xml
+ chica_hl7_export_map.hbm.xml
+ chica_hl7_export_status.hbm.xml
+ </mappingFiles>
+
+ <!-- Servlets -->
+ <!-- Accessed through the url \
/pageContext()/moduleServlet/<moduleId>/<servlet-name> --> + \
<servlet> + <servlet-name>chicaMobile</servlet-name>
+ <servlet-class>@MODULE_PACKAGE@.web.ChicaMobileServlet</servlet-class>
+ </servlet>
+
+</module>
+
</ins></span></pre></div>
<a id="openmrsmoduleschicatagsRelease1606srcorgopenmrsmodulechicahl7immunizationImmunizationRegistryQueryjava"></a>
<div class="delfile"><h4>Deleted: openmrs-modules/chica/tags/Release \
1.60.6/src/org/openmrs/module/chica/hl7/immunization/ImmunizationRegistryQuery.java \
(30883 => 30901)</h4> <pre class="diff"><span>
<span class="info">--- \
openmrs-modules/chica/trunk/src/org/openmrs/module/chica/hl7/immunization/ImmunizationRegistryQuery.java 2014-09-03 \
03:00:09 UTC (rev 30883)
+++ openmrs-modules/chica/tags/Release \
1.60.6/src/org/openmrs/module/chica/hl7/immunization/ImmunizationRegistryQuery.java 2014-09-10 \
03:48:58 UTC (rev 30901) </span><span class="lines">@@ -1,935 +0,0 @@
</span><del>-package org.openmrs.module.chica.hl7.immunization;
-
-/**
- *
- */
-
-import java.io.IOException;
-import java.net.URLEncoder;
-import java.text.SimpleDateFormat;
-import java.util.Date;
-import java.util.HashMap;
-import java.util.HashSet;
-import java.util.List;
-import java.util.Locale;
-import java.util.Set;
-
-import org.apache.commons.logging.Log;
-import org.apache.commons.logging.LogFactory;
-import org.hibernate.Hibernate;
-import org.openmrs.Concept;
-import org.openmrs.ConceptMap;
-import org.openmrs.Encounter;
-import org.openmrs.Patient;
-import org.openmrs.PatientIdentifier;
-import org.openmrs.PatientIdentifierType;
-import org.openmrs.PersonAddress;
-import org.openmrs.PersonAttribute;
-import org.openmrs.PersonAttributeType;
-import org.openmrs.PersonName;
-import org.openmrs.api.AdministrationService;
-import org.openmrs.api.ConceptService;
-import org.openmrs.api.LocationService;
-import org.openmrs.api.PatientService;
-import org.openmrs.api.PersonService;
-import org.openmrs.api.context.Context;
-import org.openmrs.module.chica.ImmunizationForecast;
-import org.openmrs.module.chica.ImmunizationForecastLookup;
-import org.openmrs.module.chica.ImmunizationPrevious;
-import org.openmrs.module.chica.ImmunizationQueryOutput;
-import org.openmrs.module.chica.service.ChicaService;
-import org.openmrs.module.chirdlutil.util.HttpUtil;
-import org.openmrs.module.chirdlutil.util.Util;
-import org.openmrs.module.chirdlutilbackports.hibernateBeans.Error;
-import org.openmrs.module.chirdlutilbackports.service.ChirdlUtilBackportsService;
-
-import ca.uhn.hl7v2.HL7Exception;
-import ca.uhn.hl7v2.model.Message;
-import ca.uhn.hl7v2.model.Type;
-import ca.uhn.hl7v2.model.v231.datatype.CE;
-import ca.uhn.hl7v2.model.v231.datatype.CX;
-import ca.uhn.hl7v2.model.v231.datatype.FN;
-import ca.uhn.hl7v2.model.v231.datatype.NM;
-import ca.uhn.hl7v2.model.v231.datatype.ST;
-import ca.uhn.hl7v2.model.v231.datatype.TS;
-import ca.uhn.hl7v2.model.v231.datatype.XAD;
-import ca.uhn.hl7v2.model.v231.datatype.XPN;
-import ca.uhn.hl7v2.model.v231.group.VXX_V02_PIDNK1;
-import ca.uhn.hl7v2.model.v231.message.VXQ_V01;
-import ca.uhn.hl7v2.model.v231.message.VXR_V03;
-import ca.uhn.hl7v2.model.v231.message.VXU_V04;
-import ca.uhn.hl7v2.model.v231.message.VXX_V02;
-import ca.uhn.hl7v2.model.v231.segment.NK1;
-import ca.uhn.hl7v2.model.v231.segment.OBX;
-import ca.uhn.hl7v2.model.v231.segment.PID;
-import ca.uhn.hl7v2.model.v231.segment.RXA;
-import ca.uhn.hl7v2.parser.PipeParser;
-import ca.uhn.hl7v2.util.Terser;
-import ca.uhn.hl7v2.validation.impl.NoValidation;
-
-/**
- * @author tmdugan
- *
- */
-public class ImmunizationRegistryQuery
-{
- private static Log log = LogFactory.getLog(ImmunizationRegistryQuery.class);
-
- private static org.openmrs.Encounter encounter = null;
- private static String CHIRP_NOT_AVAILABLE = "CHIRP_not_available";
- private static String NOT_IN_CHIRP = "not_in_chirp_registry";
- private static String NOT_MATCHED = "CHIRP_match_not_found";
- private static String NEXT_OF_KIN = "Next of Kin";
- private static String IMMUNIZATION_REGISTRY = "Immunization Registry";
- private static String MATCHED = "CHIRP_match_found";
- private static String CREATED = "CHIRP_patient_created";
- private static String SOURCE = "CVX";
- private static String GENERIC = "CVX unspecified";
- private static String ERROR_CATEGORY = "Query Immunization List \
Connection";
- private static String LOINC_DOSE_NUMBER_CODE = "30973-2";
- private static String LOINC_EARLIEST_TIME_TO_GIVE = "30981-5";
- private static String LOINC_DATE_VACCINE_DUE = "30980-7";
- private static String LOINC_VACCINE_TYPE = "30956-7";
- private static String CHIRP_ERROR = "CHIRP is not accessible.";
- private static String CHIRP_PARSING_ERROR = "CHIRP HL7 parsing error.";
- private static String CHIRP_UPDATE_FAILED = "CHIRP is accessible, but the \
immunization update failed.";
- private static String CHIRP_RESPONSE_INVALID = "CHIRP response was empty or \
invalid";
-
- /**
- *
- * Auto generated method comment
- *
- * @param messageString
- * @param mrn
- * @param patientId
- */
- private static void createImmunizationList(String messageString, String mrn,
- Integer patientId) {
-
- if (messageString == null) {
- log.info("immunization list is null for mrn: " + mrn
- + " so immunization list could not be created");
- return;
- }
-
- try {
-
- messageString = messageString.trim();
-
- if (messageString.length() == 0) {
- return;
- }
- String newMessageString = messageString;
- PipeParser pipeParser = new PipeParser();
- pipeParser.setValidationContext(new NoValidation());
- Message message = null;
- try {
- message = pipeParser.parse(newMessageString);
- } catch (Exception e) {
-
- logError( CHIRP_PARSING_ERROR,
- "HL7 response = " + messageString ,
- null, patientId);
- return;
- }
- parseImmunizations(message, patientId);
- } catch (Exception e) {
- e.printStackTrace();
- }
- }
-
- public static void parseImmunizations(Message message, Integer patientId)
- throws Exception {
-
- ConceptService conceptService = Context.getConceptService();
- ChicaService chicaService = \
Context.getService(org.openmrs.module.chica.service.ChicaService.class);
- ImmunizationForecastLookup.removeImmunizationList(patientId);
-
- if (message instanceof VXR_V03) {
- VXR_V03 vxr = (VXR_V03) message;
- int numReps = vxr.getORCRXARXROBXNTEReps();
- for (int i = 0; i < numReps; i++) {
- HashMap<String, ImmunizationPrevious> prevImmunizationList = new \
HashMap<String, ImmunizationPrevious>();
- HashMap<String, ImmunizationForecast> forecastedImmunizationList = new \
HashMap<String, ImmunizationForecast>();
-
- RXA rxa = vxr.getORCRXARXROBXNTE(i).getRXA();
-
- String vaccineCode = null;
- String vaccineName = null;
- String vaccineDate = null;
- NM doseNM = null;
-
-
- ImmunizationPrevious previousImmunization = null;
- ImmunizationForecast forecastedImmunization = null;
-
- // previously given vaccines
- if (rxa != null) {
- vaccineCode = rxa.getAdministeredCode().getIdentifier()
- .getValue();
- vaccineName = rxa.getAdministeredCode().getText()
- .getValue();
- doseNM = rxa.getAdministrationSubIDCounter();
-
-
- //2013-05-08 - Format for forecasted messaegs no longer has
- // 0 for the dose number. Now that same field has 999 just like the
- //vaccine history. The forecasting messages now have
- //vaccine code = 998 and name = "no vaccine administered".
- if (vaccineCode != null && \
!vaccineCode.equalsIgnoreCase("998")){
- // This is a previous immunization
- Integer doseNumber = Integer.valueOf(doseNM.getValue());
- vaccineDate = rxa.getDateTimeEndOfAdministration()
- .getTimeOfAnEvent().getValue();
-
- System.out.println("history: " + vaccineCode + " "
- + vaccineName + " "
- + doseNM.getValue() + " "
- + vaccineDate);
-
- // Use Concept maps vaccine category
- // Combination vaccines will map to multiple codes
- Concept cvxVaccineConcept = conceptService.getConceptByMapping(vaccineCode, \
SOURCE );
- if (cvxVaccineConcept == null ){
- log.info("Immunization: CVX vaccine code " + vaccineCode + " \
(" + vaccineName + ") " + "not mapped to a \
concept" );
- continue;
- }
-
- //Get all general (unspecified) mapped vaccine concepts for each RXA vaccine \
code.
- List<ConceptMap> conceptMaps = \
chicaService.getConceptMapsByVaccine(cvxVaccineConcept, GENERIC);
- if (conceptMaps == null || conceptMaps.size() == 0){
- continue;
- }
-
- for (ConceptMap conceptMap: conceptMaps){
- String unspecifiedVaccineCode = conceptMap.getSourceCode();
- String unspecifiedVaccineName = "";
- Concept unspecifiedVaccineConcept = \
conceptService.getConceptByMapping(unspecifiedVaccineCode, SOURCE );
- if (unspecifiedVaccineConcept != null && \
unspecifiedVaccineConcept.getName() != null){
- unspecifiedVaccineName = unspecifiedVaccineConcept.getName().getName();
- }
- if (vaccineCode != null) {
- previousImmunization = new ImmunizationPrevious();
-
- previousImmunization.setVaccineName(unspecifiedVaccineName);
- previousImmunization
- .setVaccineCode(unspecifiedVaccineCode);
- previousImmunization.setPatientId(patientId);
- previousImmunization.setDate(vaccineDate);
- previousImmunization.setDose(doseNumber);
- prevImmunizationList.put(unspecifiedVaccineCode,
- previousImmunization);
- }
- }
-
- // add the previous immunizations
- for (ImmunizationPrevious prevImmunization : prevImmunizationList
- .values()) {
-
- Integer immundDoseNumber = prevImmunization.getDose();
-
- if (immundDoseNumber != null && immundDoseNumber > 0) {
- ImmunizationQueryOutput immuneOutput = ImmunizationForecastLookup
- .getImmunizationList(patientId);
-
- if (immuneOutput == null) {
- immuneOutput = new ImmunizationQueryOutput();
- ImmunizationForecastLookup.addImmunizationList(
- patientId, immuneOutput);
- }
-
- immuneOutput.addImmunizationPrevious(prevImmunization);
- }
- }
-
- }
- else {
-
- // get the rxa information for forecasting
- // 2013-05-08 - CHIRP changed - vaccine code and vaccine code are useless.
- // Get the vaccine name from a value in an OBX.
- // Now we need to through forecast OBX information for forecasting
- forecastedImmunization = new ImmunizationForecast();
-
- int numObs = vxr.getORCRXARXROBXNTE(i).getOBXNTEReps();
- for (int j = 0; j < numObs; j++) {
- OBX obx = vxr.getORCRXARXROBXNTE(i).getOBXNTE(j).getOBX();
- if (obx == null){
- continue;
- }
- String obxCode = obx.getObservationIdentifier()
- .getIdentifier().getValue();
- if (obxCode == null) {
- continue;
- }
- Type obxValue = obx.getObservationValue(0).getData();
- if (obxValue == null){
- continue;
- }
- String obsValueType = obxValue.getName();
-
-
- // this code indicates the type of vaccine
- if (obxCode.equals(LOINC_VACCINE_TYPE)) {
- if (obsValueType.equals("CE")) {
- CE data = (CE) obxValue;
- if (data == null || data.getIdentifier() == null
- ||data.getText() == null){
- //Must have a vaccine type
- continue;
- }
-
- //Note: newer hl7 has a junky vaccine name
- String obxVaccineName = data.getText()
- .getValue();
- if (obxVaccineName != null && forecastedImmunization != null) {
- forecastedImmunization
- .setVaccineName(obxVaccineName);
- }
-
- String obxVaccineCode = data.getIdentifier()
- .getValue();
- if (obxVaccineCode != null && forecastedImmunization != null) {
- forecastedImmunization
- .setVaccineCode(obxVaccineCode);
- }
- }
- }
- // this code indicates the due date of the next
- // vaccination
- if (obxCode.equals(LOINC_DATE_VACCINE_DUE)) {
- if (obsValueType.equals("TS")) {
- TS data = (TS) obxValue;
- String dateString = data.getTimeOfAnEvent()
- .getValue();
- if (dateString != null && forecastedImmunization != null) {
- forecastedImmunization
- .setDateDue(dateString);
- }
- }
- }
-
- // this code indicates the dose of the next vaccination
- //if (obxCode.equals("30979-9&30973-2")) {
- if (obxCode.equals(LOINC_DOSE_NUMBER_CODE)) {
- if (obsValueType.equals("NM")) {
- NM data = (NM) obxValue;
- String dataString = data.getValue();
- if (dataString != null && forecastedImmunization != null) {
- forecastedImmunization.setDose(Integer
- .parseInt(dataString));
- }
- }
- }
-
- // this code indicates the earliest date of the next
- // vaccination
- //if (obxCode.equals("30979-9&30981-5")) {
- if (obxCode.equals(LOINC_EARLIEST_TIME_TO_GIVE)) {
- if (obsValueType.equals("TS")) {
- TS data = (TS) obxValue;
- String dateString = data.getTimeOfAnEvent()
- .getValue();
- if (dateString != null && forecastedImmunization != null ) {
- forecastedImmunization
- .setEarliestDate(dateString);
- }
- }
- }
-
-
- }
-
- //Create the forecasted list
-
- String forecastVaccineCode = forecastedImmunization.getVaccineCode();
- //get the concept for hl7 CVX vaccine code
- Concept vaccineConcept = \
conceptService.getConceptByMapping(forecastVaccineCode, SOURCE );
- if (vaccineConcept == null){
- log.error("ImmunizationForecast: CVX vaccine code not mapped to a \
concept : " + forecastVaccineCode + " (" + \
forecastedImmunization.getVaccineName() );
- continue;
- }
-
- //Find the mapped codes for the concept
- List<ConceptMap> conceptMaps = \
chicaService.getConceptMapsByVaccine(vaccineConcept, GENERIC);
- if (conceptMaps == null || conceptMaps.size() == 0){
- log.info("ImmunizationForecast: No unspecified CVX code exists for \
concept: "
- + vaccineConcept.getName().getName() + ", CVX: " + \
forecastVaccineCode);
- }
-
- //Get the unspecified name and cvx code to add to forecasting list
- for (ConceptMap conceptMap : conceptMaps) {
-
- String unspecfiedCode = conceptMap.getSourceCode();
- if (unspecfiedCode == null || \
unspecfiedCode.trim().equalsIgnoreCase("") ){
- log.info("ImmunizationForecast: Concept map exists, but no source_code \
defined. Concept id: "
- + conceptMap.getConcept().getConceptId());
- continue;
- }
- Concept unspecifiedConcept = \
conceptService.getConceptByMapping(unspecfiedCode, SOURCE );
- if (unspecifiedConcept == null || unspecifiedConcept.getName() == null ){
- log.info("ImmunizationForecast: There is no concept for CVX code: \
"
- + unspecfiedCode);
- continue;
- }
-
- String unspecifiedVaccineName = unspecifiedConcept.getName().getName();
-
- forecastedImmunization.setVaccineName(unspecifiedVaccineName);
- forecastedImmunization
- .setVaccineCode(unspecfiedCode);
- forecastedImmunization.setPatientId(patientId);
- forecastedImmunizationList.put(unspecfiedCode,
- forecastedImmunization);
-
- }
-
- //loop through forecast immunization obx
- // added the forecasted immunizations
- for (ImmunizationForecast foreImmunization : forecastedImmunizationList
- .values()) {
-
- Integer doseNumber = foreImmunization.getDose();
-
- if (doseNumber != null && doseNumber > 0) {
- ImmunizationQueryOutput immuneOutput = ImmunizationForecastLookup
- .getImmunizationList(patientId);
-
- if (immuneOutput == null) {
- immuneOutput = new ImmunizationQueryOutput();
- ImmunizationForecastLookup.addImmunizationList(
- patientId, immuneOutput);
- }
-
- immuneOutput.addImmunizationForecast(foreImmunization);
- }
- }
- }// end of forecast parsing
- }// rxa exists
- }//end of loop through all rxa's
- }// is VXR
- }
-
- private static String getData(String message){
- String data = "";
- try {
- AdministrationService adminService = Context.getAdministrationService();
- String userId = adminService
- .getGlobalProperty("chica.ImmunizationQueryUserId");
- String password = adminService
- .getGlobalProperty("chica.ImmunizationQueryPassword");
-
- data = URLEncoder.encode("USERID", "UTF-8") + "="
- + URLEncoder.encode(userId, "UTF-8");
- data += "&" + URLEncoder.encode("PASSWORD", \
"UTF-8") + "="
- + URLEncoder.encode(password, "UTF-8");
-
- if (message != null && message.contains("VXU")){
- data += "&" + URLEncoder.encode("debug", \
"UTF-8") + "="
- + URLEncoder.encode("debug", "UTF-8");
- data += "&" + URLEncoder.encode("deduplication", \
"UTF-8") + "="
- + URLEncoder.encode("deduplication", "UTF-8");
- }
- data += "&" + URLEncoder.encode("MESSAGEDATA", \
"UTF-8") + "="
- + URLEncoder.encode(message, "UTF-8");
- } catch (Exception e) {
- e.printStackTrace();
- }
- return data;
-
- }
-
- public static String queryCHIRP( Encounter encounter){
-
- AdministrationService adminService = Context.getAdministrationService();
- ConceptService conceptService = Context.getConceptService();
- PatientService patientService = Context.getPatientService();
- String dir = adminService.getGlobalProperty("chica.ImmunizationOutputDirectory");
- String url = adminService.getGlobalProperty("chica.ImmunizationQueryURL");
- Integer timeout = \
Integer.parseInt(adminService.getGlobalProperty("chica.immunizationListTimeout"));
- String activateQuery = \
adminService.getGlobalProperty("chica.ImmunizationQueryActivated");
- boolean OkToQuery = false;
- if (activateQuery != null &&
- (activateQuery.equalsIgnoreCase("true")
- || activateQuery.equalsIgnoreCase("yes")
- || activateQuery.equalsIgnoreCase("T")
- || activateQuery.equalsIgnoreCase("Y"))){
- OkToQuery = true;
-
- }
-
- Concept statusConcept = conceptService.getConceptByName("CHIRP_Status");
- timeout = timeout*1000;
- String queryResponse = null;
- long queryTime = 0;
- Integer encounterId = encounter.getEncounterId();;
- Patient chicaPatient = encounter.getPatient();
- PipeParser parser = new PipeParser();
-
- try {
-
- // Get identifier
- chicaPatient = patientService.getPatient(chicaPatient.getPatientId());
- Hibernate.initialize(chicaPatient);
- String mrn = chicaPatient.getPatientIdentifier().getIdentifier();
-
- //construct vxq
-
- ImmunizationQueryConstructor constructor = new ImmunizationQueryConstructor();
- VXQ_V01 vxq = new VXQ_V01();
- String vxqString = ImmunizationQueryConstructor.constructVXQ(vxq, encounter);
- if (vxqString == null || vxqString.trim().equals("")){
- log.error("Immunization: VXQ string for " + mrn + " is null or \
empty.");
- return null;
- }
-
- ImmunizationQueryConstructor.saveFile(dir, vxqString, "vxq_1", \
encounter);
- String data = getData(vxqString);
- log.info("Immunization: vxq = " + vxqString);
- if (!OkToQuery){
- log.info("Immunization: Activate query: " + OkToQuery);
- return null;
- }
-
- //post VXQ
- long queryStartTime = System.currentTimeMillis();
-
-
- try {
- queryResponse = HttpUtil.post(url, data,timeout,timeout);
- queryTime = System.currentTimeMillis()-queryStartTime;
- } catch (Exception e1) {
- logError(CHIRP_ERROR
- , Util.getStackTrace(e1),
- url, encounter.getPatientId());
- Util.saveObs(chicaPatient, statusConcept, encounterId, CHIRP_NOT_AVAILABLE
- , new Date());
- return null;
- }
-
- // log post timing
- log.info("Immunization: Encounter = " + encounter.getEncounterId() +
- " CHIRP response time = " + queryTime);
- log.info("Immunization: CHIRP response text = " + queryResponse);
-
- //log errors
- if (queryResponse == null ){
- logError( CHIRP_ERROR, "", url, encounter.getPatientId());
- Util.saveObs(chicaPatient, statusConcept, encounterId, CHIRP_NOT_AVAILABLE
- , new Date());
- return null;
- }
-
- if (queryResponse.isEmpty() || queryResponse.trim().equals("")) {
- logError(CHIRP_RESPONSE_INVALID, "", url, encounter.getPatientId());
- Util.saveObs(chicaPatient, statusConcept, encounterId, CHIRP_NOT_AVAILABLE
- , new Date());
- return null;
- }
-
- //CHIRP does not send QCK MSH segment in proper format!!
- //FIRST do a string search for "QCK" to avoid parsing errors,
- //THEN, if not "QCK", continue parse the response.
-
- //patient not found
-
- if (queryResponse.indexOf("|QCK") > 0){
-
-
- //save the obs and file
- Util.saveObs(chicaPatient, statusConcept, encounterId, NOT_IN_CHIRP, new \
Date());
- ImmunizationQueryConstructor.saveFile(dir, queryResponse, "qck", \
encounter);
-
- //create the patient in chirp with VXU if VXU is activated.
-
- VXU_V04 vxu = new VXU_V04();
- ImmunizationQueryConstructor.constructVXU(vxu,encounter);
- String vxuString = ImmunizationQueryConstructor.getVXUMessageString(vxu);
- ImmunizationQueryConstructor.saveFile(dir, vxuString, "vxu", \
encounter);
- data = getData(vxuString);
-
- //Only send VXU if VXU update is enabled in global property
-
- String activateVXUToCreatePatient = \
adminService.getGlobalProperty("chica.activateVXUToCreatePatient");
- log.info(" Immunization: Create Patient VXU Activated = " + \
activateVXUToCreatePatient);
- log.info(" Immunization: Create Patient VXU String = " + vxuString);
- if (activateVXUToCreatePatient != null &&
- (activateVXUToCreatePatient.equalsIgnoreCase("true")
- || activateVXUToCreatePatient.equalsIgnoreCase("yes")
- || activateVXUToCreatePatient.equalsIgnoreCase("T")
- || activateVXUToCreatePatient.equalsIgnoreCase("Y"))){
- try {
- queryResponse = HttpUtil.post(url, data,timeout,timeout);
- log.info("Immunization: Create patient response = " + \
queryResponse);
- if (queryResponse != null && \
queryResponse.contains("accepted")){
- Util.saveObs(chicaPatient, statusConcept, encounterId, CREATED, new Date());
- } else {
- //Chirp status remains at "not in chirp"
- logError(CHIRP_UPDATE_FAILED,
- queryResponse, url, encounter.getPatientId());
- }
- ImmunizationQueryConstructor.saveFile(dir, queryResponse, \
"vxu_confirm", encounter);
-
- } catch (IOException e) {
- logError(CHIRP_ERROR,
- Util.getStackTrace(e),
- url, encounter.getPatientId());
- Util.saveObs(chicaPatient, statusConcept, encounterId, CHIRP_NOT_AVAILABLE
- , new Date());
- return null;
- }
-
- }
- return null;
- }
-
-
- //Parse to get MSA for error information.
- //CHIRP sends invalid characters! Remove before parsing.
- String msaControlId = "";
- queryResponse = removeIllegalCharacter(queryResponse);
- Message queryResponseMessage;
- try {
- queryResponseMessage = parser.parse(queryResponse);
- Terser terser = new Terser(queryResponseMessage);
- msaControlId = terser.get("/MSA-1-1");
- if (msaControlId == null || !msaControlId.equalsIgnoreCase("AA") )
- {
- logError(CHIRP_ERROR,
- "HL7 response: " + queryResponse, url, encounter.getPatientId());
- Util.saveObs(chicaPatient, statusConcept, encounterId, CHIRP_NOT_AVAILABLE
- , new Date());
- return null;
- }
- } catch (HL7Exception hl7e){
- logError( CHIRP_PARSING_ERROR,
- "HL7 response = " + queryResponse ,
- null, encounter.getPatientId());
- Util.saveObs(chicaPatient, statusConcept, encounterId, CHIRP_NOT_AVAILABLE
- , new Date());
- return null;
- }
-
- //VXX possible match
-
- if (queryResponseMessage instanceof VXX_V02) {
-
- ImmunizationQueryConstructor.saveFile(dir, queryResponse, "vxx_1", \
encounter);
-
- //match check
-
- Set<Patient> chirpPatients = getChirpPatients(queryResponseMessage);
- PatientMatching patientMatching = new PatientMatching();
- Patient matchPatient = patientMatching.verifyPatientMatch(chicaPatient, \
chirpPatients);
- if (matchPatient == null){
- log.info("Immunization: Patient not matched in CHIRP. Encounter id = \
" + encounterId);
- Util.saveObs(chicaPatient, statusConcept, encounterId, NOT_MATCHED, new \
Date());
- return null;
- }
-
- //Match found.. Save identifier for patient that matches.
- //Do not save as preferred
- try {
- PatientIdentifier identifier = \
matchPatient.getPatientIdentifier(IMMUNIZATION_REGISTRY);
- if (identifier != null){
- identifier.setPreferred(false);
- chicaPatient.addIdentifier(identifier);
- patientService.savePatient(chicaPatient);
- }
- } catch (Exception e1) {
- log.error(Util.getStackTrace(e1));
- Util.saveObs(chicaPatient, statusConcept, encounterId, NOT_MATCHED, new \
Date());
- return null;
- }
-
- //Construct the 2nd vxq
-
- vxqString = constructor.updateVXQ(vxqString, matchPatient);
- log.info("Immunization: 2nd Vxq: " + vxqString);
- ImmunizationQueryConstructor.saveFile(dir, vxqString, "vxq_2", \
encounter);
-
- //requery
-
- data = getData(vxqString);
- queryStartTime = System.currentTimeMillis();
- queryResponse = HttpUtil.post(url, data, timeout, timeout);
-
- log.info("Immunization: Requery CHIRP response time = " + \
encounter.getEncounterId()
- + ": " + (System.currentTimeMillis()-queryStartTime) + \
"msec");
-
- if (queryResponse == null || queryResponse.trim().equals("")
- || !queryResponse.contains("MSH")) {
- Util.saveObs(chicaPatient, statusConcept, encounterId, NOT_MATCHED, new \
Date());
- return null;
- }
-
- //remove possible illegal character from CHIRP
- try {
- queryResponse = removeIllegalCharacter(queryResponse);
- PipeParser pipeParser = new PipeParser();
- queryResponseMessage = pipeParser.parse(queryResponse);
- } catch (HL7Exception e) {
- logError( CHIRP_PARSING_ERROR,
- "HL7 response = " + queryResponse ,
- null, encounter.getPatientId());
- Util.saveObs(chicaPatient, statusConcept, encounterId, CHIRP_NOT_AVAILABLE
- , new Date());
- return null;
- }
-
- log.info("Immunization: CHIRP response after requery = " + \
queryResponse);
- //VXX 2nd time after requery indicates no confirmed match
- if (queryResponseMessage instanceof VXX_V02) {
- ImmunizationQueryConstructor.saveFile(dir, queryResponse, "vxx_2",
- encounter);
- Util.saveObs(chicaPatient, statusConcept, encounterId, NOT_MATCHED, new \
Date());
- return null;
-
- }
-
- }
-
- //VXR returned from query or requery. Create immunization list
-
- if (queryResponseMessage instanceof VXR_V03) {
-
- Set<Patient> chirpPatients = getChirpPatientFromVXR(queryResponseMessage);
- PatientMatching patientMatching = new PatientMatching();
- Patient matchPatient = patientMatching.verifyPatientMatch(chicaPatient, \
chirpPatients);
- if (matchPatient == null){
- log.info("Immunization: VXR Patient is not a match. Encounter id = " \
+ encounterId);
- Util.saveObs(chicaPatient, statusConcept, encounterId, NOT_MATCHED, new \
Date());
- return null;
- }
- Util.saveObs(chicaPatient, statusConcept, encounterId, MATCHED,
- new Date());
- ImmunizationQueryConstructor.saveFile(dir, queryResponse,
- "vxr", encounter);
- createImmunizationList(queryResponse, mrn, encounter
- .getPatientId());
- return queryResponse;
- }
-
- } catch (IOException e) {
-
- logError( CHIRP_ERROR, Util.getStackTrace(e),
- url, encounter.getPatientId());
- Util.saveObs(chicaPatient, statusConcept, encounterId, CHIRP_NOT_AVAILABLE
- , new Date());
- }
-
- return queryResponse;
- }
-
- private static Set<Patient> getChirpPatients(Message message){
- PatientService patientService = Context.getPatientService();
- PersonService personService = Context.getPersonService();
- LocationService locationService = Context.getLocationService();
- Set<Patient> chirpPatients = new HashSet<Patient>();
-
- try {
- Integer count = ((VXX_V02) message).getPIDNK1Reps();
- for (int i = 0 ; i < count; i++){
-
- Patient patient = new Patient();
- VXX_V02_PIDNK1 pidnk1 = ((VXX_V02) message).getPIDNK1(i);
-
- if (pidnk1 != null){
- XPN[] xpns = pidnk1.getPID().getPatientName();
- XPN xpn_alias = pidnk1.getPID().getPatientAlias(0);
- for (XPN xpn : xpns){
- xpn = pidnk1.getPID().getPatientName(0);
- if (xpn != null){
- PersonName personName = new PersonName();
- String last = xpn.getFamilyLastName().getFamilyName().getValue();
- String first = xpn.getGivenName().getValue();
- String middle = xpn.getMiddleInitialOrName().getValue();
- personName.setFamilyName(last);
- personName.setGivenName(first);
- personName.setMiddleName(middle);
- patient.addName(personName);
- }
-
- CX cx = pidnk1.getPID().getPatientIdentifierList(0);
- PatientIdentifier pident = new PatientIdentifier();
- if (cx != null){
- String id = cx.getID().getValue();
- PatientIdentifierType type = \
patientService.getPatientIdentifierTypeByName(IMMUNIZATION_REGISTRY);
- pident.setIdentifierType(type);
- pident.setIdentifier(id);;
- pident.setLocation(locationService.getLocation("Unknown \
Location"));
- patient.addIdentifier(pident);
- }
- patient.addIdentifier(pident);
-
- XAD xad = pidnk1.getPID().getPatientAddress(0);
- PersonAddress address = new PersonAddress();
- if (xad != null){
- address.setCityVillage(xad.getCity().getValue());
- address.setAddress1(xad.getStreetAddress().getValue());
- address.setPostalCode(xad.getZipOrPostalCode().getValue());
- patient.addAddress(address);
- }
-
-
- Integer nkReps = pidnk1.getNK1Reps();
- PersonAttributeType patype = \
personService.getPersonAttributeTypeByName(NEXT_OF_KIN);
- for (int j = 0; j < nkReps; j++){
- String lastNameString = "";
- String firstNameString = "";
- NK1 nk1 = pidnk1.getNK1(j);
- XPN xpname = nk1.getNKName(0);
- if (xpname != null){
- FN nkfname = xpname.getFamilyLastName();
- ST nkfirstName = xpname.getGivenName();
- ST lastName = nkfname.getFamilyName();
- if (lastName != null){
- lastNameString = lastName.getValue();
- }
- if (nkfirstName != null){
- firstNameString = nkfirstName.getValue();
- }
- }
-
- if (lastNameString != null || firstNameString != null){
- String concatNKString = firstNameString + "|" + lastNameString;
- if (!concatNKString.equalsIgnoreCase("")) {
- PersonAttribute nkpersonAttr =
- new PersonAttribute(patype, concatNKString);
- patient.addAttribute(nkpersonAttr);
- }
- }
-
- }
-
- }
- //Check the alias name PID-9 (not in the list of names in PID-5)
- if (xpn_alias != null){
- PersonName personName = new PersonName();
- String last = xpn_alias.getFamilyLastName().getFamilyName().getValue();
- String first = xpn_alias.getGivenName().getValue();
- String middle = xpn_alias.getMiddleInitialOrName().getValue();
- personName.setFamilyName(last);
- personName.setGivenName(first);
- personName.setMiddleName(middle);
- patient.addName(personName);
- }
-
- TS dob = pidnk1.getPID().getDateTimeOfBirth();
-
- if (dob != null && dob.getTimeOfAnEvent() != null){
- String dobString = dob.getTimeOfAnEvent().getValue();
- Date birthDate = new SimpleDateFormat("yyyyMMdd", \
Locale.ENGLISH).parse(dobString);
- patient.setBirthdate(birthDate);
- }
- }
- chirpPatients.add(patient);
- }
- } catch (Exception e) {
- log.error(Util.getStackTrace(e));
- }
-
- return chirpPatients;
- }
-
- private static String removeIllegalCharacter(String queryResponse){
-
- if (queryResponse != null) {
- if (queryResponse.indexOf("Dose number in series^LN||B") > 0){
- log.info("Immunization: Replaced invalid character in VXR");
- queryResponse = queryResponse
- .replace("Dose number in series^LN||B", "Dose number in \
series^LN||1");
- }
-
- }
- return queryResponse;
-
- }
-
- private static void logError(String text, String details, String url, Integer \
patientId){
- if (details == null){
- details = "No details";
- }
- if (url == null){
- url = "No url";
- }
- ChirdlUtilBackportsService chirdlutilbackportsService = \
Context.getService(ChirdlUtilBackportsService.class);
- Error error = new Error("ERROR", ERROR_CATEGORY,
- text , " URL: " + url + " Patient ID: "
- + patientId + ". " + details, new Date(), null);
- chirdlutilbackportsService.saveError(error);
- log.error("Immunization: " + text + "Details:" + details );
- return;
- }
-
- private static Set<Patient> getChirpPatientFromVXR(Message message){
- //Past errors with CHIRP require that we check the matched patient
- // for VXRs also.
-
- //VXR only has one PID
- PatientService patientService = Context.getPatientService();
- PersonService personService = Context.getPersonService();
- LocationService locationService = Context.getLocationService();
- Set<Patient> chirpPatients = new HashSet<Patient>();
-
- try {
- PID pid = ((VXR_V03) message).getPID();
- if (pid == null){
- return null;
- }
- Patient patient = new Patient();
- XPN[] xpns = pid.getPatientName();
- for (XPN xpn : xpns){
- xpn = pid.getPatientName(0);
- if (xpn != null){
- PersonName personName = new PersonName();
- String last = xpn.getFamilyLastName().getFamilyName().getValue();
- String first = xpn.getGivenName().getValue();
- String middle = xpn.getMiddleInitialOrName().getValue();
- personName.setFamilyName(last);
- personName.setGivenName(first);
- personName.setMiddleName(middle);
- patient.addName(personName);
- }
-
- CX cx = pid.getPatientIdentifierList(0);
- PatientIdentifier pident = new PatientIdentifier();
- if (cx != null){
- String id = cx.getID().getValue();
- PatientIdentifierType type = \
patientService.getPatientIdentifierTypeByName(IMMUNIZATION_REGISTRY);
- pident.setIdentifierType(type);
- pident.setIdentifier(id);;
- pident.setLocation(locationService.getLocation("Unknown Location"));
- patient.addIdentifier(pident);
- }
- patient.addIdentifier(pident);
-
- XAD xad = pid.getPatientAddress(0);
- PersonAddress address = new PersonAddress();
- if (xad != null){
- address.setCityVillage(xad.getCity().getValue());
- address.setAddress1(xad.getStreetAddress().getValue());
- address.setPostalCode(xad.getZipOrPostalCode().getValue());
- patient.addAddress(address);
- }
-
- }
-
- TS dob = pid.getDateTimeOfBirth();
-
- if (dob != null && dob.getTimeOfAnEvent() != null){
- String dobString = dob.getTimeOfAnEvent().getValue();
- Date birthDate = new SimpleDateFormat("yyyyMMdd", \
Locale.ENGLISH).parse(dobString);
- patient.setBirthdate(birthDate);
- }
-
- chirpPatients.add(patient);
-
- } catch (Exception e) {
- log.error(Util.getStackTrace(e));
- }
-
- return chirpPatients;
- }
-
-}
</del></span></pre></div>
<a id="openmrsmoduleschicatagsRelease1606srcorgopenmrsmodulechicahl7immunizationImmuni \
zationRegistryQueryjavafromrev30900openmrsmoduleschicatrunksrcorgopenmrsmodulechicahl7immunizationImmunizationRegistryQueryjava"></a>
<div class="copfile"><h4>Copied: openmrs-modules/chica/tags/Release \
1.60.6/src/org/openmrs/module/chica/hl7/immunization/ImmunizationRegistryQuery.java \
(from rev 30900, openmrs-modules/chica/trunk/src/org/openmrs/module/chica/hl7/immunization/ImmunizationRegistryQuery.java) \
(0 => 30901)</h4> <pre class="diff"><span>
<span class="info">--- openmrs-modules/chica/tags/Release \
1.60.6/src/org/openmrs/module/chica/hl7/immunization/ImmunizationRegistryQuery.java \
(rev 0)
+++ openmrs-modules/chica/tags/Release \
1.60.6/src/org/openmrs/module/chica/hl7/immunization/ImmunizationRegistryQuery.java 2014-09-10 \
03:48:58 UTC (rev 30901) </span><span class="lines">@@ -0,0 +1,937 @@
</span><ins>+package org.openmrs.module.chica.hl7.immunization;
+
+/**
+ *
+ */
+
+import java.io.IOException;
+import java.net.URLEncoder;
+import java.text.SimpleDateFormat;
+import java.util.Date;
+import java.util.HashMap;
+import java.util.HashSet;
+import java.util.List;
+import java.util.Locale;
+import java.util.Set;
+
+import org.apache.commons.logging.Log;
+import org.apache.commons.logging.LogFactory;
+import org.hibernate.Hibernate;
+import org.openmrs.Concept;
+import org.openmrs.ConceptMap;
+import org.openmrs.Encounter;
+import org.openmrs.Patient;
+import org.openmrs.PatientIdentifier;
+import org.openmrs.PatientIdentifierType;
+import org.openmrs.PersonAddress;
+import org.openmrs.PersonAttribute;
+import org.openmrs.PersonAttributeType;
+import org.openmrs.PersonName;
+import org.openmrs.api.AdministrationService;
+import org.openmrs.api.ConceptService;
+import org.openmrs.api.LocationService;
+import org.openmrs.api.PatientService;
+import org.openmrs.api.PersonService;
+import org.openmrs.api.context.Context;
+import org.openmrs.module.chica.ImmunizationForecast;
+import org.openmrs.module.chica.ImmunizationForecastLookup;
+import org.openmrs.module.chica.ImmunizationPrevious;
+import org.openmrs.module.chica.ImmunizationQueryOutput;
+import org.openmrs.module.chica.service.ChicaService;
+import org.openmrs.module.chirdlutil.util.HttpUtil;
+import org.openmrs.module.chirdlutil.util.Util;
+import org.openmrs.module.chirdlutilbackports.hibernateBeans.Error;
+import org.openmrs.module.chirdlutilbackports.service.ChirdlUtilBackportsService;
+
+import ca.uhn.hl7v2.HL7Exception;
+import ca.uhn.hl7v2.model.Message;
+import ca.uhn.hl7v2.model.Type;
+import ca.uhn.hl7v2.model.v231.datatype.CE;
+import ca.uhn.hl7v2.model.v231.datatype.CX;
+import ca.uhn.hl7v2.model.v231.datatype.FN;
+import ca.uhn.hl7v2.model.v231.datatype.NM;
+import ca.uhn.hl7v2.model.v231.datatype.ST;
+import ca.uhn.hl7v2.model.v231.datatype.TS;
+import ca.uhn.hl7v2.model.v231.datatype.XAD;
+import ca.uhn.hl7v2.model.v231.datatype.XPN;
+import ca.uhn.hl7v2.model.v231.group.VXX_V02_PIDNK1;
+import ca.uhn.hl7v2.model.v231.message.VXQ_V01;
+import ca.uhn.hl7v2.model.v231.message.VXR_V03;
+import ca.uhn.hl7v2.model.v231.message.VXU_V04;
+import ca.uhn.hl7v2.model.v231.message.VXX_V02;
+import ca.uhn.hl7v2.model.v231.segment.NK1;
+import ca.uhn.hl7v2.model.v231.segment.OBX;
+import ca.uhn.hl7v2.model.v231.segment.PID;
+import ca.uhn.hl7v2.model.v231.segment.RXA;
+import ca.uhn.hl7v2.parser.PipeParser;
+import ca.uhn.hl7v2.util.Terser;
+import ca.uhn.hl7v2.validation.impl.NoValidation;
+
+/**
+ * @author tmdugan
+ *
+ */
+public class ImmunizationRegistryQuery
+{
+ private static Log log = LogFactory.getLog(ImmunizationRegistryQuery.class);
+
+ private static org.openmrs.Encounter encounter = null;
+ private static String CHIRP_NOT_AVAILABLE = "CHIRP_not_available";
+ private static String NOT_IN_CHIRP = "not_in_chirp_registry";
+ private static String NOT_MATCHED = "CHIRP_match_not_found";
+ private static String NEXT_OF_KIN = "Next of Kin";
+ private static String IMMUNIZATION_REGISTRY = "Immunization Registry";
+ private static String MATCHED = "CHIRP_match_found";
+ private static String CREATED = "CHIRP_patient_created";
+ private static String SOURCE = "CVX";
+ private static String GENERIC = "CVX unspecified";
+ private static String ERROR_CATEGORY = "Query Immunization List \
Connection"; + private static String LOINC_DOSE_NUMBER_CODE = \
"30973-2"; + private static String LOINC_EARLIEST_TIME_TO_GIVE = \
"30981-5"; + private static String LOINC_DATE_VACCINE_DUE = \
"30980-7"; + private static String LOINC_VACCINE_TYPE = \
"30956-7"; + private static String CHIRP_ERROR = "CHIRP is not \
accessible."; + private static String CHIRP_PARSING_ERROR = "CHIRP HL7 \
parsing error."; + private static String CHIRP_UPDATE_FAILED = "CHIRP is \
accessible, but the immunization update failed."; + private static String \
CHIRP_RESPONSE_INVALID = "CHIRP response was empty or invalid"; +
+ /**
+ *
+ * Auto generated method comment
+ *
+ * @param messageString
+ * @param mrn
+ * @param patientId
+ */
+ private static void createImmunizationList(String messageString, String mrn,
+ Integer patientId) {
+
+ if (messageString == null) {
+ log.info("immunization list is null for mrn: " + mrn
+ + " so immunization list could not be created");
+ return;
+ }
+
+ try {
+
+ messageString = messageString.trim();
+
+ if (messageString.length() == 0) {
+ return;
+ }
+ String newMessageString = messageString;
+ PipeParser pipeParser = new PipeParser();
+ pipeParser.setValidationContext(new NoValidation());
+ Message message = null;
+ try {
+ message = pipeParser.parse(newMessageString);
+ } catch (Exception e) {
+
+ logError( CHIRP_PARSING_ERROR,
+ "HL7 response = " + messageString ,
+ null, patientId);
+ return;
+ }
+ parseImmunizations(message, patientId);
+ } catch (Exception e) {
+ e.printStackTrace();
+ }
+ }
+
+ public static void parseImmunizations(Message message, Integer patientId)
+ throws Exception {
+
+ ConceptService conceptService = Context.getConceptService();
+ ChicaService chicaService = \
Context.getService(org.openmrs.module.chica.service.ChicaService.class); \
+ ImmunizationForecastLookup.removeImmunizationList(patientId); +
+ if (message instanceof VXR_V03) {
+ VXR_V03 vxr = (VXR_V03) message;
+ int numReps = vxr.getORCRXARXROBXNTEReps();
+ for (int i = 0; i < numReps; i++) {
+ HashMap<String, ImmunizationPrevious> prevImmunizationList = new \
HashMap<String, ImmunizationPrevious>(); + HashMap<String, \
ImmunizationForecast> forecastedImmunizationList = new HashMap<String, \
ImmunizationForecast>(); +
+ RXA rxa = vxr.getORCRXARXROBXNTE(i).getRXA();
+
+ String vaccineCode = null;
+ String vaccineName = null;
+ String vaccineDate = null;
+ NM doseNM = null;
+
+
+ ImmunizationPrevious previousImmunization = null;
+ ImmunizationForecast forecastedImmunization = null;
+
+ // previously given vaccines
+ if (rxa != null) {
+ vaccineCode = rxa.getAdministeredCode().getIdentifier()
+ .getValue();
+ vaccineName = rxa.getAdministeredCode().getText()
+ .getValue();
+ doseNM = rxa.getAdministrationSubIDCounter();
+
+
+ //2013-05-08 - Format for forecasted messaegs no longer has
+ // 0 for the dose number. Now that same field has 999 just like the
+ //vaccine history. The forecasting messages now have
+ //vaccine code = 998 and name = "no vaccine administered".
+ if (vaccineCode != null && \
!vaccineCode.equalsIgnoreCase("998")){ + // This is a previous \
immunization + Integer doseNumber = Integer.valueOf(doseNM.getValue());
+ vaccineDate = rxa.getDateTimeEndOfAdministration()
+ .getTimeOfAnEvent().getValue();
+
+ System.out.println("history: " + vaccineCode + " "
+ + vaccineName + " "
+ + doseNM.getValue() + " "
+ + vaccineDate);
+
+ // Use Concept maps vaccine category
+ // Combination vaccines will map to multiple codes
+ Concept cvxVaccineConcept = conceptService.getConceptByMapping(vaccineCode, \
SOURCE ); + if (cvxVaccineConcept == null ){
+ log.info("Immunization: CVX vaccine code " + vaccineCode + " \
(" + vaccineName + ") " + "not mapped to a concept" ); \
+ continue; + }
+
+ //Get all general (unspecified) mapped vaccine concepts for each RXA vaccine \
code. + List<ConceptMap> conceptMaps = \
chicaService.getConceptMapsByVaccine(cvxVaccineConcept, GENERIC); + if \
(conceptMaps == null || conceptMaps.size() == 0){ + continue;
+ }
+
+ for (ConceptMap conceptMap: conceptMaps){
+ String unspecifiedVaccineCode = conceptMap.getSourceCode();
+ String unspecifiedVaccineName = "";
+ Concept unspecifiedVaccineConcept = \
conceptService.getConceptByMapping(unspecifiedVaccineCode, SOURCE ); + if \
(unspecifiedVaccineConcept != null && unspecifiedVaccineConcept.getName() != \
null){ + unspecifiedVaccineName = \
unspecifiedVaccineConcept.getName().getName(); + }
+ if (vaccineCode != null) {
+ previousImmunization = new ImmunizationPrevious();
+
+ previousImmunization.setVaccineName(unspecifiedVaccineName);
+ previousImmunization
+ .setVaccineCode(unspecifiedVaccineCode);
+ previousImmunization.setPatientId(patientId);
+ previousImmunization.setDate(vaccineDate);
+ previousImmunization.setDose(doseNumber);
+ prevImmunizationList.put(unspecifiedVaccineCode,
+ previousImmunization);
+ }
+ }
+
+ // add the previous immunizations
+ for (ImmunizationPrevious prevImmunization : prevImmunizationList
+ .values()) {
+
+ Integer immundDoseNumber = prevImmunization.getDose();
+
+ if (immundDoseNumber != null && immundDoseNumber > 0) {
+ ImmunizationQueryOutput immuneOutput = ImmunizationForecastLookup
+ .getImmunizationList(patientId);
+
+ if (immuneOutput == null) {
+ immuneOutput = new ImmunizationQueryOutput();
+ ImmunizationForecastLookup.addImmunizationList(
+ patientId, immuneOutput);
+ }
+
+ immuneOutput.addImmunizationPrevious(prevImmunization);
+ }
+ }
+
+ }
+ else {
+
+ // get the rxa information for forecasting
+ // 2013-05-08 - CHIRP changed - vaccine code and vaccine code are useless.
+ // Get the vaccine name from a value in an OBX.
+ // Now we need to through forecast OBX information for forecasting
+ forecastedImmunization = new ImmunizationForecast();
+
+ int numObs = vxr.getORCRXARXROBXNTE(i).getOBXNTEReps();
+ for (int j = 0; j < numObs; j++) {
+ OBX obx = vxr.getORCRXARXROBXNTE(i).getOBXNTE(j).getOBX();
+ if (obx == null){
+ continue;
+ }
+ String obxCode = obx.getObservationIdentifier()
+ .getIdentifier().getValue();
+ if (obxCode == null) {
+ continue;
+ }
+ Type obxValue = obx.getObservationValue(0).getData();
+ if (obxValue == null){
+ continue;
+ }
+ String obsValueType = obxValue.getName();
+
+
+ // this code indicates the type of vaccine
+ if (obxCode.equals(LOINC_VACCINE_TYPE)) {
+ if (obsValueType.equals("CE")) {
+ CE data = (CE) obxValue;
+ if (data == null || data.getIdentifier() == null
+ ||data.getText() == null){
+ //Must have a vaccine type
+ continue;
+ }
+
+ //Note: newer hl7 has a junky vaccine name
+ String obxVaccineName = data.getText()
+ .getValue();
+ if (obxVaccineName != null && forecastedImmunization != null) {
+ forecastedImmunization
+ .setVaccineName(obxVaccineName);
+ }
+
+ String obxVaccineCode = data.getIdentifier()
+ .getValue();
+ if (obxVaccineCode != null && forecastedImmunization != null) {
+ forecastedImmunization
+ .setVaccineCode(obxVaccineCode);
+ }
+ }
+ }
+ // this code indicates the due date of the next
+ // vaccination
+ if (obxCode.equals(LOINC_DATE_VACCINE_DUE)) {
+ if (obsValueType.equals("TS")) {
+ TS data = (TS) obxValue;
+ String dateString = data.getTimeOfAnEvent()
+ .getValue();
+ if (dateString != null && forecastedImmunization != null) {
+ forecastedImmunization
+ .setDateDue(dateString);
+ }
+ }
+ }
+
+ // this code indicates the dose of the next vaccination
+ //if (obxCode.equals("30979-9&30973-2")) {
+ if (obxCode.equals(LOINC_DOSE_NUMBER_CODE)) {
+ if (obsValueType.equals("NM")) {
+ NM data = (NM) obxValue;
+ String dataString = data.getValue();
+ if (dataString != null && forecastedImmunization != null) {
+ forecastedImmunization.setDose(Integer
+ .parseInt(dataString));
+ }
+ }
+ }
+
+ // this code indicates the earliest date of the next
+ // vaccination
+ //if (obxCode.equals("30979-9&30981-5")) {
+ if (obxCode.equals(LOINC_EARLIEST_TIME_TO_GIVE)) {
+ if (obsValueType.equals("TS")) {
+ TS data = (TS) obxValue;
+ String dateString = data.getTimeOfAnEvent()
+ .getValue();
+ if (dateString != null && forecastedImmunization != null ) {
+ forecastedImmunization
+ .setEarliestDate(dateString);
+ }
+ }
+ }
+
+
+ }
+
+ //Create the forecasted list
+
+ String forecastVaccineCode = forecastedImmunization.getVaccineCode();
+ //get the concept for hl7 CVX vaccine code
+ Concept vaccineConcept = \
conceptService.getConceptByMapping(forecastVaccineCode, SOURCE ); + if \
(vaccineConcept == null){ + log.error("ImmunizationForecast: CVX vaccine \
code not mapped to a concept : " + forecastVaccineCode + " (" + \
forecastedImmunization.getVaccineName() ); + continue;
+ }
+
+ //Find the mapped codes for the concept
+ List<ConceptMap> conceptMaps = \
chicaService.getConceptMapsByVaccine(vaccineConcept, GENERIC); + if \
(conceptMaps == null || conceptMaps.size() == 0){ \
+ log.info("ImmunizationForecast: No unspecified CVX code exists for \
concept: " + + vaccineConcept.getName().getName() + ", CVX: \
" + forecastVaccineCode); + }
+
+ //Get the unspecified name and cvx code to add to forecasting list
+ for (ConceptMap conceptMap : conceptMaps) {
+
+ String unspecfiedCode = conceptMap.getSourceCode();
+ if (unspecfiedCode == null || \
unspecfiedCode.trim().equalsIgnoreCase("") ){ \
+ log.info("ImmunizationForecast: Concept map exists, but no source_code \
defined. Concept id: " + + conceptMap.getConcept().getConceptId());
+ continue;
+ }
+ Concept unspecifiedConcept = \
conceptService.getConceptByMapping(unspecfiedCode, SOURCE ); + if \
(unspecifiedConcept == null || unspecifiedConcept.getName() == null ){ \
+ log.info("ImmunizationForecast: There is no concept for CVX code: \
" + + unspecfiedCode);
+ continue;
+ }
+
+ String unspecifiedVaccineName = unspecifiedConcept.getName().getName();
+
+ forecastedImmunization.setVaccineName(unspecifiedVaccineName);
+ forecastedImmunization
+ .setVaccineCode(unspecfiedCode);
+ forecastedImmunization.setPatientId(patientId);
+ forecastedImmunizationList.put(unspecfiedCode,
+ forecastedImmunization);
+
+ }
+
+ //loop through forecast immunization obx
+ // added the forecasted immunizations
+ for (ImmunizationForecast foreImmunization : forecastedImmunizationList
+ .values()) {
+
+ Integer doseNumber = foreImmunization.getDose();
+
+ if (doseNumber != null && doseNumber > 0) {
+ ImmunizationQueryOutput immuneOutput = ImmunizationForecastLookup
+ .getImmunizationList(patientId);
+
+ if (immuneOutput == null) {
+ immuneOutput = new ImmunizationQueryOutput();
+ ImmunizationForecastLookup.addImmunizationList(
+ patientId, immuneOutput);
+ }
+
+ immuneOutput.addImmunizationForecast(foreImmunization);
+ }
+ }
+ }// end of forecast parsing
+ }// rxa exists
+ }//end of loop through all rxa's
+ }// is VXR
+ }
+
+ private static String getData(String message){
+ String data = "";
+ try {
+ AdministrationService adminService = Context.getAdministrationService();
+ String userId = adminService
+ .getGlobalProperty("chica.ImmunizationQueryUserId");
+ String password = adminService
+ .getGlobalProperty("chica.ImmunizationQueryPassword");
+
+ data = URLEncoder.encode("USERID", "UTF-8") + "="
+ + URLEncoder.encode(userId, "UTF-8");
+ data += "&" + URLEncoder.encode("PASSWORD", \
"UTF-8") + "=" + + URLEncoder.encode(password, \
"UTF-8"); +
+ if (message != null && message.contains("VXU")){
+ data += "&" + URLEncoder.encode("debug", \
"UTF-8") + "=" + + URLEncoder.encode("debug", \
"UTF-8"); + data += "&" + \
URLEncoder.encode("deduplication", "UTF-8") + "=" \
+ + URLEncoder.encode("deduplication", "UTF-8"); + }
+ data += "&" + URLEncoder.encode("MESSAGEDATA", \
"UTF-8") + "=" + + URLEncoder.encode(message, \
"UTF-8"); + } catch (Exception e) {
+ e.printStackTrace();
+ }
+ return data;
+
+ }
+
+ public static String queryCHIRP( Encounter encounter){
+
+ AdministrationService adminService = Context.getAdministrationService();
+ ConceptService conceptService = Context.getConceptService();
+ PatientService patientService = Context.getPatientService();
+ String dir = adminService.getGlobalProperty("chica.ImmunizationOutputDirectory");
+ String url = adminService.getGlobalProperty("chica.ImmunizationQueryURL");
+ Integer timeout = \
Integer.parseInt(adminService.getGlobalProperty("chica.immunizationListTimeout"));
+ String activateQuery = \
adminService.getGlobalProperty("chica.ImmunizationQueryActivated"); \
+ boolean OkToQuery = false; + if (activateQuery != null &&
+ (activateQuery.equalsIgnoreCase("true")
+ || activateQuery.equalsIgnoreCase("yes")
+ || activateQuery.equalsIgnoreCase("T")
+ || activateQuery.equalsIgnoreCase("Y"))){
+ OkToQuery = true;
+
+ }
+
+ Concept statusConcept = conceptService.getConceptByName("CHIRP_Status");
+ timeout = timeout*1000;
+ String queryResponse = null;
+ long queryTime = 0;
+ Integer encounterId = encounter.getEncounterId();;
+ Patient chicaPatient = encounter.getPatient();
+ PipeParser parser = new PipeParser();
+
+ try {
+
+ // Get identifier
+ chicaPatient = patientService.getPatient(chicaPatient.getPatientId());
+ Hibernate.initialize(chicaPatient);
+ String mrn = chicaPatient.getPatientIdentifier().getIdentifier();
+
+ //construct vxq
+
+ ImmunizationQueryConstructor constructor = new ImmunizationQueryConstructor();
+ VXQ_V01 vxq = new VXQ_V01();
+ String vxqString = ImmunizationQueryConstructor.constructVXQ(vxq, encounter);
+ if (vxqString == null || vxqString.trim().equals("")){
+ log.error("Immunization: VXQ string for " + mrn + " is null or \
empty."); + return null;
+ }
+
+ ImmunizationQueryConstructor.saveFile(dir, vxqString, "vxq_1", \
encounter); + String data = getData(vxqString);
+ log.info("Immunization: vxq = " + vxqString);
+ if (!OkToQuery){
+ log.info("Immunization: Activate query: " + OkToQuery);
+ return null;
+ }
+
+ //post VXQ
+ long queryStartTime = System.currentTimeMillis();
+
+
+ try {
+ queryResponse = HttpUtil.post(url, data,timeout,timeout);
+ queryTime = System.currentTimeMillis()-queryStartTime;
+ } catch (Exception e1) {
+ logError(CHIRP_ERROR
+ , Util.getStackTrace(e1),
+ url, encounter.getPatientId());
+ Util.saveObs(chicaPatient, statusConcept, encounterId, CHIRP_NOT_AVAILABLE
+ , new Date());
+ return null;
+ }
+
+ // log post timing
+ log.info("Immunization: Encounter = " + encounter.getEncounterId() +
+ " CHIRP response time = " + queryTime);
+ log.info("Immunization: CHIRP response text = " + queryResponse);
+
+ //log errors
+ if (queryResponse == null ){
+ logError( CHIRP_ERROR, "", url, encounter.getPatientId());
+ Util.saveObs(chicaPatient, statusConcept, encounterId, CHIRP_NOT_AVAILABLE
+ , new Date());
+ return null;
+ }
+
+ if (queryResponse.isEmpty() || queryResponse.trim().equals("")) {
+ logError(CHIRP_RESPONSE_INVALID, "", url, encounter.getPatientId());
+ Util.saveObs(chicaPatient, statusConcept, encounterId, CHIRP_NOT_AVAILABLE
+ , new Date());
+ return null;
+ }
+
+ //CHIRP does not send QCK MSH segment in proper format!!
+ //FIRST do a string search for "QCK" to avoid parsing errors,
+ //THEN, if not "QCK", continue parse the response.
+
+ //patient not found
+
+ if (queryResponse.indexOf("|QCK") > 0){
+
+
+ //save the obs and file
+ Util.saveObs(chicaPatient, statusConcept, encounterId, NOT_IN_CHIRP, new \
Date()); + ImmunizationQueryConstructor.saveFile(dir, queryResponse, \
"qck", encounter); +
+ //create the patient in chirp with VXU if VXU is activated.
+
+ VXU_V04 vxu = new VXU_V04();
+ ImmunizationQueryConstructor.constructVXU(vxu,encounter);
+ String vxuString = ImmunizationQueryConstructor.getVXUMessageString(vxu);
+ ImmunizationQueryConstructor.saveFile(dir, vxuString, "vxu", \
encounter); + data = getData(vxuString);
+
+ //Only send VXU if VXU update is enabled in global property
+
+ String activateVXUToCreatePatient = \
adminService.getGlobalProperty("chica.activateVXUToCreatePatient"); \
+ log.info(" Immunization: Create Patient VXU Activated = " + \
activateVXUToCreatePatient); + log.info(" Immunization: Create Patient VXU \
String = " + vxuString); + if (activateVXUToCreatePatient != null &&
+ (activateVXUToCreatePatient.equalsIgnoreCase("true")
+ || activateVXUToCreatePatient.equalsIgnoreCase("yes")
+ || activateVXUToCreatePatient.equalsIgnoreCase("T")
+ || activateVXUToCreatePatient.equalsIgnoreCase("Y"))){
+ try {
+ queryResponse = HttpUtil.post(url, data,timeout,timeout);
+ log.info("Immunization: Create patient response = " + \
queryResponse); + if (queryResponse != null && \
queryResponse.contains("accepted")){ + Util.saveObs(chicaPatient, \
statusConcept, encounterId, CREATED, new Date()); + } else {
+ //Chirp status remains at "not in chirp"
+ logError(CHIRP_UPDATE_FAILED,
+ queryResponse, url, encounter.getPatientId());
+ }
+ ImmunizationQueryConstructor.saveFile(dir, queryResponse, \
"vxu_confirm", encounter); +
+ } catch (IOException e) {
+ logError(CHIRP_ERROR,
+ Util.getStackTrace(e),
+ url, encounter.getPatientId());
+ Util.saveObs(chicaPatient, statusConcept, encounterId, CHIRP_NOT_AVAILABLE
+ , new Date());
+ return null;
+ }
+
+ }
+ return null;
+ }
+
+
+ //Parse to get MSA for error information.
+ //CHIRP sends invalid characters! Remove before parsing.
+ String msaControlId = "";
+ queryResponse = removeIllegalCharacter(queryResponse);
+ Message queryResponseMessage;
+ try {
+ parser.setValidationContext(new NoValidation());
+ queryResponseMessage = parser.parse(queryResponse);
+ Terser terser = new Terser(queryResponseMessage);
+ msaControlId = terser.get("/MSA-1-1");
+ if (msaControlId == null || !msaControlId.equalsIgnoreCase("AA") )
+ {
+ logError(CHIRP_ERROR,
+ "HL7 response: " + queryResponse, url, encounter.getPatientId());
+ Util.saveObs(chicaPatient, statusConcept, encounterId, CHIRP_NOT_AVAILABLE
+ , new Date());
+ return null;
+ }
+ } catch (HL7Exception hl7e){
+ logError( CHIRP_PARSING_ERROR,
+ "HL7 response = " + queryResponse ,
+ null, encounter.getPatientId());
+ Util.saveObs(chicaPatient, statusConcept, encounterId, CHIRP_NOT_AVAILABLE
+ , new Date());
+ return null;
+ }
+
+ //VXX possible match
+
+ if (queryResponseMessage instanceof VXX_V02) {
+
+ ImmunizationQueryConstructor.saveFile(dir, queryResponse, "vxx_1", \
encounter); +
+ //match check
+
+ Set<Patient> chirpPatients = getChirpPatients(queryResponseMessage);
+ PatientMatching patientMatching = new PatientMatching();
+ Patient matchPatient = patientMatching.verifyPatientMatch(chicaPatient, \
chirpPatients); + if (matchPatient == null){
+ log.info("Immunization: Patient not matched in CHIRP. Encounter id = \
" + encounterId); + Util.saveObs(chicaPatient, statusConcept, encounterId, \
NOT_MATCHED, new Date()); + return null;
+ }
+
+ //Match found.. Save identifier for patient that matches.
+ //Do not save as preferred
+ try {
+ PatientIdentifier identifier = \
matchPatient.getPatientIdentifier(IMMUNIZATION_REGISTRY); + if (identifier != \
null){ + identifier.setPreferred(false);
+ chicaPatient.addIdentifier(identifier);
+ patientService.savePatient(chicaPatient);
+ }
+ } catch (Exception e1) {
+ log.error(Util.getStackTrace(e1));
+ Util.saveObs(chicaPatient, statusConcept, encounterId, NOT_MATCHED, new \
Date()); + return null;
+ }
+
+ //Construct the 2nd vxq
+
+ vxqString = constructor.updateVXQ(vxqString, matchPatient);
+ log.info("Immunization: 2nd Vxq: " + vxqString);
+ ImmunizationQueryConstructor.saveFile(dir, vxqString, "vxq_2", \
encounter); +
+ //requery
+
+ data = getData(vxqString);
+ queryStartTime = System.currentTimeMillis();
+ queryResponse = HttpUtil.post(url, data, timeout, timeout);
+
+ log.info("Immunization: Requery CHIRP response time = " + \
encounter.getEncounterId() + + ": " + \
(System.currentTimeMillis()-queryStartTime) + "msec"); +
+ if (queryResponse == null || queryResponse.trim().equals("")
+ || !queryResponse.contains("MSH")) {
+ Util.saveObs(chicaPatient, statusConcept, encounterId, NOT_MATCHED, new \
Date()); + return null;
+ }
+
+ //remove possible illegal character from CHIRP
+ try {
+ queryResponse = removeIllegalCharacter(queryResponse);
+ PipeParser pipeParser = new PipeParser();
+ pipeParser.setValidationContext(new NoValidation());
+ queryResponseMessage = pipeParser.parse(queryResponse);
+ } catch (HL7Exception e) {
+ logError( CHIRP_PARSING_ERROR,
+ "HL7 response = " + queryResponse ,
+ null, encounter.getPatientId());
+ Util.saveObs(chicaPatient, statusConcept, encounterId, CHIRP_NOT_AVAILABLE
+ , new Date());
+ return null;
+ }
+
+ log.info("Immunization: CHIRP response after requery = " + \
queryResponse); + //VXX 2nd time after requery indicates no confirmed match
+ if (queryResponseMessage instanceof VXX_V02) {
+ ImmunizationQueryConstructor.saveFile(dir, queryResponse, "vxx_2",
+ encounter);
+ Util.saveObs(chicaPatient, statusConcept, encounterId, NOT_MATCHED, new \
Date()); + return null;
+
+ }
+
+ }
+
+ //VXR returned from query or requery. Create immunization list
+
+ if (queryResponseMessage instanceof VXR_V03) {
+
+ Set<Patient> chirpPatients = getChirpPatientFromVXR(queryResponseMessage);
+ PatientMatching patientMatching = new PatientMatching();
+ Patient matchPatient = patientMatching.verifyPatientMatch(chicaPatient, \
chirpPatients); + if (matchPatient == null){
+ log.info("Immunization: VXR Patient is not a match. Encounter id = " \
+ encounterId); + Util.saveObs(chicaPatient, statusConcept, encounterId, \
NOT_MATCHED, new Date()); + return null;
+ }
+ Util.saveObs(chicaPatient, statusConcept, encounterId, MATCHED,
+ new Date());
+ ImmunizationQueryConstructor.saveFile(dir, queryResponse,
+ "vxr", encounter);
+ createImmunizationList(queryResponse, mrn, encounter
+ .getPatientId());
+ return queryResponse;
+ }
+
+ } catch (IOException e) {
+
+ logError( CHIRP_ERROR, Util.getStackTrace(e),
+ url, encounter.getPatientId());
+ Util.saveObs(chicaPatient, statusConcept, encounterId, CHIRP_NOT_AVAILABLE
+ , new Date());
+ }
+
+ return queryResponse;
+ }
+
+ private static Set<Patient> getChirpPatients(Message message){
+ PatientService patientService = Context.getPatientService();
+ PersonService personService = Context.getPersonService();
+ LocationService locationService = Context.getLocationService();
+ Set<Patient> chirpPatients = new HashSet<Patient>();
+
+ try {
+ Integer count = ((VXX_V02) message).getPIDNK1Reps();
+ for (int i = 0 ; i < count; i++){
+
+ Patient patient = new Patient();
+ VXX_V02_PIDNK1 pidnk1 = ((VXX_V02) message).getPIDNK1(i);
+
+ if (pidnk1 != null){
+ XPN[] xpns = pidnk1.getPID().getPatientName();
+ XPN xpn_alias = pidnk1.getPID().getPatientAlias(0);
+ for (XPN xpn : xpns){
+ xpn = pidnk1.getPID().getPatientName(0);
+ if (xpn != null){
+ PersonName personName = new PersonName();
+ String last = xpn.getFamilyLastName().getFamilyName().getValue();
+ String first = xpn.getGivenName().getValue();
+ String middle = xpn.getMiddleInitialOrName().getValue();
+ personName.setFamilyName(last);
+ personName.setGivenName(first);
+ personName.setMiddleName(middle);
+ patient.addName(personName);
+ }
+
+ CX cx = pidnk1.getPID().getPatientIdentifierList(0);
+ PatientIdentifier pident = new PatientIdentifier();
+ if (cx != null){
+ String id = cx.getID().getValue();
+ PatientIdentifierType type = \
patientService.getPatientIdentifierTypeByName(IMMUNIZATION_REGISTRY); \
+ pident.setIdentifierType(type); + pident.setIdentifier(id);;
+ pident.setLocation(locationService.getLocation("Unknown \
Location")); + patient.addIdentifier(pident);
+ }
+ patient.addIdentifier(pident);
+
+ XAD xad = pidnk1.getPID().getPatientAddress(0);
+ PersonAddress address = new PersonAddress();
+ if (xad != null){
+ address.setCityVillage(xad.getCity().getValue());
+ address.setAddress1(xad.getStreetAddress().getValue());
+ address.setPostalCode(xad.getZipOrPostalCode().getValue());
+ patient.addAddress(address);
+ }
+
+
+ Integer nkReps = pidnk1.getNK1Reps();
+ PersonAttributeType patype = \
personService.getPersonAttributeTypeByName(NEXT_OF_KIN); + for (int j = 0; j \
< nkReps; j++){ + String lastNameString = "";
+ String firstNameString = "";
+ NK1 nk1 = pidnk1.getNK1(j);
+ XPN xpname = nk1.getNKName(0);
+ if (xpname != null){
+ FN nkfname = xpname.getFamilyLastName();
+ ST nkfirstName = xpname.getGivenName();
+ ST lastName = nkfname.getFamilyName();
+ if (lastName != null){
+ lastNameString = lastName.getValue();
+ }
+ if (nkfirstName != null){
+ firstNameString = nkfirstName.getValue();
+ }
+ }
+
+ if (lastNameString != null || firstNameString != null){
+ String concatNKString = firstNameString + "|" + lastNameString;
+ if (!concatNKString.equalsIgnoreCase("")) {
+ PersonAttribute nkpersonAttr =
+ new PersonAttribute(patype, concatNKString);
+ patient.addAttribute(nkpersonAttr);
+ }
+ }
+
+ }
+
+ }
+ //Check the alias name PID-9 (not in the list of names in PID-5)
+ if (xpn_alias != null){
+ PersonName personName = new PersonName();
+ String last = xpn_alias.getFamilyLastName().getFamilyName().getValue();
+ String first = xpn_alias.getGivenName().getValue();
+ String middle = xpn_alias.getMiddleInitialOrName().getValue();
+ personName.setFamilyName(last);
+ personName.setGivenName(first);
+ personName.setMiddleName(middle);
+ patient.addName(personName);
+ }
+
+ TS dob = pidnk1.getPID().getDateTimeOfBirth();
+
+ if (dob != null && dob.getTimeOfAnEvent() != null){
+ String dobString = dob.getTimeOfAnEvent().getValue();
+ Date birthDate = new SimpleDateFormat("yyyyMMdd", \
Locale.ENGLISH).parse(dobString); + patient.setBirthdate(birthDate);
+ }
+ }
+ chirpPatients.add(patient);
+ }
+ } catch (Exception e) {
+ log.error(Util.getStackTrace(e));
+ }
+
+ return chirpPatients;
+ }
+
+ private static String removeIllegalCharacter(String queryResponse){
+
+ if (queryResponse != null) {
+ if (queryResponse.indexOf("Dose number in series^LN||B") > 0){
+ log.info("Immunization: Replaced invalid character in VXR");
+ queryResponse = queryResponse
+ .replace("Dose number in series^LN||B", "Dose number in \
series^LN||1"); + }
+
+ }
+ return queryResponse;
+
+ }
+
+ private static void logError(String text, String details, String url, Integer \
patientId){ + if (details == null){
+ details = "No details";
+ }
+ if (url == null){
+ url = "No url";
+ }
+ ChirdlUtilBackportsService chirdlutilbackportsService = \
Context.getService(ChirdlUtilBackportsService.class); + Error error = new \
Error("ERROR", ERROR_CATEGORY, + text , " URL: " + url + \
" Patient ID: " + + patientId + ". " + details, new Date(), \
null); + chirdlutilbackportsService.saveError(error);
+ log.error("Immunization: " + text + "Details:" + details );
+ return;
+ }
+
+ private static Set<Patient> getChirpPatientFromVXR(Message message){
+ //Past errors with CHIRP require that we check the matched patient
+ // for VXRs also.
+
+ //VXR only has one PID
+ PatientService patientService = Context.getPatientService();
+ PersonService personService = Context.getPersonService();
+ LocationService locationService = Context.getLocationService();
+ Set<Patient> chirpPatients = new HashSet<Patient>();
+
+ try {
+ PID pid = ((VXR_V03) message).getPID();
+ if (pid == null){
+ return null;
+ }
+ Patient patient = new Patient();
+ XPN[] xpns = pid.getPatientName();
+ for (XPN xpn : xpns){
+ xpn = pid.getPatientName(0);
+ if (xpn != null){
+ PersonName personName = new PersonName();
+ String last = xpn.getFamilyLastName().getFamilyName().getValue();
+ String first = xpn.getGivenName().getValue();
+ String middle = xpn.getMiddleInitialOrName().getValue();
+ personName.setFamilyName(last);
+ personName.setGivenName(first);
+ personName.setMiddleName(middle);
+ patient.addName(personName);
+ }
+
+ CX cx = pid.getPatientIdentifierList(0);
+ PatientIdentifier pident = new PatientIdentifier();
+ if (cx != null){
+ String id = cx.getID().getValue();
+ PatientIdentifierType type = \
patientService.getPatientIdentifierTypeByName(IMMUNIZATION_REGISTRY); \
+ pident.setIdentifierType(type); + pident.setIdentifier(id);;
+ pident.setLocation(locationService.getLocation("Unknown Location"));
+ patient.addIdentifier(pident);
+ }
+ patient.addIdentifier(pident);
+
+ XAD xad = pid.getPatientAddress(0);
+ PersonAddress address = new PersonAddress();
+ if (xad != null){
+ address.setCityVillage(xad.getCity().getValue());
+ address.setAddress1(xad.getStreetAddress().getValue());
+ address.setPostalCode(xad.getZipOrPostalCode().getValue());
+ patient.addAddress(address);
+ }
+
+ }
+
+ TS dob = pid.getDateTimeOfBirth();
+
+ if (dob != null && dob.getTimeOfAnEvent() != null){
+ String dobString = dob.getTimeOfAnEvent().getValue();
+ Date birthDate = new SimpleDateFormat("yyyyMMdd", \
Locale.ENGLISH).parse(dobString); + patient.setBirthdate(birthDate);
+ }
+
+ chirpPatients.add(patient);
+
+ } catch (Exception e) {
+ log.error(Util.getStackTrace(e));
+ }
+
+ return chirpPatients;
+ }
+
+}
</ins></span></pre>
</div>
</div>
</body>
</html>
<p></p>
-- <br />
-- OpenMRS Subversion Commits: <a \
href="http://go.openmrs.org/svn">http://go.openmrs.org/svn</a><br /> Posting is not \
allowed - please join dev@openmrs.org for discussion.<br />
Unsubscribe: svn+unsubscribe@openmrs.org<br />
<p></p>
To unsubscribe from this group and stop receiving emails from it, send an email to <a \
href="mailto:svn+unsubscribe@openmrs.org">svn+unsubscribe@openmrs.org</a>.<br />
[prev in list] [next in list] [prev in thread] [next in thread]
Configure |
About |
News |
Add a list |
Sponsored by KoreLogic