Downloads Documentation Community Contribute Demo






Show Sidebar
Login | Register

Changeset 5361

Show
Ignore:
Timestamp:
08/26/08 13:46:08 (3 months ago)
Author:
nribeka
Message:

patient matching module: added flat file output for the report. modified web report view and report generator class.

Files:

Legend:

Unmodified
Added
Removed
Modified
Copied
Moved
  • openmrs-modules/patientmatching/src/org/openmrs/module/patientmatching/PatientMatchingActivator.java

    r5267 r5361  
    235235                String value = ""; 
    236236                try { 
    237                     value = BeanUtils.getProperty(patient, property); 
     237                    String classProperty = property.substring(property.lastIndexOf(".") + 1); 
     238                    value = BeanUtils.getProperty(patient, classProperty); 
    238239                } catch (Exception e) { 
    239240                    logger.debug("Error getting the value for property: " + property, e); 
  • openmrs-modules/patientmatching/web/module/dupesList.jsp

    r5321 r5361  
    3030        <table> 
    3131            <tr> 
    32                 <th>Analysis Result</th> 
     32                <th colspan="2">Analysis Result</th> 
    3333            </tr> 
     34                <c:set var="currentGroupId" value="-9999" /> 
    3435                <c:forEach items="${analysisResults}" var="analysisResult"> 
     36                    <c:choose> 
     37                        <c:when test="${currentGroupId == analysisResult['Group Id']}"> 
     38                        </c:when> 
     39                        <c:otherwise> 
     40                            <c:set var="currentGroupId" value="${analysisResult['Group Id']}" /> 
     41                            <tr> 
     42                                <td colspan="2">****************************************</td> 
     43                            </tr> 
     44                            <tr> 
     45                                <td>Group</td> 
     46                                <td><c:out value="${analysisResult['Group Id']}" /></td> 
     47                            </tr> 
     48                            <tr> 
     49                                <td colspan="2">&nbsp;</td> 
     50                            </tr> 
     51                        </c:otherwise> 
     52                    </c:choose> 
    3553                    <tr> 
    36                         <td> 
    37                             <c:out value="${analysisResult}" />. 
    38                         </td> 
     54                        <td>UID</td> 
     55                        <td><c:out value="${analysisResult['UID']}" /></td> 
     56                    </tr> 
     57                    <c:forEach var="item" items="${analysisResult}"> 
     58                        <c:if test="${item.key != 'Group Id' && item.key != 'UID'}"> 
     59                            <tr> 
     60                                <td> 
     61                                    <spring:message code="${item.key}" /> 
     62                                </td> 
     63                                <td> 
     64                                    <c:out value="${item.value}" />. 
     65                                </td> 
     66                            </tr> 
     67                        </c:if> 
     68                    </c:forEach> 
     69                    <tr> 
     70                        <td colspan="2">&nbsp;</td> 
    3971                    </tr> 
    4072                </c:forEach> 
     73            <tr> 
     74                <td colspan="2">****************************************</td> 
     75            </tr> 
    4176        </table> 
    4277</div> 
  • openmrs-modules/patientmatching/web/src/org/openmrs/module/patientmatching/web/MatchingConfigUtilities.java

    r5321 r5361  
    22 
    33import java.beans.PropertyDescriptor; 
     4import java.io.BufferedWriter; 
    45import java.io.File; 
     6import java.io.FileWriter; 
     7import java.io.IOException; 
     8import java.text.SimpleDateFormat; 
    59import java.util.ArrayList; 
     10import java.util.Arrays; 
    611import java.util.Collections; 
     12import java.util.Date; 
    713import java.util.Hashtable; 
    814import java.util.List; 
     15import java.util.Map; 
     16import java.util.TreeMap; 
    917 
    1018import org.apache.commons.beanutils.PropertyUtils; 
     
    321329    } 
    322330 
    323     public static List<String> doAnalysis()
     331    public static List<Map<String, String>> doAnalysis() throws IOException
    324332         
    325333        HibernateConnection connection = new HibernateConnection(); 
     
    360368        } 
    361369         
     370        List<String> globalIncludeColumns = new ArrayList<String>(); 
    362371        DedupMatchResultList list = new DedupMatchResultList(); 
    363372        for (MatchingConfig matchingConfig : matchingConfigLists) { 
     
    377386                list.sort(); 
    378387            } 
    379         } 
    380          
     388            List<String> blockingColumns = Arrays.asList(matchingConfig.getBlockingColumns()); 
     389            globalIncludeColumns.addAll(blockingColumns); 
     390            List<String> includeColumns = Arrays.asList(matchingConfig.getIncludedColumnsNames()); 
     391            globalIncludeColumns.addAll(includeColumns); 
     392        } 
     393 
    381394        SetSimilarityAnalysis ssa = new SetSimilarityAnalysis(); 
    382395        List<List<MatchResult>> groups = ssa.getSimilarSets(list.getResults()); 
    383396        List<List<Record>> records = ssa.getSimilarRecords(groups); 
    384          
    385         List<String> buffer = new ArrayList<String>(); 
    386         buffer.add("Possible Similar Record Sets: "); 
     397 
     398        int groupId = 0; 
     399        String separator = "|"; 
     400 
     401        SimpleDateFormat format = new SimpleDateFormat("dd-MM-yyyy"); 
     402        String dateString = format.format(new Date()); 
     403 
     404        File reportFile = new File(configFileFolder, "dedup-report-" + dateString); 
     405        BufferedWriter writer = new BufferedWriter(new FileWriter(reportFile)); 
     406 
     407        List<Map<String, String>> buffer = new ArrayList<Map<String, String>>(); 
     408         
     409        Collections.sort(globalIncludeColumns); 
     410 
    387411        for (List<Record> recordList: records) { 
    388412            for (Record r : recordList) { 
    389                 buffer.add("UID: " + r.getUID()); 
    390                 Hashtable<String, String> ht1 = r.getDemographics(); 
    391                 buffer.add("(Attribute) Phone : " + ht1.get("(Attribute) Phone") + "\t"); 
    392             } 
    393             buffer.add("----------------------------------------"); 
    394         } 
     413                 
     414                Map<String, String> displayMap = new TreeMap<String, String>(); 
     415                 
     416                String report = groupId + separator; 
     417                displayMap.put("Group Id", String.valueOf(groupId)); 
     418                 
     419                report = report + r.getUID() + separator; 
     420                displayMap.put("UID", String.valueOf(r.getUID())); 
     421                 
     422                Hashtable<String, String> h = r.getDemographics(); 
     423                for(String demographic: globalIncludeColumns) { 
     424                    report = report + h.get(demographic) + separator; 
     425                    if (demographic.indexOf(".") == -1) { 
     426                        displayMap.put(demographic, h.get(demographic)); 
     427                    } else { 
     428                        displayMap.put("patientmatching." + demographic, h.get(demographic)); 
     429                    } 
     430                } 
     431                buffer.add(displayMap); 
     432                report = report.substring(0, report.length() - 1); 
     433                writer.write(report); 
     434                writer.write(System.getProperty("line.separator")); 
     435            } 
     436            groupId ++; 
     437        } 
     438        writer.close(); 
     439         
    395440        return buffer; 
    396441    } 
  • openmrs-modules/patientmatching/web/src/org/openmrs/module/patientmatching/web/ReportSimpleFormController.java

    r5321 r5361  
    3535        protected Map<String, Object> referenceData(HttpServletRequest req) throws Exception { 
    3636             
    37         List<String> analysisResult = MatchingConfigUtilities.doAnalysis(); 
     37        List<Map<String, String>> analysisResult = MatchingConfigUtilities.doAnalysis(); 
    3838                 
    3939                Map<String, Object> requestMap = new HashMap<String, Object>();