Changeset 2687
- Timestamp:
- 11/21/07 05:59:41 (1 year ago)
- Files:
-
- openmrs-modules/doubleentryreconciliation/.classpath (modified) (2 diffs)
- openmrs-modules/doubleentryreconciliation/build.xml (modified) (1 diff)
- openmrs-modules/doubleentryreconciliation/lib-common/openmrs-api-1.1.10.2283.jar (deleted)
- openmrs-modules/doubleentryreconciliation/lib-common/openmrs-api-1.1.10.2582.jar (added)
- openmrs-modules/doubleentryreconciliation/metadata/config.xml (modified) (1 diff)
- openmrs-modules/doubleentryreconciliation/metadata/messages.properties (modified) (1 diff)
- openmrs-modules/doubleentryreconciliation/metadata/moduleApplicationContext.xml (modified) (1 diff)
- openmrs-modules/doubleentryreconciliation/src/org/openmrs/module/doubleentryreconciliation/DoubleEntryReconciliationUtil.java (added)
- openmrs-modules/doubleentryreconciliation/src/org/openmrs/module/doubleentryreconciliation/ReconcileFormError.java (added)
- openmrs-modules/doubleentryreconciliation/test/org/openmrs/module/doubleentryreconciliation/DoubleEntryReconciliationUtilTest.java (added)
- openmrs-modules/doubleentryreconciliation/web/module/reconcileForm.jsp (moved) (moved from openmrs-modules/doubleentryreconciliation/web/module/basicmoduleForm.jsp) (1 diff)
- openmrs-modules/doubleentryreconciliation/web/src/org/openmrs/module/doubleentryreconciliation/web/controller/ReconcileFormCommandObject.java (added)
- openmrs-modules/doubleentryreconciliation/web/src/org/openmrs/module/doubleentryreconciliation/web/controller/ReconcileFormController.java (modified) (3 diffs)
Legend:
- Unmodified
- Added
- Removed
- Modified
- Copied
- Moved
openmrs-modules/doubleentryreconciliation/.classpath
r2587 r2687 6 6 <classpathentry kind="con" path="org.eclipse.jdt.launching.JRE_CONTAINER"/> 7 7 <classpathentry kind="lib" path="metadata"/> 8 9 <!-- Uncomment this line to be able to recognize omods placed in here for junit testing -->10 <!-- <classpathentry kind="lib" path="dist"/> -->11 12 8 <classpathentry kind="lib" path="lib-common/junit-3.8.1.jar"/> 13 <classpathentry kind="lib" path="lib-common/openmrs-api-1.1.10.2283.jar"/>14 9 <classpathentry kind="lib" path="lib-common/web-openmrs-api-1.1.10.2283.jar"/> 15 10 <classpathentry kind="lib" path="lib-common/commons-logging-1.0.4.jar"/> … … 17 12 <classpathentry kind="lib" path="lib-common/servlet-api.jar"/> 18 13 <classpathentry kind="lib" path="lib-common/hibernate3.jar"/> 19 14 <classpathentry kind="lib" path="lib-common/openmrs-api-1.1.10.2582.jar"/> 15 <classpathentry kind="lib" path="/clean-alpha/lib/mail/activation.jar"/> 16 <classpathentry kind="lib" path="/clean-alpha/lib/mail/mail.jar"/> 17 <classpathentry kind="lib" path="/clean-alpha/lib/antlr/antlr_2.7.6.jar"/> 18 <classpathentry kind="lib" path="/clean-alpha/lib/asm/asm.jar"/> 19 <classpathentry kind="lib" path="/clean-alpha/lib/c3p0/c3p0-0.9.1.jar" sourcepath="/openmrs-source/c3p0-0.9.1-pre9.zip"/> 20 <classpathentry kind="lib" path="/clean-alpha/lib/cglib/cglib-2.1_3.jar"/> 21 <classpathentry kind="lib" path="/clean-alpha/lib/commons-collections/commons-collections-3.1.jar"/> 22 <classpathentry kind="lib" path="/clean-alpha/lib/dom4j/dom4j-1.6.1.jar"/> 23 <classpathentry kind="lib" path="/clean-alpha/lib/ehcache/ehcache-1.2.4.jar" sourcepath="/openmrs-source/ehcache-1.2.4-src.zip"/> 24 <classpathentry kind="lib" path="/clean-alpha/lib/hl7api/hapi-0.5.jar"/> 25 <classpathentry kind="lib" path="/clean-alpha/lib/jakarta-log4j/log4j-1.2.13.jar"/> 26 <classpathentry kind="lib" path="/clean-alpha/lib/jta/jta.jar"/> 27 <classpathentry kind="lib" path="/clean-alpha/lib/mysql-connector-java/mysql-connector-java-3.1.10-bin.jar"/> 28 <classpathentry kind="lib" path="/clean-alpha/lib/xerces/xercesImpl.jar"/> 20 29 <classpathentry kind="output" path="build"/> 21 30 </classpath> openmrs-modules/doubleentryreconciliation/build.xml
r2587 r2687 1 1 <?xml version="1.0"?> 2 2 <!-- ********************************************************* --> 3 <!-- ** Basic Module** -->3 <!-- ** Double Entry Reconciliation Module ** --> 4 4 <!-- ** ** --> 5 5 <!-- ** @author Ben Wolfe ** --> 6 6 <!-- ** @version 1.0 ** --> 7 7 <!-- ********************************************************* --> 8 <project name=" BasicModule" default="package-module">8 <project name="Double Entry Reconciliation Module" default="package-module"> 9 9 10 10 <!-- *********************************************************** --> openmrs-modules/doubleentryreconciliation/metadata/config.xml
r2662 r2687 16 16 <activator>@MODULE_PACKAGE@.DoubleEntryReconciliationActivator</activator> 17 17 18 < !-- <updateURL>https://dev.openmrs.org/modules/download/@MODULE_ID@/update.rdf</updateURL> -->18 <updateURL>https://dev.openmrs.org/modules/download/@MODULE_ID@/update.rdf</updateURL> 19 19 <!-- /Base Module Properties --> 20 20 21 <require_version>1.1.10.2 283</require_version>21 <require_version>1.1.10.2582</require_version> 22 22 23 <!-- Extensions 23 <!-- Extensions --> 24 24 <extension> 25 25 <point>org.openmrs.admin.list</point> 26 26 <class>@MODULE_PACKAGE@.extension.html.AdminList</class> 27 27 </extension> 28 /Extensions -->28 <!-- /Extensions --> 29 29 30 30 openmrs-modules/doubleentryreconciliation/metadata/messages.properties
r2663 r2687 1 1 @MODULE_ID@.title=Double Entry Reconciliation 2 2 @MODULE_ID@.reconcile=Reconcile 3 @MODULE_ID@.reconciling=Reconciling 4 @MODULE_ID@.noErrors=No discrepencies! 5 @MODULE_ID@.noSingleEntries=No single-entered forms! 6 @MODULE_ID@.singleEnteredEncounters=Single-entered forms 7 @MODULE_ID@.doubleEnteredForms=Double-entered forms 8 @MODULE_ID@.numberWithNoErrors=Number with no errors 9 @MODULE_ID@.numberOfErrors=Number of errors 10 @MODULE_ID@.patient=Patient 11 @MODULE_ID@.date=Date 12 @MODULE_ID@.value1=Value #1 13 @MODULE_ID@.value2=Value #2 openmrs-modules/doubleentryreconciliation/metadata/moduleApplicationContext.xml
r2662 r2687 16 16 <!-- Controllers --> 17 17 18 <bean id="reconcile eForm" class="@MODULE_PACKAGE@.web.controller.ReconcileFormController">18 <bean id="reconcileForm" class="@MODULE_PACKAGE@.web.controller.ReconcileFormController"> 19 19 <property name="commandName"><value>reconcileForm</value></property> 20 20 <property name="formView"><value>/module/@MODULE_ID@/reconcileForm</value></property> openmrs-modules/doubleentryreconciliation/web/module/reconcileForm.jsp
r2428 r2687 3 3 <%@ include file="/WEB-INF/template/header.jsp"%> 4 4 5 <h2><spring:message code=" basicmodule.replace.this.link.name" /></h2>5 <h2><spring:message code="doubleentryreconciliation.title" /></h2> 6 6 7 Hello, world! 7 <c:if test="${reconcileForm.errors == null}"> 8 <form method="post"> 9 <spring:bind path="reconcileForm.form"> 10 <select name="${status.expression}"> 11 <option value=""></option> 12 <c:forEach var="form" items="${forms}"> 13 <option value="${form.formId}"<c:if test="${form == status.value}"> selected="true"</c:if>>${form.name}</option> 14 </c:forEach> 15 </select> 16 </spring:bind> 17 <input type="submit" value="<spring:message code="doubleentryreconciliation.reconcile" />"> 18 </form> 19 </c:if> 20 21 <c:if test="${reconcileForm.errors != null || reconcileForm.doubleEntryOkay != null}"> 22 <h3><spring:message code="doubleentryreconciliation.reconciling" /> ${reconcileForm.form.name} (${reconcileForm.form.formId}) ...</h3> 23 24 <div style="border: 1px black solid; margin: 5px"> 25 <div style="text-align: center; border-bottom: 1px black solid"> 26 <h3><spring:message code="doubleentryreconciliation.doubleEnteredForms" /></h3> 27 </div> 28 29 <c:if test="${reconcileForm.doubleEntryOkay != null}"> 30 <br/><br/> 31 <b> 32 <spring:message code="doubleentryreconciliation.numberWithNoErrors" />: ${fn:length(reconcileForm.doubleEntryOkay)} 33 </b> 34 </c:if> 35 36 <c:if test="${reconcileForm.errors != null}"> 37 38 <b> 39 <spring:message code="doubleentryreconciliation.numberOfErrors" />: ${fn:length(reconcileForm.errors)} 40 </b> 41 <c:if test="${fn:length(reconcileForm.errors) > 0}"> 42 <br/><br/> 43 <table> 44 <tr> 45 <th><spring:message code="doubleentryreconciliation.patient" /></th> 46 <th><spring:message code="doubleentryreconciliation.date" /></th> 47 <th><spring:message code="doubleentryreconciliation.value1" /></th> 48 <th><spring:message code="doubleentryreconciliation.value2" /></th> 49 </tr> 50 <c:set var="lastPatientId" value="-1"/> 51 <c:forEach var="err" items="${reconcileForm.errors}"> 52 <tr <c:if test="${err.patient.patientId != lastPatientId}"> style="background-color: #e0e0e0"</c:if>> 53 <td>${err.patient}</td> 54 <td><openmrs:formatDate date="${err.encounterDatetime}"/></td> 55 <td> 56 <a target="doubleEntryReconcilePopup" href="${pageContext.request.contextPath}/admin/encounters/encounter.form?encounterId=${err.encounter1.encounterId}"> 57 [<spring:message code="general.edit"/>] 58 </a> 59 ${err.value1} 60 </td> 61 <td> 62 <a target="doubleEntryReconcilePopup" href="${pageContext.request.contextPath}/admin/encounters/encounter.form?encounterId=${err.encounter2.encounterId}"> 63 [<spring:message code="general.edit"/>] 64 </a> 65 ${err.value2} 66 </td> 67 </tr> 68 <c:set var="lastPatientId" value="${err.patient.patientId}"/> 69 </c:forEach> 70 </table> 71 </c:if> 72 </c:if> 73 74 </div> 75 </c:if> 76 77 <c:if test="${reconcileForm.singleEnteredEncounters != null}"> 78 <br/> 79 <br/> 80 <br/> 81 <div style="border: 1px black solid; margin: 5px"> 82 <div style="text-align: center; border-bottom: 1px black solid"> 83 <h3><spring:message code="doubleentryreconciliation.singleEnteredEncounters" /></h3> 84 </div> 85 86 <c:if test="${fn:length(reconcileForm.singleEnteredEncounters) == 0}"> 87 <b><spring:message code="doubleentryreconciliation.noSingleEntries"/></b> 88 </c:if> 89 <c:if test="${fn:length(reconcileForm.singleEnteredEncounters) > 0}"> 90 <table> 91 <c:forEach var="enc" items="${reconcileForm.singleEnteredEncounters}"> 92 <tr> 93 <td> 94 <a target="doubleEntryReconcilePopup" href="${pageContext.request.contextPath}/admin/encounters/encounter.form?encounterId=${enc.encounterId}"> 95 ${enc.patient} <spring:message code="general.onDate"/> <openmrs:formatDate date="${enc.encounterDatetime}"/> 96 </a> 97 </td> 98 </tr> 99 </c:forEach> 100 </table> 101 </c:if> 102 </div> 103 </c:if> 8 104 9 105 <%@ include file="/WEB-INF/template/footer.jsp"%> openmrs-modules/doubleentryreconciliation/web/src/org/openmrs/module/doubleentryreconciliation/web/controller/ReconcileFormController.java
r2663 r2687 14 14 package org.openmrs.module.doubleentryreconciliation.web.controller; 15 15 16 import java.util.ArrayList; 17 import java.util.Collections; 16 18 import java.util.HashMap; 19 import java.util.HashSet; 20 import java.util.List; 17 21 import java.util.Map; 22 import java.util.Set; 18 23 19 24 import javax.servlet.http.HttpServletRequest; … … 22 27 import org.apache.commons.logging.Log; 23 28 import org.apache.commons.logging.LogFactory; 29 import org.openmrs.Concept; 30 import org.openmrs.Encounter; 31 import org.openmrs.Form; 32 import org.openmrs.api.context.Context; 33 import org.openmrs.module.doubleentryreconciliation.DoubleEntryReconciliationUtil; 34 import org.openmrs.module.doubleentryreconciliation.ReconcileFormError; 35 import org.openmrs.propertyeditor.FormEditor; 36 import org.openmrs.util.OpenmrsUtil; 37 import org.springframework.beans.propertyeditors.CustomNumberEditor; 24 38 import org.springframework.validation.BindException; 25 39 import org.springframework.validation.Errors; 40 import org.springframework.web.bind.ServletRequestDataBinder; 26 41 import org.springframework.web.servlet.ModelAndView; 27 42 import org.springframework.web.servlet.mvc.SimpleFormController; 28 import org.springframework.web.servlet.view.RedirectView;29 43 30 44 /** … … 36 50 /** Logger for this class and subclasses */ 37 51 protected final Log log = LogFactory.getLog(getClass()); 38 52 53 protected void initBinder(HttpServletRequest request, ServletRequestDataBinder binder) throws Exception { 54 super.initBinder(request, binder); 55 binder.registerCustomEditor(java.lang.Integer.class, 56 new CustomNumberEditor(java.lang.Integer.class, true)); 57 binder.registerCustomEditor(Form.class, new FormEditor()); 58 } 59 39 60 @Override 40 61 protected Map<String, Object> referenceData(HttpServletRequest request, Object obj, Errors err) throws Exception { 41 42 return new HashMap<String,Object>(); 62 Map<String, Object> ret = new HashMap<String, Object>(); 63 if (Context.isAuthenticated()) 64 ret.put("forms", Context.getFormService().getForms()); 65 return ret; 43 66 } 44 67 45 68 46 69 @Override 47 protected ModelAndView onSubmit(HttpServletRequest request, HttpServletResponse response, Object object, BindException exceptions) throws Exception { 48 //HttpSession httpSession = request.getSession(); 49 50 //MessageSourceAccessor msa = getMessageSourceAccessor(); 70 protected ModelAndView onSubmit(HttpServletRequest request, HttpServletResponse response, Object command, BindException errors) throws Exception { 71 ReconcileFormCommandObject rc = (ReconcileFormCommandObject) command; 72 73 Set<Concept> toIgnore = new HashSet<Concept>(); 74 { 75 String ignoreString = Context.getAdministrationService().getGlobalProperty("doubleentryreconciliation.ignoreConcepts"); 76 if (ignoreString != null && ignoreString.length() > 0) 77 toIgnore.addAll(OpenmrsUtil.conceptListHelper(ignoreString)); 78 } 79 log.debug("ignoring " + toIgnore.size() + " concepts"); 80 81 Map<String, List<Encounter>> byPatientAndDate = new HashMap<String, List<Encounter>>(); 82 for (Encounter e : Context.getEncounterService().getEncounters(null, null, null, null, Collections.singleton(rc.getForm()), null, false)) { 83 String key = e.getPatientId() + "." + e.getEncounterDatetime().getTime(); 84 List<Encounter> list = byPatientAndDate.get(key); 85 if (list == null) { 86 list = new ArrayList<Encounter>(); 87 byPatientAndDate.put(key, list); 88 } 89 list.add(e); 90 } 91 92 List<Encounter> doubleEntryOk = new ArrayList<Encounter>(); 93 List<Encounter> singleEntered = new ArrayList<Encounter>(); 94 List<ReconcileFormError> differences = new ArrayList<ReconcileFormError>(); 95 96 for (List<Encounter> list : byPatientAndDate.values()) { 97 if (list.size() == 1) { 98 singleEntered.add(list.get(0)); 99 continue; 100 } 101 List<ReconcileFormError> errs = DoubleEntryReconciliationUtil.findDiscrepancies(list, toIgnore); 102 if (errs == null || errs.size() == 0) 103 doubleEntryOk.add(list.get(0)); 104 else 105 differences.addAll(errs); 106 } 107 108 rc.setErrors(differences); 109 rc.setSingleEnteredEncounters(singleEntered); 110 rc.setDoubleEntryOkay(doubleEntryOk); 51 111 52 return new ModelAndView( new RedirectView(getSuccessView()));112 return new ModelAndView(getFormView(), getCommandName(), rc); 53 113 } 54 114 55 115 56 116 /** 57 * This class returns the form backing object. This can be a string, a boolean, or a normal58 * java pojo.59 *60 117 * @see org.springframework.web.servlet.mvc.AbstractFormController#formBackingObject(javax.servlet.http.HttpServletRequest) 61 118 */ 62 119 @Override 63 120 protected Object formBackingObject(HttpServletRequest request) throws Exception { 64 return "REPLACE ME";121 return new ReconcileFormCommandObject(); 65 122 } 66 123