dhis2-devs team mailing list archive
-
dhis2-devs team
-
Mailing list archive
-
Message #18139
[Branch ~dhis2-devs-core/dhis2/trunk] Rev 7527: Minor fix.
------------------------------------------------------------
revno: 7527
committer: Tran Chau <tran.hispvietnam@xxxxxxxxx>
branch nick: dhis2
timestamp: Fri 2012-07-06 20:10:53 +0700
message:
Minor fix.
modified:
dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-mobile/src/main/java/org/hisp/dhis/mobile/action/SearchPatientAction.java
dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-mobile/src/main/webapp/dhis-web-maintenance-mobile/javascript/patient.js
--
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-web/dhis-web-maintenance/dhis-web-maintenance-mobile/src/main/java/org/hisp/dhis/mobile/action/SearchPatientAction.java'
--- dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-mobile/src/main/java/org/hisp/dhis/mobile/action/SearchPatientAction.java 2012-05-09 02:52:11 +0000
+++ dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-mobile/src/main/java/org/hisp/dhis/mobile/action/SearchPatientAction.java 2012-07-06 13:10:53 +0000
@@ -37,11 +37,7 @@
import org.hisp.dhis.organisationunit.OrganisationUnit;
import org.hisp.dhis.paging.ActionPagingSupport;
import org.hisp.dhis.patient.Patient;
-import org.hisp.dhis.patient.PatientAttribute;
-import org.hisp.dhis.patient.PatientAttributeService;
import org.hisp.dhis.patient.PatientService;
-import org.hisp.dhis.patientattributevalue.PatientAttributeValue;
-import org.hisp.dhis.patientattributevalue.PatientAttributeValueService;
import org.springframework.beans.factory.annotation.Autowired;
/**
@@ -61,83 +57,64 @@
@Autowired
private PatientService patientService;
- @Autowired
- private PatientAttributeValueService patientAttributeValueService;
-
- @Autowired
- private PatientAttributeService patientAttributeService;
-
- // -------------------------------------------------------------------------
- // Input
- // -------------------------------------------------------------------------
-
- private List<String> searchText = new ArrayList<String>();
-
- private Boolean listAll;
-
- private List<Integer> searchingAttributeId = new ArrayList<Integer>();
-
- // -------------------------------------------------------------------------
- // Output
- // -------------------------------------------------------------------------
-
- private Integer total;
+ // -------------------------------------------------------------------------
+ // Input/output
+ // -------------------------------------------------------------------------
+
+ private List<String> searchTexts = new ArrayList<String>();
+
+ private Boolean searchBySelectedOrgunit;
+
+ private boolean listAll;
private Collection<Patient> patients = new ArrayList<Patient>();
- private Map<String, String> mapPatientPatientAttr = new HashMap<String, String>();
-
- private Map<Integer, String> mapPatientOrgunit = new HashMap<Integer, String>();
-
- private List<PatientAttribute> patientAttributes = new ArrayList<PatientAttribute>();
-
- // -------------------------------------------------------------------------
- // Getters/Setters
- // -------------------------------------------------------------------------
-
- public List<PatientAttribute> getPatientAttributes()
- {
- return patientAttributes;
- }
-
- public Map<Integer, String> getMapPatientOrgunit()
- {
- return mapPatientOrgunit;
- }
-
- public void setSearchText( List<String> searchText )
- {
- this.searchText = searchText;
- }
-
- public void setListAll( Boolean listAll )
+ // -------------------------------------------------------------------------
+ // Getters && Setters
+ // -------------------------------------------------------------------------
+
+ public void setSearchBySelectedOrgunit( Boolean searchBySelectedOrgunit )
+ {
+ this.searchBySelectedOrgunit = searchBySelectedOrgunit;
+ }
+
+ public void setSelectedStateManager( SelectedStateManager selectedStateManager )
+ {
+ this.selectedStateManager = selectedStateManager;
+ }
+
+ public void setPatientService( PatientService patientService )
+ {
+ this.patientService = patientService;
+ }
+
+ public void setSearchTexts( List<String> searchTexts )
+ {
+ this.searchTexts = searchTexts;
+ }
+
+ public void setListAll( boolean listAll )
{
this.listAll = listAll;
}
- public Boolean getListAll()
- {
- return listAll;
- }
-
- public void setSearchingAttributeId( List<Integer> searchingAttributeId )
- {
- this.searchingAttributeId = searchingAttributeId;
- }
-
public Collection<Patient> getPatients()
{
return patients;
}
+ private Integer total;
+
public Integer getTotal()
{
return total;
}
- public Map<String, String> getMapPatientPatientAttr()
+ private Map<Integer, String> mapPatientOrgunit = new HashMap<Integer, String>();
+
+ public Map<Integer, String> getMapPatientOrgunit()
{
- return mapPatientPatientAttr;
+ return mapPatientOrgunit;
}
// -------------------------------------------------------------------------
@@ -149,70 +126,33 @@
{
OrganisationUnit organisationUnit = selectedStateManager.getSelectedOrganisationUnit();
- // ---------------------------------------------------------------------
- // Get all of patients into the selected organisation unit
- // ---------------------------------------------------------------------
-
- if ( listAll != null && listAll )
+ // List all patients
+ if ( listAll )
{
- listAllPatient( organisationUnit );
-
- return SUCCESS;
+ total = patientService.countGetPatientsByOrgUnit( organisationUnit );
+ this.paging = createPaging( total );
+
+ patients = new ArrayList<Patient>( patientService.getPatients( organisationUnit, paging.getStartPos(),
+ paging.getPageSize() ) );
+
}
-
- // ---------------------------------------------------------------------
- // Search patients by attributes
- // ---------------------------------------------------------------------
-
- for ( Integer attributeId : searchingAttributeId )
+ // search patients
+ else if ( searchTexts.size() > 0 )
{
- if ( attributeId != null && attributeId > 0 )
+ organisationUnit = (searchBySelectedOrgunit) ? organisationUnit : null;
+
+ total = patientService.countSearchPatients( searchTexts, organisationUnit );
+ this.paging = createPaging( total );
+ patients = patientService.searchPatients( searchTexts, organisationUnit, paging.getStartPos(),
+ paging.getPageSize() );
+
+ for ( Patient patient : patients )
{
- patientAttributes.add( patientAttributeService.getPatientAttribute( attributeId ) );
+ mapPatientOrgunit.put( patient.getId(), getHierarchyOrgunit( patient.getOrganisationUnit() ) );
}
}
- searchPatientByAttributes( searchingAttributeId, searchText );
-
return SUCCESS;
-
- }
-
- // -------------------------------------------------------------------------
- // Supporting methods
- // -------------------------------------------------------------------------
-
- private void listAllPatient( OrganisationUnit organisationUnit )
- {
- total = patientService.countGetPatientsByOrgUnit( organisationUnit );
- this.paging = createPaging( total );
-
- patients = new ArrayList<Patient>( patientService.getPatients( organisationUnit, paging.getStartPos(), paging
- .getPageSize() ) );
- }
-
- private void searchPatientByAttributes( List<Integer> searchingAttributeId, List<String> searchText )
- {
- total = patientAttributeValueService.countSearchPatients( searchingAttributeId, searchText );
-
- this.paging = createPaging( total );
-
- patients = patientAttributeValueService.searchPatients( searchingAttributeId, searchText, paging.getStartPos(),
- paging.getPageSize() );
-
- Collection<PatientAttributeValue> attributeValues = patientAttributeValueService
- .getPatientAttributeValues( patients );
-
- for ( Patient patient : patients )
- {
- mapPatientOrgunit.put( patient.getId(), getHierarchyOrgunit( patient.getOrganisationUnit() ) );
-
- for ( PatientAttributeValue attributeValue : attributeValues )
- {
- mapPatientPatientAttr.put( patient.getId() + "-" + attributeValue.getPatientAttribute().getId(),
- attributeValue.getValue() );
- }
- }
}
private String getHierarchyOrgunit( OrganisationUnit orgunit )
=== modified file 'dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-mobile/src/main/webapp/dhis-web-maintenance-mobile/javascript/patient.js'
--- dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-mobile/src/main/webapp/dhis-web-maintenance-mobile/javascript/patient.js 2012-06-04 08:37:52 +0000
+++ dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-mobile/src/main/webapp/dhis-web-maintenance-mobile/javascript/patient.js 2012-07-06 13:10:53 +0000
@@ -232,10 +232,24 @@
function searchPatient()
{
+ var params = '';
+ jQuery( '#advancedSearchTB tbody tr' ).each( function( i, row ){
+ jQuery( this ).find(':input').each( function( idx, item ){
+ if( idx == 0){
+ params += "searchTexts=" + item.value;
+ }
+ else if( idx == 1){
+ params += "_" + htmlEncode( item.value.toLowerCase() );
+ }
+ })
+ });
+ params += '&listAll=false';
+ params += '&searchBySelectedOrgunit=' + byId('searchBySelectedOrgunit').checked;
+
$.ajax({
url: 'searchRegistrationPatient.action',
type:"POST",
- data: getParamsForDiv( 'advancedSearchTB' ),
+ data: params,
success: function( html ){
statusSearching = 1;
setInnerHTML( 'listPatientDiv', html );