[prev in list] [next in list] [prev in thread] [next in thread] 

List:       openmrs-svn
Subject:    [30913] openmrs-modules/chica/branches/cerner: Electronic PWS updates.
From:       svn-noreply () openmrs ! org
Date:       2014-09-17 19:14:47
Message-ID: 20140917191447.243AE4028F () 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>[30913] openmrs-modules/chica/branches/cerner: Electronic PWS updates.</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>30913</dd>
<dt>Author</dt> <dd>sjmckee</dd>
<dt>Date</dt> <dd>2014-09-17 19:14:47 +0000 (Wed, 17 Sep 2014)</dd>
</dl>

<h3>Log Message</h3>
<pre>Electronic PWS updates.</pre>

<h3>Modified Paths</h3>
<ul>
<li><a href="#openmrsmoduleschicabranchescernermetadatamoduleApplicationContextxml">op \
enmrs-modules/chica/branches/cerner/metadata/moduleApplicationContext.xml</a></li> \
<li><a href="#openmrsmoduleschicabranchescernerwebmodulepwsjsp">openmrs-modules/chica/branches/cerner/web/module/pws.jsp</a></li>
 </ul>

<h3>Added Paths</h3>
<ul>
<li><a href="#openmrsmoduleschicabranchescernerwebmodulefinishFormsWebjsp">openmrs-modules/chica/branches/cerner/web/module/finishFormsWeb.jsp</a></li>
 <li><a href="#openmrsmoduleschicabranchescernerwebmoduleformAuthenticationjsp">openmrs-modules/chica/branches/cerner/web/module/formAuthentication.jsp</a></li>
 <li><a href="#openmrsmoduleschicabranchescernerwebmoduleresourcesfinishFormsWebcss">o \
penmrs-modules/chica/branches/cerner/web/module/resources/finishFormsWeb.css</a></li> \
<li><a href="#openmrsmoduleschicabranchescernerwebsrcorgopenmrsmodulechicawebExternalF \
ormControllerjava">openmrs-modules/chica/branches/cerner/web/src/org/openmrs/module/chica/web/ExternalFormController.java</a></li>
 </ul>

</div>
<div id="patch">
<h3>Diff</h3>
<a id="openmrsmoduleschicabranchescernermetadatamoduleApplicationContextxml"></a>
<div class="modfile"><h4>Modified: \
openmrs-modules/chica/branches/cerner/metadata/moduleApplicationContext.xml (30912 => \
30913)</h4> <pre class="diff"><span>
<span class="info">--- \
openmrs-modules/chica/branches/cerner/metadata/moduleApplicationContext.xml	2014-09-17 \
                14:36:22 UTC (rev 30912)
+++ openmrs-modules/chica/branches/cerner/metadata/moduleApplicationContext.xml	2014-09-17 \
19:14:47 UTC (rev 30913) </span><span class="lines">@@ -35,6 +35,8 @@
</span><span class="cx">                 &lt;prop \
key=&quot;/module/@MODULE_ID@/sexRiskMobile.form&quot;&gt;sexRiskMobile&lt;/prop&gt; \
</span><span class="cx">                 &lt;prop \
key=&quot;/module/@MODULE_ID@/CRAFFTMobile.form&quot;&gt;CRAFFTMobile&lt;/prop&gt; \
</span><span class="cx">                 &lt;prop \
key=&quot;/module/@MODULE_ID@/pws.form&quot;&gt;pws&lt;/prop&gt; </span><ins>+        \
&lt;prop key=&quot;/module/@MODULE_ID@/finishFormsWeb.form&quot;&gt;finishFormsWeb&lt;/prop&gt;
 +                &lt;prop \
key=&quot;/module/@MODULE_ID@/formAuthentication.form&quot;&gt;formAuthentication&lt;/prop&gt;
 </ins><span class="cx">             &lt;/props&gt;
