=== 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 2012-09-27 06:54:00 +0000
+++ dhis-2/dhis-web/dhis-web-light/src/main/java/org/hisp/dhis/light/namebaseddataentry/action/FindBeneficiarytAction.java 2012-09-28 08:13:37 +0000
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 2004-2009, University of Oslo
+ * Copyright (c) 2004-2009, University of Oslo
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
=== added file 'dhis-2/dhis-web/dhis-web-light/src/main/java/org/hisp/dhis/light/singleevent/action/FindSingleEventOptionSetAction.java'
--- dhis-2/dhis-web/dhis-web-light/src/main/java/org/hisp/dhis/light/singleevent/action/FindSingleEventOptionSetAction.java 1970-01-01 00:00:00 +0000
+++ dhis-2/dhis-web/dhis-web-light/src/main/java/org/hisp/dhis/light/singleevent/action/FindSingleEventOptionSetAction.java 2012-09-28 08:13:37 +0000
@@ -0,0 +1,159 @@
+/*
+ * 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.HashMap;
+import java.util.List;
+import java.util.Map;
+
+import org.hisp.dhis.dataelement.DataElement;
+import org.hisp.dhis.dataelement.DataElementService;
+import org.hisp.dhis.option.OptionSet;
+import org.hisp.dhis.util.SessionUtils;
+
+import com.opensymphony.xwork2.Action;
+
+/**
+ * @author Nguyen Kim Lai
+ *
+ * @version $ FindOptionSetAction.java Sep 25, 2012 $
+ */
+public class FindSingleEventOptionSetAction
+ implements Action
+
+{
+ // -------------------------------------------------------------------------
+ // Dependencies
+ // -------------------------------------------------------------------------
+
+ private DataElementService dataElementService;
+
+ public void setDataElementService( DataElementService dataElementService )
+ {
+ this.dataElementService = dataElementService;
+ }
+ // -------------------------------------------------------------------------
+ // Input & Output
+ // -------------------------------------------------------------------------
+
+ private String keyword;
+
+ public void setKeyword( String keyword )
+ {
+ this.keyword = keyword;
+ }
+
+ private int dataElementIdForSearching;
+
+ public void setDataElementIdForSearching( int dataElementIdForSearching )
+ {
+ this.dataElementIdForSearching = dataElementIdForSearching;
+ }
+
+ public int getDataElementIdForSearching()
+ {
+ return dataElementIdForSearching;
+ }
+
+ private List searchingResultList;
+
+ public List getSearchingResultList()
+ {
+ return searchingResultList;
+ }
+
+ private Integer programId;
+
+ public Integer getProgramId()
+ {
+ return programId;
+ }
+
+ public void setProgramId( Integer programId )
+ {
+ this.programId = programId;
+ }
+
+ private Integer patientId;
+
+ public Integer getPatientId()
+ {
+ return patientId;
+ }
+
+ public void setPatientId( Integer patientId )
+ {
+ this.patientId = patientId;
+ }
+
+ private Integer organisationUnitId;
+
+ public void setOrganisationUnitId( Integer organisationUnitId )
+ {
+ this.organisationUnitId = organisationUnitId;
+ }
+
+ public Integer getOrganisationUnitId()
+ {
+ return this.organisationUnitId;
+ }
+
+ @Override
+ public String execute()
+ throws Exception
+ {
+/* this.test = (Map) SessionUtils.getSessionVar( "test" );
+ System.out.println( "size: " + this.test.size() );
+ System.out.println( "Key word: " + this.keyword );
+ System.out.println( "ID: " + this.dataElementIdForSearching );
+ System.out.println( "program ID: " + this.programId);
+ System.out.println( "patient ID: " + this.patientId);
+ System.out.println( "org ID: " + this.organisationUnitId);*/
+ DataElement dataElement = dataElementService.getDataElement( this.dataElementIdForSearching );
+
+ OptionSet optionSet = dataElement.getOptionSet();
+
+ List optionList = optionSet.getOptions();
+
+ searchingResultList = new ArrayList();
+
+ for( String each: optionList )
+ {
+ if(each != null)
+ {
+ if( each.contains( this.keyword ) )
+ {
+ this.searchingResultList.add( each );
+ }
+ }
+ }
+ return SUCCESS;
+ }
+
+}
=== modified 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 2012-07-13 09:18:09 +0000
+++ dhis-2/dhis-web/dhis-web-light/src/main/java/org/hisp/dhis/light/singleevent/action/GetSingleEventFormAction.java 2012-09-28 08:13:37 +0000
@@ -31,10 +31,14 @@
import java.util.ArrayList;
import java.util.Collections;
import java.util.Comparator;
+import java.util.HashMap;
+import java.util.Map;
+
import org.hisp.dhis.program.Program;
import org.hisp.dhis.program.ProgramService;
import org.hisp.dhis.program.ProgramStage;
import org.hisp.dhis.program.ProgramStageDataElement;
+import org.hisp.dhis.util.SessionUtils;
public class GetSingleEventFormAction
implements Action
@@ -136,10 +140,42 @@
}
};
+ private Map prevDataValues = new HashMap();
+
+ public Map getPrevDataValues()
+ {
+ return prevDataValues;
+ }
+
+ private String searchResult;
+
+ public void setSearchResult( String searchResult )
+ {
+ this.searchResult = searchResult;
+ }
+
+ private int dataElementIdForSearching;
+
+ public void setDataElementIdForSearching( int dataElementIdForSearching )
+ {
+ this.dataElementIdForSearching = dataElementIdForSearching;
+ }
+
@Override
public String execute()
throws Exception
{
+ System.out.println("searching Result: " + searchResult );
+
+ if( SessionUtils.getSessionVar( "prevDataValues" ) != null )
+ {
+ this.prevDataValues = (Map) SessionUtils.getSessionVar( "prevDataValues" );
+ }
+ if( searchResult != null)
+ {
+ this.prevDataValues.put( "DE"+this.dataElementIdForSearching, searchResult );
+ }
+
Program program = programService.getProgram( programId );
eventName = program.getName();
ProgramStage programStage = program.getProgramStages().iterator().next();
=== modified 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 2012-07-13 09:18:09 +0000
+++ dhis-2/dhis-web/dhis-web-light/src/main/java/org/hisp/dhis/light/singleevent/action/SaveSingleEventAction.java 2012-09-28 08:13:37 +0000
@@ -57,6 +57,7 @@
import org.hisp.dhis.program.ProgramStageInstance;
import org.hisp.dhis.program.ProgramStageInstanceService;
import org.hisp.dhis.util.ContextUtils;
+import org.hisp.dhis.util.SessionUtils;
import com.opensymphony.xwork2.Action;
import com.opensymphony.xwork2.ActionContext;
@@ -64,6 +65,8 @@
public class SaveSingleEventAction
implements Action
{
+ private static final String REDIRECT = "redirect";
+
// -------------------------------------------------------------------------
// Dependencies
// -------------------------------------------------------------------------
@@ -271,6 +274,22 @@
return i1.getSortOrder().compareTo( i2.getSortOrder() );
}
};
+
+ private String keyword;
+
+ public String getKeyword()
+ {
+ return keyword;
+ }
+
+ private int dataElementIdForSearching;
+
+ public int getDataElementIdForSearching()
+ {
+ return dataElementIdForSearching;
+ }
+
+
@Override
public String execute()
@@ -289,11 +308,20 @@
HttpServletRequest request = (HttpServletRequest) ActionContext.getContext().get(
ServletActionContext.HTTP_REQUEST );
Map parameterMap = ContextUtils.getParameterMap( request );
-
+
typeViolations.clear();
prevDataValues.clear();
-
+
+ if( SessionUtils.getSessionVar( "prevDataValues" ) == null)
+ {
+ SessionUtils.setSessionVar( "prevDataValues", this.prevDataValues );
+ }
+ else
+ {
+ this.prevDataValues = (Map) SessionUtils.getSessionVar( "prevDataValues" );
+ }
+
// -------------------------------------------------------------------------
// Validation
// -------------------------------------------------------------------------
@@ -337,7 +365,12 @@
{
return ERROR;
}
-
+
+ if( isSearching( parameterMap ) == true )
+ {
+ return REDIRECT;
+ }
+
ProgramInstance programInstance = new ProgramInstance();
programInstance.setEnrollmentDate( new Date() );
programInstance.setDateOfIncident( new Date() );
@@ -375,8 +408,45 @@
patientDataValueService.savePatientDataValue( patientDataValue );
}
+ SessionUtils.removeSessionVar( "prevDataValues" );
return SUCCESS;
}
+
+ public boolean isSearching( Map parameterMap )
+ {
+ boolean isCorrect = false;
+ for( ProgramStageDataElement each : this.programStageDataElements)
+ {
+ DataElement dataElement = each.getDataElement();
+
+ if( dataElement.getOptionSet() != null && dataElement.getOptionSet().getOptions().size() > 15)
+ {
+ System.out.println("truoc: "+parameterMap.get( "preDE"+dataElement.getId() ));
+ System.out.println("sau: "+parameterMap.get( "DE"+dataElement.getId() ));
+
+ this.keyword = parameterMap.get( "DE"+dataElement.getId() ).trim();
+
+ dataElementIdForSearching = dataElement.getId();
+
+ //if( !parameterMap.get( "preDE"+dataElement.getId() ).equals( parameterMap.get( "DE"+dataElement.getId() )))
+ for( String option: dataElement.getOptionSet().getOptions() )
+ {
+ if( option != null )
+ {
+ if(option.equals( this.keyword ))
+ {
+ isCorrect = true;
+ }
+ }
+ }
+ if( isCorrect == false && !this.keyword.isEmpty())
+ return true;
+ else
+ isCorrect = false;
+ }
+ }
+ return false;
+ }
}
=== 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-09-24 03:28:31 +0000
+++ dhis-2/dhis-web/dhis-web-light/src/main/resources/META-INF/dhis/beans.xml 2012-09-28 08:13:37 +0000
@@ -393,6 +393,10 @@
+
+
+
+
+
=== 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-09-27 10:11:02 +0000
+++ dhis-2/dhis-web/dhis-web-light/src/main/resources/org/hisp/dhis/light/i18n_module.properties 2012-09-28 08:13:37 +0000
@@ -80,6 +80,7 @@
program_list=Program List
single_event=Single Event
single_event_list=Single Event List
+back_single_event_form=Back To Single Event Form
tracking=Tracking
find_beneficiary=Find Person
activity_plan=Activity Plan
=== 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-09-24 03:28:31 +0000
+++ dhis-2/dhis-web/dhis-web-light/src/main/resources/struts.xml 2012-09-28 08:13:37 +0000
@@ -303,7 +303,7 @@
+ class="org.hisp.dhis.light.singleevent.action.GetSingleEventFormAction">
/dhis-web-light/main.vm
/dhis-web-light/singleevent/singleEventForm.vm
@@ -314,8 +314,17 @@
/light/selectSingleEventBeneficiary.action?programId=${programId}&organisationUnitId=${organisationUnitId}&validated=true
/dhis-web-light/main.vm
+ findSingleEventOptionSet.action?keyword=${keyword}&dataElementIdForSearching=${dataElementIdForSearching}&organisationUnitId=${organisationUnitId}&patientId=${patientId}&programId=${programId}
/dhis-web-light/singleevent/singleEventForm.vm
+
+
+
+ /dhis-web-light/main.vm
+ /dhis-web-light/singleevent/singleEventOptionSetFindForm.vm
+
@@ -424,5 +433,6 @@
/dhis-web-light/main.vm
/dhis-web-light/anonymous/anonymousProgramForm.vm
+
=== modified file 'dhis-2/dhis-web/dhis-web-light/src/main/webapp/dhis-web-light/singleevent/singleEventForm.vm'
--- dhis-2/dhis-web/dhis-web-light/src/main/webapp/dhis-web-light/singleevent/singleEventForm.vm 2012-07-13 09:18:09 +0000
+++ dhis-2/dhis-web/dhis-web-light/src/main/webapp/dhis-web-light/singleevent/singleEventForm.vm 2012-09-28 08:13:37 +0000
@@ -35,14 +35,21 @@
#end
#elseif ($dataElement.getOptionSet())
- #set( $options = $dataElement.getOptionSet().getOptions() )
-
-
- #foreach ($option in $options)
-
+ #set( $options = $dataElement.getOptionSet().getOptions() )
+
+ #if( $options.size() > 15 )
+
+
+
+ #else
+
+
+ #foreach ($option in $options)
+
+ #end
+
+ #end
#end
-
- #end
#end
=== added file 'dhis-2/dhis-web/dhis-web-light/src/main/webapp/dhis-web-light/singleevent/singleEventOptionSetFindForm.vm'
--- dhis-2/dhis-web/dhis-web-light/src/main/webapp/dhis-web-light/singleevent/singleEventOptionSetFindForm.vm 1970-01-01 00:00:00 +0000
+++ dhis-2/dhis-web/dhis-web-light/src/main/webapp/dhis-web-light/singleevent/singleEventOptionSetFindForm.vm 2012-09-28 08:13:37 +0000
@@ -0,0 +1,19 @@
+Option Set Searching Result
+
+ #if( $searchingResultList.size() == 0 )
+ No result
+ #else
+
+ #foreach( $option in $searchingResultList )
+ - $option
+ #end
+
+ #end
+
+
\ No newline at end of file