------------------------------------------------------------ revno: 4249 committer: Tran Chau <tran.hispviet...@gmail.com> branch nick: dhis2 timestamp: Wed 2011-08-03 14:44:26 +0700 message: Add hierarchy orgunit for searching patients in caseentry module. modified: dhis-2/dhis-services/dhis-service-patient/src/main/java/org/hisp/dhis/patientattributevalue/hibernate/HibernatePatientAttributeValueStore.java dhis-2/dhis-web/dhis-web-caseentry/src/main/java/org/hisp/dhis/caseentry/action/caseentry/SearchPatientAction.java dhis-2/dhis-web/dhis-web-caseentry/src/main/resources/org/hisp/dhis/caseentry/i18n_module.properties dhis-2/dhis-web/dhis-web-caseentry/src/main/webapp/dhis-web-caseentry/listPatient.vm dhis-2/dhis-web/dhis-web-caseentry/src/main/webapp/dhis-web-caseentry/select.vm
-- lp:dhis2 https://code.launchpad.net/~dhis2-devs-core/dhis2/trunk Your team DHIS 2 developers is subscribed to branch lp:dhis2. To unsubscribe from this branch go to https://code.launchpad.net/~dhis2-devs-core/dhis2/trunk/+edit-subscription
=== modified file 'dhis-2/dhis-services/dhis-service-patient/src/main/java/org/hisp/dhis/patientattributevalue/hibernate/HibernatePatientAttributeValueStore.java' --- dhis-2/dhis-services/dhis-service-patient/src/main/java/org/hisp/dhis/patientattributevalue/hibernate/HibernatePatientAttributeValueStore.java 2011-08-03 02:51:23 +0000 +++ dhis-2/dhis-services/dhis-service-patient/src/main/java/org/hisp/dhis/patientattributevalue/hibernate/HibernatePatientAttributeValueStore.java 2011-08-03 07:44:26 +0000 @@ -28,7 +28,6 @@ import java.util.Collection; import java.util.List; -import java.util.Map; import org.hibernate.Query; import org.hibernate.criterion.Projections; @@ -156,7 +155,7 @@ public Collection<Patient> searchPatients( List<Integer> patientAttributeIds, List<String> searchTexts, int min, int max ) { - String hql = "SELECT pav.patient FROM PatientAttributeValue as pav WHERE pav.patient in "; + String hql = "SELECT DISTINCT pav.patient FROM PatientAttributeValue as pav WHERE pav.patient in "; String end = ""; int index = 0; @@ -178,7 +177,7 @@ public int countSearchPatients( List<Integer> patientAttributeIds, List<String> searchTexts ) { - String hql = "SELECT COUNT( pav.patient ) FROM PatientAttributeValue as pav WHERE pav.patient in "; + String hql = "SELECT COUNT( DISTINCT pav.patient ) FROM PatientAttributeValue as pav WHERE pav.patient in "; String end = ""; int index = 0; @@ -201,7 +200,7 @@ // ------------------------------------------------------------------------- // Supportive methods // ------------------------------------------------------------------------- - + private String createHQL( Integer patientAttributeId, String searchText, int index, int noCondition ) { String hql = ""; @@ -213,12 +212,6 @@ // --------------------------------------------------------------------- if ( patientAttributeId == null ) { -// hql += " ( SELECT p" + index + " FROM Patient as p" + index + " JOIN p" + index -// + ".identifiers as identifier" + index + " " + "WHERE lower(identifier" + index -// + ".identifier) LIKE lower('%" + searchText + "%') " + "OR lower(p" + index -// + ".firstName) LIKE lower('%" + searchText + "%') " + "OR lower(p" + index -// + ".middleName) LIKE lower('%" + searchText + "%') " + "OR lower(p" + index -// + ".lastName) LIKE lower('%" + searchText + "%') "; int startIndex = searchText.indexOf( ' ' ); int endIndex = searchText.lastIndexOf( ' ' ); @@ -240,13 +233,12 @@ lastName = searchText.substring( endIndex + 1, searchText.length() ); } } - + hql += " ( SELECT p" + index + " FROM Patient as p" + index + " JOIN p" + index + ".identifiers as identifier" + index + " " + "WHERE lower(identifier" + index + ".identifier) LIKE lower('%" + searchText + "%') " + "OR (lower(p" + index - + ".firstName) LIKE lower('%" + firstName + "%') " + "AND lower(p" + index - + ".middleName) = lower('" + middleName + "') " + "AND lower(p" + index - + ".lastName) LIKE lower('%" + lastName + "%')) "; + + ".firstName) LIKE lower('%" + firstName + "%') " + "AND lower(p" + index + ".middleName) = lower('" + + middleName + "') " + "AND lower(p" + index + ".lastName) LIKE lower('%" + lastName + "%')) "; isSearchByAttribute = false; } === modified file 'dhis-2/dhis-web/dhis-web-caseentry/src/main/java/org/hisp/dhis/caseentry/action/caseentry/SearchPatientAction.java' --- dhis-2/dhis-web/dhis-web-caseentry/src/main/java/org/hisp/dhis/caseentry/action/caseentry/SearchPatientAction.java 2011-07-25 02:08:33 +0000 +++ dhis-2/dhis-web/dhis-web-caseentry/src/main/java/org/hisp/dhis/caseentry/action/caseentry/SearchPatientAction.java 2011-08-03 07:44:26 +0000 @@ -29,6 +29,8 @@ import java.util.ArrayList; import java.util.Collection; +import java.util.HashMap; +import java.util.Map; import org.hisp.dhis.organisationunit.OrganisationUnit; import org.hisp.dhis.ouwt.manager.OrganisationUnitSelectionManager; @@ -70,6 +72,8 @@ private Collection<Patient> patients = new ArrayList<Patient>(); + private Map<Integer, String> mapPatientOrgunit = new HashMap<Integer, String>(); + // ------------------------------------------------------------------------- // Getters && Setters // ------------------------------------------------------------------------- @@ -94,6 +98,11 @@ this.patientAttributeValueService = patientAttributeValueService; } + public Map<Integer, String> getMapPatientOrgunit() + { + return mapPatientOrgunit; + } + public void setSearchText( String searchText ) { this.searchText = searchText; @@ -170,15 +179,38 @@ patients = patientAttributeValueService.searchPatients( searchingPatientAttribute, searchText, paging .getStartPos(), paging.getPageSize() ); - - return SUCCESS; - } - - total = patientService.countGetPatients( searchText ); - this.paging = createPaging( total ); - - patients = patientService.getPatients( searchText, paging.getStartPos(), paging.getPageSize() ); - + } + else + { + total = patientService.countGetPatients( searchText ); + this.paging = createPaging( total ); + + patients = patientService.getPatients( searchText, paging.getStartPos(), paging.getPageSize() ); + } + + for ( Patient patient : patients ) + { + mapPatientOrgunit.put( patient.getId(), getHierarchyOrgunit( patient.getOrganisationUnit() ) ); + } + return SUCCESS; } + + // ------------------------------------------------------------------------- + // Supportive method + // ------------------------------------------------------------------------- + + private String getHierarchyOrgunit( OrganisationUnit orgunit ) + { + String hierarchyOrgunit = orgunit.getName(); + + while ( orgunit.getParent() != null ) + { + hierarchyOrgunit = orgunit.getParent().getName() + " / " + hierarchyOrgunit; + + orgunit = orgunit.getParent(); + } + + return hierarchyOrgunit; + } } === modified file 'dhis-2/dhis-web/dhis-web-caseentry/src/main/resources/org/hisp/dhis/caseentry/i18n_module.properties' --- dhis-2/dhis-web/dhis-web-caseentry/src/main/resources/org/hisp/dhis/caseentry/i18n_module.properties 2011-07-27 03:07:45 +0000 +++ dhis-2/dhis-web/dhis-web-caseentry/src/main/resources/org/hisp/dhis/caseentry/i18n_module.properties 2011-08-03 07:44:26 +0000 @@ -311,3 +311,4 @@ select_sorting_attribute = Select a specfied attribute / ALL no_result = No result filter_by = Filter by +hierachy_orgunit = Hierarchy Organisation Unit \ No newline at end of file === modified file 'dhis-2/dhis-web/dhis-web-caseentry/src/main/webapp/dhis-web-caseentry/listPatient.vm' --- dhis-2/dhis-web/dhis-web-caseentry/src/main/webapp/dhis-web-caseentry/listPatient.vm 2011-07-25 02:08:33 +0000 +++ dhis-2/dhis-web/dhis-web-caseentry/src/main/webapp/dhis-web-caseentry/listPatient.vm 2011-08-03 07:44:26 +0000 @@ -17,9 +17,12 @@ <col> <col> <col> - <col> - <col width="20"> - <col width="20"> + <col> + #if($mapPatientOrgunit.size()!=0) + <col/> + #end + <col width="20"> + <col width="20"> <tr> <td></td> <td></td> @@ -35,7 +38,10 @@ <th>$i18n.getString( "last_name" )</th> <th>$i18n.getString( "gender" )</th> <th>$i18n.getString( "date_of_birth" )</th> - <th>$i18n.getString( "age" )</th> + <th>$i18n.getString( "age" )</th> + #if($mapPatientOrgunit.size()!=0) + <th>$i18n.getString( "hierachy_orgunit" )</th> + #end <th colspan="2">$i18n.getString( "operations" )</th> </tr> @@ -61,7 +67,11 @@ </td> <td> $encoder.htmlEncode( $patient.getAge() ) - </td> + </td> + #if($mapPatientOrgunit.size()!=0) + <td>$!mapPatientOrgunit.get($patient.id)</td> + #end + <td style="text-align:center"#alternate( $mark )> <a href="javascript:showSelectedDataRecoding('$patient.id');" title="$i18n.getString( 'data_entry' )"><img src="images/data_entry.png" alt="$i18n.getString( 'data_entry' )"></a> </td> === modified file 'dhis-2/dhis-web/dhis-web-caseentry/src/main/webapp/dhis-web-caseentry/select.vm' --- dhis-2/dhis-web/dhis-web-caseentry/src/main/webapp/dhis-web-caseentry/select.vm 2011-07-25 02:08:33 +0000 +++ dhis-2/dhis-web/dhis-web-caseentry/src/main/webapp/dhis-web-caseentry/select.vm 2011-08-03 07:44:26 +0000 @@ -9,7 +9,7 @@ </td> <td> </td> <td> - <input type="button" id='listPatientBtn' value="$i18n.getString( "list_all_patients" )" onclick="javascript:listAllPatient();" #if($organisationUnit) #else disabled #end> + <input type="button" id='listPatientBtn' value="$i18n.getString( 'list_all_patients' )" onclick="javascript:listAllPatient();" #if($organisationUnit) #else disabled #end> </td> </tr> </table> @@ -19,7 +19,7 @@ <table> <tr> <td> - <select id="searchingAttributeId" name="searchingAttributeId" style="min-width:300px" #if( $patientAttributes.size() == 0 ) disabled="disabled" #end #if($organisationUnit) #else disabled #end> + <select id="searchingAttributeId" name="searchingAttributeId" style="min-width:300px" #if($organisationUnit) #else disabled #end> <option value="">$i18n.getString( "search_by_name_identifier" )</option> #foreach( $attribute in $patientAttributes ) <option value="$attribute.id" #if( $searchingAttributeId && $attribute.id == $searchingAttributeId ) selected="selected" #end>$encoder.htmlEncode( $attribute.name )</option>
_______________________________________________ Mailing list: https://launchpad.net/~dhis2-devs Post to : dhis2-devs@lists.launchpad.net Unsubscribe : https://launchpad.net/~dhis2-devs More help : https://help.launchpad.net/ListHelp