dhis2-devs team mailing list archive
-
dhis2-devs team
-
Mailing list archive
-
Message #25766
[Branch ~dhis2-devs-core/dhis2/trunk] Rev 12812: Reorganize tracker module ( WIP ).
------------------------------------------------------------
revno: 12812
committer: Tran Chau <tran.hispvietnam@xxxxxxxxx>
branch nick: dhis2
timestamp: Thu 2013-10-24 15:31:35 +0700
message:
Reorganize tracker module ( WIP ).
removed:
dhis-2/dhis-web/dhis-web-caseentry/src/main/java/org/hisp/dhis/caseentry/state/
dhis-2/dhis-web/dhis-web-caseentry/src/main/java/org/hisp/dhis/caseentry/state/DefaultSelectedStateManager.java
dhis-2/dhis-web/dhis-web-caseentry/src/main/java/org/hisp/dhis/caseentry/state/SelectedStateManager.java
dhis-2/dhis-web/dhis-web-caseentry/src/main/webapp/dhis-web-caseentry/responseDuplicate.vm
modified:
dhis-2/dhis-api/src/main/java/org/hisp/dhis/program/ProgramService.java
dhis-2/dhis-api/src/main/java/org/hisp/dhis/program/ProgramStageInstanceService.java
dhis-2/dhis-services/dhis-service-patient/src/main/java/org/hisp/dhis/patient/hibernate/HibernatePatientStore.java
dhis-2/dhis-services/dhis-service-patient/src/main/java/org/hisp/dhis/program/DefaultProgramService.java
dhis-2/dhis-services/dhis-service-patient/src/main/java/org/hisp/dhis/program/DefaultProgramStageInstanceService.java
dhis-2/dhis-web/dhis-web-caseentry/src/main/java/org/hisp/dhis/caseentry/action/caseentry/CompleteDataEntryAction.java
dhis-2/dhis-web/dhis-web-caseentry/src/main/java/org/hisp/dhis/caseentry/action/caseentry/CreateAnonymousEncounterAction.java
dhis-2/dhis-web/dhis-web-caseentry/src/main/java/org/hisp/dhis/caseentry/action/caseentry/DataRecordingSelectAction.java
dhis-2/dhis-web/dhis-web-caseentry/src/main/java/org/hisp/dhis/caseentry/action/caseentry/GetAllProgramsAction.java
dhis-2/dhis-web/dhis-web-caseentry/src/main/java/org/hisp/dhis/caseentry/action/caseentry/GetDataRecordsAction.java
dhis-2/dhis-web/dhis-web-caseentry/src/main/java/org/hisp/dhis/caseentry/action/caseentry/GetProgramsByOrgunitAction.java
dhis-2/dhis-web/dhis-web-caseentry/src/main/java/org/hisp/dhis/caseentry/action/caseentry/GetSingleEventProgramListAction.java
dhis-2/dhis-web/dhis-web-caseentry/src/main/java/org/hisp/dhis/caseentry/action/caseentry/LoadDataEntryAction.java
dhis-2/dhis-web/dhis-web-caseentry/src/main/java/org/hisp/dhis/caseentry/action/caseentry/LoadProgramStageInstancesAction.java
dhis-2/dhis-web/dhis-web-caseentry/src/main/java/org/hisp/dhis/caseentry/action/caseentry/MultiDataEntrySelectAction.java
dhis-2/dhis-web/dhis-web-caseentry/src/main/java/org/hisp/dhis/caseentry/action/caseentry/SaveExecutionDateAction.java
dhis-2/dhis-web/dhis-web-caseentry/src/main/java/org/hisp/dhis/caseentry/action/caseentry/SaveProvidingFacilityAction.java
dhis-2/dhis-web/dhis-web-caseentry/src/main/java/org/hisp/dhis/caseentry/action/caseentry/SaveValuesAction.java
dhis-2/dhis-web/dhis-web-caseentry/src/main/java/org/hisp/dhis/caseentry/action/patient/AddPatientAction.java
dhis-2/dhis-web/dhis-web-caseentry/src/main/java/org/hisp/dhis/caseentry/action/patient/AddRelationshipPatientAction.java
dhis-2/dhis-web/dhis-web-caseentry/src/main/java/org/hisp/dhis/caseentry/action/patient/ProgramEnrollmentAction.java
dhis-2/dhis-web/dhis-web-caseentry/src/main/java/org/hisp/dhis/caseentry/action/patient/ProgramEnrollmentSelectAction.java
dhis-2/dhis-web/dhis-web-caseentry/src/main/java/org/hisp/dhis/caseentry/action/patient/SaveProgramEnrollmentAction.java
dhis-2/dhis-web/dhis-web-caseentry/src/main/java/org/hisp/dhis/caseentry/action/patient/SelectAction.java
dhis-2/dhis-web/dhis-web-caseentry/src/main/java/org/hisp/dhis/caseentry/action/patient/ValidatePatientAction.java
dhis-2/dhis-web/dhis-web-caseentry/src/main/resources/META-INF/dhis/beans.xml
dhis-2/dhis-web/dhis-web-caseentry/src/main/resources/struts.xml
dhis-2/dhis-web/dhis-web-caseentry/src/main/webapp/dhis-web-caseentry/addPatientForm.vm
dhis-2/dhis-web/dhis-web-caseentry/src/main/webapp/dhis-web-caseentry/caseAggregationResult.vm
dhis-2/dhis-web/dhis-web-caseentry/src/main/webapp/dhis-web-caseentry/defaultDataEntryForm.vm
dhis-2/dhis-web/dhis-web-caseentry/src/main/webapp/dhis-web-caseentry/javascript/commons.js
dhis-2/dhis-web/dhis-web-caseentry/src/main/webapp/dhis-web-caseentry/javascript/entry.js
dhis-2/dhis-web/dhis-web-caseentry/src/main/webapp/dhis-web-caseentry/javascript/form.js
dhis-2/dhis-web/dhis-web-caseentry/src/main/webapp/dhis-web-caseentry/javascript/patient.js
dhis-2/dhis-web/dhis-web-caseentry/src/main/webapp/dhis-web-caseentry/patientForm.vm
dhis-2/dhis-web/dhis-web-caseentry/src/main/webapp/dhis-web-caseentry/sectionDataEntryForm.vm
dhis-2/dhis-web/dhis-web-caseentry/src/main/webapp/dhis-web-caseentry/selectPatient.vm
dhis-2/dhis-web/dhis-web-caseentry/src/main/webapp/dhis-web-caseentry/updatePatientForm.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-api/src/main/java/org/hisp/dhis/program/ProgramService.java'
--- dhis-2/dhis-api/src/main/java/org/hisp/dhis/program/ProgramService.java 2013-09-16 17:07:25 +0000
+++ dhis-2/dhis-api/src/main/java/org/hisp/dhis/program/ProgramService.java 2013-10-24 08:31:35 +0000
@@ -70,4 +70,6 @@
Program getProgram( String uid );
Collection<Program> getProgramsByDisplayOnAllOrgunit( boolean displayOnAllOrgunit, OrganisationUnit orgunit );
+
+ Collection<Program> getProgramsByCurrentUser( OrganisationUnit organisationUnit );
}
=== modified file 'dhis-2/dhis-api/src/main/java/org/hisp/dhis/program/ProgramStageInstanceService.java'
--- dhis-2/dhis-api/src/main/java/org/hisp/dhis/program/ProgramStageInstanceService.java 2013-10-08 03:23:55 +0000
+++ dhis-2/dhis-api/src/main/java/org/hisp/dhis/program/ProgramStageInstanceService.java 2013-10-24 08:31:35 +0000
@@ -62,7 +62,8 @@
ProgramStageInstance getProgramStageInstance( ProgramInstance programInstance, ProgramStage programStage );
- Collection<ProgramStageInstance> getProgramStageInstances( ProgramInstance programInstance, ProgramStage programStage );
+ Collection<ProgramStageInstance> getProgramStageInstances( ProgramInstance programInstance,
+ ProgramStage programStage );
Collection<ProgramStageInstance> getProgramStageInstances( ProgramStage programStage );
@@ -92,12 +93,12 @@
/**
* Get all {@link ProgramStageInstance program stage instances} for unit,
* optionally filtering by date or completed.
- *
- * @param unit - the unit to get instances for.
- * @param after - optional date the instance should be on or after.
- * @param before - optional date the instance should be on or before.
+ *
+ * @param unit - the unit to get instances for.
+ * @param after - optional date the instance should be on or after.
+ * @param before - optional date the instance should be on or before.
* @param completed - optional flag to only get completed (<code>true</code>
- * ) or uncompleted (<code>false</code>) instances.
+ * ) or uncompleted (<code>false</code>) instances.
* @return
*/
List<ProgramStageInstance> get( OrganisationUnit unit, Date after, Date before, Boolean completed );
@@ -125,7 +126,7 @@
List<ProgramStageInstance> getStatisticalProgramStageDetailsReport( ProgramStage programStage,
Collection<Integer> orgunitIds, Date startDate, Date endDate, int status, Integer max, Integer min );
-
+
// -------------------------------------------------------------------------
// Statistical
// -------------------------------------------------------------------------
@@ -149,4 +150,10 @@
I18nFormat format );
void completeProgramStageInstance( ProgramStageInstance programStageInstance, I18nFormat format );
+
+ void setExecutionDate( ProgramStageInstance programStageInstance, Date executionDate,
+ OrganisationUnit organisationUnit );
+
+ void createProgramStageInstance( Patient patient, Program program, Date executionDate,
+ OrganisationUnit organisationUnit );
}
=== modified file 'dhis-2/dhis-services/dhis-service-patient/src/main/java/org/hisp/dhis/patient/hibernate/HibernatePatientStore.java'
--- dhis-2/dhis-services/dhis-service-patient/src/main/java/org/hisp/dhis/patient/hibernate/HibernatePatientStore.java 2013-10-23 12:24:18 +0000
+++ dhis-2/dhis-services/dhis-service-patient/src/main/java/org/hisp/dhis/patient/hibernate/HibernatePatientStore.java 2013-10-24 08:31:35 +0000
@@ -364,16 +364,16 @@
public int validate( Patient patient, Program program )
{
- Criteria criteria = getCriteria();
- criteria.createAlias( "identifiers", "patientIdentifier" );
- criteria.createAlias( "organisationUnit", "orgunit" );
- criteria.createAlias( "programInstances", "programInstance" );
- criteria.createAlias( "programInstance.program", "program" );
-
if ( patient.getIdentifiers() != null && patient.getIdentifiers().size() > 0 )
{
+ Criteria criteria = getCriteria();
+ criteria.createAlias( "identifiers", "patientIdentifier" );
+ criteria.createAlias( "organisationUnit", "orgunit" );
+ criteria.createAlias( "programInstances", "programInstance" );
+ criteria.createAlias( "programInstance.program", "program" );
+
Disjunction disjunction = Restrictions.disjunction();
-
+
for ( PatientIdentifier identifier : patient.getIdentifiers() )
{
PatientIdentifierType patientIdentifierType = identifier.getIdentifierType();
@@ -413,13 +413,15 @@
}
criteria.add( disjunction );
-
- if ( criteria.list() != null )
+
+ Number rs = (Number) criteria.setProjection( Projections.rowCount() ).uniqueResult();
+
+ if ( rs != null && rs.intValue() > 0 )
{
return PatientService.ERROR_DUPLICATE_IDENTIFIER;
}
}
-
+
if ( program != null )
{
ValidationCriteria validationCriteria = program.isValid( patient );
=== modified file 'dhis-2/dhis-services/dhis-service-patient/src/main/java/org/hisp/dhis/program/DefaultProgramService.java'
--- dhis-2/dhis-services/dhis-service-patient/src/main/java/org/hisp/dhis/program/DefaultProgramService.java 2013-09-16 17:07:25 +0000
+++ dhis-2/dhis-services/dhis-service-patient/src/main/java/org/hisp/dhis/program/DefaultProgramService.java 2013-10-24 08:31:35 +0000
@@ -34,6 +34,7 @@
import org.hisp.dhis.validation.ValidationCriteria;
import org.springframework.transaction.annotation.Transactional;
+import java.util.ArrayList;
import java.util.Collection;
import java.util.HashSet;
import java.util.Set;
@@ -187,4 +188,13 @@
return i18n( i18nService, programStore.getByCode( code ) );
}
+ public Collection<Program> getProgramsByCurrentUser( OrganisationUnit organisationUnit )
+ {
+ Collection<Program> programs = new ArrayList<Program>( getProgramsByDisplayOnAllOrgunit( true, null ) );
+ programs.addAll( getProgramsByDisplayOnAllOrgunit( false, organisationUnit ) );
+ programs.retainAll( getProgramsByCurrentUser() );
+
+ return programs;
+ }
+
}
=== modified file 'dhis-2/dhis-services/dhis-service-patient/src/main/java/org/hisp/dhis/program/DefaultProgramStageInstanceService.java'
--- dhis-2/dhis-services/dhis-service-patient/src/main/java/org/hisp/dhis/program/DefaultProgramStageInstanceService.java 2013-10-08 03:23:55 +0000
+++ dhis-2/dhis-services/dhis-service-patient/src/main/java/org/hisp/dhis/program/DefaultProgramStageInstanceService.java 2013-10-24 08:31:35 +0000
@@ -166,7 +166,8 @@
}
@Override
- public Collection<ProgramStageInstance> getProgramStageInstances( ProgramInstance programInstance, ProgramStage programStage )
+ public Collection<ProgramStageInstance> getProgramStageInstances( ProgramInstance programInstance,
+ ProgramStage programStage )
{
return programStageInstanceStore.getAll( programInstance, programStage );
}
@@ -683,6 +684,84 @@
updateProgramStageInstance( programStageInstance );
}
+ @Override
+ public void setExecutionDate( ProgramStageInstance programStageInstance, Date executionDate,
+ OrganisationUnit organisationUnit )
+ {
+ programStageInstance.setExecutionDate( executionDate );
+ programStageInstance.setOrganisationUnit( organisationUnit );
+
+ if ( programStageInstance.getProgramInstance().getProgram().isSingleEvent() )
+ {
+ programStageInstance.setDueDate( executionDate );
+ }
+
+ updateProgramStageInstance( programStageInstance );
+ }
+
+ /**
+ * For the first case of an anonymous program, the program-instance doesn't
+ * exist, So system has to create a program-instance and
+ * program-stage-instance. The similar thing happens for single event with
+ * registration.
+ */
+ @Override
+ public void createProgramStageInstance( Patient patient, Program program, Date executionDate,
+ OrganisationUnit organisationUnit )
+ {
+ ProgramStage programStage = null;
+
+ if ( program.getProgramStages() != null )
+ {
+ programStage = program.getProgramStages().iterator().next();
+ }
+
+ int type = program.getType();
+ ProgramInstance programInstance = null;
+
+ if ( type == Program.SINGLE_EVENT_WITH_REGISTRATION )
+ {
+ // Add a new program-instance
+ programInstance = new ProgramInstance();
+ programInstance.setEnrollmentDate( executionDate );
+ programInstance.setDateOfIncident( executionDate );
+ programInstance.setProgram( program );
+ programInstance.setStatus( ProgramInstance.STATUS_ACTIVE );
+
+ programInstance.setPatient( patient );
+
+ programInstanceService.addProgramInstance( programInstance );
+ }
+ else if ( type == Program.SINGLE_EVENT_WITHOUT_REGISTRATION )
+ {
+ Collection<ProgramInstance> programInstances = programInstanceService.getProgramInstances( program );
+ if ( programInstances == null || programInstances.size() == 0 )
+ {
+ // Add a new program-instance if it doesn't exist
+ programInstance = new ProgramInstance();
+ programInstance.setEnrollmentDate( executionDate );
+ programInstance.setDateOfIncident( executionDate );
+ programInstance.setProgram( program );
+ programInstance.setStatus( ProgramInstance.STATUS_ACTIVE );
+ programInstanceService.addProgramInstance( programInstance );
+ }
+ else
+ {
+ programInstance = programInstanceService.getProgramInstances( program ).iterator().next();
+ }
+ }
+
+ // Add a new program-stage-instance
+ ProgramStageInstance programStageInstance = new ProgramStageInstance();
+ programStageInstance.setProgramInstance( programInstance );
+ programStageInstance.setProgramStage( programStage );
+ programStageInstance.setDueDate( executionDate );
+ programStageInstance.setExecutionDate( executionDate );
+ programStageInstance.setOrganisationUnit( organisationUnit );
+
+ addProgramStageInstance( programStageInstance );
+ }
+
// -------------------------------------------------------------------------
// Supportive methods
// -------------------------------------------------------------------------
=== modified file 'dhis-2/dhis-web/dhis-web-caseentry/src/main/java/org/hisp/dhis/caseentry/action/caseentry/CompleteDataEntryAction.java'
--- dhis-2/dhis-web/dhis-web-caseentry/src/main/java/org/hisp/dhis/caseentry/action/caseentry/CompleteDataEntryAction.java 2013-09-18 06:54:48 +0000
+++ dhis-2/dhis-web/dhis-web-caseentry/src/main/java/org/hisp/dhis/caseentry/action/caseentry/CompleteDataEntryAction.java 2013-10-24 08:31:35 +0000
@@ -128,7 +128,6 @@
}
programInstanceService.completeProgramInstanceStatus( programStageInstance.getProgramInstance(), format );
-
}
return "programcompleted";
=== modified file 'dhis-2/dhis-web/dhis-web-caseentry/src/main/java/org/hisp/dhis/caseentry/action/caseentry/CreateAnonymousEncounterAction.java'
--- dhis-2/dhis-web/dhis-web-caseentry/src/main/java/org/hisp/dhis/caseentry/action/caseentry/CreateAnonymousEncounterAction.java 2013-08-23 16:05:01 +0000
+++ dhis-2/dhis-web/dhis-web-caseentry/src/main/java/org/hisp/dhis/caseentry/action/caseentry/CreateAnonymousEncounterAction.java 2013-10-24 08:31:35 +0000
@@ -30,9 +30,9 @@
import java.util.Date;
-import org.hisp.dhis.caseentry.state.SelectedStateManager;
import org.hisp.dhis.i18n.I18n;
import org.hisp.dhis.i18n.I18nFormat;
+import org.hisp.dhis.ouwt.manager.OrganisationUnitSelectionManager;
import org.hisp.dhis.program.Program;
import org.hisp.dhis.program.ProgramInstance;
import org.hisp.dhis.program.ProgramInstanceService;
@@ -55,13 +55,13 @@
// Dependencies
// -------------------------------------------------------------------------
- private SelectedStateManager selectedStateManager;
+ private OrganisationUnitSelectionManager selectionManager;
- public void setSelectedStateManager( SelectedStateManager selectedStateManager )
+ public void setSelectionManager( OrganisationUnitSelectionManager selectionManager )
{
- this.selectedStateManager = selectedStateManager;
+ this.selectionManager = selectionManager;
}
-
+
private ProgramService programService;
public void setProgramService( ProgramService programService )
@@ -148,7 +148,7 @@
programStageInstance.setProgramStage( programStage );
programStageInstance.setDueDate( date );
programStageInstance.setExecutionDate( date );
- programStageInstance.setOrganisationUnit( selectedStateManager.getSelectedOrganisationUnit() );
+ programStageInstance.setOrganisationUnit( selectionManager.getSelectedOrganisationUnit() );
int id = programStageInstanceService.addProgramStageInstance( programStageInstance );
=== modified file 'dhis-2/dhis-web/dhis-web-caseentry/src/main/java/org/hisp/dhis/caseentry/action/caseentry/DataRecordingSelectAction.java'
--- dhis-2/dhis-web/dhis-web-caseentry/src/main/java/org/hisp/dhis/caseentry/action/caseentry/DataRecordingSelectAction.java 2013-09-18 03:49:35 +0000
+++ dhis-2/dhis-web/dhis-web-caseentry/src/main/java/org/hisp/dhis/caseentry/action/caseentry/DataRecordingSelectAction.java 2013-10-24 08:31:35 +0000
@@ -31,8 +31,8 @@
import java.util.Collection;
import java.util.HashSet;
-import org.hisp.dhis.caseentry.state.SelectedStateManager;
import org.hisp.dhis.organisationunit.OrganisationUnit;
+import org.hisp.dhis.ouwt.manager.OrganisationUnitSelectionManager;
import org.hisp.dhis.patient.Patient;
import org.hisp.dhis.patient.PatientService;
import org.hisp.dhis.program.Program;
@@ -65,11 +65,11 @@
this.programService = programService;
}
- private SelectedStateManager selectedStateManager;
+ private OrganisationUnitSelectionManager selectionManager;
- public void setSelectedStateManager( SelectedStateManager selectedStateManager )
+ public void setSelectionManager( OrganisationUnitSelectionManager selectionManager )
{
- this.selectedStateManager = selectedStateManager;
+ this.selectionManager = selectionManager;
}
// -------------------------------------------------------------------------
@@ -104,7 +104,7 @@
public String execute()
throws Exception
{
- OrganisationUnit orgunit = selectedStateManager.getSelectedOrganisationUnit();
+ OrganisationUnit orgunit = selectionManager.getSelectedOrganisationUnit();
patient = patientService.getPatient( patientId );
@@ -112,10 +112,7 @@
// Get programs which patient enrolls
// ---------------------------------------------------------------------
- programs = programService.getPrograms( orgunit );
- programs.retainAll( programService.getProgramsByCurrentUser());
-
- selectedStateManager.setSelectedPatient( patient );
+ programs = programService.getProgramsByCurrentUser( orgunit );
return SUCCESS;
}
=== modified file 'dhis-2/dhis-web/dhis-web-caseentry/src/main/java/org/hisp/dhis/caseentry/action/caseentry/GetAllProgramsAction.java'
--- dhis-2/dhis-web/dhis-web-caseentry/src/main/java/org/hisp/dhis/caseentry/action/caseentry/GetAllProgramsAction.java 2013-08-23 16:05:01 +0000
+++ dhis-2/dhis-web/dhis-web-caseentry/src/main/java/org/hisp/dhis/caseentry/action/caseentry/GetAllProgramsAction.java 2013-10-24 08:31:35 +0000
@@ -85,13 +85,11 @@
{
OrganisationUnit organisationUnit = selectionManager.getSelectedOrganisationUnit();
- programs = new ArrayList<Program>( programService.getProgramsByDisplayOnAllOrgunit( true, null ) );
- programs.addAll( programService.getProgramsByDisplayOnAllOrgunit( false, organisationUnit ) );
- programs.retainAll( programService.getProgramsByCurrentUser() );
+ programs = new ArrayList<Program>( programService.getProgramsByCurrentUser( organisationUnit ) );
programs.removeAll( programService.getPrograms( Program.SINGLE_EVENT_WITHOUT_REGISTRATION ) );
Collections.sort( programs, IdentifiableObjectNameComparator.INSTANCE );
-
+
return SUCCESS;
}
=== modified file 'dhis-2/dhis-web/dhis-web-caseentry/src/main/java/org/hisp/dhis/caseentry/action/caseentry/GetDataRecordsAction.java'
--- dhis-2/dhis-web/dhis-web-caseentry/src/main/java/org/hisp/dhis/caseentry/action/caseentry/GetDataRecordsAction.java 2013-10-02 11:24:32 +0000
+++ dhis-2/dhis-web/dhis-web-caseentry/src/main/java/org/hisp/dhis/caseentry/action/caseentry/GetDataRecordsAction.java 2013-10-24 08:31:35 +0000
@@ -36,11 +36,11 @@
import java.util.List;
import java.util.Map;
-import org.hisp.dhis.caseentry.state.SelectedStateManager;
import org.hisp.dhis.common.Grid;
import org.hisp.dhis.common.comparator.IdentifiableObjectNameComparator;
import org.hisp.dhis.i18n.I18n;
import org.hisp.dhis.organisationunit.OrganisationUnit;
+import org.hisp.dhis.ouwt.manager.OrganisationUnitSelectionManager;
import org.hisp.dhis.paging.ActionPagingSupport;
import org.hisp.dhis.patient.Patient;
import org.hisp.dhis.patient.PatientAttribute;
@@ -61,12 +61,12 @@
// -------------------------------------------------------------------------
// Dependencies
// -------------------------------------------------------------------------
-
- private SelectedStateManager selectedStateManager;
-
- public void setSelectedStateManager( SelectedStateManager selectedStateManager )
+
+ private OrganisationUnitSelectionManager selectionManager;
+
+ public void setSelectionManager( OrganisationUnitSelectionManager selectionManager )
{
- this.selectedStateManager = selectedStateManager;
+ this.selectionManager = selectionManager;
}
private PatientService patientService;
@@ -220,7 +220,7 @@
public String execute()
throws Exception
{
- OrganisationUnit orgunit = selectedStateManager.getSelectedOrganisationUnit();
+ OrganisationUnit orgunit = selectionManager.getSelectedOrganisationUnit();
Collection<OrganisationUnit> orgunits = new HashSet<OrganisationUnit>();
orgunits.add( orgunit );
=== modified file 'dhis-2/dhis-web/dhis-web-caseentry/src/main/java/org/hisp/dhis/caseentry/action/caseentry/GetProgramsByOrgunitAction.java'
--- dhis-2/dhis-web/dhis-web-caseentry/src/main/java/org/hisp/dhis/caseentry/action/caseentry/GetProgramsByOrgunitAction.java 2013-08-23 16:05:01 +0000
+++ dhis-2/dhis-web/dhis-web-caseentry/src/main/java/org/hisp/dhis/caseentry/action/caseentry/GetProgramsByOrgunitAction.java 2013-10-24 08:31:35 +0000
@@ -31,8 +31,8 @@
import java.util.ArrayList;
import java.util.Collection;
-import org.hisp.dhis.caseentry.state.SelectedStateManager;
import org.hisp.dhis.organisationunit.OrganisationUnit;
+import org.hisp.dhis.ouwt.manager.OrganisationUnitSelectionManager;
import org.hisp.dhis.program.Program;
import org.hisp.dhis.program.ProgramService;
@@ -57,11 +57,11 @@
this.programService = programService;
}
- private SelectedStateManager selectedStateManager;
+ private OrganisationUnitSelectionManager selectionManager;
- public void setSelectedStateManager( SelectedStateManager selectedStateManager )
+ public void setSelectionManager( OrganisationUnitSelectionManager selectionManager )
{
- this.selectedStateManager = selectedStateManager;
+ this.selectionManager = selectionManager;
}
// -------------------------------------------------------------------------
@@ -89,18 +89,14 @@
public String execute()
throws Exception
{
- organisationUnit = selectedStateManager.getSelectedOrganisationUnit();
+ organisationUnit = selectionManager.getSelectedOrganisationUnit();
if ( organisationUnit != null )
{
- programs = programService.getPrograms( organisationUnit );
- programs.retainAll( programService.getProgramsByCurrentUser());
- programs.removeAll( programService.getPrograms( Program.SINGLE_EVENT_WITHOUT_REGISTRATION, organisationUnit ) );
+ programs = programService.getProgramsByCurrentUser( organisationUnit );
+ programs.removeAll( programService.getProgramsByCurrentUser( Program.SINGLE_EVENT_WITH_REGISTRATION ) );
+ programs.removeAll( programService.getProgramsByCurrentUser( Program.SINGLE_EVENT_WITHOUT_REGISTRATION ) );
}
-
- selectedStateManager.clearSelectedPatient();
- selectedStateManager.clearSelectedProgramInstance();
- selectedStateManager.clearSelectedProgramStageInstance();
return SUCCESS;
}
=== modified file 'dhis-2/dhis-web/dhis-web-caseentry/src/main/java/org/hisp/dhis/caseentry/action/caseentry/GetSingleEventProgramListAction.java'
--- dhis-2/dhis-web/dhis-web-caseentry/src/main/java/org/hisp/dhis/caseentry/action/caseentry/GetSingleEventProgramListAction.java 2013-08-23 16:05:01 +0000
+++ dhis-2/dhis-web/dhis-web-caseentry/src/main/java/org/hisp/dhis/caseentry/action/caseentry/GetSingleEventProgramListAction.java 2013-10-24 08:31:35 +0000
@@ -85,10 +85,11 @@
if ( orgunit != null )
{
- programs = programService.getPrograms( Program.SINGLE_EVENT_WITH_REGISTRATION, orgunit );
- programs.retainAll( programService.getProgramsByCurrentUser());
+ programs = programService.getProgramsByCurrentUser( orgunit );
+ programs.removeAll( programService.getPrograms( Program.MULTIPLE_EVENTS_WITH_REGISTRATION, orgunit ) );
+ programs.removeAll( programService.getPrograms( Program.SINGLE_EVENT_WITHOUT_REGISTRATION, orgunit ) );
}
-
+
return SUCCESS;
}
=== modified file 'dhis-2/dhis-web/dhis-web-caseentry/src/main/java/org/hisp/dhis/caseentry/action/caseentry/LoadDataEntryAction.java'
--- dhis-2/dhis-web/dhis-web-caseentry/src/main/java/org/hisp/dhis/caseentry/action/caseentry/LoadDataEntryAction.java 2013-09-18 02:45:29 +0000
+++ dhis-2/dhis-web/dhis-web-caseentry/src/main/java/org/hisp/dhis/caseentry/action/caseentry/LoadDataEntryAction.java 2013-10-24 08:31:35 +0000
@@ -35,11 +35,11 @@
import java.util.List;
import java.util.Map;
-import org.hisp.dhis.caseentry.state.SelectedStateManager;
import org.hisp.dhis.dataentryform.DataEntryForm;
import org.hisp.dhis.i18n.I18n;
import org.hisp.dhis.organisationunit.OrganisationUnit;
import org.hisp.dhis.organisationunit.OrganisationUnitService;
+import org.hisp.dhis.ouwt.manager.OrganisationUnitSelectionManager;
import org.hisp.dhis.patient.Patient;
import org.hisp.dhis.patientdatavalue.PatientDataValue;
import org.hisp.dhis.patientdatavalue.PatientDataValueService;
@@ -98,11 +98,11 @@
this.programStageInstanceService = programStageInstanceService;
}
- private SelectedStateManager selectedStateManager;
+ private OrganisationUnitSelectionManager selectionManager;
- public void setSelectedStateManager( SelectedStateManager selectedStateManager )
+ public void setSelectionManager( OrganisationUnitSelectionManager selectionManager )
{
- this.selectedStateManager = selectedStateManager;
+ this.selectionManager = selectionManager;
}
private ProgramStageSectionService programStageSectionService;
@@ -119,13 +119,6 @@
this.organisationUnitService = organisationUnitService;
}
- private String displayOptionSetAsRadioButton;
-
- public String getDisplayOptionSetAsRadioButton()
- {
- return displayOptionSetAsRadioButton;
- }
-
// -------------------------------------------------------------------------
// Input && Output
// -------------------------------------------------------------------------
@@ -158,6 +151,8 @@
private ProgramIndicatorService programIndicatorService;
+ private String displayOptionSetAsRadioButton;
+
// -------------------------------------------------------------------------
// Getters && Setters
// -------------------------------------------------------------------------
@@ -267,6 +262,11 @@
return programIndicatorsMap;
}
+ public String getDisplayOptionSetAsRadioButton()
+ {
+ return displayOptionSetAsRadioButton;
+ }
+
// -------------------------------------------------------------------------
// Implementation Action
// -------------------------------------------------------------------------
@@ -281,8 +281,6 @@
program = programStageInstance.getProgramStage().getProgram();
programStage = programStageInstance.getProgramStage();
-
- selectedStateManager.setSelectedProgramStageInstance( programStageInstance );
}
else if ( programStageId != null )
{
@@ -330,7 +328,7 @@
// Get registration orgunit
// ---------------------------------------------------------------------
- organisationUnit = organisationUnitId == null ? selectedStateManager.getSelectedOrganisationUnit()
+ organisationUnit = organisationUnitId == null ? selectionManager.getSelectedOrganisationUnit()
: organisationUnitService.getOrganisationUnit( organisationUnitId );
if ( program.isRegistration() )
@@ -362,7 +360,7 @@
longitude = ValidationUtils.getLongitude( programStageInstance.getCoordinates() );
latitude = ValidationUtils.getLatitude( programStageInstance.getCoordinates() );
}
-
+
return SUCCESS;
}
=== modified file 'dhis-2/dhis-web/dhis-web-caseentry/src/main/java/org/hisp/dhis/caseentry/action/caseentry/LoadProgramStageInstancesAction.java'
--- dhis-2/dhis-web/dhis-web-caseentry/src/main/java/org/hisp/dhis/caseentry/action/caseentry/LoadProgramStageInstancesAction.java 2013-08-23 16:05:01 +0000
+++ dhis-2/dhis-web/dhis-web-caseentry/src/main/java/org/hisp/dhis/caseentry/action/caseentry/LoadProgramStageInstancesAction.java 2013-10-24 08:31:35 +0000
@@ -33,8 +33,8 @@
import java.util.List;
import java.util.Map;
-import org.hisp.dhis.caseentry.state.SelectedStateManager;
import org.hisp.dhis.patient.Patient;
+import org.hisp.dhis.patient.PatientService;
import org.hisp.dhis.program.Program;
import org.hisp.dhis.program.ProgramInstance;
import org.hisp.dhis.program.ProgramInstanceService;
@@ -54,6 +54,13 @@
// Dependencies
// -------------------------------------------------------------------------
+ private PatientService patientService;
+
+ public void setPatientService( PatientService patientService )
+ {
+ this.patientService = patientService;
+ }
+
private ProgramService programService;
public void setProgramService( ProgramService programService )
@@ -75,17 +82,17 @@
this.programStageInstanceService = programStageInstanceService;
}
- private SelectedStateManager selectedStateManager;
-
- public void setSelectedStateManager( SelectedStateManager selectedStateManager )
- {
- this.selectedStateManager = selectedStateManager;
- }
-
// -------------------------------------------------------------------------
// Input && Output
// -------------------------------------------------------------------------
+ private Integer patientId;
+
+ public void setPatientId( Integer patientId )
+ {
+ this.patientId = patientId;
+ }
+
private Integer programId;
public void setProgramId( Integer programId )
@@ -99,9 +106,9 @@
{
return statusMap;
}
-
+
private ProgramInstance programInstance;
-
+
public ProgramInstance getProgramInstance()
{
return programInstance;
@@ -120,7 +127,7 @@
{
return program;
}
-
+
// -------------------------------------------------------------------------
// Implementation Action
// -------------------------------------------------------------------------
@@ -128,16 +135,13 @@
public String execute()
throws Exception
{
- selectedStateManager.clearSelectedProgramInstance();
- selectedStateManager.clearSelectedProgramStageInstance();
-
- Patient patient = selectedStateManager.getSelectedPatient();
+ Patient patient = patientService.getPatient( patientId );
program = programService.getProgram( programId );
List<ProgramInstance> programInstances = new ArrayList<ProgramInstance>();
- if ( program.getType() == Program.MULTIPLE_EVENTS_WITH_REGISTRATION)
+ if ( program.getType() == Program.MULTIPLE_EVENTS_WITH_REGISTRATION )
{
programInstances = new ArrayList<ProgramInstance>( programInstanceService.getProgramInstances( patient,
program, ProgramInstance.STATUS_ACTIVE ) );
@@ -156,17 +160,16 @@
{
programInstance = programInstances.iterator().next();
- selectedStateManager.setSelectedProgramInstance( programInstance );
-
if ( programInstance.getProgramStageInstances() != null )
{
if ( program.isRegistration() )
{
- statusMap = programStageInstanceService.statusProgramStageInstances( programInstance.getProgramStageInstances() );
+ statusMap = programStageInstanceService.statusProgramStageInstances( programInstance
+ .getProgramStageInstances() );
}
}
}
-
+
return SUCCESS;
}
}
=== modified file 'dhis-2/dhis-web/dhis-web-caseentry/src/main/java/org/hisp/dhis/caseentry/action/caseentry/MultiDataEntrySelectAction.java'
--- dhis-2/dhis-web/dhis-web-caseentry/src/main/java/org/hisp/dhis/caseentry/action/caseentry/MultiDataEntrySelectAction.java 2013-08-23 16:05:01 +0000
+++ dhis-2/dhis-web/dhis-web-caseentry/src/main/java/org/hisp/dhis/caseentry/action/caseentry/MultiDataEntrySelectAction.java 2013-10-24 08:31:35 +0000
@@ -31,8 +31,8 @@
import java.util.ArrayList;
import java.util.Collection;
-import org.hisp.dhis.caseentry.state.SelectedStateManager;
import org.hisp.dhis.organisationunit.OrganisationUnit;
+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;
@@ -47,11 +47,11 @@
// Dependencies
// -------------------------------------------------------------------------
- private SelectedStateManager selectedStateManager;
+ private OrganisationUnitSelectionManager selectionManager;
- public void setSelectedStateManager( SelectedStateManager selectedStateManager )
+ public void setSelectionManager( OrganisationUnitSelectionManager selectionManager )
{
- this.selectedStateManager = selectedStateManager;
+ this.selectionManager = selectionManager;
}
private ProgramService programService;
@@ -114,15 +114,16 @@
{
patientAttributes = patientAttributeService.getAllPatientAttributes();
- organisationUnit = selectedStateManager.getSelectedOrganisationUnit();
+ organisationUnit = selectionManager.getSelectedOrganisationUnit();
if ( organisationUnit != null )
{
- programs = programService.getPrograms( organisationUnit );
- programs.retainAll( programService.getProgramsByCurrentUser());
- programs.removeAll( programService.getPrograms( Program.SINGLE_EVENT_WITHOUT_REGISTRATION, organisationUnit ) );
+ programs = programService.getProgramsByCurrentUser( organisationUnit );
+ programs.removeAll( programService.getPrograms( Program.SINGLE_EVENT_WITH_REGISTRATION, organisationUnit ) );
+ programs.removeAll( programService
+ .getPrograms( Program.SINGLE_EVENT_WITHOUT_REGISTRATION, organisationUnit ) );
}
-
+
return SUCCESS;
}
}
=== modified file 'dhis-2/dhis-web/dhis-web-caseentry/src/main/java/org/hisp/dhis/caseentry/action/caseentry/SaveExecutionDateAction.java'
--- dhis-2/dhis-web/dhis-web-caseentry/src/main/java/org/hisp/dhis/caseentry/action/caseentry/SaveExecutionDateAction.java 2013-09-18 03:49:35 +0000
+++ dhis-2/dhis-web/dhis-web-caseentry/src/main/java/org/hisp/dhis/caseentry/action/caseentry/SaveExecutionDateAction.java 2013-10-24 08:31:35 +0000
@@ -28,22 +28,18 @@
* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/
-import java.util.Collection;
import java.util.Date;
import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
-import org.hisp.dhis.caseentry.state.SelectedStateManager;
import org.hisp.dhis.i18n.I18nFormat;
import org.hisp.dhis.organisationunit.OrganisationUnit;
import org.hisp.dhis.organisationunit.OrganisationUnitService;
+import org.hisp.dhis.ouwt.manager.OrganisationUnitSelectionManager;
import org.hisp.dhis.patient.Patient;
import org.hisp.dhis.patient.PatientService;
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.ProgramStageInstance;
import org.hisp.dhis.program.ProgramStageInstanceService;
@@ -76,13 +72,6 @@
this.programService = programService;
}
- private ProgramInstanceService programInstanceService;
-
- public void setProgramInstanceService( ProgramInstanceService programInstanceService )
- {
- this.programInstanceService = programInstanceService;
- }
-
private PatientService patientService;
public void setPatientService( PatientService patientService )
@@ -97,11 +86,11 @@
this.organisationUnitService = organisationUnitService;
}
- private SelectedStateManager selectedStateManager;
+ private OrganisationUnitSelectionManager selectionManager;
- public void setSelectedStateManager( SelectedStateManager selectedStateManager )
+ public void setSelectionManager( OrganisationUnitSelectionManager selectionManager )
{
- this.selectedStateManager = selectedStateManager;
+ this.selectionManager = selectionManager;
}
private I18nFormat format;
@@ -166,91 +155,25 @@
{
Date dateValue = format.parseDate( executionDate );
- OrganisationUnit organisationUnit = organisationUnitId == null ? selectedStateManager
- .getSelectedOrganisationUnit() : organisationUnitService.getOrganisationUnit( organisationUnitId );
-
- Patient patient = patientId == null ? selectedStateManager.getSelectedPatient() : patientService
- .getPatient( patientId );
-
if ( dateValue != null )
{
+ OrganisationUnit organisationUnit = organisationUnitId == null ? selectionManager
+ .getSelectedOrganisationUnit() : organisationUnitService.getOrganisationUnit( organisationUnitId );
ProgramStageInstance programStageInstance = programStageInstanceService
.getProgramStageInstance( programStageInstanceId );
- // If the program-stage-instance of the patient not exists,
- // create a program-instance and program-stage-instance for
- // single-event program
if ( programStageInstance == null )
{
- Program program = programService.getProgram( programId );
- ProgramStage programStage = null;
-
- if ( program.getProgramStages() != null )
- {
- programStage = program.getProgramStages().iterator().next();
- }
-
- int type = program.getType();
- ProgramInstance programInstance = null;
-
- if ( type == Program.SINGLE_EVENT_WITH_REGISTRATION )
- {
- // Add a new program-instance
- programInstance = new ProgramInstance();
- programInstance.setEnrollmentDate( dateValue );
- programInstance.setDateOfIncident( dateValue );
- programInstance.setProgram( program );
- programInstance.setStatus( ProgramInstance.STATUS_ACTIVE );
-
- programInstance.setPatient( patient );
-
- programInstanceService.addProgramInstance( programInstance );
- }
- else if ( type == Program.SINGLE_EVENT_WITHOUT_REGISTRATION )
- {
- Collection<ProgramInstance> programInstances = programInstanceService.getProgramInstances( program );
- if ( programInstances == null || programInstances.size() == 0 )
- {
- // Add a new program-instance
- programInstance = new ProgramInstance();
- programInstance.setEnrollmentDate( dateValue );
- programInstance.setDateOfIncident( dateValue );
- programInstance.setProgram( program );
- programInstance.setStatus( ProgramInstance.STATUS_ACTIVE );
- programInstanceService.addProgramInstance( programInstance );
- }
- else
- {
- programInstance = programInstanceService.getProgramInstances( program ).iterator().next();
- }
- }
-
- // Add a new program-stage-instance
- programStageInstance = new ProgramStageInstance();
- programStageInstance.setProgramInstance( programInstance );
- programStageInstance.setProgramStage( programStage );
- programStageInstance.setDueDate( dateValue );
- programStageInstance.setExecutionDate( dateValue );
- programStageInstance.setOrganisationUnit( organisationUnit );
-
- programStageInstanceService.addProgramStageInstance( programStageInstance );
- selectedStateManager.setSelectedProgramInstance( programInstance );
- selectedStateManager.setSelectedProgramStageInstance( programStageInstance );
+ Program program = (programId == null) ? null : programService.getProgram( programId );
+ Patient patient = patientService.getPatient( patientId );
+ programStageInstanceService.createProgramStageInstance( patient, program, dateValue, organisationUnit );
}
else
{
- programStageInstance.setExecutionDate( dateValue );
- programStageInstance.setOrganisationUnit( organisationUnit );
-
- if ( programStageInstance.getProgramInstance().getProgram().isSingleEvent() )
- {
- programStageInstance.setDueDate( dateValue );
- }
-
- programStageInstanceService.updateProgramStageInstance( programStageInstance );
+ programStageInstanceService.setExecutionDate( programStageInstance, dateValue, organisationUnit );
}
- LOG.debug( "Updating Execution Date, value added/changed" );
+ LOG.debug( "Updating Execution Date, value added/updated" );
message = programStageInstance.getId() + "";
=== modified file 'dhis-2/dhis-web/dhis-web-caseentry/src/main/java/org/hisp/dhis/caseentry/action/caseentry/SaveProvidingFacilityAction.java'
--- dhis-2/dhis-web/dhis-web-caseentry/src/main/java/org/hisp/dhis/caseentry/action/caseentry/SaveProvidingFacilityAction.java 2013-08-23 16:05:01 +0000
+++ dhis-2/dhis-web/dhis-web-caseentry/src/main/java/org/hisp/dhis/caseentry/action/caseentry/SaveProvidingFacilityAction.java 2013-10-24 08:31:35 +0000
@@ -28,12 +28,12 @@
* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/
-import org.hisp.dhis.caseentry.state.SelectedStateManager;
import org.hisp.dhis.dataelement.DataElement;
import org.hisp.dhis.dataelement.DataElementService;
import org.hisp.dhis.patientdatavalue.PatientDataValue;
import org.hisp.dhis.patientdatavalue.PatientDataValueService;
import org.hisp.dhis.program.ProgramStageInstance;
+import org.hisp.dhis.program.ProgramStageInstanceService;
import com.opensymphony.xwork2.Action;
@@ -48,13 +48,6 @@
// Dependencies
// -------------------------------------------------------------------------
- private SelectedStateManager selectedStateManager;
-
- public void setSelectedStateManager( SelectedStateManager selectedStateManager )
- {
- this.selectedStateManager = selectedStateManager;
- }
-
private DataElementService dataElementService;
public void setDataElementService( DataElementService dataElementService )
@@ -69,17 +62,31 @@
this.patientDataValueService = patientDataValueService;
}
+ private ProgramStageInstanceService programStageInstanceService;
+
+ public void setProgramStageInstanceService( ProgramStageInstanceService programStageInstanceService )
+ {
+ this.programStageInstanceService = programStageInstanceService;
+ }
+
// -------------------------------------------------------------------------
// Input/Output
// -------------------------------------------------------------------------
- private int dataElementId;
+ private String dataElementId;
- public void setDataElementId( int dataElementId )
+ public void setDataElementId( String dataElementId )
{
this.dataElementId = dataElementId;
}
+ private Integer programStageInstanceId;
+
+ public void setProgramStageInstanceId( Integer programStageInstanceId )
+ {
+ this.programStageInstanceId = programStageInstanceId;
+ }
+
private Boolean providedElsewhere;
public void setProvidedElsewhere( Boolean providedElsewhere )
@@ -101,7 +108,8 @@
public String execute()
throws Exception
{
- ProgramStageInstance programStageInstance = selectedStateManager.getSelectedProgramStageInstance();
+ ProgramStageInstance programStageInstance = programStageInstanceService
+ .getProgramStageInstance( programStageInstanceId );
DataElement dataElement = dataElementService.getDataElement( dataElementId );
=== modified file 'dhis-2/dhis-web/dhis-web-caseentry/src/main/java/org/hisp/dhis/caseentry/action/caseentry/SaveValuesAction.java'
--- dhis-2/dhis-web/dhis-web-caseentry/src/main/java/org/hisp/dhis/caseentry/action/caseentry/SaveValuesAction.java 2013-09-18 03:49:35 +0000
+++ dhis-2/dhis-web/dhis-web-caseentry/src/main/java/org/hisp/dhis/caseentry/action/caseentry/SaveValuesAction.java 2013-10-24 08:31:35 +0000
@@ -36,7 +36,7 @@
import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
import org.apache.struts2.ServletActionContext;
-import org.hisp.dhis.caseentry.state.SelectedStateManager;
+import org.hisp.dhis.ouwt.manager.OrganisationUnitSelectionManager;
import org.hisp.dhis.patient.Patient;
import org.hisp.dhis.patient.PatientService;
import org.hisp.dhis.patientdatavalue.PatientDataValue;
@@ -102,13 +102,14 @@
this.programInstanceService = programInstanceService;
}
- private SelectedStateManager selectedStateManager;
+ private OrganisationUnitSelectionManager selectionManager;
- public void setSelectedStateManager( SelectedStateManager selectedStateManager )
+ public void setSelectionManager( OrganisationUnitSelectionManager selectionManager )
{
- this.selectedStateManager = selectedStateManager;
+ this.selectionManager = selectionManager;
}
+
private CurrentUserService currentUserService;
public void setCurrentUserService( CurrentUserService currentUserService )
@@ -175,7 +176,7 @@
programStageInstance.setProgramStage( programStage );
programStageInstance.setDueDate( currentDate );
programStageInstance.setExecutionDate( currentDate );
- programStageInstance.setOrganisationUnit( selectedStateManager.getSelectedOrganisationUnit() );
+ programStageInstance.setOrganisationUnit( selectionManager.getSelectedOrganisationUnit() );
programStageInstance.setCompleted( true );
programStageInstanceService.addProgramStageInstance( programStageInstance );
=== modified file 'dhis-2/dhis-web/dhis-web-caseentry/src/main/java/org/hisp/dhis/caseentry/action/patient/AddPatientAction.java'
--- dhis-2/dhis-web/dhis-web-caseentry/src/main/java/org/hisp/dhis/caseentry/action/patient/AddPatientAction.java 2013-10-08 17:16:47 +0000
+++ dhis-2/dhis-web/dhis-web-caseentry/src/main/java/org/hisp/dhis/caseentry/action/patient/AddPatientAction.java 2013-10-24 08:31:35 +0000
@@ -28,11 +28,16 @@
* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/
-import com.opensymphony.xwork2.Action;
+import java.util.ArrayList;
+import java.util.Collection;
+import java.util.Date;
+import java.util.List;
+
+import javax.servlet.http.HttpServletRequest;
+
import org.apache.commons.lang.StringUtils;
import org.apache.commons.lang.math.NumberUtils;
import org.apache.struts2.ServletActionContext;
-import org.hisp.dhis.caseentry.state.SelectedStateManager;
import org.hisp.dhis.i18n.I18nFormat;
import org.hisp.dhis.organisationunit.OrganisationUnit;
import org.hisp.dhis.ouwt.manager.OrganisationUnitSelectionManager;
@@ -55,11 +60,7 @@
import org.hisp.dhis.setting.SystemSettingManager;
import org.hisp.dhis.user.UserService;
-import javax.servlet.http.HttpServletRequest;
-import java.util.ArrayList;
-import java.util.Collection;
-import java.util.Date;
-import java.util.List;
+import com.opensymphony.xwork2.Action;
/**
* @author Abyot Asalefew Gizaw
@@ -86,8 +87,6 @@
private OrganisationUnitSelectionManager selectionManager;
- private SelectedStateManager selectedStateManager;
-
private PatientAttributeService patientAttributeService;
private PatientAttributeOptionService patientAttributeOptionService;
@@ -178,7 +177,7 @@
phone = (phone.isEmpty()) ? null : phone.substring( 0, phone.length() - 1 );
patient.setPhoneNumber( phone );
}
-
+
patient.setGender( gender );
patient.setIsDead( false );
patient.setUnderAge( underAge );
@@ -290,10 +289,6 @@
patient.getIdentifiers().add( systemGenerateIdentifier );
- selectedStateManager.clearListAll();
- selectedStateManager.clearSearchingAttributeId();
- selectedStateManager.setSearchText( systemGenerateIdentifier.getIdentifier() );
-
// -----------------------------------------------------------------------------
// Prepare Patient Attributes
// -----------------------------------------------------------------------------
@@ -476,11 +471,6 @@
this.selectionManager = selectionManager;
}
- public void setSelectedStateManager( SelectedStateManager selectedStateManager )
- {
- this.selectedStateManager = selectedStateManager;
- }
-
public void setPatientAttributeService( PatientAttributeService patientAttributeService )
{
this.patientAttributeService = patientAttributeService;
=== modified file 'dhis-2/dhis-web/dhis-web-caseentry/src/main/java/org/hisp/dhis/caseentry/action/patient/AddRelationshipPatientAction.java'
--- dhis-2/dhis-web/dhis-web-caseentry/src/main/java/org/hisp/dhis/caseentry/action/patient/AddRelationshipPatientAction.java 2013-09-19 12:43:34 +0000
+++ dhis-2/dhis-web/dhis-web-caseentry/src/main/java/org/hisp/dhis/caseentry/action/patient/AddRelationshipPatientAction.java 2013-10-24 08:31:35 +0000
@@ -36,9 +36,9 @@
import org.apache.commons.lang.StringUtils;
import org.apache.commons.lang.math.NumberUtils;
import org.apache.struts2.ServletActionContext;
-import org.hisp.dhis.caseentry.state.SelectedStateManager;
import org.hisp.dhis.i18n.I18nFormat;
import org.hisp.dhis.organisationunit.OrganisationUnit;
+import org.hisp.dhis.ouwt.manager.OrganisationUnitSelectionManager;
import org.hisp.dhis.patient.Patient;
import org.hisp.dhis.patient.PatientAttribute;
import org.hisp.dhis.patient.PatientAttributeOption;
@@ -80,7 +80,7 @@
private PatientIdentifierTypeService patientIdentifierTypeService;
- private SelectedStateManager selectedStateManager;
+ private OrganisationUnitSelectionManager selectionManager;
private PatientAttributeService patientAttributeService;
@@ -154,7 +154,7 @@
public String execute()
{
- OrganisationUnit organisationUnit = selectedStateManager.getSelectedOrganisationUnit();
+ OrganisationUnit organisationUnit = selectionManager.getSelectedOrganisationUnit();
patient = new Patient();
@@ -263,12 +263,7 @@
systemGenerateIdentifier.setPatient( patient );
patient.getIdentifiers().add( systemGenerateIdentifier );
-
- selectedStateManager.clearListAll();
- selectedStateManager.clearSearchingAttributeId();
- selectedStateManager.clearSortingAttributeId();
- selectedStateManager.setSearchText( systemGenerateIdentifier.getIdentifier() );
-
+
// ---------------------------------------------------------------------
// Save Patient Identifiers
// ---------------------------------------------------------------------
@@ -412,9 +407,9 @@
this.patientIdentifierService = patientIdentifierService;
}
- public void setSelectedStateManager( SelectedStateManager selectedStateManager )
+ public void setSelectionManager( OrganisationUnitSelectionManager selectionManager )
{
- this.selectedStateManager = selectedStateManager;
+ this.selectionManager = selectionManager;
}
public void setPatientAttributeService( PatientAttributeService patientAttributeService )
=== modified file 'dhis-2/dhis-web/dhis-web-caseentry/src/main/java/org/hisp/dhis/caseentry/action/patient/ProgramEnrollmentAction.java'
--- dhis-2/dhis-web/dhis-web-caseentry/src/main/java/org/hisp/dhis/caseentry/action/patient/ProgramEnrollmentAction.java 2013-09-27 11:13:20 +0000
+++ dhis-2/dhis-web/dhis-web-caseentry/src/main/java/org/hisp/dhis/caseentry/action/patient/ProgramEnrollmentAction.java 2013-10-24 08:31:35 +0000
@@ -36,8 +36,8 @@
import java.util.List;
import java.util.Map;
-import org.hisp.dhis.caseentry.state.SelectedStateManager;
import org.hisp.dhis.organisationunit.OrganisationUnit;
+import org.hisp.dhis.ouwt.manager.OrganisationUnitSelectionManager;
import org.hisp.dhis.patient.PatientAttribute;
import org.hisp.dhis.patient.PatientAttributeGroup;
import org.hisp.dhis.patient.PatientIdentifier;
@@ -69,7 +69,7 @@
private PatientAttributeValueService patientAttributeValueService;
- private SelectedStateManager selectedStateManager;
+ private OrganisationUnitSelectionManager selectionManager;
// -------------------------------------------------------------------------
// Input/Output
@@ -98,10 +98,9 @@
// -------------------------------------------------------------------------
// Getters/Setters
// -------------------------------------------------------------------------
-
- public void setSelectedStateManager( SelectedStateManager selectedStateManager )
+ public void setSelectionManager( OrganisationUnitSelectionManager selectionManager )
{
- this.selectedStateManager = selectedStateManager;
+ this.selectionManager = selectionManager;
}
public Collection<PatientAttribute> getNoGroupAttributes()
@@ -176,7 +175,7 @@
public String execute()
throws Exception
{
- OrganisationUnit orgunit = selectedStateManager.getSelectedOrganisationUnit();
+ OrganisationUnit orgunit = selectionManager.getSelectedOrganisationUnit();
// ---------------------------------------------------------------------
// Load active ProgramInstance, completed = false
=== modified file 'dhis-2/dhis-web/dhis-web-caseentry/src/main/java/org/hisp/dhis/caseentry/action/patient/ProgramEnrollmentSelectAction.java'
--- dhis-2/dhis-web/dhis-web-caseentry/src/main/java/org/hisp/dhis/caseentry/action/patient/ProgramEnrollmentSelectAction.java 2013-09-18 03:49:35 +0000
+++ dhis-2/dhis-web/dhis-web-caseentry/src/main/java/org/hisp/dhis/caseentry/action/patient/ProgramEnrollmentSelectAction.java 2013-10-24 08:31:35 +0000
@@ -32,8 +32,8 @@
import java.util.Collection;
import java.util.Iterator;
-import org.hisp.dhis.caseentry.state.SelectedStateManager;
import org.hisp.dhis.organisationunit.OrganisationUnit;
+import org.hisp.dhis.ouwt.manager.OrganisationUnitSelectionManager;
import org.hisp.dhis.patient.Patient;
import org.hisp.dhis.patient.PatientService;
import org.hisp.dhis.program.Program;
@@ -75,11 +75,11 @@
this.programInstanceService = programInstanceService;
}
- private SelectedStateManager selectedStateManager;
+ private OrganisationUnitSelectionManager selectionManager;
- public void setSelectedStateManager( SelectedStateManager selectedStateManager )
+ public void setSelectionManager( OrganisationUnitSelectionManager selectionManager )
{
- this.selectedStateManager = selectedStateManager;
+ this.selectionManager = selectionManager;
}
// -------------------------------------------------------------------------
@@ -114,32 +114,31 @@
public String execute()
throws Exception
{
- OrganisationUnit orgunit = selectedStateManager.getSelectedOrganisationUnit();
+ OrganisationUnit orgunit = selectionManager.getSelectedOrganisationUnit();
patient = patientService.getPatient( id );
// Get all programs
-
- programs = new ArrayList<Program>( programService.getProgramsByDisplayOnAllOrgunit( true, null ) );
- programs.addAll( programService.getProgramsByDisplayOnAllOrgunit( false, orgunit ) );
- programs.retainAll( programService.getProgramsByCurrentUser() );
+
+ programs = new ArrayList<Program>( programService.getProgramsByCurrentUser( orgunit ) );
programs.removeAll( programService.getPrograms( Program.SINGLE_EVENT_WITHOUT_REGISTRATION ) );
-
+
Iterator<Program> iterProgram = programs.iterator();
- while(iterProgram.hasNext() )
+ while ( iterProgram.hasNext() )
{
- if( iterProgram.next().getOnlyEnrollOnce())
+ if ( iterProgram.next().getOnlyEnrollOnce() )
{
iterProgram.remove();
}
}
-
- Collection<ProgramInstance> programInstances = programInstanceService.getProgramInstances( patient, ProgramInstance.STATUS_ACTIVE );
+
+ Collection<ProgramInstance> programInstances = programInstanceService.getProgramInstances( patient,
+ ProgramInstance.STATUS_ACTIVE );
for ( ProgramInstance programInstance : programInstances )
{
programs.remove( programInstance.getProgram() );
}
-
+
return SUCCESS;
}
}
=== modified file 'dhis-2/dhis-web/dhis-web-caseentry/src/main/java/org/hisp/dhis/caseentry/action/patient/SaveProgramEnrollmentAction.java'
--- dhis-2/dhis-web/dhis-web-caseentry/src/main/java/org/hisp/dhis/caseentry/action/patient/SaveProgramEnrollmentAction.java 2013-10-16 17:29:40 +0000
+++ dhis-2/dhis-web/dhis-web-caseentry/src/main/java/org/hisp/dhis/caseentry/action/patient/SaveProgramEnrollmentAction.java 2013-10-24 08:31:35 +0000
@@ -34,9 +34,9 @@
import java.util.Date;
import java.util.List;
-import org.hisp.dhis.caseentry.state.SelectedStateManager;
import org.hisp.dhis.i18n.I18nFormat;
import org.hisp.dhis.organisationunit.OrganisationUnit;
+import org.hisp.dhis.ouwt.manager.OrganisationUnitSelectionManager;
import org.hisp.dhis.patient.Patient;
import org.hisp.dhis.patient.PatientService;
import org.hisp.dhis.program.Program;
@@ -80,11 +80,11 @@
this.programInstanceService = programInstanceService;
}
- private SelectedStateManager selectedStateManager;
+ private OrganisationUnitSelectionManager selectionManager;
- public void setSelectedStateManager( SelectedStateManager selectedStateManager )
+ public void setSelectionManager( OrganisationUnitSelectionManager selectionManager )
{
- this.selectedStateManager = selectedStateManager;
+ this.selectionManager = selectionManager;
}
private I18nFormat format;
@@ -157,7 +157,7 @@
Program program = programService.getProgram( programId );
- OrganisationUnit orgunit = selectedStateManager.getSelectedOrganisationUnit();
+ OrganisationUnit orgunit = selectionManager.getSelectedOrganisationUnit();
Date enrollment = (enrollmentDate == null || enrollmentDate.isEmpty()) ? null : format
.parseDate( enrollmentDate );
@@ -166,7 +166,7 @@
Collection<ProgramInstance> programInstances = programInstanceService.getProgramInstances( patient, program,
ProgramInstance.STATUS_ACTIVE );
-
+
if ( programInstances.iterator().hasNext() )
{
programInstance = programInstances.iterator().next();
=== modified file 'dhis-2/dhis-web/dhis-web-caseentry/src/main/java/org/hisp/dhis/caseentry/action/patient/SelectAction.java'
--- dhis-2/dhis-web/dhis-web-caseentry/src/main/java/org/hisp/dhis/caseentry/action/patient/SelectAction.java 2013-10-09 06:58:10 +0000
+++ dhis-2/dhis-web/dhis-web-caseentry/src/main/java/org/hisp/dhis/caseentry/action/patient/SelectAction.java 2013-10-24 08:31:35 +0000
@@ -118,11 +118,9 @@
patientAttributes = patientAttributeService.getAllPatientAttributes();
- programs = new ArrayList<Program>( programService.getProgramsByDisplayOnAllOrgunit( true, null ) );
- programs.addAll( programService.getProgramsByDisplayOnAllOrgunit( false, organisationUnit ) );
- programs.retainAll( programService.getProgramsByCurrentUser() );
+ programs = new ArrayList<Program>( programService.getProgramsByCurrentUser( organisationUnit ) );
programs.removeAll( programService.getPrograms( Program.SINGLE_EVENT_WITHOUT_REGISTRATION ) );
-
+
Collections.sort( programs, IdentifiableObjectNameComparator.INSTANCE );
return SUCCESS;
=== modified file 'dhis-2/dhis-web/dhis-web-caseentry/src/main/java/org/hisp/dhis/caseentry/action/patient/ValidatePatientAction.java'
--- dhis-2/dhis-web/dhis-web-caseentry/src/main/java/org/hisp/dhis/caseentry/action/patient/ValidatePatientAction.java 2013-10-23 18:10:11 +0000
+++ dhis-2/dhis-web/dhis-web-caseentry/src/main/java/org/hisp/dhis/caseentry/action/patient/ValidatePatientAction.java 2013-10-24 08:31:35 +0000
@@ -38,7 +38,6 @@
import org.apache.commons.lang.StringUtils;
import org.apache.struts2.ServletActionContext;
-import org.hisp.dhis.i18n.I18n;
import org.hisp.dhis.i18n.I18nFormat;
import org.hisp.dhis.organisationunit.OrganisationUnit;
import org.hisp.dhis.ouwt.manager.OrganisationUnitSelectionManager;
@@ -47,8 +46,6 @@
import org.hisp.dhis.patient.PatientIdentifierType;
import org.hisp.dhis.patient.PatientIdentifierTypeService;
import org.hisp.dhis.patient.PatientService;
-import org.hisp.dhis.patientattributevalue.PatientAttributeValue;
-import org.hisp.dhis.patientattributevalue.PatientAttributeValueService;
import org.hisp.dhis.program.Program;
import org.hisp.dhis.program.ProgramService;
@@ -70,8 +67,6 @@
private PatientService patientService;
- private PatientAttributeValueService patientAttributeValueService;
-
private PatientIdentifierTypeService identifierTypeService;
private ProgramService programService;
@@ -92,14 +87,8 @@
private Integer id;
- private boolean checkedDuplicate;
-
private boolean underAge;
- private Integer representativeId;
-
- private Integer relationshipTypeId;
-
private Integer programId;
// -------------------------------------------------------------------------
@@ -108,8 +97,6 @@
private String message;
- private I18n i18n;
-
private Map<String, String> patientAttributeValueMap = new HashMap<String, String>();
private PatientIdentifier patientIdentifier;
@@ -122,53 +109,13 @@
public String execute()
{
- // ---------------------------------------------------------------------
- // Check duplicate patients based on name, birthdate and gender
- // ---------------------------------------------------------------------
-
- if ( fullName != null )
- {
- fullName = fullName.trim();
-
- if ( !checkedDuplicate && birthDate != null && gender != null )
- {
- patients = patientService.getPatients( fullName, format.parseDate( birthDate ), gender );
-
- if ( patients != null && patients.size() > 0 )
- {
- message = i18n.getString( "patient_duplicate" );
-
- boolean flagDuplicate = false;
- for ( Patient p : patients )
- {
- if ( id == null || (id != null && p.getId() != id) )
- {
- flagDuplicate = true;
- Collection<PatientAttributeValue> patientAttributeValues = patientAttributeValueService
- .getPatientAttributeValues( p );
-
- for ( PatientAttributeValue patientAttributeValue : patientAttributeValues )
- {
- patientAttributeValueMap.put( p.getId() + "_"
- + patientAttributeValue.getPatientAttribute().getId(),
- patientAttributeValue.getValue() );
- }
- }
- }
-
- if ( flagDuplicate )
- {
- return PATIENT_DUPLICATE;
- }
- }
- }
- }
-
- // ---------------------------------------------------------------------
- // Check Under age information
- // ---------------------------------------------------------------------
-
OrganisationUnit orgunit = selectionManager.getSelectedOrganisationUnit();
+ Program program = null;
+ if ( programId != null )
+ {
+ program = programService.getProgram( programId );
+ }
+
Patient patient = null;
if ( id != null )
{
@@ -197,26 +144,6 @@
patient.setName( fullName );
patient.setOrganisationUnit( orgunit );
- Program program = null;
- if ( programId != null )
- {
- program = programService.getProgram( programId );
- }
-
- if ( underAge )
- {
- if ( representativeId == null )
- {
- message = i18n.getString( "please_choose_representative_for_this_under_age_patient" );
- return INPUT;
- }
- if ( relationshipTypeId == null )
- {
- message = i18n.getString( "please_choose_relationshipType_for_this_under_age_patient" );
- return INPUT;
- }
- }
-
HttpServletRequest request = ServletActionContext.getRequest();
Collection<PatientIdentifierType> identifierTypes = identifierTypeService.getAllPatientIdentifierTypes();
@@ -247,12 +174,12 @@
patient.setIdentifiers( patientIdentifiers );
}
+ // ---------------------------------------------------------------------
+ // Validate patient
+ // ---------------------------------------------------------------------
+
int errorCode = patientService.validatePatient( patient, program );
- // ---------------------------------------------------------------------
- // Validation success
- // ---------------------------------------------------------------------
-
message = errorCode + " ";
return SUCCESS;
@@ -297,11 +224,6 @@
this.selectionManager = selectionManager;
}
- public void setPatientAttributeValueService( PatientAttributeValueService patientAttributeValueService )
- {
- this.patientAttributeValueService = patientAttributeValueService;
- }
-
public void setFullName( String fullName )
{
this.fullName = fullName;
@@ -322,11 +244,6 @@
return message;
}
- public void setI18n( I18n i18n )
- {
- this.i18n = i18n;
- }
-
public Map<String, String> getPatientAttributeValueMap()
{
return patientAttributeValueMap;
@@ -342,11 +259,6 @@
this.id = id;
}
- public void setCheckedDuplicate( boolean checkedDuplicate )
- {
- this.checkedDuplicate = checkedDuplicate;
- }
-
public void setGender( String gender )
{
this.gender = gender;
@@ -357,13 +269,4 @@
this.underAge = underAge;
}
- public void setRepresentativeId( Integer representativeId )
- {
- this.representativeId = representativeId;
- }
-
- public void setRelationshipTypeId( Integer relationshipTypeId )
- {
- this.relationshipTypeId = relationshipTypeId;
- }
}
=== removed directory 'dhis-2/dhis-web/dhis-web-caseentry/src/main/java/org/hisp/dhis/caseentry/state'
=== removed file 'dhis-2/dhis-web/dhis-web-caseentry/src/main/java/org/hisp/dhis/caseentry/state/DefaultSelectedStateManager.java'
--- dhis-2/dhis-web/dhis-web-caseentry/src/main/java/org/hisp/dhis/caseentry/state/DefaultSelectedStateManager.java 2013-08-23 16:05:01 +0000
+++ dhis-2/dhis-web/dhis-web-caseentry/src/main/java/org/hisp/dhis/caseentry/state/DefaultSelectedStateManager.java 1970-01-01 00:00:00 +0000
@@ -1,256 +0,0 @@
-package org.hisp.dhis.caseentry.state;
-
-/*
- * Copyright (c) 2004-2013, 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.
- */
-
-import java.util.Map;
-
-import org.hisp.dhis.organisationunit.OrganisationUnit;
-import org.hisp.dhis.ouwt.manager.OrganisationUnitSelectionManager;
-import org.hisp.dhis.patient.Patient;
-import org.hisp.dhis.patient.PatientService;
-import org.hisp.dhis.program.ProgramInstance;
-import org.hisp.dhis.program.ProgramInstanceService;
-import org.hisp.dhis.program.ProgramStageInstance;
-import org.hisp.dhis.program.ProgramStageInstanceService;
-
-import com.opensymphony.xwork2.ActionContext;
-
-/**
- * @author Abyot Asalefew
- * @version $Id$
- */
-public class DefaultSelectedStateManager
- implements SelectedStateManager
-{
- public static final String SESSION_KEY_SELECTED_PATIENT_ID = "selected_patient_id";
-
- public static final String SESSION_KEY_SELECTED_PROGRAM_INSTANCE_ID = "selected_program_instance_id";
-
- public static final String SESSION_KEY_SELECTED_PROGRAM_STAGE_INSTANCE_ID = "selected_program_stage_instance_id";
-
- public static final String SESSION_KEY_SELECTED_PROGRAM_ID = "selected_program_id";
-
- public static final String SESSION_KEY_SELECTED_PROGRAMSTAGE_ID = "selected_program_stage_id";
-
- public static final String SESSION_KEY_LISTALL = "list_all_value";
-
- public static final String SESSION_KEY_SELECTED_SEARCHING_ATTRIBUTE_ID = "selected_searching_attribute_id";
-
- public static final String SESSION_KEY_SPECIFIED_SEARCH_TEXT = "specified_search_text";
-
- public static final String SESSION_KEY_SELECTED_SORT_ATTRIBUTE_ID = "selected_sort_attribute_id";
-
- // -------------------------------------------------------------------------
- // Dependencies
- // -------------------------------------------------------------------------
-
- private OrganisationUnitSelectionManager selectionManager;
-
- public void setSelectionManager( OrganisationUnitSelectionManager selectionManager )
- {
- this.selectionManager = selectionManager;
- }
-
- private PatientService patientService;
-
- public void setPatientService( PatientService patientService )
- {
- this.patientService = patientService;
- }
-
- private ProgramInstanceService programInstanceService;
-
- public void setProgramInstanceService( ProgramInstanceService programInstanceService )
- {
- this.programInstanceService = programInstanceService;
- }
-
- private ProgramStageInstanceService programStageInstanceService;
-
- public void setProgramStageInstanceService( ProgramStageInstanceService programStageInstanceService )
- {
- this.programStageInstanceService = programStageInstanceService;
- }
-
- // -------------------------------------------------------------------------
- // Implementation methods
- // -------------------------------------------------------------------------
-
- public OrganisationUnit getSelectedOrganisationUnit()
- {
- return selectionManager.getSelectedOrganisationUnit();
- }
-
- public void setSelectedPatient( Patient patient )
- {
- getSession().put( SESSION_KEY_SELECTED_PATIENT_ID, patient.getId() );
- }
-
- public Patient getSelectedPatient()
- {
- Integer id = (Integer) getSession().get( SESSION_KEY_SELECTED_PATIENT_ID );
-
- if ( id == null )
- {
- return null;
- }
-
- return patientService.getPatient( id );
- }
-
- public void clearSelectedPatient()
- {
- getSession().remove( SESSION_KEY_SELECTED_PATIENT_ID );
- }
-
- public void setSelectedProgramInstance( ProgramInstance programInstance )
- {
- getSession().put( SESSION_KEY_SELECTED_PROGRAM_INSTANCE_ID, programInstance.getId() );
- }
-
- public ProgramInstance getSelectedProgramInstance()
- {
- Integer id = (Integer) getSession().get( SESSION_KEY_SELECTED_PROGRAM_INSTANCE_ID );
-
- if ( id == null )
- {
- return null;
- }
-
- return programInstanceService.getProgramInstance( id );
- }
-
- public void clearSelectedProgramInstance()
- {
- getSession().remove( SESSION_KEY_SELECTED_PROGRAM_INSTANCE_ID );
- }
-
- public void setSelectedProgramStageInstance( ProgramStageInstance programStageInstance )
- {
- getSession().put( SESSION_KEY_SELECTED_PROGRAM_STAGE_INSTANCE_ID, programStageInstance.getId() );
- }
-
- public ProgramStageInstance getSelectedProgramStageInstance()
- {
- Integer id = (Integer) getSession().get( SESSION_KEY_SELECTED_PROGRAM_STAGE_INSTANCE_ID );
-
- if ( id == null )
- {
- return null;
- }
-
- return programStageInstanceService.getProgramStageInstance( id );
- }
-
- public void clearSelectedProgramStageInstance()
- {
- getSession().remove( SESSION_KEY_SELECTED_PROGRAM_STAGE_INSTANCE_ID );
- }
-
- public void clearListAll()
- {
- getSession().remove( SESSION_KEY_LISTALL );
- }
-
- public void clearSearchTest()
- {
- getSession().remove( SESSION_KEY_SPECIFIED_SEARCH_TEXT );
- }
-
- public void clearSearchingAttributeId()
- {
- getSession().remove( SESSION_KEY_SELECTED_SEARCHING_ATTRIBUTE_ID );
- }
-
- public boolean getListAll()
- {
- if ( getSession().get( SESSION_KEY_LISTALL ) != null )
- {
- return (Boolean) getSession().get( SESSION_KEY_LISTALL );
- }
-
- else
- {
- return false;
- }
- }
-
- public String getSearchText()
- {
- return (String) getSession().get( SESSION_KEY_SPECIFIED_SEARCH_TEXT );
- }
-
- public Integer getSearchingAttributeId()
- {
- return (Integer) getSession().get( SESSION_KEY_SELECTED_SEARCHING_ATTRIBUTE_ID );
- }
-
- public void setListAll( boolean listAll )
- {
- getSession().put( SESSION_KEY_LISTALL, listAll );
- }
-
- public void setSearchText( String searchText )
- {
- getSession().put( SESSION_KEY_SPECIFIED_SEARCH_TEXT, searchText );
- }
-
- public void setSearchingAttributeId( int searchingAttributeId )
- {
- getSession().put( SESSION_KEY_SELECTED_SEARCHING_ATTRIBUTE_ID, searchingAttributeId );
- }
-
- // -------------------------------------------------------------------------
- // Sort by patient-attribute
- // -------------------------------------------------------------------------
-
- public void setSortingAttributeId( int sortAttributeId )
- {
- getSession().put( SESSION_KEY_SELECTED_SORT_ATTRIBUTE_ID, sortAttributeId );
- }
-
- public Integer getSortAttributeId()
- {
- return (Integer) getSession().get( SESSION_KEY_SELECTED_SORT_ATTRIBUTE_ID );
- }
-
- public void clearSortingAttributeId()
- {
- getSession().remove( SESSION_KEY_SELECTED_SORT_ATTRIBUTE_ID );
- }
-
- // -------------------------------------------------------------------------
- // Support methods
- // -------------------------------------------------------------------------
-
- private static final Map<String, Object> getSession()
- {
- return ActionContext.getContext().getSession();
- }
-}
=== removed file 'dhis-2/dhis-web/dhis-web-caseentry/src/main/java/org/hisp/dhis/caseentry/state/SelectedStateManager.java'
--- dhis-2/dhis-web/dhis-web-caseentry/src/main/java/org/hisp/dhis/caseentry/state/SelectedStateManager.java 2013-08-23 16:05:01 +0000
+++ dhis-2/dhis-web/dhis-web-caseentry/src/main/java/org/hisp/dhis/caseentry/state/SelectedStateManager.java 1970-01-01 00:00:00 +0000
@@ -1,105 +0,0 @@
-package org.hisp.dhis.caseentry.state;
-
-/*
- * Copyright (c) 2004-2013, 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.
- */
-
-import org.hisp.dhis.organisationunit.OrganisationUnit;
-import org.hisp.dhis.patient.Patient;
-import org.hisp.dhis.program.ProgramInstance;
-import org.hisp.dhis.program.ProgramStageInstance;
-
-/**
- * @author Abyot Asalefew
- * @version $Id$
- */
-public interface SelectedStateManager
-{
- OrganisationUnit getSelectedOrganisationUnit();
-
- // -------------------------------------------------------------------------
- // Patient
- // -------------------------------------------------------------------------
-
- void setSelectedPatient( Patient patient );
-
- Patient getSelectedPatient();
-
- void clearSelectedPatient();
-
- // -------------------------------------------------------------------------
- // Program-instance
- // -------------------------------------------------------------------------
-
- void setSelectedProgramInstance( ProgramInstance programInstance );
-
- ProgramInstance getSelectedProgramInstance();
-
- void clearSelectedProgramInstance();
-
- // -------------------------------------------------------------------------
- // Program-stage-instance
- // -------------------------------------------------------------------------
-
- void setSelectedProgramStageInstance( ProgramStageInstance programStageInstance );
-
- ProgramStageInstance getSelectedProgramStageInstance();
-
- void clearSelectedProgramStageInstance();
-
- // -------------------------------------------------------------------------
- // for searching patients
- // -------------------------------------------------------------------------
-
- void setListAll( boolean listAll );
-
- boolean getListAll();
-
- void clearListAll();
-
- void setSearchingAttributeId( int searchingAttributeId );
-
- Integer getSearchingAttributeId();
-
- void clearSearchingAttributeId();
-
- void setSearchText( String searchText );
-
- String getSearchText();
-
- void clearSearchTest();
-
- // -------------------------------------------------------------------------
- // for Sorting patients - Sort by patient-attribute
- // -------------------------------------------------------------------------
-
- void setSortingAttributeId( int sortAttributeId );
-
- Integer getSortAttributeId();
-
- void clearSortingAttributeId();
-}
=== modified file 'dhis-2/dhis-web/dhis-web-caseentry/src/main/resources/META-INF/dhis/beans.xml'
--- dhis-2/dhis-web/dhis-web-caseentry/src/main/resources/META-INF/dhis/beans.xml 2013-10-23 18:10:11 +0000
+++ dhis-2/dhis-web/dhis-web-caseentry/src/main/resources/META-INF/dhis/beans.xml 2013-10-24 08:31:35 +0000
@@ -2,18 +2,7 @@
<beans xmlns="http://www.springframework.org/schema/beans"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans-3.2.xsd">
- <!-- Selection -->
-
- <bean id="org.hisp.dhis.caseentry.state.SelectedStateManager"
- class="org.hisp.dhis.caseentry.state.DefaultSelectedStateManager">
- <property name="patientService" ref="org.hisp.dhis.patient.PatientService" />
- <property name="selectionManager"
- ref="org.hisp.dhis.ouwt.manager.OrganisationUnitSelectionManager" />
- <property name="programInstanceService" ref="org.hisp.dhis.program.ProgramInstanceService" />
- <property name="programStageInstanceService"
- ref="org.hisp.dhis.program.ProgramStageInstanceService" />
- </bean>
-
+
<!-- Data Entry -->
<bean id="org.hisp.dhis.caseentry.action.caseentry.ValidateSearchAction"
@@ -40,8 +29,8 @@
class="org.hisp.dhis.caseentry.action.caseentry.DataRecordingSelectAction"
scope="prototype">
<property name="patientService" ref="org.hisp.dhis.patient.PatientService" />
- <property name="selectedStateManager"
- ref="org.hisp.dhis.caseentry.state.SelectedStateManager" />
+ <property name="selectionManager"
+ ref="org.hisp.dhis.ouwt.manager.OrganisationUnitSelectionManager" />
<property name="programService" ref="org.hisp.dhis.program.ProgramService" />
</bean>
@@ -52,12 +41,11 @@
<property name="programStageInstanceService"
ref="org.hisp.dhis.program.ProgramStageInstanceService" />
<property name="programService" ref="org.hisp.dhis.program.ProgramService" />
- <property name="programInstanceService" ref="org.hisp.dhis.program.ProgramInstanceService" />
<property name="patientService" ref="org.hisp.dhis.patient.PatientService" />
<property name="organisationUnitService"
ref="org.hisp.dhis.organisationunit.OrganisationUnitService" />
- <property name="selectedStateManager"
- ref="org.hisp.dhis.caseentry.state.SelectedStateManager" />
+ <property name="selectionManager"
+ ref="org.hisp.dhis.ouwt.manager.OrganisationUnitSelectionManager" />
</bean>
<bean id="org.hisp.dhis.caseentry.action.caseentry.SaveValueAction"
@@ -75,8 +63,8 @@
id="org.hisp.dhis.caseentry.action.caseentry.SaveProvidingFacilityAction"
class="org.hisp.dhis.caseentry.action.caseentry.SaveProvidingFacilityAction"
scope="prototype">
- <property name="selectedStateManager"
- ref="org.hisp.dhis.caseentry.state.SelectedStateManager" />
+ <property name="programStageInstanceService"
+ ref="org.hisp.dhis.program.ProgramStageInstanceService" />
<property name="dataElementService" ref="org.hisp.dhis.dataelement.DataElementService" />
<property name="patientDataValueService"
ref="org.hisp.dhis.patientdatavalue.PatientDataValueService" />
@@ -86,12 +74,11 @@
id="org.hisp.dhis.caseentry.action.caseentry.LoadProgramStageInstancesAction"
class="org.hisp.dhis.caseentry.action.caseentry.LoadProgramStageInstancesAction"
scope="prototype">
+ <property name="patientService" ref="org.hisp.dhis.patient.PatientService" />
<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="selectedStateManager"
- ref="org.hisp.dhis.caseentry.state.SelectedStateManager" />
</bean>
<bean id="org.hisp.dhis.caseentry.action.caseentry.LoadDataEntryAction"
@@ -104,8 +91,8 @@
<property name="programStageService" ref="org.hisp.dhis.program.ProgramStageService" />
<property name="programStageInstanceService"
ref="org.hisp.dhis.program.ProgramStageInstanceService" />
- <property name="selectedStateManager"
- ref="org.hisp.dhis.caseentry.state.SelectedStateManager" />
+ <property name="selectionManager"
+ ref="org.hisp.dhis.ouwt.manager.OrganisationUnitSelectionManager" />
<property name="programStageSectionService"
ref="org.hisp.dhis.program.ProgramStageSectionService" />
<property name="organisationUnitService"
@@ -182,8 +169,8 @@
id="org.hisp.dhis.caseentry.action.caseentry.MultiDataEntrySelectAction"
class="org.hisp.dhis.caseentry.action.caseentry.MultiDataEntrySelectAction"
scope="prototype">
- <property name="selectedStateManager"
- ref="org.hisp.dhis.caseentry.state.SelectedStateManager" />
+ <property name="selectionManager"
+ ref="org.hisp.dhis.ouwt.manager.OrganisationUnitSelectionManager" />
<property name="programService" ref="org.hisp.dhis.program.ProgramService" />
<property name="patientAttributeService"
ref="org.hisp.dhis.patient.PatientAttributeService" />
@@ -194,8 +181,8 @@
class="org.hisp.dhis.caseentry.action.caseentry.GetProgramsByOrgunitAction"
scope="prototype">
<property name="programService" ref="org.hisp.dhis.program.ProgramService" />
- <property name="selectedStateManager"
- ref="org.hisp.dhis.caseentry.state.SelectedStateManager" />
+ <property name="selectionManager"
+ ref="org.hisp.dhis.ouwt.manager.OrganisationUnitSelectionManager" />
</bean>
<bean id="org.hisp.dhis.caseentry.action.caseentry.GetAllProgramsAction"
@@ -209,8 +196,8 @@
<bean id="org.hisp.dhis.caseentry.action.caseentry.GetDataRecordsAction"
class="org.hisp.dhis.caseentry.action.caseentry.GetDataRecordsAction"
scope="prototype">
- <property name="selectedStateManager"
- ref="org.hisp.dhis.caseentry.state.SelectedStateManager" />
+ <property name="selectionManager"
+ ref="org.hisp.dhis.ouwt.manager.OrganisationUnitSelectionManager" />
<property name="patientService" ref="org.hisp.dhis.patient.PatientService" />
<property name="programStageInstanceService"
ref="org.hisp.dhis.program.ProgramStageInstanceService" />
@@ -261,8 +248,8 @@
<property name="programStageInstanceService"
ref="org.hisp.dhis.program.ProgramStageInstanceService" />
<property name="programInstanceService" ref="org.hisp.dhis.program.ProgramInstanceService" />
- <property name="selectedStateManager"
- ref="org.hisp.dhis.caseentry.state.SelectedStateManager" />
+ <property name="selectionManager"
+ ref="org.hisp.dhis.ouwt.manager.OrganisationUnitSelectionManager" />
<property name="currentUserService" ref="org.hisp.dhis.user.CurrentUserService" />
</bean>
@@ -401,8 +388,8 @@
id="org.hisp.dhis.caseentry.action.caseentry.CreateAnonymousEncounterAction"
class="org.hisp.dhis.caseentry.action.caseentry.CreateAnonymousEncounterAction"
scope="prototype">
- <property name="selectedStateManager"
- ref="org.hisp.dhis.caseentry.state.SelectedStateManager" />
+ <property name="selectionManager"
+ ref="org.hisp.dhis.ouwt.manager.OrganisationUnitSelectionManager" />
<property name="programInstanceService" ref="org.hisp.dhis.program.ProgramInstanceService" />
<property name="programService" ref="org.hisp.dhis.program.ProgramService" />
<property name="programStageInstanceService"
@@ -475,8 +462,6 @@
<property name="patientService" ref="org.hisp.dhis.patient.PatientService" />
<property name="patientIdentifierService"
ref="org.hisp.dhis.patient.PatientIdentifierService" />
- <property name="selectedStateManager"
- ref="org.hisp.dhis.caseentry.state.SelectedStateManager" />
<property name="patientAttributeService"
ref="org.hisp.dhis.patient.PatientAttributeService" />
<property name="patientIdentifierTypeService"
@@ -547,12 +532,7 @@
scope="prototype">
<property name="programService" ref="org.hisp.dhis.program.ProgramService" />
<property name="patientService" ref="org.hisp.dhis.patient.PatientService" />
- <property name="patientAttributeValueService">
- <ref bean="org.hisp.dhis.patientattributevalue.PatientAttributeValueService" />
- </property>
- <property name="identifierTypeService">
- <ref bean="org.hisp.dhis.patient.PatientIdentifierTypeService" />
- </property>
+ <property name="identifierTypeService" ref="org.hisp.dhis.patient.PatientIdentifierTypeService" />
<property name="selectionManager">
<ref bean="org.hisp.dhis.ouwt.manager.OrganisationUnitSelectionManager" />
</property>
@@ -640,8 +620,8 @@
<property name="patientService" ref="org.hisp.dhis.patient.PatientService" />
<property name="programService" ref="org.hisp.dhis.program.ProgramService" />
<property name="programInstanceService" ref="org.hisp.dhis.program.ProgramInstanceService" />
- <property name="selectedStateManager"
- ref="org.hisp.dhis.caseentry.state.SelectedStateManager" />
+ <property name="selectionManager"
+ ref="org.hisp.dhis.ouwt.manager.OrganisationUnitSelectionManager" />
</bean>
<bean id="org.hisp.dhis.caseentry.action.patient.ProgramEnrollmentAction"
@@ -652,8 +632,8 @@
ref="org.hisp.dhis.patient.PatientIdentifierService" />
<property name="patientAttributeValueService"
ref="org.hisp.dhis.patientattributevalue.PatientAttributeValueService" />
- <property name="selectedStateManager"
- ref="org.hisp.dhis.caseentry.state.SelectedStateManager" />
+ <property name="selectionManager"
+ ref="org.hisp.dhis.ouwt.manager.OrganisationUnitSelectionManager" />
</bean>
<bean
@@ -663,8 +643,8 @@
<property name="patientService" ref="org.hisp.dhis.patient.PatientService" />
<property name="programService" ref="org.hisp.dhis.program.ProgramService" />
<property name="programInstanceService" ref="org.hisp.dhis.program.ProgramInstanceService" />
- <property name="selectedStateManager"
- ref="org.hisp.dhis.caseentry.state.SelectedStateManager" />
+ <property name="selectionManager"
+ ref="org.hisp.dhis.ouwt.manager.OrganisationUnitSelectionManager" />
</bean>
<bean id="org.hisp.dhis.caseentry.action.patient.SaveDueDateAction"
@@ -725,8 +705,8 @@
<property name="patientService" ref="org.hisp.dhis.patient.PatientService" />
<property name="patientIdentifierService"
ref="org.hisp.dhis.patient.PatientIdentifierService" />
- <property name="selectedStateManager"
- ref="org.hisp.dhis.caseentry.state.SelectedStateManager" />
+ <property name="selectionManager"
+ ref="org.hisp.dhis.ouwt.manager.OrganisationUnitSelectionManager" />
<property name="patientAttributeValueService"
ref="org.hisp.dhis.patientattributevalue.PatientAttributeValueService" />
<property name="patientAttributeService"
=== modified file 'dhis-2/dhis-web/dhis-web-caseentry/src/main/resources/struts.xml'
--- dhis-2/dhis-web/dhis-web-caseentry/src/main/resources/struts.xml 2013-10-15 10:28:59 +0000
+++ dhis-2/dhis-web/dhis-web-caseentry/src/main/resources/struts.xml 2013-10-24 08:31:35 +0000
@@ -572,17 +572,8 @@
<action name="validatePatient"
class="org.hisp.dhis.caseentry.action.patient.ValidatePatientAction">
- <result name="success" type="velocity-xml">
- /dhis-web-commons/ajax/xmlResponseSuccess.vm
- </result>
- <result name="error" type="velocity-xml">
- /dhis-web-commons/ajax/xmlResponseError.vm
- </result>
- <result name="input" type="velocity-xml">
- /dhis-web-commons/ajax/xmlResponseInput.vm
- </result>
- <result name="duplicate" type="velocity-xml">
- /dhis-web-caseentry/responseDuplicate.vm
+ <result name="success" type="velocity-json">
+ /dhis-web-commons/ajax/jsonResponseSuccess.vm
</result>
<param name="onExceptionReturn">plainTextError</param>
</action>
=== modified file 'dhis-2/dhis-web/dhis-web-caseentry/src/main/webapp/dhis-web-caseentry/addPatientForm.vm'
--- dhis-2/dhis-web/dhis-web-caseentry/src/main/webapp/dhis-web-caseentry/addPatientForm.vm 2013-09-05 17:59:57 +0000
+++ dhis-2/dhis-web/dhis-web-caseentry/src/main/webapp/dhis-web-caseentry/addPatientForm.vm 2013-10-24 08:31:35 +0000
@@ -12,12 +12,11 @@
{
#if($!relatedProgram)
var programId = getFieldValue("relatedProgramId");
- validateAddPatient(programId, true, isContinue);
+ addPatient( programId, true, isContinue);
#else
var programId = getFieldValue('programIdAddPatient');
- validateAddPatient(programId, false, isContinue);
+ addPatient(programId, false, isContinue);
#end
-
}
,beforeValidateHandler: function(form)
{
=== modified file 'dhis-2/dhis-web/dhis-web-caseentry/src/main/webapp/dhis-web-caseentry/caseAggregationResult.vm'
--- dhis-2/dhis-web/dhis-web-caseentry/src/main/webapp/dhis-web-caseentry/caseAggregationResult.vm 2013-10-23 18:10:11 +0000
+++ dhis-2/dhis-web/dhis-web-caseentry/src/main/webapp/dhis-web-caseentry/caseAggregationResult.vm 2013-10-24 08:31:35 +0000
@@ -8,7 +8,7 @@
#set($divIdx=0)
#set($hashValues=false)
#foreach( $grid in $grids )
- #if(${grid.height} > 0)
+ #if($grid.getRows().size() > 0)
#set($hashValues=true)
#set($divIdx=$divIdx+1)
<h3>
=== modified file 'dhis-2/dhis-web/dhis-web-caseentry/src/main/webapp/dhis-web-caseentry/defaultDataEntryForm.vm'
--- dhis-2/dhis-web/dhis-web-caseentry/src/main/webapp/dhis-web-caseentry/defaultDataEntryForm.vm 2013-10-23 18:56:32 +0000
+++ dhis-2/dhis-web/dhis-web-caseentry/src/main/webapp/dhis-web-caseentry/defaultDataEntryForm.vm 2013-10-24 08:31:35 +0000
@@ -74,7 +74,7 @@
<table style='width:100%'>
<tr>
<td>
- <input id='$id' class='$id' name="$id" type='radio' options='no' optionset='$programStageDataElement.dataElement.optionSet.uid'
+ <input id='$id' class='$id' name="$id" options='no' type='radio' optionset='$programStageDataElement.dataElement.optionSet.uid'
data="{compulsory: $programStageDataElement.compulsory, deName:'$programStageDataElement.dataElement.name', deType:'$programStageDataElement.dataElement.getDetailedNumberType()' }"
#if( $patientDataValue.value == $option) checked #end
onclick="saveRadio( '$programStageDataElement.dataElement.uid', '' )" tabindex="$tabIndex" />$i18n.getString("non_value")
@@ -96,7 +96,7 @@
</tr>
</table>
#else
- <input options='$hasOptionSet' optionset='$programStageDataElement.dataElement.optionSet.uid' id='$id' name="entryfield" data="{compulsory: $programStageDataElement.compulsory, deName:'$programStageDataElement.dataElement.name', deType:'$programStageDataElement.dataElement.getDetailedNumberType()' }" type="text" value="$!encoder.htmlEncode( $patientDataValue.value )" onkeypress="return keyPress(event, this)" tabindex="$tabIndex" class="auto-field optionset" />
+ <input optionset='$programStageDataElement.dataElement.optionSet.uid' id='$id' name="entryfield" options='$hasOptionSet' data="{compulsory: $programStageDataElement.compulsory, deName:'$programStageDataElement.dataElement.name', deType:'$programStageDataElement.dataElement.getDetailedNumberType()' }" type="text" value="$!encoder.htmlEncode( $patientDataValue.value )" onkeypress="return keyPress(event, this)" tabindex="$tabIndex" class="auto-field optionset" />
#end
#elseif($programStageDataElement.dataElement.type=='username')
<input name="entryfield" username='true' class="auto-field optionset" data="{compulsory: $programStageDataElement.compulsory, deName:'$programStageDataElement.dataElement.name', deType:'$programStageDataElement.dataElement.getDetailedNumberType()' }" id="$id" type="text" value="$!encoder.htmlEncode( $patientDataValue.value )" onkeypress="return keyPress(event, this)" tabindex="$tabIndex" />
=== modified file 'dhis-2/dhis-web/dhis-web-caseentry/src/main/webapp/dhis-web-caseentry/javascript/commons.js'
--- dhis-2/dhis-web/dhis-web-caseentry/src/main/webapp/dhis-web-caseentry/javascript/commons.js 2013-10-23 12:24:18 +0000
+++ dhis-2/dhis-web/dhis-web-caseentry/src/main/webapp/dhis-web-caseentry/javascript/commons.js 2013-10-24 08:31:35 +0000
@@ -1050,70 +1050,6 @@
});
}
-function validateUpdatePatient()
-{
- $("#editPatientDiv :input").attr("disabled", true);
- $.ajax({
- type: "POST",
- url: 'validatePatient.action',
- data: getParamsForDiv('editPatientDiv'),
- success:updateValidationCompleted
- });
-}
-
-function updateValidationCompleted( messageElement )
-{
- var type = $(messageElement).find('message').attr('type');
- var message = $(messageElement).find('message').text();
-
- if ( type == 'success' )
- {
- if( message == 0 ){
- removeDisabledIdentifier();
- updatePatient();
- }
- else if( message == 1 ){
- showErrorMessage( i18n_adding_patient_failed + ':' + '\n' + i18n_duplicate_identifier );
- }
- else if( message == 2 ){
- showErrorMessage( i18n_adding_patient_failed + ':' + '\n' + i18n_this_patient_could_not_be_enrolled_please_check_validation_criteria );
- }
- }
- else
- {
- $("#editPatientDiv :input").attr("disabled", true);
-
- if ( type == 'error' )
- {
- showErrorMessage( i18n_saving_patient_failed + ':' + '\n' + message );
- }
- else if ( type == 'input' )
- {
- showWarningMessage( message );
- }
- else if( type == 'duplicate' )
- {
- showListPatientDuplicate(messageElement, true);
- }
- $("#editPatientDiv :input").attr("disabled", false);
- }
-}
-
-function updatePatient()
-{
- var params = 'programId=' + getFieldValue('programIdAddPatient')
- + '&' + getParamsForDiv('editPatientDiv');
-
- $.ajax({
- type: "POST",
- url: 'updatePatient.action',
- data: params,
- success: function( json ) {
- showPatientDashboardForm( getFieldValue('id') );
- }
- });
-}
-
function addEventForPatientForm( divname )
{
$("#" + divname + " [id=checkDuplicateBtn]").click(function() {
=== modified file 'dhis-2/dhis-web/dhis-web-caseentry/src/main/webapp/dhis-web-caseentry/javascript/entry.js'
--- dhis-2/dhis-web/dhis-web-caseentry/src/main/webapp/dhis-web-caseentry/javascript/entry.js 2013-10-16 10:03:02 +0000
+++ dhis-2/dhis-web/dhis-web-caseentry/src/main/webapp/dhis-web-caseentry/javascript/entry.js 2013-10-24 08:31:35 +0000
@@ -104,9 +104,7 @@
function updateProvidingFacility( dataElementUid, checkField )
{
- var programStageUid = byId( 'programStageUid' ).value;
var checked= checkField.checked;
-
var facilitySaver = new FacilitySaver( dataElementUid, checked, SUCCESS_COLOR );
facilitySaver.save();
}
@@ -343,14 +341,16 @@
function FacilitySaver( dataElementId_, providedElsewhere_, resultColor_ )
{
- var dataElementUid = dataElementId_;
+ var programStageInstanceId = getFieldValue('programStageInstanceId');
+ var dataElementUid = dataElementId_;
var providedElsewhere = providedElsewhere_;
var resultColor = resultColor_;
this.save = function()
{
- var params = 'dataElementUid=' + dataElementUid;
+ var params = 'dataElementId=' + dataElementUid;
params += '&providedElsewhere=' + providedElsewhere ;
+ params += '&programStageInstanceId=' + programStageInstanceId;
$.ajax({
type: "POST",
url: "saveProvidingFacility.action",
=== modified file 'dhis-2/dhis-web/dhis-web-caseentry/src/main/webapp/dhis-web-caseentry/javascript/form.js'
--- dhis-2/dhis-web/dhis-web-caseentry/src/main/webapp/dhis-web-caseentry/javascript/form.js 2013-08-14 06:58:11 +0000
+++ dhis-2/dhis-web/dhis-web-caseentry/src/main/webapp/dhis-web-caseentry/javascript/form.js 2013-10-24 08:31:35 +0000
@@ -166,6 +166,7 @@
{
jQuery.getJSON( "loadProgramStageInstances.action",
{
+ patientId:patientId,
programId: programId
},
function( json )
=== modified file 'dhis-2/dhis-web/dhis-web-caseentry/src/main/webapp/dhis-web-caseentry/javascript/patient.js'
--- dhis-2/dhis-web/dhis-web-caseentry/src/main/webapp/dhis-web-caseentry/javascript/patient.js 2013-10-23 12:24:18 +0000
+++ dhis-2/dhis-web/dhis-web-caseentry/src/main/webapp/dhis-web-caseentry/javascript/patient.js 2013-10-24 08:31:35 +0000
@@ -66,13 +66,94 @@
});
};
- this.remove = function( confirm_delete_patient )
+ this.validate = function( programId )
{
- removeItem( this.patientId, this.fullName, confirm_delete_patient, 'removePatient.action' );
+ setMessage('');
+ if( byId('underAge').checked ){
+ if ( getFieldValue('representativeId') == '' )
+ {
+ setMessage( i18n_please_choose_representative_for_this_under_age_patient );
+ $("#patientForm :input").attr("disabled", false);
+ $("#patientForm").find("select").attr("disabled", false);
+ return false;
+ }
+
+ if ( getFieldValue('relationshipTypeId') == '' )
+ {
+ setMessage( i18n_please_choose_relationshipType_for_this_under_age_patient );
+ $("#patientForm :input").attr("disabled", false);
+ $("#patientForm").find("select").attr("disabled", false);
+ return false;
+ }
+ }
+
+ var params = "";
+ if( programId !== "undefined" ){
+ params = "programId=" + programId + "&"
+ }
+ params += getParamsForDiv('patientForm');
+ $("#patientForm :input").attr("disabled", true);
+ $("#patientForm").find("select").attr("disabled", true);
+ var json = null;
+ $.ajax({
+ type: "POST",
+ url: 'validatePatient.action',
+ data: params,
+ datatype: "json",
+ async: false,
+ success: function(data) {
+ json = data;
+ }
+ });
+
+ var response = json.response;
+ var message = json.message;
+
+ if ( response == 'success' )
+ {
+ if( message == 0 ){
+ removeDisabledIdentifier();
+ return true;
+ }
+ else {
+
+ if( message == 1 ){
+ setMessage( i18n_adding_patient_failed + ':' + '\n' + i18n_duplicate_identifier );
+ }
+ else if( message == 2 ){
+ setMessage( i18n_adding_patient_failed + ':' + '\n' + i18n_this_patient_could_not_be_enrolled_please_check_validation_criteria );
+ }
+
+ $("#patientForm :input").attr("disabled", false);
+ $("#patientForm").find("select").attr("disabled", false);
+ return false;
+ }
+ }
+ else
+ {
+ if ( response == 'error' )
+ {
+ setMessage( i18n_adding_patient_failed + ':' + '\n' + message );
+ }
+ else if ( response == 'input' )
+ {
+ setMessage( message );
+ }
+ else if( response == 'duplicate' )
+ {
+ showListPatientDuplicate(data, false);
+ }
+
+ $("#patientForm :input").attr("disabled", false);
+ $("#patientForm").find("select").attr("disabled", false);
+ return false;
+ }
};
- this.add = function( programId, related, params,isContinue)
+ this.add = function( programId, related, params, isContinue)
{
+ if( !this.validate(programId) ) return;
+
$.ajax({
type: "POST",
url: 'addPatient.action',
@@ -106,8 +187,6 @@
$(this).val("");
}
});
- $("#patientForm :input").attr("disabled", false);
- $("#patientForm").find("select").attr("disabled", false);
}
else{
showPatientDashboardForm( patientId );
@@ -135,7 +214,31 @@
}
}
});
- }
+ };
+
+ this.update = function()
+ {
+ if( !this.validate() ) return;
+
+ var params = 'programId=' + getFieldValue('programIdAddPatient')
+ + '&' + getParamsForDiv('editPatientDiv');
+ $.ajax({
+ type: "POST",
+ url: 'updatePatient.action',
+ data: params,
+ success: function( json ) {
+ showPatientDashboardForm( getFieldValue('id') );
+ $("#patientForm :input").attr("disabled", false);
+ $("#patientForm").find("select").attr("disabled", false);
+ }
+ });
+ };
+
+ this.remove = function( confirm_delete_patient )
+ {
+ removeItem( this.patientId, this.fullName, confirm_delete_patient, 'removePatient.action' );
+ };
+
}
Patient.listAll = function()
@@ -171,6 +274,7 @@
jQuery('#loaderDiv').hide();
});
}
+
}
function listAllPatient()
@@ -238,59 +342,6 @@
}
-function validateAddPatient( programId, related, isContinue )
-{
- var params = "programId=" + programId + "&" + getParamsForDiv('patientForm');
- $("#patientForm :input").attr("disabled", true);
- $("#patientForm").find("select").attr("disabled", true);
- $.ajax({
- type: "POST",
- url: 'validatePatient.action',
- data: params,
- success: function(data){
- addValidationCompleted( programId, related, data,isContinue);
- }
- });
-}
-
-function addValidationCompleted( programId, related, data, isContinue )
-{
- var type = jQuery(data).find('message').attr('type');
- var message = jQuery(data).find('message').text();
-
- if ( type == 'success' )
- {
- if( message == 0 ){
- removeDisabledIdentifier( );
- addPatient( programId, related, isContinue );
- }
- else if( message == 1 ){
- showErrorMessage( i18n_adding_patient_failed + ':' + '\n' + i18n_duplicate_identifier );
- }
- else if( message == 2 ){
- showErrorMessage( i18n_adding_patient_failed + ':' + '\n' + i18n_this_patient_could_not_be_enrolled_please_check_validation_criteria );
- }
- }
- else
- {
- if ( type == 'error' )
- {
- showErrorMessage( i18n_adding_patient_failed + ':' + '\n' + message );
- }
- else if ( type == 'input' )
- {
- showWarningMessage( message );
- }
- else if( type == 'duplicate' )
- {
- showListPatientDuplicate(data, false);
- }
- }
-
- $("#patientForm :input").attr("disabled", false);
- $("#patientForm").find("select").attr("disabled", false);
-}
-
function addRelationship()
{
jQuery('#loaderDiv').show();
=== modified file 'dhis-2/dhis-web/dhis-web-caseentry/src/main/webapp/dhis-web-caseentry/patientForm.vm'
--- dhis-2/dhis-web/dhis-web-caseentry/src/main/webapp/dhis-web-caseentry/patientForm.vm 2013-10-08 17:16:47 +0000
+++ dhis-2/dhis-web/dhis-web-caseentry/src/main/webapp/dhis-web-caseentry/patientForm.vm 2013-10-24 08:31:35 +0000
@@ -264,6 +264,10 @@
#end
+<tr>
+ <td colspan='3'><span id='message'></td>
+</tr>
+
<script>
var disableButtons = true;
=== removed file 'dhis-2/dhis-web/dhis-web-caseentry/src/main/webapp/dhis-web-caseentry/responseDuplicate.vm'
--- dhis-2/dhis-web/dhis-web-caseentry/src/main/webapp/dhis-web-caseentry/responseDuplicate.vm 2013-09-23 03:15:40 +0000
+++ dhis-2/dhis-web/dhis-web-caseentry/src/main/webapp/dhis-web-caseentry/responseDuplicate.vm 1970-01-01 00:00:00 +0000
@@ -1,38 +0,0 @@
-<?xml version="1.0" encoding="UTF-8"?>
-<message type="duplicate">$encoder.xmlEncode( $message )
-#foreach( $patient in $patients )
-<patient>
- <id>$patient.id</id>
- <fullName>$!encoder.xmlEncode( $patient.name )</fullName>
- <gender>$encoder.xmlEncode( $i18n.getString($patient.gender ))</gender>
- <dateOfBirth>$format.formatDate( $patient.birthDate )</dateOfBirth>
- <age>$encoder.xmlEncode( $patient.getAge() )</age>
- #foreach( $identifier in $patient.identifiers )
- #if( $identifier.identifierType )
- <identifier>
- <id>$identifier.identifierType.id</id>
- <name>$encoder.xmlEncode( $identifier.identifierType.displayName )</name>
- <value>$encoder.xmlEncode( $identifier.identifier )</value>
- </identifier>
- #else
- <systemIdentifier>$encoder.xmlEncode( $identifier.identifier )</systemIdentifier>
- #end
- #end
-
- #foreach( $attribute in $patient.attributes )
- #set( $attributeValue = "" )
- #set( $key = $patient.id + "_" + $attribute.id )
- #set( $attributeValue = $patientAttributeValueMap.get( $key ) )
- <attribute>
- <name>$encoder.xmlEncode( $attribute.displayName )</name>
- <value>$encoder.xmlEncode( $attributeValue )</value>
- </attribute>
- #end
- #foreach( $program in $patient.programs )
- <program>
- <name>$encoder.xmlEncode( $program.displayName )</name>
- </program>
- #end
-</patient>
-#end
-</message>
\ No newline at end of file
=== modified file 'dhis-2/dhis-web/dhis-web-caseentry/src/main/webapp/dhis-web-caseentry/sectionDataEntryForm.vm'
--- dhis-2/dhis-web/dhis-web-caseentry/src/main/webapp/dhis-web-caseentry/sectionDataEntryForm.vm 2013-10-23 18:56:32 +0000
+++ dhis-2/dhis-web/dhis-web-caseentry/src/main/webapp/dhis-web-caseentry/sectionDataEntryForm.vm 2013-10-24 08:31:35 +0000
@@ -82,12 +82,12 @@
</script>
#elseif($hasOptionSet=='true')
#if( $programStageDataElement.dataElement.optionSet.options.size() <= 7 && $program.dataEntryMethod =='false' )
- <input id='$id' name="entryfield" options='$hasOptionSet' optionset="$programStageDataElement.dataElement.optionSet.uid" data="{compulsory: $programStageDataElement.compulsory, deName:'$programStageDataElement.dataElement.name', deType:'$programStageDataElement.dataElement.getDetailedNumberType()' }" type="text" value="$!encoder.htmlEncode( $patientDataValue.value )" onkeypress="return keyPress(event, this)" tabindex="$tabIndex" class="auto-field optionset" />
+ <input id='$id' name="entryfield" data-optionset="$!programStageDataElement.dataElement.optionSet.uid" options='$hasOptionSet' data="{compulsory: $programStageDataElement.compulsory, deName:'$programStageDataElement.dataElement.name', deType:'$programStageDataElement.dataElement.getDetailedNumberType()' }" type="text" value="$!encoder.htmlEncode( $patientDataValue.value )" onkeypress="return keyPress(event, this)" tabindex="$tabIndex" class="auto-field optionset" />
#elseif( $programStageDataElement.dataElement.optionSet.options.size() <= 7 && $program.dataEntryMethod =='true' )
<table style='width:100%'>
<tr>
<td>
- <input id='$id' name="$id" type='radio' options='no' optionset="$programStageDataElement.dataElement.optionSet.uid"
+ <input id='$id' name="$id" options='no' type='radio'
data="{compulsory: $programStageDataElement.compulsory, deName:'$programStageDataElement.dataElement.name', deType:'$programStageDataElement.dataElement.getDetailedNumberType()' }"
#if( $patientDataValue.value == $option) checked #end
onclick="saveRadio( '$programStageDataElement.dataElement.uid', '$option' )" tabindex="$tabIndex" />$i18n.getString("non_value")
@@ -109,7 +109,7 @@
</tr>
</table>
#else
- <input id='$id' name="entryfield" options='$hasOptionSet' optionset="$programStageDataElement.dataElement.optionSet.uid" data="{compulsory: $programStageDataElement.compulsory, deName:'$programStageDataElement.dataElement.name', deType:'$programStageDataElement.dataElement.getDetailedNumberType()' }" type="text" value="$!encoder.htmlEncode( $patientDataValue.value )" onkeypress="return keyPress(event, this)" tabindex="$tabIndex" class="auto-field optionset" />
+ <input id='$id' name="entryfield" options='$hasOptionSet' data="{compulsory: $programStageDataElement.compulsory, deName:'$programStageDataElement.dataElement.name', deType:'$programStageDataElement.dataElement.getDetailedNumberType()' }" type="text" value="$!encoder.htmlEncode( $patientDataValue.value )" onkeypress="return keyPress(event, this)" tabindex="$tabIndex" class="auto-field optionset" />
#end
#elseif($programStageDataElement.dataElement.type=='username')
<input name="entryfield" username='true' class="auto-field optionset" data="{compulsory: $programStageDataElement.compulsory, deName:'$programStageDataElement.dataElement.name', deType:'$programStageDataElement.dataElement.getDetailedNumberType()' }" id="$id" type="text" value="$!encoder.htmlEncode( $patientDataValue.value )" onkeypress="return keyPress(event, this)" tabindex="$tabIndex" />
=== modified file 'dhis-2/dhis-web/dhis-web-caseentry/src/main/webapp/dhis-web-caseentry/selectPatient.vm'
--- dhis-2/dhis-web/dhis-web-caseentry/src/main/webapp/dhis-web-caseentry/selectPatient.vm 2013-10-23 12:24:18 +0000
+++ dhis-2/dhis-web/dhis-web-caseentry/src/main/webapp/dhis-web-caseentry/selectPatient.vm 2013-10-24 08:31:35 +0000
@@ -110,6 +110,8 @@
var i18n_insert_a_report_date = '$encoder.jsEscape( $i18n.getString( "insert_a_report_date" ) , "'")';
var i18n_duplicate_identifier = '$encoder.jsEscape( $i18n.getString( "duplicate_identifier" ) , "'")';
var i18n_this_patient_could_not_be_enrolled_please_check_validation_criteria = '$encoder.jsEscape( $i18n.getString( "this_patient_could_not_be_enrolled_please_check_validation_criteria" ) , "'")';
+ var i18n_please_choose_representative_for_this_under_age_patient = '$encoder.jsEscape( $i18n.getString( "please_choose_representative_for_this_under_age_patient" ) , "'")';
+ var i18n_please_choose_relationshipType_for_this_under_age_patient = '$encoder.jsEscape( $i18n.getString( "please_choose_relationshipType_for_this_under_age_patient" ) , "'")';
var checkedDuplicate = false;
// -1: no search anything
=== modified file 'dhis-2/dhis-web/dhis-web-caseentry/src/main/webapp/dhis-web-caseentry/updatePatientForm.vm'
--- dhis-2/dhis-web/dhis-web-caseentry/src/main/webapp/dhis-web-caseentry/updatePatientForm.vm 2013-10-22 03:14:36 +0000
+++ dhis-2/dhis-web/dhis-web-caseentry/src/main/webapp/dhis-web-caseentry/updatePatientForm.vm 2013-10-24 08:31:35 +0000
@@ -15,7 +15,7 @@
,errorElement:"span"
,submitHandler: function(form)
{
- validateUpdatePatient( false );
+ validatePatient( true );
}
,beforeValidateHandler: function(form)
{