Downloads Documentation Community Contribute Demo






Show Sidebar
Login | Register

Changeset 2687

Show
Ignore:
Timestamp:
11/21/07 05:59:41 (1 year ago)
Author:
djazayeri
Message:

doubleentryreconciliation module - version 1.0. It ain't pretty, but it works.

Files:

Legend:

Unmodified
Added
Removed
Modified
Copied
Moved
  • openmrs-modules/doubleentryreconciliation/.classpath

    r2587 r2687  
    66        <classpathentry kind="con" path="org.eclipse.jdt.launching.JRE_CONTAINER"/> 
    77        <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          
    128        <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"/> 
    149        <classpathentry kind="lib" path="lib-common/web-openmrs-api-1.1.10.2283.jar"/> 
    1510        <classpathentry kind="lib" path="lib-common/commons-logging-1.0.4.jar"/> 
     
    1712        <classpathentry kind="lib" path="lib-common/servlet-api.jar"/> 
    1813        <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"/> 
    2029        <classpathentry kind="output" path="build"/> 
    2130</classpath> 
  • openmrs-modules/doubleentryreconciliation/build.xml

    r2587 r2687  
    11<?xml version="1.0"?> 
    22<!-- ********************************************************* --> 
    3 <!-- ** Basic Module                                        ** --> 
     3<!-- ** Double Entry Reconciliation Module                  ** --> 
    44<!-- **                                                     ** --> 
    55<!-- ** @author Ben Wolfe                                   ** --> 
    66<!-- ** @version 1.0                                        ** --> 
    77<!-- ********************************************************* --> 
    8 <project name="BasicModule" default="package-module"> 
     8<project name="Double Entry Reconciliation Module" default="package-module"> 
    99                 
    1010        <!-- *********************************************************** --> 
  • openmrs-modules/doubleentryreconciliation/metadata/config.xml

    r2662 r2687  
    1616        <activator>@MODULE_PACKAGE@.DoubleEntryReconciliationActivator</activator> 
    1717         
    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
    1919        <!-- /Base Module Properties --> 
    2020         
    21         <require_version>1.1.10.2283</require_version> 
     21        <require_version>1.1.10.2582</require_version> 
    2222         
    23         <!-- Extensions  
     23        <!-- Extensions --> 
    2424        <extension> 
    2525                <point>org.openmrs.admin.list</point> 
    2626                <class>@MODULE_PACKAGE@.extension.html.AdminList</class> 
    2727        </extension> 
    28         /Extensions --> 
     28        <!-- /Extensions --> 
    2929         
    3030         
  • openmrs-modules/doubleentryreconciliation/metadata/messages.properties

    r2663 r2687  
    11@MODULE_ID@.title=Double Entry Reconciliation 
    22@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  
    1616    <!-- Controllers --> 
    1717         
    18     <bean id="reconcileeForm" class="@MODULE_PACKAGE@.web.controller.ReconcileFormController"> 
     18    <bean id="reconcileForm" class="@MODULE_PACKAGE@.web.controller.ReconcileFormController"> 
    1919        <property name="commandName"><value>reconcileForm</value></property> 
    2020        <property name="formView"><value>/module/@MODULE_ID@/reconcileForm</value></property> 
  • openmrs-modules/doubleentryreconciliation/web/module/reconcileForm.jsp

    r2428 r2687  
    33<%@ include file="/WEB-INF/template/header.jsp"%> 
    44 
    5 <h2><spring:message code="basicmodule.replace.this.link.name" /></h2> 
     5<h2><spring:message code="doubleentryreconciliation.title" /></h2> 
    66 
    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                        &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; 
     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> 
    8104 
    9105<%@ include file="/WEB-INF/template/footer.jsp"%> 
  • openmrs-modules/doubleentryreconciliation/web/src/org/openmrs/module/doubleentryreconciliation/web/controller/ReconcileFormController.java

    r2663 r2687  
    1414package org.openmrs.module.doubleentryreconciliation.web.controller; 
    1515 
     16import java.util.ArrayList; 
     17import java.util.Collections; 
    1618import java.util.HashMap; 
     19import java.util.HashSet; 
     20import java.util.List; 
    1721import java.util.Map; 
     22import java.util.Set; 
    1823 
    1924import javax.servlet.http.HttpServletRequest; 
     
    2227import org.apache.commons.logging.Log; 
    2328import org.apache.commons.logging.LogFactory; 
     29import org.openmrs.Concept; 
     30import org.openmrs.Encounter; 
     31import org.openmrs.Form; 
     32import org.openmrs.api.context.Context; 
     33import org.openmrs.module.doubleentryreconciliation.DoubleEntryReconciliationUtil; 
     34import org.openmrs.module.doubleentryreconciliation.ReconcileFormError; 
     35import org.openmrs.propertyeditor.FormEditor; 
     36import org.openmrs.util.OpenmrsUtil; 
     37import org.springframework.beans.propertyeditors.CustomNumberEditor; 
    2438import org.springframework.validation.BindException; 
    2539import org.springframework.validation.Errors; 
     40import org.springframework.web.bind.ServletRequestDataBinder; 
    2641import org.springframework.web.servlet.ModelAndView; 
    2742import org.springframework.web.servlet.mvc.SimpleFormController; 
    28 import org.springframework.web.servlet.view.RedirectView; 
    2943 
    3044/** 
     
    3650    /** Logger for this class and subclasses */ 
    3751    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     
    3960    @Override 
    4061        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; 
    4366        } 
    4467 
    4568 
    4669        @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); 
    51111                                 
    52         return new ModelAndView(new RedirectView(getSuccessView())); 
     112        return new ModelAndView(getFormView(), getCommandName(), rc); 
    53113    } 
    54114 
    55115 
    56116    /** 
    57      * This class returns the form backing object.  This can be a string, a boolean, or a normal 
    58      * java pojo. 
    59      *  
    60117     * @see org.springframework.web.servlet.mvc.AbstractFormController#formBackingObject(javax.servlet.http.HttpServletRequest) 
    61118     */ 
    62119    @Override 
    63120        protected Object formBackingObject(HttpServletRequest request) throws Exception {  
    64         return "REPLACE ME"
     121        return new ReconcileFormCommandObject()
    65122    } 
    66123