dhis2-devs team mailing list archive
-
dhis2-devs team
-
Mailing list archive
-
Message #17316
[Branch ~dhis2-devs-core/dhis2/trunk] Rev 6842: [mobile] add Single Event for mobile browser + minor fix
------------------------------------------------------------
revno: 6842
committer: Long <thanhlongngo1988@xxxxxxxxx>
branch nick: dhis2
timestamp: Thu 2012-05-03 16:53:40 +0700
message:
[mobile] add Single Event for mobile browser + minor fix
added:
dhis-2/dhis-web/dhis-web-light/src/main/java/org/hisp/dhis/light/singleevent/
dhis-2/dhis-web/dhis-web-light/src/main/java/org/hisp/dhis/light/singleevent/action/
dhis-2/dhis-web/dhis-web-light/src/main/java/org/hisp/dhis/light/singleevent/action/GetSingleEventAction.java
dhis-2/dhis-web/dhis-web-light/src/main/java/org/hisp/dhis/light/singleevent/action/GetSingleEventBeneficiaryAction.java
dhis-2/dhis-web/dhis-web-light/src/main/java/org/hisp/dhis/light/singleevent/action/GetSingleEventFormAction.java
dhis-2/dhis-web/dhis-web-light/src/main/java/org/hisp/dhis/light/singleevent/action/SaveSingleEventAction.java
dhis-2/dhis-web/dhis-web-light/src/main/webapp/dhis-web-light/selectSingleEvent.vm
dhis-2/dhis-web/dhis-web-light/src/main/webapp/dhis-web-light/selectSingleEventBeneficiary.vm
dhis-2/dhis-web/dhis-web-light/src/main/webapp/dhis-web-light/singleEventForm.vm
modified:
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/org/hisp/dhis/light/i18n_module.properties
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/selectActivityType.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
=== added directory 'dhis-2/dhis-web/dhis-web-light/src/main/java/org/hisp/dhis/light/singleevent'
=== added directory 'dhis-2/dhis-web/dhis-web-light/src/main/java/org/hisp/dhis/light/singleevent/action'
=== added file 'dhis-2/dhis-web/dhis-web-light/src/main/java/org/hisp/dhis/light/singleevent/action/GetSingleEventAction.java'
--- dhis-2/dhis-web/dhis-web-light/src/main/java/org/hisp/dhis/light/singleevent/action/GetSingleEventAction.java 1970-01-01 00:00:00 +0000
+++ dhis-2/dhis-web/dhis-web-light/src/main/java/org/hisp/dhis/light/singleevent/action/GetSingleEventAction.java 2012-05-03 09:53:40 +0000
@@ -0,0 +1,117 @@
+/*
+ * Copyright (c) 2004-2012, University of Oslo
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions are met:
+ * * Redistributions of source code must retain the above copyright notice, this
+ * list of conditions and the following disclaimer.
+ * * Redistributions in binary form must reproduce the above copyright notice,
+ * this list of conditions and the following disclaimer in the documentation
+ * and/or other materials provided with the distribution.
+ * * Neither the name of the HISP project nor the names of its contributors may
+ * be used to endorse or promote products derived from this software without
+ * specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
+ * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
+ * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
+ * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR
+ * ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
+ * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
+ * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON
+ * ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+ * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
+ * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+package org.hisp.dhis.light.singleevent.action;
+
+import java.util.ArrayList;
+import java.util.Collection;
+import java.util.List;
+import org.hisp.dhis.organisationunit.OrganisationUnit;
+import org.hisp.dhis.organisationunit.OrganisationUnitService;
+import org.hisp.dhis.program.Program;
+import org.hisp.dhis.program.ProgramService;
+
+import com.opensymphony.xwork2.Action;
+
+public class GetSingleEventAction
+ implements Action
+{
+ // -------------------------------------------------------------------------
+ // Dependencies
+ // -------------------------------------------------------------------------
+
+ private ProgramService programService;
+
+ public ProgramService getProgramService()
+ {
+ return programService;
+ }
+
+ public void setProgramService( ProgramService programService )
+ {
+ this.programService = programService;
+ }
+
+ private OrganisationUnitService organisationUnitService;
+
+ public OrganisationUnitService getOrganisationUnitService()
+ {
+ return organisationUnitService;
+ }
+
+ public void setOrganisationUnitService( OrganisationUnitService organisationUnitService )
+ {
+ this.organisationUnitService = organisationUnitService;
+ }
+
+ // -------------------------------------------------------------------------
+ // Input & Output
+ // -------------------------------------------------------------------------
+
+ private List<Program> singleEventList = new ArrayList<Program>();
+
+ public List<Program> getSingleEventList()
+ {
+ return singleEventList;
+ }
+
+ public void setSingleEventList( List<Program> singleEventList )
+ {
+ this.singleEventList = singleEventList;
+ }
+
+ private String organisationUnitId;
+
+ public String getOrganisationUnitId()
+ {
+ return organisationUnitId;
+ }
+
+ public void setOrganisationUnitId( String organisationUnitId )
+ {
+ this.organisationUnitId = organisationUnitId;
+ }
+
+ @Override
+ public String execute()
+ throws Exception
+ {
+ OrganisationUnit orgUnit = organisationUnitService.getOrganisationUnit( Integer.parseInt( organisationUnitId ) );
+ Collection<Program> allProgram = programService.getPrograms( orgUnit );
+
+ for ( Program program : allProgram )
+ {
+ if ( program.getSingleEvent() && !program.getAnonymous() )
+ {
+ singleEventList.add( program );
+ }
+ }
+
+ return SUCCESS;
+ }
+
+}
=== added file 'dhis-2/dhis-web/dhis-web-light/src/main/java/org/hisp/dhis/light/singleevent/action/GetSingleEventBeneficiaryAction.java'
--- dhis-2/dhis-web/dhis-web-light/src/main/java/org/hisp/dhis/light/singleevent/action/GetSingleEventBeneficiaryAction.java 1970-01-01 00:00:00 +0000
+++ dhis-2/dhis-web/dhis-web-light/src/main/java/org/hisp/dhis/light/singleevent/action/GetSingleEventBeneficiaryAction.java 2012-05-03 09:53:40 +0000
@@ -0,0 +1,168 @@
+/*
+ * Copyright (c) 2004-2012, University of Oslo
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions are met:
+ * * Redistributions of source code must retain the above copyright notice, this
+ * list of conditions and the following disclaimer.
+ * * Redistributions in binary form must reproduce the above copyright notice,
+ * this list of conditions and the following disclaimer in the documentation
+ * and/or other materials provided with the distribution.
+ * * Neither the name of the HISP project nor the names of its contributors may
+ * be used to endorse or promote products derived from this software without
+ * specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
+ * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
+ * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
+ * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR
+ * ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
+ * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
+ * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON
+ * ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+ * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
+ * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+package org.hisp.dhis.light.singleevent.action;
+
+import java.util.ArrayList;
+import java.util.Collection;
+import java.util.List;
+import org.hisp.dhis.organisationunit.OrganisationUnit;
+import org.hisp.dhis.organisationunit.OrganisationUnitService;
+import org.hisp.dhis.patient.Patient;
+import org.hisp.dhis.patient.PatientService;
+import org.hisp.dhis.program.Program;
+import org.hisp.dhis.program.ProgramInstanceService;
+import org.hisp.dhis.program.ProgramService;
+
+import com.opensymphony.xwork2.Action;
+
+public class GetSingleEventBeneficiaryAction
+ implements Action
+{
+ // -------------------------------------------------------------------------
+ // Dependencies
+ // -------------------------------------------------------------------------
+
+ private ProgramInstanceService programInstanceService;
+
+ public ProgramInstanceService getProgramInstanceService()
+ {
+ return programInstanceService;
+ }
+
+ public void setProgramInstanceService( ProgramInstanceService programInstanceService )
+ {
+ this.programInstanceService = programInstanceService;
+ }
+
+ private ProgramService programService;
+
+ public ProgramService getProgramService()
+ {
+ return programService;
+ }
+
+ public void setProgramService( ProgramService programService )
+ {
+ this.programService = programService;
+ }
+
+ private OrganisationUnitService organisationUnitService;
+
+ public OrganisationUnitService getOrganisationUnitService()
+ {
+ return organisationUnitService;
+ }
+
+ public void setOrganisationUnitService( OrganisationUnitService organisationUnitService )
+ {
+ this.organisationUnitService = organisationUnitService;
+ }
+
+ private PatientService patientService;
+
+ public PatientService getPatientService()
+ {
+ return patientService;
+ }
+
+ public void setPatientService( PatientService patientService )
+ {
+ this.patientService = patientService;
+ }
+
+ // -------------------------------------------------------------------------
+ // Input & Output
+ // -------------------------------------------------------------------------
+
+ private List<Patient> singleEventBeneficiaryList = new ArrayList<Patient>();
+
+ public List<Patient> getSingleEventBeneficiaryList()
+ {
+ return singleEventBeneficiaryList;
+ }
+
+ public void setSingleEventBeneficiaryList( List<Patient> singleEventBeneficiaryList )
+ {
+ this.singleEventBeneficiaryList = singleEventBeneficiaryList;
+ }
+
+ private String organisationUnitId;
+
+ public String getOrganisationUnitId()
+ {
+ return organisationUnitId;
+ }
+
+ public void setOrganisationUnitId( String organisationUnitId )
+ {
+ this.organisationUnitId = organisationUnitId;
+ }
+
+ private String programId;
+
+ public String getProgramId()
+ {
+ return programId;
+ }
+
+ public void setProgramId( String programId )
+ {
+ this.programId = programId;
+ }
+
+ private boolean validated;
+
+ public boolean isValidated()
+ {
+ return validated;
+ }
+
+ public void setValidated( boolean validated )
+ {
+ this.validated = validated;
+ }
+
+ @Override
+ public String execute()
+ throws Exception
+ {
+ OrganisationUnit orgUnit = organisationUnitService.getOrganisationUnit( Integer.parseInt( organisationUnitId ) );
+ Program program = programService.getProgram( Integer.parseInt( programId ) );
+ Collection<Patient> allPatient = patientService.getPatients( orgUnit );
+ for ( Patient patient : allPatient )
+ {
+ if ( programInstanceService.getProgramInstances( patient, program ).size() == 0 )
+ {
+ singleEventBeneficiaryList.add( patient );
+ }
+ }
+
+ return SUCCESS;
+ }
+
+}
=== added file 'dhis-2/dhis-web/dhis-web-light/src/main/java/org/hisp/dhis/light/singleevent/action/GetSingleEventFormAction.java'
--- dhis-2/dhis-web/dhis-web-light/src/main/java/org/hisp/dhis/light/singleevent/action/GetSingleEventFormAction.java 1970-01-01 00:00:00 +0000
+++ dhis-2/dhis-web/dhis-web-light/src/main/java/org/hisp/dhis/light/singleevent/action/GetSingleEventFormAction.java 2012-05-03 09:53:40 +0000
@@ -0,0 +1,160 @@
+/*
+ * Copyright (c) 2004-2012, University of Oslo
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions are met:
+ * * Redistributions of source code must retain the above copyright notice, this
+ * list of conditions and the following disclaimer.
+ * * Redistributions in binary form must reproduce the above copyright notice,
+ * this list of conditions and the following disclaimer in the documentation
+ * and/or other materials provided with the distribution.
+ * * Neither the name of the HISP project nor the names of its contributors may
+ * be used to endorse or promote products derived from this software without
+ * specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
+ * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
+ * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
+ * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR
+ * ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
+ * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
+ * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON
+ * ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+ * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
+ * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+package org.hisp.dhis.light.singleevent.action;
+
+import com.opensymphony.xwork2.Action;
+import java.util.ArrayList;
+import java.util.Collections;
+import java.util.Comparator;
+import java.util.List;
+import org.hisp.dhis.program.Program;
+import org.hisp.dhis.program.ProgramService;
+import org.hisp.dhis.program.ProgramStage;
+import org.hisp.dhis.program.ProgramStageDataElement;
+
+public class GetSingleEventFormAction
+ implements Action
+{
+ // -------------------------------------------------------------------------
+ // Dependencies
+ // -------------------------------------------------------------------------
+
+ private ProgramService programService;
+
+ public void setProgramService( ProgramService programService )
+ {
+ this.programService = programService;
+ }
+
+ // -------------------------------------------------------------------------
+ // Input Output
+ // -------------------------------------------------------------------------
+
+ private Integer organisationUnitId;
+
+ public void setOrganisationUnitId( Integer organisationUnitId )
+ {
+ this.organisationUnitId = organisationUnitId;
+ }
+
+ public Integer getOrganisationUnitId()
+ {
+ return this.organisationUnitId;
+ }
+
+ private Integer programId;
+
+ public Integer getProgramId()
+ {
+ return programId;
+ }
+
+ public void setProgramId( Integer programId )
+ {
+ this.programId = programId;
+ }
+
+ private String eventName;
+
+ public String getEventName()
+ {
+ return this.eventName;
+ }
+
+ private Integer beneficiaryId;
+
+ public Integer getBeneficiaryId()
+ {
+ return beneficiaryId;
+ }
+
+ public void setBeneficiaryId( Integer beneficiaryId )
+ {
+ this.beneficiaryId = beneficiaryId;
+ }
+
+ private Integer instId;
+
+ public void setInstId( Integer instId )
+ {
+ this.instId = instId;
+ }
+
+ public Integer getInstId()
+ {
+ return this.instId;
+ }
+
+ private boolean update;
+
+ public void setUpdate( boolean update )
+ {
+ this.update = update;
+ }
+
+ public boolean getUpdate()
+ {
+ return this.update;
+ }
+
+ private List<String> dynForm = new ArrayList<String>( 100 );
+
+ public List<String> getDynForm()
+ {
+ return dynForm;
+ }
+
+ private ArrayList<ProgramStageDataElement> programStageDataElements = new ArrayList<ProgramStageDataElement>();
+
+ public ArrayList<ProgramStageDataElement> getProgramStageDataElements()
+ {
+ return this.programStageDataElements;
+ }
+
+ static final Comparator<ProgramStageDataElement> OrderBySortOrder = new Comparator<ProgramStageDataElement>()
+ {
+ public int compare( ProgramStageDataElement i1, ProgramStageDataElement i2 )
+ {
+ return i1.getSortOrder().compareTo( i2.getSortOrder() );
+ }
+ };
+
+ @Override
+ public String execute()
+ throws Exception
+ {
+ Program program = programService.getProgram( programId );
+ eventName = program.getName();
+ ProgramStage programStage = program.getProgramStages().iterator().next();
+ programStageDataElements = new ArrayList<ProgramStageDataElement>( programStage.getProgramStageDataElements() );
+ Collections.sort( programStageDataElements, OrderBySortOrder );
+ dynForm.clear();
+ return SUCCESS;
+ }
+
+}
=== added file 'dhis-2/dhis-web/dhis-web-light/src/main/java/org/hisp/dhis/light/singleevent/action/SaveSingleEventAction.java'
--- dhis-2/dhis-web/dhis-web-light/src/main/java/org/hisp/dhis/light/singleevent/action/SaveSingleEventAction.java 1970-01-01 00:00:00 +0000
+++ dhis-2/dhis-web/dhis-web-light/src/main/java/org/hisp/dhis/light/singleevent/action/SaveSingleEventAction.java 2012-05-03 09:53:40 +0000
@@ -0,0 +1,317 @@
+/*
+ * Copyright (c) 2004-2012, University of Oslo
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions are met:
+ * * Redistributions of source code must retain the above copyright notice, this
+ * list of conditions and the following disclaimer.
+ * * Redistributions in binary form must reproduce the above copyright notice,
+ * this list of conditions and the following disclaimer in the documentation
+ * and/or other materials provided with the distribution.
+ * * Neither the name of the HISP project nor the names of its contributors may
+ * be used to endorse or promote products derived from this software without
+ * specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
+ * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
+ * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
+ * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR
+ * ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
+ * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
+ * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON
+ * ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+ * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
+ * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+package org.hisp.dhis.light.singleevent.action;
+
+import java.util.ArrayList;
+import java.util.Collections;
+import java.util.Comparator;
+import java.util.Date;
+import java.util.HashMap;
+import java.util.List;
+import java.util.Map;
+import org.hisp.dhis.dataelement.DataElement;
+import org.hisp.dhis.light.utils.NamebasedUtils;
+import org.hisp.dhis.organisationunit.OrganisationUnit;
+import org.hisp.dhis.organisationunit.OrganisationUnitService;
+import org.hisp.dhis.patient.Patient;
+import org.hisp.dhis.patient.PatientService;
+import org.hisp.dhis.patientdatavalue.PatientDataValue;
+import org.hisp.dhis.patientdatavalue.PatientDataValueService;
+import org.hisp.dhis.program.Program;
+import org.hisp.dhis.program.ProgramInstance;
+import org.hisp.dhis.program.ProgramInstanceService;
+import org.hisp.dhis.program.ProgramService;
+import org.hisp.dhis.program.ProgramStage;
+import org.hisp.dhis.program.ProgramStageDataElement;
+import org.hisp.dhis.program.ProgramStageInstance;
+import org.hisp.dhis.program.ProgramStageInstanceService;
+import com.opensymphony.xwork2.Action;
+
+public class SaveSingleEventAction
+ implements Action
+{
+ // -------------------------------------------------------------------------
+ // Dependencies
+ // -------------------------------------------------------------------------
+
+ private ProgramInstanceService programInstanceService;
+
+ public void setProgramInstanceService( ProgramInstanceService programInstanceService )
+ {
+ this.programInstanceService = programInstanceService;
+ }
+
+ private ProgramStageInstanceService programStageInstanceService;
+
+ public void setProgramStageInstanceService( ProgramStageInstanceService programStageInstanceService )
+ {
+ this.programStageInstanceService = programStageInstanceService;
+ }
+
+ private ProgramService programService;
+
+ public void setProgramService( ProgramService programService )
+ {
+ this.programService = programService;
+ }
+
+ private PatientService patientService;
+
+ public void setPatientService( PatientService patientService )
+ {
+ this.patientService = patientService;
+ }
+
+ private PatientDataValueService patientDataValueService;
+
+ public void setPatientDataValueService( PatientDataValueService patientDataValueService )
+ {
+ this.patientDataValueService = patientDataValueService;
+ }
+
+ private OrganisationUnitService organisationUnitService;
+
+ public void setOrganisationUnitService( OrganisationUnitService organisationUnitService )
+ {
+ this.organisationUnitService = organisationUnitService;
+ }
+
+ private NamebasedUtils util;
+
+ public NamebasedUtils getUtil()
+ {
+ return util;
+ }
+
+ public void setUtil( NamebasedUtils util )
+ {
+ this.util = util;
+ }
+
+ // -------------------------------------------------------------------------
+ // Input Output
+ // -------------------------------------------------------------------------
+
+ private Map<String, String> typeViolations = new HashMap<String, String>();
+
+ public Map<String, String> getTypeViolations()
+ {
+ return typeViolations;
+ }
+
+ private Integer programId;
+
+ public Integer getProgramId()
+ {
+ return programId;
+ }
+
+ public void setProgramId( Integer programId )
+ {
+ this.programId = programId;
+ }
+
+ private Integer beneficiaryId;
+
+ public Integer getBeneficiaryId()
+ {
+ return beneficiaryId;
+ }
+
+ public void setBeneficiaryId( Integer beneficiaryId )
+ {
+ this.beneficiaryId = beneficiaryId;
+ }
+
+ private Patient patient;
+
+ public Patient getPatient()
+ {
+ return patient;
+ }
+
+ private String eventName;
+
+ public String getEventName()
+ {
+ return this.eventName;
+ }
+
+ private Integer organisationUnitId;
+
+ public void setOrganisationUnitId( Integer organisationUnitId )
+ {
+ this.organisationUnitId = organisationUnitId;
+ }
+
+ public Integer getOrganisationUnitId()
+ {
+ return this.organisationUnitId;
+ }
+
+ private boolean update;
+
+ public void setUpdate( boolean update )
+ {
+ this.update = update;
+ }
+
+ public boolean getUpdate()
+ {
+ return this.update;
+ }
+
+ private Integer instId;
+
+ public void setInstId( Integer instId )
+ {
+ this.instId = instId;
+ }
+
+ public Integer getInstId()
+ {
+ return this.instId;
+ }
+
+ private List<String> dynForm = new ArrayList<String>();
+
+ public void setDynForm( List<String> dynForm )
+ {
+ this.dynForm = dynForm;
+ }
+
+ public List<String> getDynForm()
+ {
+ return dynForm;
+ }
+
+ private String resultString;
+
+ public void setResultString( String resultString )
+ {
+ this.resultString = resultString;
+ }
+
+ public String getResultString()
+ {
+ return this.resultString;
+ }
+
+ private ArrayList<ProgramStageDataElement> programStageDataElements = new ArrayList<ProgramStageDataElement>();
+
+ public ArrayList<ProgramStageDataElement> getProgramStageDataElements()
+ {
+ return this.programStageDataElements;
+ }
+
+ static final Comparator<ProgramStageDataElement> OrderBySortOrder = new Comparator<ProgramStageDataElement>()
+ {
+ public int compare( ProgramStageDataElement i1, ProgramStageDataElement i2 )
+ {
+ return i1.getSortOrder().compareTo( i2.getSortOrder() );
+ }
+ };
+
+ @Override
+ public String execute()
+ throws Exception
+ {
+ Program program = programService.getProgram( programId );
+ eventName = program.getName();
+
+ Patient patient = patientService.getPatient( beneficiaryId );
+ ProgramStage programStage = program.getProgramStages().iterator().next();
+ OrganisationUnit organisationUnit = organisationUnitService.getOrganisationUnit( organisationUnitId );
+
+ programStageDataElements = new ArrayList<ProgramStageDataElement>( programStage.getProgramStageDataElements() );
+ Collections.sort( programStageDataElements, OrderBySortOrder );
+
+ // -------------------------------------------------------------------------
+ // Validation
+ // -------------------------------------------------------------------------
+
+ int i = 0;
+ for ( ProgramStageDataElement programStageDataElement : programStageDataElements )
+ {
+ DataElement dataElement = programStageDataElement.getDataElement();
+ String value = dynForm.get( i ).trim();
+ Boolean valueIsEmpty = (value == null || value.length() == 0);
+
+ if ( !valueIsEmpty )
+ {
+ String typeViolation = util.getTypeViolation( dataElement, value );
+
+ if ( typeViolation != null )
+ {
+ typeViolations.put( String.valueOf( dataElement.getId() ), typeViolation );
+ }
+ }
+
+ i++;
+ }
+
+ if ( !typeViolations.isEmpty() )
+ {
+ return ERROR;
+ }
+
+ ProgramInstance programInstance = new ProgramInstance();
+ programInstance.setEnrollmentDate( new Date() );
+ programInstance.setDateOfIncident( new Date() );
+ programInstance.setProgram( program );
+ programInstance.setPatient( patient );
+ programInstance.setCompleted( false );
+ programInstanceService.addProgramInstance( programInstance );
+
+ ProgramStageInstance programStageInstance = new ProgramStageInstance();
+ programStageInstance.setOrganisationUnit( organisationUnit );
+ programStageInstance.setProgramInstance( programInstance );
+ programStageInstance.setProgramStage( programStage );
+ programStageInstance.setDueDate( new Date() );
+ programStageInstance.setExecutionDate( new Date() );
+ programStageInstance.setCompleted( false );
+ programStageInstanceService.addProgramStageInstance( programStageInstance );
+
+ i = 0;
+ for ( ProgramStageDataElement programStageDataElement : programStageDataElements )
+ {
+ DataElement dataElement = programStageDataElement.getDataElement();
+
+ PatientDataValue patientDataValue = new PatientDataValue();
+ patientDataValue.setDataElement( dataElement );
+ patientDataValue.setProgramStageInstance( programStageInstance );
+ patientDataValue.setValue( dynForm.get( i ).trim() );
+ patientDataValue.setProgramStageInstance( programStageInstance );
+ patientDataValueService.savePatientDataValue( patientDataValue );
+ i++;
+ }
+
+ return SUCCESS;
+ }
+
+}
=== 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 2012-04-20 02:32:43 +0000
+++ dhis-2/dhis-web/dhis-web-light/src/main/resources/META-INF/dhis/beans.xml 2012-05-03 09:53:40 +0000
@@ -286,10 +286,61 @@
ref="org.hisp.dhis.program.ProgramInstanceService"/>
<property name="programStageInstanceService"
ref="org.hisp.dhis.program.ProgramStageInstanceService"/>
- <property name="formUtils"
+ <property name="formUtils"
ref="org.hisp.dhis.light.dataentry.utils.FormUtils"/>
</bean>
+ <!-- Single Event -->
+
+ <bean id="org.hisp.dhis.light.singleevent.action.GetSingleEventAction"
+ class="org.hisp.dhis.light.singleevent.action.GetSingleEventAction"
+ scope="prototype">
+ <property name="programService"
+ ref="org.hisp.dhis.program.ProgramService"/>
+ <property name="organisationUnitService"
+ ref="org.hisp.dhis.organisationunit.OrganisationUnitService"/>
+ </bean>
+
+ <bean
+ id="org.hisp.dhis.light.singleevent.action.GetSingleEventBeneficiaryAction"
+ class="org.hisp.dhis.light.singleevent.action.GetSingleEventBeneficiaryAction"
+ scope="prototype">
+ <property name="programService"
+ ref="org.hisp.dhis.program.ProgramService"/>
+ <property name="organisationUnitService"
+ ref="org.hisp.dhis.organisationunit.OrganisationUnitService"/>
+ <property name="programInstanceService"
+ ref="org.hisp.dhis.program.ProgramInstanceService"/>
+ <property name="patientService"
+ ref="org.hisp.dhis.patient.PatientService"/>
+ </bean>
+
+ <bean id="org.hisp.dhis.light.singleevent.action.GetSingleEventFormAction"
+ class="org.hisp.dhis.light.singleevent.action.GetSingleEventFormAction"
+ scope="prototype">
+ <property name="programService"
+ ref="org.hisp.dhis.program.ProgramService"/>
+ </bean>
+
+ <bean id="org.hisp.dhis.light.singleevent.action.SaveSingleEventAction"
+ class="org.hisp.dhis.light.singleevent.action.SaveSingleEventAction"
+ scope="prototype">
+ <property name="programService"
+ ref="org.hisp.dhis.program.ProgramService"/>
+ <property name="programInstanceService"
+ ref="org.hisp.dhis.program.ProgramInstanceService"/>
+ <property name="programStageInstanceService"
+ ref="org.hisp.dhis.program.ProgramStageInstanceService"/>
+ <property name="patientService"
+ ref="org.hisp.dhis.patient.PatientService"/>
+ <property name="patientDataValueService"
+ ref="org.hisp.dhis.patientdatavalue.PatientDataValueService"/>
+ <property name="organisationUnitService"
+ ref="org.hisp.dhis.organisationunit.OrganisationUnitService"/>
+ <property name="util"
+ ref="org.hisp.dhis.light.utils.NamebasedUtils"/>
+ </bean>
+
<!-- Dashboard -->
<bean id="org.hisp.dhis.light.dashboard.action.ProvideContentAction"
=== modified file 'dhis-2/dhis-web/dhis-web-light/src/main/resources/org/hisp/dhis/light/i18n_module.properties'
--- dhis-2/dhis-web/dhis-web-light/src/main/resources/org/hisp/dhis/light/i18n_module.properties 2012-04-20 02:32:43 +0000
+++ dhis-2/dhis-web/dhis-web-light/src/main/resources/org/hisp/dhis/light/i18n_module.properties 2012-05-03 09:53:40 +0000
@@ -70,4 +70,6 @@
enroll=Enroll
enrollment_date=Enrollment Date
incident_date=Incident Date
-program_list=Program List
\ No newline at end of file
+program_list=Program List
+single_event=Single Event
+single_event_list=Single Event List
=== 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 2012-04-20 02:32:43 +0000
+++ dhis-2/dhis-web/dhis-web-light/src/main/resources/struts.xml 2012-05-03 09:53:40 +0000
@@ -152,6 +152,7 @@
</action>
<!-- Beneficiary Enrollment -->
+
<action name="selectEnrollmentOrganisationUnit"
class="org.hisp.dhis.light.beneficiaryenrollment.action.GetBeneficiaryEnrollmentOrganisationUnitAction">
<result name="success" type="velocity">
@@ -197,6 +198,37 @@
<param name="page">/dhis-web-light/programEnrollmentForm.vm</param>
</action>
+ <!-- Single Event -->
+
+ <action name="selectSingleEvent"
+ class="org.hisp.dhis.light.singleevent.action.GetSingleEventAction">
+ <result name="success" type="velocity">
+ /dhis-web-light/main.vm</result>
+ <param name="page">/dhis-web-light/selectSingleEvent.vm</param>
+ </action>
+
+ <action name="selectSingleEventBeneficiary"
+ class="org.hisp.dhis.light.singleevent.action.GetSingleEventBeneficiaryAction">
+ <result name="success" type="velocity">
+ /dhis-web-light/main.vm</result>
+ <param name="page">/dhis-web-light/selectSingleEventBeneficiary.vm</param>
+ </action>
+
+ <action name="showSingleEventForm"
+ class="org.hisp.dhis.light.singleevent.action.GetSingleEventFormAction">
+ <result name="success" type="velocity">
+ /dhis-web-light/main.vm</result>
+ <param name="page">/dhis-web-light/singleEventForm.vm</param>
+ </action>
+
+ <action name="saveSingleEvent"
+ class="org.hisp.dhis.light.singleevent.action.SaveSingleEventAction">
+ <result name="success" type="redirect">
+ /mobile/selectSingleEventBeneficiary.action?programId=${programId}&organisationUnitId=${organisationUnitId}&validated=true</result>
+ <result name="error" type="velocity">/dhis-web-light/main.vm</result>
+ <param name="page">/dhis-web-light/singleEventForm.vm</param>
+ </action>
+
<!-- Reports -->
<action name="reports"
=== modified file 'dhis-2/dhis-web/dhis-web-light/src/main/webapp/dhis-web-light/selectActivityType.vm'
--- dhis-2/dhis-web/dhis-web-light/src/main/webapp/dhis-web-light/selectActivityType.vm 2012-04-13 08:56:48 +0000
+++ dhis-2/dhis-web/dhis-web-light/src/main/webapp/dhis-web-light/selectActivityType.vm 2012-05-03 09:53:40 +0000
@@ -3,6 +3,7 @@
<ul>
<li><a href="selectBeneficiary.action?organisationUnitId=$organisationUnitId¤t=true&validated=false">$i18n.getString( "current_activityplan" )</a></li>
<li><a href="selectBeneficiary.action?organisationUnitId=$organisationUnitId¤t=false&validated=false">$i18n.getString( "all_activityplan" )</a></li>
+ <li><a href="selectSingleEvent.action?organisationUnitId=$organisationUnitId">$i18n.getString( "single_event" )</a></li>
</ul>
</p>
=== added file 'dhis-2/dhis-web/dhis-web-light/src/main/webapp/dhis-web-light/selectSingleEvent.vm'
--- dhis-2/dhis-web/dhis-web-light/src/main/webapp/dhis-web-light/selectSingleEvent.vm 1970-01-01 00:00:00 +0000
+++ dhis-2/dhis-web/dhis-web-light/src/main/webapp/dhis-web-light/selectSingleEvent.vm 2012-05-03 09:53:40 +0000
@@ -0,0 +1,19 @@
+<h2>$i18n.getString( "single_event_list" )</h2>
+<ul>
+#foreach( $singleEvent in $singleEventList )
+ <li>
+ <a href="selectSingleEventBeneficiary.action?organisationUnitId=$organisationUnitId&programId=$singleEvent.getId()">
+ $singleEvent.getName()
+ </a>
+ </li>
+#end
+</ul>
+</p>
+
+<div id="footer">
+<h2>$i18n.getString( "navigate_to" )</h2>
+<ul>
+ <li><a href="selectActivityType.action?orgUnitId=$organisationUnitId">$i18n.getString("activity_type")</a></li>
+ <li><a href="index.action">$i18n.getString("home")</a></li>
+</ul>
+</div>
\ No newline at end of file
=== added file 'dhis-2/dhis-web/dhis-web-light/src/main/webapp/dhis-web-light/selectSingleEventBeneficiary.vm'
--- dhis-2/dhis-web/dhis-web-light/src/main/webapp/dhis-web-light/selectSingleEventBeneficiary.vm 1970-01-01 00:00:00 +0000
+++ dhis-2/dhis-web/dhis-web-light/src/main/webapp/dhis-web-light/selectSingleEventBeneficiary.vm 2012-05-03 09:53:40 +0000
@@ -0,0 +1,23 @@
+<h2>$i18n.getString( "beneficiary_list" )</h2>
+ #if( $validated)
+ <div class="header-box">
+ <h3 style="text-align: left;">$i18n.getString("successfully_saved")</h3>
+ </div>
+ #else
+
+ #end
+<p>
+<ul>
+#foreach( $patient in $singleEventBeneficiaryList )
+ <li><a href="showSingleEventForm.action?organisationUnitId=$organisationUnitId&beneficiaryId=$patient.id&programId=$programId">$!encoder.htmlEncode( ${patient.getFullName()} )</a></li>
+#end
+</ul>
+</p>
+
+<div id="footer">
+<h2>$i18n.getString( "navigate_to" )</h2>
+<ul>
+ <li><a href="selectSingleEvent.action?organisationUnitId=$organisationUnitId">$i18n.getString("single_event_list")</a></li>
+ <li><a href="index.action">$i18n.getString("home")</a></li>
+</ul>
+</div>
\ No newline at end of file
=== added file 'dhis-2/dhis-web/dhis-web-light/src/main/webapp/dhis-web-light/singleEventForm.vm'
--- dhis-2/dhis-web/dhis-web-light/src/main/webapp/dhis-web-light/singleEventForm.vm 1970-01-01 00:00:00 +0000
+++ dhis-2/dhis-web/dhis-web-light/src/main/webapp/dhis-web-light/singleEventForm.vm 2012-05-03 09:53:40 +0000
@@ -0,0 +1,48 @@
+<h2>Single Event: $eventName</h2>
+
+<form method="post" action="saveSingleEvent.action">
+ <div class="header-box" align="center">
+ <p style="text-align: left;">
+
+ #set( $i = 0 )
+ #foreach( $element in $programStageDataElements )
+
+ <label>$element.getDataElement().getName() #if($element.getDataElement().getType() == "date") (yyyy-mm-dd) #end</label>
+ #set( $key = $element.getDataElement().getId() + '' )
+ #if($typeViolations.get($key))
+ #set( $typeViolation = $typeViolations.get($key) )
+ <label style="color:red;"> $i18n.getString($typeViolation) </label>
+ #end
+
+ #if ($element.getDataElement().getType() == "bool")
+ <br />
+ <select name="dynForm">
+ <option value="please_select">$i18n.getString("please_select")</option>
+ <option value="true" #if($dynForm.isEmpty() == false) #if($!dynForm.get($i) == "true") selected="selected" #end #end >$i18n.getString("Yes")</option>
+ <option value="false" #if($dynForm.isEmpty() == false) #if($!dynForm.get($i) == "false") selected="selected" #end #end >$i18n.getString("No")</option>
+ </select>
+ <br />
+ #elseif ($element.getDataElement().getType() == "date")
+ <input type="date" maxlength="255" size="24" name="dynForm" value="#if($dynForm.isEmpty() == false)$!dynForm.get($i)#end" />
+ #else
+ <input type="text" maxlength="255" size="24" name="dynForm" value="#if($dynForm.isEmpty() == false)$!dynForm.get($i)#end" />
+ #end
+ #set( $i = $i + 1)
+ #end
+
+ <input type="hidden" name="organisationUnitId" value="$organisationUnitId" />
+ <input type="hidden" name="programId" value="$programId" />
+ <input type="hidden" name="beneficiaryId" value="$beneficiaryId" />
+
+ <input type="submit" value=$i18n.getString("Submit") />
+ </p>
+ </div>
+</form>
+
+<div id="footer">
+<h2>$i18n.getString( "navigate_to" )</h2>
+<ul>
+ <li><a href="selectSingleEventBeneficiary.action?organisationUnitId=$organisationUnitId&programId=$programId">$i18n.getString("beneficiary_list")</a></li>
+ <li><a href="index.action">$i18n.getString("home")</a></li>
+</ul>
+</div>