</span><span class="cx">         &lt;/property&gt;
</span><span class="cx">     &lt;/bean&gt;
</span><span class="lines">@@ -141,7 +143,7 @@
</span><span class="cx">     &lt;bean id=&quot;pws&quot; \
class=&quot;@MODULE_PACKAGE@.web.MobileFormController&quot;&gt; </span><span \
class="cx">         &lt;property \
name=&quot;commandName&quot;&gt;&lt;value&gt;pwsObject&lt;/value&gt;&lt;/property&gt; \
</span><span class="cx">         &lt;property \
name=&quot;formView&quot;&gt;&lt;value&gt;/module/@MODULE_ID@/pws&lt;/value&gt;&lt;/property&gt;
 </span><del>-        &lt;property \
name=&quot;successView&quot;&gt;&lt;value&gt;finishFormsMobile.form&lt;/value&gt;&lt;/property&gt;
 </del><ins>+        &lt;property \
name=&quot;successView&quot;&gt;&lt;value&gt;finishFormsWeb.form&lt;/value&gt;&lt;/property&gt;
 </ins><span class="cx">     &lt;/bean&gt;
</span><span class="cx">     &lt;bean id=&quot;psfMobileTabs&quot; \
class=&quot;@MODULE_PACKAGE@.web.MobileFormController&quot;&gt; </span><span \
class="cx">         &lt;property \
name=&quot;commandName&quot;&gt;&lt;value&gt;psfMobileTabsObject&lt;/value&gt;&lt;/property&gt;
 </span><span class="lines">@@ -173,6 +175,16 @@
</span><span class="cx">         &lt;property \
name=&quot;formView&quot;&gt;&lt;value&gt;/module/@MODULE_ID@/sexRiskMobile&lt;/value&gt;&lt;/property&gt;
 </span><span class="cx">         &lt;property \
name=&quot;successView&quot;&gt;&lt;value&gt;finishFormsMobile.form&lt;/value&gt;&lt;/property&gt;
 </span><span class="cx">     &lt;/bean&gt;
</span><ins>+    &lt;bean id=&quot;finishFormsWeb&quot; \
class=&quot;@MODULE_PACKAGE@.web.MobileFormsCompletionController&quot;&gt; +        \
&lt;property name=&quot;commandName&quot;&gt;&lt;value&gt;finishFormsWebObject&lt;/value&gt;&lt;/property&gt;
 +        &lt;property \
name=&quot;formView&quot;&gt;&lt;value&gt;/module/@MODULE_ID@/finishFormsWeb&lt;/value&gt;&lt;/property&gt;
 +        &lt;property \
name=&quot;successView&quot;&gt;&lt;value&gt;finishFormsWeb.form&lt;/value&gt;&lt;/property&gt;
 +    &lt;/bean&gt;
+    &lt;bean id=&quot;formAuthentication&quot; \
class=&quot;@MODULE_PACKAGE@.web.ExternalFormController&quot;&gt; +        \
&lt;property name=&quot;commandName&quot;&gt;&lt;value&gt;formAuthenticationObject&lt;/value&gt;&lt;/property&gt;
 +        &lt;property \
name=&quot;formView&quot;&gt;&lt;value&gt;/module/@MODULE_ID@/formAuthentication&lt;/value&gt;&lt;/property&gt;
 +        &lt;property \
name=&quot;successView&quot;&gt;&lt;value&gt;formAuthentication.form&lt;/value&gt;&lt;/property&gt;
 +    &lt;/bean&gt;
</ins><span class="cx">     &lt;bean parent=&quot;serviceContext&quot;&gt;
</span><span class="cx">         &lt;property name=&quot;moduleService&quot;&gt;
</span><span class="cx">             &lt;list&gt;
</span></span></pre></div>
<a id="openmrsmoduleschicabranchescernerwebmodulefinishFormsWebjsp"></a>
<div class="addfile"><h4>Added: \
openmrs-modules/chica/branches/cerner/web/module/finishFormsWeb.jsp (0 => 30913)</h4> \
<pre class="diff"><span> <span class="info">--- \
openmrs-modules/chica/branches/cerner/web/module/finishFormsWeb.jsp	                  \
                (rev 0)
