dhis2-devs team mailing list archive
-
dhis2-devs team
-
Mailing list archive
-
Message #30016
[Branch ~dhis2-devs-core/dhis2/trunk] Rev 15225: [mobile] correct usage of Grid object
------------------------------------------------------------
revno: 15225
committer: Long <long.hispvietnam@xxxxxxxxx>
branch nick: trunk
timestamp: Mon 2014-05-12 16:15:31 +0700
message:
[mobile] correct usage of Grid object
modified:
dhis-2/dhis-services/dhis-service-mobile/src/main/java/org/hisp/dhis/mobile/service/ActivityReportingServiceImpl.java
dhis-2/dhis-web/dhis-web-light/src/main/java/org/hisp/dhis/light/namebaseddataentry/action/FindBeneficiarytAction.java
dhis-2/dhis-web/dhis-web-light/src/main/java/org/hisp/dhis/light/namebaseddataentry/action/GetPatientProgramListAction.java
dhis-2/dhis-web/dhis-web-light/src/main/resources/META-INF/dhis/beans.xml
dhis-2/dhis-web/dhis-web-light/src/main/resources/struts.xml
dhis-2/dhis-web/dhis-web-light/src/main/webapp/dhis-web-light/namebased/beneficiaryList.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-mobile/src/main/java/org/hisp/dhis/mobile/service/ActivityReportingServiceImpl.java'
--- dhis-2/dhis-services/dhis-service-mobile/src/main/java/org/hisp/dhis/mobile/service/ActivityReportingServiceImpl.java 2014-05-12 06:45:39 +0000
+++ dhis-2/dhis-services/dhis-service-mobile/src/main/java/org/hisp/dhis/mobile/service/ActivityReportingServiceImpl.java 2014-05-12 09:15:31 +0000
@@ -60,6 +60,7 @@
import org.hisp.dhis.api.mobile.model.LWUITmodel.Section;
import org.hisp.dhis.api.mobile.model.comparator.ActivityComparator;
import org.hisp.dhis.common.Grid;
+import org.hisp.dhis.common.QueryItem;
import org.hisp.dhis.dataelement.DataElement;
import org.hisp.dhis.dataelement.DataElementService;
import org.hisp.dhis.event.EventStatus;
@@ -313,15 +314,23 @@
{
List<Activity> items = new ArrayList<Activity>();
- Collection<TrackedEntityInstance> patients = entityInstanceService.getTrackedEntityInstances( unit, 0,
- Integer.MAX_VALUE );
-
- for ( TrackedEntityInstance patient : patients )
+
+ TrackedEntityInstanceQueryParams param = new TrackedEntityInstanceQueryParams();
+ param.addOrganisationUnit( unit );
+
+ Grid trackedEntityDrid = entityInstanceService.getTrackedEntityInstances( param );
+ List<List<Object>> listOfListProgramStageInstance = trackedEntityDrid.getRows();
+
+ for ( List<Object> listProgramStageInstance : listOfListProgramStageInstance )
{
- for ( ProgramStageInstance programStageInstance : programStageInstanceService.getProgramStageInstances(
- patient, false ) )
+ for ( Object obj : listProgramStageInstance )
{
- items.add( getActivity( programStageInstance, false ) );
+ TrackedEntityInstance patient = (TrackedEntityInstance) obj;
+ for ( ProgramStageInstance programStageInstance : programStageInstanceService.getProgramStageInstances(
+ patient, false ) )
+ {
+ items.add( getActivity( programStageInstance, false ) );
+ }
}
}
@@ -767,7 +776,7 @@
{
patientModel.setOrganisationUnitName( patient.getOrganisationUnit().getName() );
}
-
+
if ( patient.getTrackedEntity() != null )
{
patientModel.setTrackedEntityName( patient.getTrackedEntity().getName() );
@@ -1632,35 +1641,19 @@
{
String[] searchEventInfosArray = searchEventInfos.split( "-" );
- int programStageStatus = 0;
+ EventStatus eventStatus = EventStatus.ACTIVE;
if ( searchEventInfosArray[1].equalsIgnoreCase( "Scheduled in future" ) )
{
- programStageStatus = ProgramStageInstance.FUTURE_VISIT_STATUS;
+ eventStatus = EventStatus.FUTURE_VISIT;
}
else if ( searchEventInfosArray[1].equalsIgnoreCase( "Overdue" ) )
{
- programStageStatus = ProgramStageInstance.LATE_VISIT_STATUS;
- }
-
- boolean followUp;
-
- if ( searchEventInfosArray[2].equalsIgnoreCase( "true" ) )
- {
- followUp = true;
- }
- else
- {
- followUp = false;
+ eventStatus = EventStatus.LATE_VISIT;
}
String eventsInfo = "";
- DateFormat formatter = new SimpleDateFormat( "yyyy-MM-dd" );
-
- List<String> searchTextList = new ArrayList<String>();
- Collection<OrganisationUnit> orgUnitList = new HashSet<OrganisationUnit>();
-
Calendar toCalendar = new GregorianCalendar();
toCalendar.add( Calendar.DATE, -1 );
toCalendar.add( Calendar.YEAR, 100 );
@@ -1672,36 +1665,41 @@
Date fromDate = fromCalendar.getTime();
- String searchText = TrackedEntityInstance.PREFIX_PROGRAM_EVENT_BY_STATUS + "_" + searchEventInfosArray[0] + "_"
- + formatter.format( fromDate ) + "_" + formatter.format( toDate ) + "_" + orgUnitId + "_" + true + "_"
- + programStageStatus;
-
- searchTextList.add( searchText );
- orgUnitList.add( organisationUnitService.getOrganisationUnit( orgUnitId ) );
-
TrackedEntityInstanceQueryParams param = new TrackedEntityInstanceQueryParams();
- param.setOrganisationUnits( new HashSet<OrganisationUnit>( orgUnitList ) );
- param.setEventStatus( EventStatus.ACTIVE );
+ List<TrackedEntityAttribute> trackedEntityAttributeList = new ArrayList<TrackedEntityAttribute>(
+ attributeService.getTrackedEntityAttributesByDisplayOnVisitSchedule( true ) );
+
+ for ( TrackedEntityAttribute trackedEntityAttribute : trackedEntityAttributeList )
+ {
+ QueryItem queryItem = new QueryItem( trackedEntityAttribute );
+ param.addAttribute( queryItem );
+ }
+
+ param.addOrganisationUnit( organisationUnitService.getOrganisationUnit( orgUnitId ) );
+ param.setEventStatus( eventStatus );
+ param.setEventStartDate( fromDate );
+ param.setEventEndDate( toDate );
Grid programStageInstanceGrid = entityInstanceService.getTrackedEntityInstances( param );
- List<List<Object>> listOfListProgramStageInstance = programStageInstanceGrid.getRows();
+ List<List<Object>> rows = programStageInstanceGrid.getRows();
- if ( listOfListProgramStageInstance.size() == 0 )
+ if ( rows.size() == 0 )
{
throw NotAllowedException.NO_EVENT_FOUND;
}
- else if ( listOfListProgramStageInstance.size() > 0 )
+ else if ( rows.size() > 0 )
{
- for ( List<Object> listProgramStageInstance : listOfListProgramStageInstance )
+ for ( List<Object> row : rows )
{
- for ( Object obj : listProgramStageInstance )
+ for ( int i = 5; i < row.size(); i++ )
{
- ProgramStageInstance programStageInstance = (ProgramStageInstance) obj;
- TrackedEntityInstance patient = programStageInstance.getProgramInstance().getEntityInstance();
- eventsInfo += programStageInstance.getId() + "/" + patient.getName() + ", "
- + programStageInstance.getProgramStage().getName() + "("
- + formatter.format( programStageInstance.getDueDate() ) + ")" + "$";
+ eventsInfo += row.get( i ) + "/";
+ if ( i == row.size() - 1 )
+ {
+ eventsInfo += "$";
+ }
}
+
}
throw new NotAllowedException( eventsInfo );
=== modified file 'dhis-2/dhis-web/dhis-web-light/src/main/java/org/hisp/dhis/light/namebaseddataentry/action/FindBeneficiarytAction.java'
--- dhis-2/dhis-web/dhis-web-light/src/main/java/org/hisp/dhis/light/namebaseddataentry/action/FindBeneficiarytAction.java 2014-03-18 08:10:10 +0000
+++ dhis-2/dhis-web/dhis-web-light/src/main/java/org/hisp/dhis/light/namebaseddataentry/action/FindBeneficiarytAction.java 2014-05-12 09:15:31 +0000
@@ -28,11 +28,17 @@
* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/
-import java.util.Collection;
-import java.util.HashSet;
+
+import java.util.List;
import java.util.Set;
-import org.hisp.dhis.trackedentity.TrackedEntityInstance;
+import org.hisp.dhis.common.Grid;
+import org.hisp.dhis.common.OrganisationUnitSelectionMode;
+import org.hisp.dhis.common.QueryItem;
+import org.hisp.dhis.common.QueryOperator;
+import org.hisp.dhis.organisationunit.OrganisationUnitService;
+import org.hisp.dhis.trackedentity.TrackedEntityAttributeService;
+import org.hisp.dhis.trackedentity.TrackedEntityInstanceQueryParams;
import org.hisp.dhis.trackedentity.TrackedEntityInstanceService;
import org.hisp.dhis.trackedentityattributevalue.TrackedEntityAttributeValue;
@@ -54,32 +60,34 @@
this.patientService = patientService;
}
+ private OrganisationUnitService organisationUnitService;
+
+ public void setOrganisationUnitService( OrganisationUnitService organisationUnitService )
+ {
+ this.organisationUnitService = organisationUnitService;
+ }
+
+ private TrackedEntityAttributeService trackedEntityAttributeService;
+
+ public void setTrackedEntityAttributeService( TrackedEntityAttributeService trackedEntityAttributeService )
+ {
+ this.trackedEntityAttributeService = trackedEntityAttributeService;
+ }
+
// -------------------------------------------------------------------------
// Input & Output
// -------------------------------------------------------------------------
- private Collection<TrackedEntityInstance> patients;
-
- public Collection<TrackedEntityInstance> getPatients()
- {
- return patients;
- }
-
- public void setPatients( Collection<TrackedEntityInstance> patients )
- {
- this.patients = patients;
- }
-
- private Set<TrackedEntityAttributeValue> pavSet;
-
- public Set<TrackedEntityAttributeValue> getPavSet()
- {
- return pavSet;
- }
-
- public void setPavSet( Set<TrackedEntityAttributeValue> pavSet )
- {
- this.pavSet = pavSet;
+ private List<List<Object>> trackedEntityList;
+
+ public List<List<Object>> getTrackedEntityList()
+ {
+ return trackedEntityList;
+ }
+
+ public void setTrackedEntityList( List<List<Object>> trackedEntityList )
+ {
+ this.trackedEntityList = trackedEntityList;
}
private Set<TrackedEntityAttributeValue> patientAttributes;
@@ -130,16 +138,16 @@
this.patientAttributeId = patientAttributeId;
}
- private Integer patientId;
+ private String patientUID;
- public Integer getPatientId()
+ public String getPatientUID()
{
- return patientId;
+ return patientUID;
}
- public void setPatientId( Integer patientId )
+ public void setPatientUID( String patientUID )
{
- this.patientId = patientId;
+ this.patientUID = patientUID;
}
// Use in search related patient
@@ -172,21 +180,30 @@
public String execute()
throws Exception
{
-
- patients = patientService.searchTrackedEntityInstancesForMobile( keyword, organisationUnitId,
- patientAttributeId );
-
- pavSet = new HashSet<TrackedEntityAttributeValue>();
-
- for ( TrackedEntityInstance p : patients )
- {
- pavSet.addAll( p.getAttributeValues() );
- }
-
- if ( patients.size() == 1 )
- {
- TrackedEntityInstance patient = patients.iterator().next();
- patientId = patient.getId();
+ TrackedEntityInstanceQueryParams param = new TrackedEntityInstanceQueryParams();
+ QueryItem queryItem = new QueryItem(
+ trackedEntityAttributeService.getTrackedEntityAttribute( patientAttributeId ), QueryOperator.EQ, keyword,
+ false );
+
+ if ( organisationUnitId == null || organisationUnitId == 0 )
+ {
+ param.setOrganisationUnitMode( OrganisationUnitSelectionMode.ALL );
+ }
+ else
+ {
+ param.addOrganisationUnit( organisationUnitService.getOrganisationUnit( organisationUnitId ) );
+ }
+
+ param.addAttribute( queryItem );
+
+ Grid trackedEntityGrid = patientService.getTrackedEntityInstances( param );
+ trackedEntityList = trackedEntityGrid.getRows();
+
+
+ if ( trackedEntityList.size() == 1 )
+ {
+ List<Object> firstRow = trackedEntityList.iterator().next();
+ patientUID = firstRow.get( 0 ).toString();
return REDIRECT;
}
=== modified file 'dhis-2/dhis-web/dhis-web-light/src/main/java/org/hisp/dhis/light/namebaseddataentry/action/GetPatientProgramListAction.java'
--- dhis-2/dhis-web/dhis-web-light/src/main/java/org/hisp/dhis/light/namebaseddataentry/action/GetPatientProgramListAction.java 2014-03-18 08:10:10 +0000
+++ dhis-2/dhis-web/dhis-web-light/src/main/java/org/hisp/dhis/light/namebaseddataentry/action/GetPatientProgramListAction.java 2014-05-12 09:15:31 +0000
@@ -126,16 +126,16 @@
// Input & Output
// -------------------------------------------------------------------------
- private Integer patientId;
+ private String patientUID;
- public Integer getPatientId()
+ public String getPatientUID()
{
- return patientId;
+ return patientUID;
}
- public void setPatientId( Integer patientId )
+ public void setPatientUID( String patientUID )
{
- this.patientId = patientId;
+ this.patientUID = patientUID;
}
private Set<ProgramInstance> programInstances = new HashSet<ProgramInstance>();
@@ -249,7 +249,7 @@
programInstances.clear();
relatedPeople = new HashMap<Relationship, TrackedEntityInstance>();
- patient = patientService.getTrackedEntityInstance( patientId );
+ patient = patientService.getTrackedEntityInstance( patientUID );
Collection<Program> programByCurrentUser = programService.getProgramsByCurrentUser();
for ( ProgramInstance programInstance : patient.getProgramInstances() )
{
=== modified file 'dhis-2/dhis-web/dhis-web-light/src/main/resources/META-INF/dhis/beans.xml'
--- dhis-2/dhis-web/dhis-web-light/src/main/resources/META-INF/dhis/beans.xml 2014-05-06 06:43:36 +0000
+++ dhis-2/dhis-web/dhis-web-light/src/main/resources/META-INF/dhis/beans.xml 2014-05-12 09:15:31 +0000
@@ -245,6 +245,8 @@
class="org.hisp.dhis.light.namebaseddataentry.action.FindBeneficiarytAction"
scope="prototype">
<property name="patientService" ref="org.hisp.dhis.trackedentity.TrackedEntityInstanceService" />
+ <property name="organisationUnitService" ref="org.hisp.dhis.organisationunit.OrganisationUnitService" />
+ <property name="trackedEntityAttributeService" ref="org.hisp.dhis.trackedentity.TrackedEntityAttributeService" />
</bean>
=== modified file 'dhis-2/dhis-web/dhis-web-light/src/main/resources/struts.xml'
--- dhis-2/dhis-web/dhis-web-light/src/main/resources/struts.xml 2014-05-06 06:43:36 +0000
+++ dhis-2/dhis-web/dhis-web-light/src/main/resources/struts.xml 2014-05-12 09:15:31 +0000
@@ -200,7 +200,7 @@
<action name="findBeneficiary"
class="org.hisp.dhis.light.namebaseddataentry.action.FindBeneficiarytAction">
- <result name="redirect" type="redirect">showPatientProgramList.action?patientId=${patientId}
+ <result name="redirect" type="redirect">showPatientProgramList.action?patientUID=${patientUID}
</result>
<result name="success" type="velocity">/dhis-web-light/main.vm</result>
<param name="page">/dhis-web-light/namebased/beneficiaryList.vm</param>
=== modified file 'dhis-2/dhis-web/dhis-web-light/src/main/webapp/dhis-web-light/namebased/beneficiaryList.vm'
--- dhis-2/dhis-web/dhis-web-light/src/main/webapp/dhis-web-light/namebased/beneficiaryList.vm 2014-03-07 08:27:33 +0000
+++ dhis-2/dhis-web/dhis-web-light/src/main/webapp/dhis-web-light/namebased/beneficiaryList.vm 2014-05-12 09:15:31 +0000
@@ -2,14 +2,14 @@
<p>
<ul>
-#foreach( $pav in $pavSet )
- #if($pav.getAttribute().getDisplayInListNoProgram()== true)
-<li><a href="showPatientProgramList.action?patientId=$pav.getEntityInstance().getId()">$!encoder.htmlEncode( ${pav.value} )</a></li>
-#end
+#foreach( $row in $trackedEntityList )
+
+<li><a href="showPatientProgramList.action?patientUID=$row.get(0)">$!encoder.htmlEncode( ${row.get(5)} )</a></li>
+
#end
</ul>
</p>
-<p><strong>Total found: $patients.size()</strong></p>
+<p><strong>Total found: $trackedEntityList.size()</strong></p>
<div id="footer">
<h2>$i18n.getString( "navigate_to" )</h2>
<ul>