dhis2-devs team mailing list archive
-
dhis2-devs team
-
Mailing list archive
-
Message #10609
[Branch ~dhis2-devs-core/dhis2/trunk] Rev 2907: Add function "Searching patients by program".
------------------------------------------------------------
revno: 2907
committer: Tran Chau <tran.hispvietnam@xxxxxxxxx>
branch nick: dhis2
timestamp: Thu 2011-02-24 13:02:31 +0700
message:
Add function "Searching patients by program".
modified:
dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-patient/src/main/java/org/hisp/dhis/patient/action/patient/SearchPatientAction.java
dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-patient/src/main/java/org/hisp/dhis/patient/action/patient/SearchPatientFormAction.java
dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-patient/src/main/java/org/hisp/dhis/patient/action/patient/ValidateSearchPatientAction.java
dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-patient/src/main/java/org/hisp/dhis/patient/state/SelectedStateManager.java
dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-patient/src/main/resources/META-INF/dhis/beans.xml
dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-patient/src/main/resources/org/hisp/dhis/patient/i18n_module.properties
dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-patient/src/main/webapp/dhis-web-maintenance-patient/javascript/patient.js
dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-patient/src/main/webapp/dhis-web-maintenance-patient/listPatient.vm
dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-patient/src/main/webapp/dhis-web-maintenance-patient/patient.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-web/dhis-web-maintenance/dhis-web-maintenance-patient/src/main/java/org/hisp/dhis/patient/action/patient/SearchPatientAction.java'
--- dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-patient/src/main/java/org/hisp/dhis/patient/action/patient/SearchPatientAction.java 2011-01-20 05:20:01 +0000
+++ dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-patient/src/main/java/org/hisp/dhis/patient/action/patient/SearchPatientAction.java 2011-02-24 06:02:31 +0000
@@ -42,6 +42,8 @@
import org.hisp.dhis.patient.state.SelectedStateManager;
import org.hisp.dhis.patientattributevalue.PatientAttributeValue;
import org.hisp.dhis.patientattributevalue.PatientAttributeValueService;
+import org.hisp.dhis.program.Program;
+import org.hisp.dhis.program.ProgramService;
import org.hisp.dhis.relationship.Relationship;
import org.hisp.dhis.relationship.RelationshipService;
@@ -68,6 +70,8 @@
private RelationshipService relationshipService;
+ private ProgramService programService;
+
// -------------------------------------------------------------------------
// Input
// -------------------------------------------------------------------------
@@ -80,6 +84,8 @@
private Integer sortPatientAttributeId;
+ private Integer programId;
+
// -------------------------------------------------------------------------
// Output
// -------------------------------------------------------------------------
@@ -99,7 +105,11 @@
private PatientAttribute sortingPatientAttribute = null;
private PatientAttribute searchingPatientAttribute = null;
-
+
+ private Collection<Program> programs;
+
+ private Program program;
+
// -------------------------------------------------------------------------
// Getters/Setters
// -------------------------------------------------------------------------
@@ -109,16 +119,36 @@
this.selectionManager = selectionManager;
}
+ public void setProgramService( ProgramService programService )
+ {
+ this.programService = programService;
+ }
+
public void setPatientService( PatientService patientService )
{
this.patientService = patientService;
}
+ public Program getProgram()
+ {
+ return program;
+ }
+
+ public void setProgram( Program program )
+ {
+ this.program = program;
+ }
+
public Map<Patient, String> getMapPatientOrgunit()
{
return mapPatientOrgunit;
}
-
+
+ public Collection<Program> getPrograms()
+ {
+ return programs;
+ }
+
public void setPatientAttributeService( PatientAttributeService patientAttributeService )
{
this.patientAttributeService = patientAttributeService;
@@ -154,6 +184,11 @@
return searchingAttributeId;
}
+ public void setProgramId( Integer programId )
+ {
+ this.programId = programId;
+ }
+
public void setSearchingAttributeId( Integer searchingAttributeId )
{
this.searchingAttributeId = searchingAttributeId;
@@ -214,22 +249,24 @@
OrganisationUnit organisationUnit = selectionManager.getSelectedOrganisationUnit();
// ---------------------------------------------------------------------
- // Get all of Patient-Attributes
+ // Get all of Patient-Attributes
+ // and programs by selected organisation unit
// ---------------------------------------------------------------------
patientAttributes = patientAttributeService.getAllPatientAttributes();
-
- getParamsToSearch();
+ programs = programService.getPrograms( organisationUnit );
+ getParamsToSearch();
// ---------------------------------------------------------------------
// Get all of patient into the selected organisation unit
// ---------------------------------------------------------------------
-
+
if ( listAll != null && listAll )
{
selectedStateManager.clearSearchingAttributeId();
selectedStateManager.clearSortingAttributeId();
selectedStateManager.clearSearchText();
+ selectedStateManager.clearSelectedProgram();
selectedStateManager.setListAll( listAll );
listAllPatient( organisationUnit, sortingPatientAttribute );
@@ -238,6 +275,31 @@
}
// ---------------------------------------------------------------------
+ // Get patients by the selected program
+ // ---------------------------------------------------------------------
+
+ if ( searchingAttributeId != null && searchingAttributeId == 0 && programId != null )
+ {
+ program = programService.getProgram( programId );
+
+ if ( sortPatientAttributeId != null )
+ {
+ selectedStateManager.setSortingAttributeId( sortPatientAttributeId );
+ }
+ else
+ {
+ selectedStateManager.clearSortingAttributeId();
+ }
+
+ selectedStateManager.setSelectedProgram( program );
+ selectedStateManager.setSearchingAttributeId( searchingAttributeId );
+
+ searchPatientByProgram( organisationUnit, program, sortingPatientAttribute );
+
+ return SUCCESS;
+ }
+
+ // ---------------------------------------------------------------------
// Get patients by searchingAttributeId and searchText
// and sort result by sortingAttributeId
// ---------------------------------------------------------------------
@@ -246,11 +308,17 @@
{
selectedStateManager.clearListAll();
selectedStateManager.setSearchingAttributeId( searchingAttributeId );
-
- if( sortPatientAttributeId != null )
+
+ if ( sortPatientAttributeId != null )
{
selectedStateManager.setSortingAttributeId( sortPatientAttributeId );
- }else
+ }
+ else
+ {
+ selectedStateManager.clearSortingAttributeId();
+ }
+
+ if ( programId != null )
{
selectedStateManager.clearSortingAttributeId();
}
@@ -261,53 +329,63 @@
return SUCCESS;
}
-
+
if ( searchingPatientAttribute == null && searchText != null )
{
selectedStateManager.clearListAll();
-
+
selectedStateManager.clearSearchingAttributeId();
-
- if( sortPatientAttributeId != null )
+
+ if ( sortPatientAttributeId != null )
{
selectedStateManager.setSortingAttributeId( sortPatientAttributeId );
- }else
+ }
+ else
+ {
+ selectedStateManager.clearSortingAttributeId();
+ }
+
+ if ( programId != null )
{
selectedStateManager.clearSortingAttributeId();
}
-
selectedStateManager.setSearchText( searchText );
-
+
searchPatientByAttribute( searchText, sortingPatientAttribute );
-
+
return SUCCESS;
}
-
+
// ---------------------------------------------------------------------
// Search patients by values into section
// ---------------------------------------------------------------------
listAll = selectedStateManager.getListAll();
-
- if ( listAll )
- {
- listAllPatient( organisationUnit, sortingPatientAttribute );
-
- return SUCCESS;
-
- }
-
searchingAttributeId = selectedStateManager.getSearchingAttributeId();
sortPatientAttributeId = selectedStateManager.getSortAttributeId();
searchText = selectedStateManager.getSearchText();
-
+ program = selectedStateManager.getSelectedProgram();
+
getParamsToSearch();
+ if ( listAll )
+ {
+ listAllPatient( organisationUnit, sortingPatientAttribute );
+
+ return SUCCESS;
+
+ }
+
+ if ( searchingAttributeId != null && searchingAttributeId == 0 && program != null )
+ {
+ searchPatientByProgram( organisationUnit, program, sortingPatientAttribute );
+ return SUCCESS;
+ }
+
if ( searchingAttributeId != null && searchText != null )
{
searchPatientByAttribute( searchText, sortingPatientAttribute );
-
return SUCCESS;
}
@@ -316,7 +394,7 @@
searchPatientByAttribute( searchText, sortingPatientAttribute );
return SUCCESS;
}
-
+
return SUCCESS;
}
@@ -329,7 +407,7 @@
// ---------------------------------------------------------------------
// Get sorting patient-attribute
// ---------------------------------------------------------------------
-
+
if ( sortPatientAttributeId != null )
{
sortingPatientAttribute = patientAttributeService.getPatientAttribute( sortPatientAttributeId );
@@ -375,6 +453,35 @@
}
}
+ private void searchPatientByProgram( OrganisationUnit organisationUnit, Program program,
+ PatientAttribute sortingPatientAttribute )
+ {
+ total = patientService.countGetPatientsByOrgUnitProgram( organisationUnit, program );
+
+ this.paging = createPaging( total );
+
+ patients = new ArrayList<Patient>( patientService.getPatients( organisationUnit, program, paging.getStartPos(),
+ paging.getPageSize() ) );
+
+ if ( patients != null && patients.size() > 0 )
+ {
+ for ( Patient patient : patients )
+ {
+ mapRelationShip.put( patient.getId(), relationshipService.getRelationshipsForPatient( patient ) );
+
+ // Get patient-attribute-values
+ if ( sortingPatientAttribute != null )
+ {
+ PatientAttributeValue attributeValue = patientAttributeValueService.getPatientAttributeValue(
+ patient, sortingPatientAttribute );
+ String value = (attributeValue == null) ? "" : attributeValue.getValue();
+
+ mapPatientPatientAttr.put( patient, value );
+ }
+ }
+ }
+ }
+
private void searchPatientByAttribute( PatientAttribute searchingPatientAttribute, String searchText,
PatientAttribute sortingPatientAttribute )
{
=== modified file 'dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-patient/src/main/java/org/hisp/dhis/patient/action/patient/SearchPatientFormAction.java'
--- dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-patient/src/main/java/org/hisp/dhis/patient/action/patient/SearchPatientFormAction.java 2010-10-30 08:35:36 +0000
+++ dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-patient/src/main/java/org/hisp/dhis/patient/action/patient/SearchPatientFormAction.java 2011-02-24 06:02:31 +0000
@@ -33,6 +33,8 @@
import org.hisp.dhis.ouwt.manager.OrganisationUnitSelectionManager;
import org.hisp.dhis.patient.PatientAttribute;
import org.hisp.dhis.patient.PatientAttributeService;
+import org.hisp.dhis.program.Program;
+import org.hisp.dhis.program.ProgramService;
import com.opensymphony.xwork2.Action;
@@ -62,6 +64,13 @@
this.patientAttributeService = patientAttributeService;
}
+ private ProgramService programService;
+
+ public void setProgramService( ProgramService programService )
+ {
+ this.programService = programService;
+ }
+
// -------------------------------------------------------------------------
// Input/output
// -------------------------------------------------------------------------
@@ -73,17 +82,24 @@
return organisationUnit;
}
- Collection<PatientAttribute> patientAttributes;
+ private Collection<PatientAttribute> patientAttributes;
public Collection<PatientAttribute> getPatientAttributes()
{
return patientAttributes;
}
+ private Collection<Program> programs;
+
+ public Collection<Program> getPrograms()
+ {
+ return programs;
+ }
+
// -------------------------------------------------------------------------
// Action implementation
// -------------------------------------------------------------------------
-
+
public String execute()
throws Exception
{
@@ -95,6 +111,8 @@
patientAttributes = patientAttributeService.getAllPatientAttributes();
+ programs = programService.getPrograms( organisationUnit );
+
return SUCCESS;
}
}
=== modified file 'dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-patient/src/main/java/org/hisp/dhis/patient/action/patient/ValidateSearchPatientAction.java'
--- dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-patient/src/main/java/org/hisp/dhis/patient/action/patient/ValidateSearchPatientAction.java 2010-12-22 07:59:59 +0000
+++ dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-patient/src/main/java/org/hisp/dhis/patient/action/patient/ValidateSearchPatientAction.java 2011-02-24 06:02:31 +0000
@@ -61,6 +61,13 @@
this.searchText = searchText;
}
+ private Integer programId;
+
+ public void setProgramId( Integer programId )
+ {
+ this.programId = programId;
+ }
+
// -------------------------------------------------------------------------
// Output
// -------------------------------------------------------------------------
@@ -94,7 +101,7 @@
return INPUT;
}
- if ( searchText == null || searchText.trim().length() == 0 )
+ if ( ( searchText == null || searchText.trim().length() == 0 ) && programId == null )
{
message = i18n.getString( "specify_a_search_criteria" );
=== modified file 'dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-patient/src/main/java/org/hisp/dhis/patient/state/SelectedStateManager.java'
--- dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-patient/src/main/java/org/hisp/dhis/patient/state/SelectedStateManager.java 2011-01-11 10:06:47 +0000
+++ dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-patient/src/main/java/org/hisp/dhis/patient/state/SelectedStateManager.java 2011-02-24 06:02:31 +0000
@@ -66,9 +66,7 @@
ProgramStage getSelectedProgramStage();
void clearSelectedProgramStage();
-
-
-
+
// -------------------------------------------------------------------------
// for Searching patients - SearchingAttribute
// -------------------------------------------------------------------------
=== modified file 'dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-patient/src/main/resources/META-INF/dhis/beans.xml'
--- dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-patient/src/main/resources/META-INF/dhis/beans.xml 2011-02-16 02:55:58 +0000
+++ dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-patient/src/main/resources/META-INF/dhis/beans.xml 2011-02-24 06:02:31 +0000
@@ -371,6 +371,8 @@
ref="org.hisp.dhis.ouwt.manager.OrganisationUnitSelectionManager" />
<property name="patientAttributeService"
ref="org.hisp.dhis.patient.PatientAttributeService" />
+ <property name="programService"
+ ref="org.hisp.dhis.program.ProgramService" />
</bean>
<bean
@@ -395,6 +397,8 @@
ref="org.hisp.dhis.patient.PatientAttributeService" />
<property name="relationshipService"
ref="org.hisp.dhis.relationship.RelationshipService" />
+ <property name="programService"
+ ref="org.hisp.dhis.program.ProgramService" />
</bean>
<bean id="org.hisp.dhis.patient.action.patient.GetPatientAction"
=== modified file 'dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-patient/src/main/resources/org/hisp/dhis/patient/i18n_module.properties'
--- dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-patient/src/main/resources/org/hisp/dhis/patient/i18n_module.properties 2011-02-18 04:29:49 +0000
+++ dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-patient/src/main/resources/org/hisp/dhis/patient/i18n_module.properties 2011-02-24 06:02:31 +0000
@@ -454,3 +454,6 @@
patient_orgunit_registration = Benificiary Organisation Unit Registration
intro_patient_orgunit_registration = Select organisation units which can register benificiaries
can_not_register_patient_for_orgunit = Cannot register patients for the selected organisation unit.
+search_by_program = Search by Program
+select_program = Select program
+list_patients_by_program = List Beneficiaries by Program
=== modified file 'dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-patient/src/main/webapp/dhis-web-maintenance-patient/javascript/patient.js'
--- dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-patient/src/main/webapp/dhis-web-maintenance-patient/javascript/patient.js 2011-01-20 15:25:13 +0000
+++ dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-patient/src/main/webapp/dhis-web-maintenance-patient/javascript/patient.js 2011-02-24 06:02:31 +0000
@@ -22,6 +22,22 @@
return true;
}
+function searchingAttributeOnChange()
+{
+ var value = byId('searchingAttributeId').value;
+
+ if(value == '0')
+ {
+ byId('programId').style.display = 'block';
+ byId('searchText').style.display = 'none';
+ }
+ else
+ {
+ byId('searchText').style.display = 'block';
+ byId('programId').style.display = 'none';
+ byId('programId').selectedIndex = 0;
+ }
+}
//------------------------------------------------------------------------------
// Validate EnrollmentDate
@@ -241,6 +257,7 @@
{
var params = 'searchText=' + getFieldValue( 'searchText' );
+ params += "&programId=" + getFieldValue( 'programId' );
var request = new Request();
request.setResponseTypeXML( 'message' );
=== modified file 'dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-patient/src/main/webapp/dhis-web-maintenance-patient/listPatient.vm'
--- dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-patient/src/main/webapp/dhis-web-maintenance-patient/listPatient.vm 2011-01-20 05:20:01 +0000
+++ dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-patient/src/main/webapp/dhis-web-maintenance-patient/listPatient.vm 2011-02-24 06:02:31 +0000
@@ -10,7 +10,9 @@
<td> </td>
<td> </td>
<td>
- #if($!searchText)
+ #if($!program)
+ $i18n.getString( "list_patients_by_program") '$program.name'
+ #elseif($!searchText)
$searchText
#else
$i18n.getString( "list_all_patients" )
=== modified file 'dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-patient/src/main/webapp/dhis-web-maintenance-patient/patient.vm'
--- dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-patient/src/main/webapp/dhis-web-maintenance-patient/patient.vm 2011-01-20 15:25:13 +0000
+++ dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-patient/src/main/webapp/dhis-web-maintenance-patient/patient.vm 2011-02-24 06:02:31 +0000
@@ -17,15 +17,26 @@
<table>
<tr>
<td>
- <select id="searchingAttributeId" name="searchingAttributeId" style="min-width:20.2em" #if( $patientAttributes.size() == 0 ) disabled="disabled" #end>
+ <select id="searchingAttributeId" name="searchingAttributeId" style="min-width:20.2em" #if( $patientAttributes.size() == 0 ) disabled="disabled" #end onchange="searchingAttributeOnChange()">
<option value="">$i18n.getString( "search_by_name_identifier" )</option>
+ <option value="0" #if( $!searchingAttributeId && $!searchingAttributeId=='0' ) selected="selected" #end>$i18n.getString( "search_by_program" )</option>
#foreach( $attribute in $patientAttributes )
<option value="$attribute.id" #if( $!searchingAttributeId && $!attribute.id == $!searchingAttributeId ) selected="selected" #end>$encoder.htmlEncode( $attribute.name )</option>
#end
</select>
<em title="$i18n.getString( "required" )" class="required">*</em></label>
</td>
- <td><input type="text" id="searchText" name="searchText" maxlength="30" style="width:20em" value="$!searchText"></td>
+ <td>
+ <input type="text" id="searchText" name="searchText" maxlength="30" style="width:20em" value="$!searchText">
+
+ <select id="programId" name='programId' style="display:none; width:20.2em" >
+ <option value="">[ $i18n.getString('select_program') ]</option>
+ #foreach ( $p in $programs )
+ <option value="$p.id" #if( $!program && $!p.id == $!program.id ) selected="selected" #end>$p.name</option>
+ #end
+ </select>
+
+ </td>
<td><input type="submit" value="$i18n.getString( "search" )"</td>
<td> </td>
<td><input type="button" value="$i18n.getString( "add_new" )" onclick="window.location.href='showAddPatientForm.action'"></td>
@@ -55,12 +66,15 @@
<script type="text/javascript">
var i18n_none = '$encoder.jsEscape( $i18n.getString( "none" ) , "'")';
+ searchingAttributeOnChange();
+
function selectPatientAttribute()
{
var patientAttributeLB = document.getElementById('patientAttributeId');
var patientAttributeId = patientAttributeLB.options[patientAttributeLB.selectedIndex].value;
- window.location.href='listAllPatients.action?sortPatientAttributeId='+patientAttributeId;
+ window.location.href='listAllPatients.action?sortPatientAttributeId='+patientAttributeId;
}
+
</script>
\ No newline at end of file