+++ openmrs-modules/chica/branches/cerner/web/module/finishFormsWeb.jsp	2014-09-17 \
19:14:47 UTC (rev 30913) </span><span class="lines">@@ -0,0 +1,26 @@
</span><ins>+&lt;%@ include file=&quot;/WEB-INF/template/include.jsp&quot;%&gt;
+&lt;!DOCTYPE html&gt;
+&lt;openmrs:require allPrivileges=&quot;View Encounters, View Patients, View Concept \
Classes&quot; otherwise=&quot;/module/chica/loginMobile.form&quot; \
redirect=&quot;/module/chica/finishFormsWeb.form&quot; /&gt; +&lt;html&gt;
+&lt;head&gt;
+&lt;meta charset=&quot;utf-8&quot;&gt;
+&lt;link rel=&quot;stylesheet&quot; \
href=&quot;${pageContext.request.contextPath}/moduleResources/chica/finishFormsWeb.css&quot;&gt;
 +&lt;/head&gt;
+&lt;body&gt;
+
+&lt;div id=&quot;content&quot;&gt;
+    &lt;div&gt;
+       &lt;h2&gt;${patient.givenName} ${patient.familyName}&lt;/h2&gt;
+    &lt;/div&gt;
+
+    &lt;div&gt;
+	    &lt;div&gt;&lt;p&gt;Submission successful!  There are no more forms to complete \
for ${patient.givenName}&amp;nbsp;${patient.familyName}.  Please click \
&quot;Close&quot; to close the window.&lt;/p&gt;&lt;/div&gt; +	    &lt;br/&gt;
+	    &lt;div&gt;
+	        &lt;input type=&quot;button&quot; onclick=&quot;window.close()&quot; \
value=&quot;Close&quot; style=&quot;width: 100px;&quot;/&gt; +	    &lt;/div&gt;
+    &lt;/div&gt;
+&lt;/div&gt;
+
+&lt;/body&gt;
+&lt;/html&gt;
</ins></span></pre></div>
<a id="openmrsmoduleschicabranchescernerwebmoduleformAuthenticationjsp"></a>
<div class="addfile"><h4>Added: \
openmrs-modules/chica/branches/cerner/web/module/formAuthentication.jsp (0 => \
30913)</h4> <pre class="diff"><span>
<span class="info">--- \
openmrs-modules/chica/branches/cerner/web/module/formAuthentication.jsp	              \
                (rev 0)
+++ openmrs-modules/chica/branches/cerner/web/module/formAuthentication.jsp	2014-09-17 \
19:14:47 UTC (rev 30913) </span><span class="lines">@@ -0,0 +1,31 @@
</span><ins>+&lt;%@ include file=&quot;/WEB-INF/template/include.jsp&quot;%&gt;
+&lt;!DOCTYPE html&gt;
+&lt;openmrs:require allPrivileges=&quot;View Encounters, View Patients, View Concept \
Classes&quot; otherwise=&quot;/module/chica/loginMobile.form&quot; \
redirect=&quot;/module/chica/formAuthentication.form&quot; /&gt; +&lt;html&gt;
+&lt;head&gt;
+&lt;meta charset=&quot;utf-8&quot;&gt;
+&lt;link rel=&quot;stylesheet&quot; \
href=&quot;${pageContext.request.contextPath}/moduleResources/chica/finishFormsWeb.css&quot;&gt;
 +&lt;/head&gt;
+&lt;body&gt;
+
+&lt;div id=&quot;content&quot;&gt;
+    &lt;div&gt;
+       &lt;h2&gt;${patient.givenName} ${patient.familyName}&lt;/h2&gt;
+    &lt;/div&gt;
+
+    &lt;div&gt;
+        &lt;div&gt;&lt;p&gt;Submission successful!  There are no more forms to \
complete for ${patient.givenName}&amp;nbsp;${patient.familyName}.  Please click \
&quot;Close&quot; to close the window.&lt;/p&gt;&lt;/div&gt; +        &lt;br/&gt;
+        &lt;div&gt;
+            &lt;input type=&quot;button&quot; onclick=&quot;window.close()&quot; \
value=&quot;Close&quot; style=&quot;width: 100px;&quot;/&gt; +        &lt;/div&gt;
+    &lt;/div&gt;
+    &lt;form id=&quot;authenticationForm&quot; method=&quot;POST&quot;&gt;
+        &lt;input id=&quot;formName&quot; name=&quot;formName&quot; \
type=&quot;hidden&quot; value=&quot;${formName}&quot;/&gt; +        &lt;input \
id=&quot;formPage&quot; name=&quot;formPage&quot; type=&quot;hidden&quot; \
value=&quot;${formPage}&quot;/&gt; +        &lt;input id=&quot;mrn&quot; \
name=&quot;mrn&quot; type=&quot;hidden&quot; value=&quot;${mrn}&quot;/&gt; +    \
&lt;/form&gt; +&lt;/div&gt;
+
+&lt;/body&gt;
+&lt;/html&gt;
</ins></span></pre></div>
<a id="openmrsmoduleschicabranchescernerwebmodulepwsjsp"></a>
<div class="modfile"><h4>Modified: \
openmrs-modules/chica/branches/cerner/web/module/pws.jsp (30912 => 30913)</h4> <pre \
class="diff"><span> <span class="info">--- \
openmrs-modules/chica/branches/cerner/web/module/pws.jsp	2014-09-17 14:36:22 UTC (rev \
                30912)
+++ openmrs-modules/chica/branches/cerner/web/module/pws.jsp	2014-09-17 19:14:47 UTC \
(rev 30913) </span><span class="lines">@@ -737,6 +737,16 @@
</span><span class="cx"> 			    &lt;input type=hidden name=&quot;Choice4&quot;/&gt;
</span><span class="cx"> 			    &lt;input type=hidden name=&quot;Choice5&quot;/&gt;
</span><span class="cx"> 			    &lt;input type=hidden name=&quot;Choice6&quot;/&gt;
</span><ins>+			    &lt;input id=&quot;patientId&quot; name=&quot;patientId&quot; \
type=&quot;hidden&quot; value=&quot;${patient.patientId}&quot;/&gt; +				&lt;input \
id=&quot;encounterId&quot; name=&quot;encounterId&quot; type=&quot;hidden&quot; \
value=&quot;${encounterId}&quot;/&gt; +				&lt;input id=&quot;sessionId&quot; \
name=&quot;sessionId&quot; type=&quot;hidden&quot; \
value=&quot;${sessionId}&quot;/&gt; +				&lt;input id=&quot;formId&quot; \
name=&quot;formId&quot; type=&quot;hidden&quot; value=&quot;${formId}&quot;/&gt; \
+				&lt;input id=&quot;formInstanceId&quot; name=&quot;formInstanceId&quot; \
type=&quot;hidden&quot; value=&quot;${formInstanceId}&quot;/&gt; +				&lt;input \
id=&quot;locationId&quot; name=&quot;locationId&quot; type=&quot;hidden&quot; \
value=&quot;${locationId}&quot;/&gt; +				&lt;input id=&quot;locationTagId&quot; \
name=&quot;locationTagId&quot; type=&quot;hidden&quot; \
value=&quot;${locationTagId}&quot;/&gt; +				&lt;input id=&quot;maxElements&quot; \
name=&quot;maxElements&quot; type=&quot;hidden&quot; value=&quot;5&quot;/&gt; \
+				&lt;input id=&quot;language&quot; name=&quot;language&quot; \
type=&quot;hidden&quot; value=&quot;${language}&quot;/&gt; +				&lt;input \
id=&quot;formInstance&quot; name=&quot;formInstance&quot; type=&quot;hidden&quot; \
value=&quot;${formInstance}&quot;/&gt; </ins><span class="cx">             \
&lt;/form&gt; </span><span class="cx">     	&lt;/div&gt;
</span><span class="cx">     &lt;/body&gt;
</span></span></pre></div>
<a id="openmrsmoduleschicabranchescernerwebmoduleresourcesfinishFormsWebcss"></a>
<div class="addfile"><h4>Added: \
openmrs-modules/chica/branches/cerner/web/module/resources/finishFormsWeb.css (0 => \
30913)</h4> <pre class="diff"><span>
<span class="info">--- \
openmrs-modules/chica/branches/cerner/web/module/resources/finishFormsWeb.css	        \
                (rev 0)
+++ openmrs-modules/chica/branches/cerner/web/module/resources/finishFormsWeb.css	2014-09-17 \
19:14:47 UTC (rev 30913) </span><span class="lines">@@ -0,0 +1,15 @@
</span><ins>+body {
+    font-family:Verdana, Geneva, sans-serif;
+    font-size:13px;
+    background-color:#75A3A3;
+}
+
+#content {
+	background-color: #FFF;
+	width: 80%;
+	display: block;
+	margin-left: auto;
+	margin-right: auto;
+	text-align: center;
+	padding: 20px;
+}
</ins></span></pre></div>
<a id="openmrsmoduleschicabranchescernerwebsrcorgopenmrsmodulechicawebExternalFormControllerjava"></a>
 <div class="addfile"><h4>Added: \
openmrs-modules/chica/branches/cerner/web/src/org/openmrs/module/chica/web/ExternalFormController.java \
(0 => 30913)</h4> <pre class="diff"><span>
<span class="info">--- \
openmrs-modules/chica/branches/cerner/web/src/org/openmrs/module/chica/web/ExternalFormController.java	 \
                (rev 0)
+++ openmrs-modules/chica/branches/cerner/web/src/org/openmrs/module/chica/web/ExternalFormController.java	2014-09-17 \
19:14:47 UTC (rev 30913) </span><span class="lines">@@ -0,0 +1,155 @@
</span><ins>+/**
+ * The contents of this file are subject to the OpenMRS Public License
+ * Version 1.0 (the &quot;License&quot;); you may not use this file except in
+ * compliance with the License. You may obtain a copy of the License at
+ * http://license.openmrs.org
+ *
+ * Software distributed under the License is distributed on an &quot;AS IS&quot;
+ * basis, WITHOUT WARRANTY OF ANY KIND, either express or implied. See the
+ * License for the specific language governing rights and limitations
+ * under the License.
+ *
+ * Copyright (C) OpenMRS, LLC.  All Rights Reserved.
+ */
+package org.openmrs.module.chica.web;
+
+import java.util.ArrayList;
+import java.util.HashMap;
+import java.util.List;
+import java.util.Map;
+
+import javax.servlet.http.HttpServletRequest;
+import javax.servlet.http.HttpServletResponse;
+
+import org.hibernate.Hibernate;
+import org.openmrs.Form;
+import org.openmrs.Patient;
+import org.openmrs.PatientIdentifierType;
+import org.openmrs.api.PatientService;
+import org.openmrs.api.context.Context;
+import org.openmrs.api.context.ContextAuthenticationException;
+import org.springframework.validation.BindException;
+import org.springframework.web.servlet.ModelAndView;
+import org.springframework.web.servlet.mvc.SimpleFormController;
+
+
+/**
+ * Controller used to authenticate an external user before allowing view of a form.
+ *
+ * @author Steve McKee
+ */
+public class ExternalFormController extends SimpleFormController {
+	
+	/**
+	 * @see org.springframework.web.servlet.mvc.AbstractFormController#formBackingObject(javax.servlet.http.HttpServletRequest)
 +	 */
+	@Override
+	protected Object formBackingObject(HttpServletRequest request) throws Exception {
+		return &quot;testing&quot;;
+	}
+	
+	/**
+	 * @see org.springframework.web.servlet.mvc.SimpleFormController#referenceData(javax.servlet.http.HttpServletRequest)
 +	 */
+	@Override
+	protected Map&lt;String, Object&gt; referenceData(HttpServletRequest request) \
throws Exception { +		Map&lt;String, Object&gt; map = new HashMap&lt;String, \
Object&gt;(); +		if (Context.getAuthenticatedUser() != null) {
+			return map;
+		}
+		
+		String username = request.getParameter(&quot;username&quot;);
+		if (username == null) {
+			map.put(&quot;invalidUser&quot;, &quot;true&quot;);
+			return map;
+		}
+		
+		String password = request.getParameter(&quot;password&quot;);
+		if (password == null) {
+			map.put(&quot;invalidPassword&quot;, &quot;true&quot;);
+			return map;
+		}
+		
+		try {
+			Context.authenticate(username, password);
+		} catch (ContextAuthenticationException e) {
+			// username/password not valid
+			map.put(&quot;invalidPassword&quot;, &quot;true&quot;);
+			return map;
+		}
+		
+		String formName = request.getParameter(&quot;formName&quot;);
+		if (formName == null) {
+			map.put(&quot;missingForm&quot;, &quot;true&quot;);
+			return map;
+		}
+		
+		Form form = Context.getFormService().getForm(formName);
+		if (form == null) {
+			map.put(&quot;invalidForm&quot;, &quot;true&quot;);
+			return map;
+		}
+		
+		String formPage = request.getParameter(&quot;formPage&quot;);
+		if (formPage == null) {
+			map.put(&quot;missingFormPage&quot;, &quot;true&quot;);
+			return map;
+		}
+		
+		String mrn = request.getParameter(&quot;mrn&quot;);
+		if (mrn == null) {
+			map.put(&quot;missingMRN&quot;, &quot;true&quot;);
+			return map;
+		}
+		
+		Patient patient = getPatientByMRN(mrn);
+		if (patient == null) {
+			map.put(&quot;invalidPatient&quot;, &quot;true&quot;);
+		}
+		
+		map.put(&quot;formName&quot;, formName);
+		map.put(&quot;formPage&quot;, formPage);
+		
+		return map;
+	}
+
+	/**
+     * @see org.springframework.web.servlet.mvc.SimpleFormController#onSubmit(javax.servlet.http.HttpServletRequest, \
javax.servlet.http.HttpServletResponse, java.lang.Object, \
org.springframework.validation.BindException) +     */
+    @Override
+    protected ModelAndView onSubmit(HttpServletRequest request, HttpServletResponse \
response, Object command, +                                    BindException errors) \
throws Exception { +	    return super.onSubmit(request, response, command, errors);
+    }
+    
+    private Patient getPatientByMRN(String mrn) {
+    	PatientService patientService = Context.getPatientService();
+		List&lt;PatientIdentifierType&gt; types = new \
ArrayList&lt;PatientIdentifierType&gt;(); +	    \
types.add(patientService.getPatientIdentifierTypeByName(&quot;MRN_OTHER&quot;)); +	   \
List&lt;Patient&gt; patients = patientService.getPatients(null, mrn, types, true); +	 \
if (patients.size() &gt; 0) { +	    	Patient patient = patients.get(0);
+	    	return patient;
+	    }
+	    
+	    // Patient not found by MRN.  Try spotting a dash.
+	    int dashIndex = mrn.indexOf(&quot;-&quot;);
+	    if (dashIndex &lt; 0) {
+	    	// Place a dash in the next-to-last character position and ask again.
+	    	int length = mrn.length();
+	    	int position = length - 1;
+	    	if (position &gt;= 0) {
+	    		String firstPart = mrn.substring(0, position);
+	    		String lastPart = mrn.substring(position, length);
+	    		String newMrn = firstPart + &quot;-&quot; + lastPart;
+	    		patients = patientService.getPatients(null, newMrn, types, true);
+			    if (patients.size() &gt; 0) {
+			    	Patient patient = patients.get(0);
+			    	return patient;
+			    }
+	    	}
+	    }
+	    
+	    return null;
+    }
+}
</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