dhis2-devs team mailing list archive
-
dhis2-devs team
-
Mailing list archive
-
Message #14998
[Branch ~dhis2-devs-core/dhis2/trunk] Rev 5242: DeletionHandler for programstage.
------------------------------------------------------------
revno: 5242
committer: Tran Chau <tran.hispvietnam@xxxxxxxxx>
branch nick: dhis2
timestamp: Wed 2011-11-30 13:38:30 +0700
message:
DeletionHandler for programstage.
modified:
dhis-2/dhis-services/dhis-service-patient/src/main/java/org/hisp/dhis/patientdatavalue/PatientDataValueDeletionHandler.java
dhis-2/dhis-services/dhis-service-patient/src/main/java/org/hisp/dhis/program/ProgramStageDataElementDeletionHandler.java
dhis-2/dhis-services/dhis-service-patient/src/main/resources/META-INF/dhis/beans.xml
dhis-2/dhis-web/dhis-web-caseentry/src/main/java/org/hisp/dhis/caseentry/action/patient/ValidatePatientProgramEnrollmentAction.java
dhis-2/dhis-web/dhis-web-caseentry/src/main/resources/org/hisp/dhis/caseentry/i18n_module.properties
dhis-2/dhis-web/dhis-web-caseentry/src/main/webapp/dhis-web-caseentry/updatePatientForm.vm
dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-patient/src/main/java/org/hisp/dhis/patient/action/programstage/RemoveProgramStageAction.java
dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-patient/src/main/resources/org/hisp/dhis/patient/i18n_module.properties
--
lp:dhis2
https://code.launchpad.net/~dhis2-devs-core/dhis2/trunk
Your team DHIS 2 developers is subscribed to branch lp:dhis2.
To unsubscribe from this branch go to https://code.launchpad.net/~dhis2-devs-core/dhis2/trunk/+edit-subscription
=== modified file 'dhis-2/dhis-services/dhis-service-patient/src/main/java/org/hisp/dhis/patientdatavalue/PatientDataValueDeletionHandler.java'
--- dhis-2/dhis-services/dhis-service-patient/src/main/java/org/hisp/dhis/patientdatavalue/PatientDataValueDeletionHandler.java 2011-09-29 07:41:04 +0000
+++ dhis-2/dhis-services/dhis-service-patient/src/main/java/org/hisp/dhis/patientdatavalue/PatientDataValueDeletionHandler.java 2011-11-30 06:38:30 +0000
@@ -28,6 +28,7 @@
package org.hisp.dhis.patientdatavalue;
import org.hisp.dhis.dataelement.DataElement;
+import org.hisp.dhis.program.ProgramStage;
import org.hisp.dhis.system.deletion.DeletionHandler;
import org.springframework.jdbc.core.JdbcTemplate;
@@ -64,7 +65,18 @@
public String allowDeleteDataElement( DataElement dataElement )
{
String sql = "SELECT COUNT(*) FROM patientdatavalue where dataelementid=" + dataElement.getId();
-
+
+ return jdbcTemplate.queryForInt( sql ) == 0 ? null : ERROR;
+ }
+
+ @Override
+ public String allowDeleteProgramStage( ProgramStage programStage )
+ {
+ String sql = "SELECT COUNT(*) "
+ + "FROM patientdatavalue pdv INNER JOIN programstageinstance psi "
+ + "ON pdv.programstageinstanceid=psi.programstageinstanceid "
+ + "WHERE psi.programstageid=" + programStage.getId() ;
+
return jdbcTemplate.queryForInt( sql ) == 0 ? null : ERROR;
}
}
=== modified file 'dhis-2/dhis-services/dhis-service-patient/src/main/java/org/hisp/dhis/program/ProgramStageDataElementDeletionHandler.java'
--- dhis-2/dhis-services/dhis-service-patient/src/main/java/org/hisp/dhis/program/ProgramStageDataElementDeletionHandler.java 2011-09-29 07:41:04 +0000
+++ dhis-2/dhis-services/dhis-service-patient/src/main/java/org/hisp/dhis/program/ProgramStageDataElementDeletionHandler.java 2011-11-30 06:38:30 +0000
@@ -45,7 +45,7 @@
// Dependencies
// -------------------------------------------------------------------------
- ProgramStageDataElementService programStageDEService;
+ private ProgramStageDataElementService programStageDEService;
public void setProgramStageDEService( ProgramStageDataElementService programStageDEService )
{
@@ -74,7 +74,7 @@
for ( ProgramStage programStage : programStages )
{
Collection<ProgramStageDataElement> dataElements = programStageDEService.get( programStage );
-
+
if ( dataElements != null && dataElements.size() > 0 )
{
for ( ProgramStageDataElement dataElement : dataElements )
@@ -94,6 +94,7 @@
// ---------------------------------------------------------------------
Collection<ProgramStageDataElement> dataElements = programStageDEService.get( programStage );
+
if ( dataElements != null && dataElements.size() > 0 )
{
for ( ProgramStageDataElement dataElement : dataElements )
@@ -102,26 +103,27 @@
}
}
}
-
+
@Override
- public String allowDeleteDataElement ( DataElement dataElement )
+ public String allowDeleteDataElement( DataElement dataElement )
{
if ( dataElement != null && DataElement.DOMAIN_TYPE_PATIENT.equals( dataElement.getDomainType() ) )
{
- //TODO use a query which will be more efficient
-
+ // TODO use a query which will be more efficient
+
Collection<ProgramStageDataElement> psDataElements = programStageDEService.getAllProgramStageDataElements();
- for ( ProgramStageDataElement psDataElement : psDataElements )
+ for ( ProgramStageDataElement psDataElement : psDataElements )
{
- Collection<DataElement> dataElements = programStageDEService.getListDataElement( psDataElement.getProgramStage() );
-
+ Collection<DataElement> dataElements = programStageDEService.getListDataElement( psDataElement
+ .getProgramStage() );
+
if ( dataElements.contains( dataElement ) )
{
return ERROR;
}
}
}
-
+
return null;
}
}
=== modified file 'dhis-2/dhis-services/dhis-service-patient/src/main/resources/META-INF/dhis/beans.xml'
--- dhis-2/dhis-services/dhis-service-patient/src/main/resources/META-INF/dhis/beans.xml 2011-10-05 08:42:46 +0000
+++ dhis-2/dhis-services/dhis-service-patient/src/main/resources/META-INF/dhis/beans.xml 2011-11-30 06:38:30 +0000
@@ -392,6 +392,11 @@
<property name="dataEntryFormService" ref="org.hisp.dhis.dataentryform.DataEntryFormService" />
<property name="programStageService" ref="org.hisp.dhis.program.ProgramStageService" />
</bean>
+
+ <bean id="org.hisp.dhis.program.ProgramStageInstanceDeletionHandler"
+ class="org.hisp.dhis.program.ProgramStageInstanceDeletionHandler">
+ <property name="jdbcTemplate" ref="jdbcTemplate" />
+ </bean>
<!-- Startup -->
@@ -440,6 +445,7 @@
<ref local="org.hisp.dhis.program.ProgramDeletionHandler"/>
<ref local="org.hisp.dhis.program.ProgramInstanceDeletionHandler"/>
+ <ref local="org.hisp.dhis.program.ProgramStageInstanceDeletionHandler"/>
<ref local="org.hisp.dhis.program.ProgramStageDataElementDeletionHandler"/>
<ref local="org.hisp.dhis.programattributevalue.ProgramAttributeValueDeletionHandler"/>
<ref local="org.hisp.dhis.program.ProgramValidationDeletionHandler"/>
=== modified file 'dhis-2/dhis-web/dhis-web-caseentry/src/main/java/org/hisp/dhis/caseentry/action/patient/ValidatePatientProgramEnrollmentAction.java'
--- dhis-2/dhis-web/dhis-web-caseentry/src/main/java/org/hisp/dhis/caseentry/action/patient/ValidatePatientProgramEnrollmentAction.java 2011-09-14 06:36:13 +0000
+++ dhis-2/dhis-web/dhis-web-caseentry/src/main/java/org/hisp/dhis/caseentry/action/patient/ValidatePatientProgramEnrollmentAction.java 2011-11-30 06:38:30 +0000
@@ -132,13 +132,13 @@
if ( criteria != null )
{
- message = i18n.getString( "program_is_invalid" ) + " " + criteria.getName();
+ message = i18n.getString( "can_not_enroll_into_the_program_because" ) + " " + criteria.getName();
return INPUT;
}
if ( enrollmentDate == null )
{
- message = i18n.getString( "please_specify_enrollment_date" );
+ message = i18n.getString( "can_not_enrol_into_the_program_because" );
return INPUT;
}
=== modified file 'dhis-2/dhis-web/dhis-web-caseentry/src/main/resources/org/hisp/dhis/caseentry/i18n_module.properties'
--- dhis-2/dhis-web/dhis-web-caseentry/src/main/resources/org/hisp/dhis/caseentry/i18n_module.properties 2011-11-25 04:10:03 +0000
+++ dhis-2/dhis-web/dhis-web-caseentry/src/main/resources/org/hisp/dhis/caseentry/i18n_module.properties 2011-11-30 06:38:30 +0000
@@ -444,4 +444,5 @@
representative_info = Representative's Information
relationship_for = Relationship for
enter_new_encounter = Enter new encounter
-date_of_edit = Date of edit
\ No newline at end of file
+date_of_edit = Date of edit
+can_not_enrol_into_the_program_because = Can not enrol into the program because
\ No newline at end of file
=== 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 2011-11-25 03:54:15 +0000
+++ dhis-2/dhis-web/dhis-web-caseentry/src/main/webapp/dhis-web-caseentry/updatePatientForm.vm 2011-11-30 06:38:30 +0000
@@ -158,7 +158,7 @@
<tr id='deathDateTR' style="display:none" >
<td><label for="deathDate">$i18n.getString("death_date")</label></td>
<td class="input-column" >
- <input type="text" name="deathDate" id="deathDate" style="width:30em" #if($!patient.deathDate) value="$format.formatDate( $!patient.deathDate )" #end>
+ <input type="text" name="deathDate" id="deathDate" style="width:28em" #if($!patient.deathDate) value="$format.formatDate( $!patient.deathDate )" #end>
</td>
</tr>
@@ -305,7 +305,7 @@
#foreach( $program in $representative.programs )
#if( $velocityCount == 1 )
$program.name
- #else , $program.name
+ #else , $program.name
#end
#end
</td>
=== modified file 'dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-patient/src/main/java/org/hisp/dhis/patient/action/programstage/RemoveProgramStageAction.java'
--- dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-patient/src/main/java/org/hisp/dhis/patient/action/programstage/RemoveProgramStageAction.java 2011-08-26 05:09:51 +0000
+++ dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-patient/src/main/java/org/hisp/dhis/patient/action/programstage/RemoveProgramStageAction.java 2011-11-30 06:38:30 +0000
@@ -27,6 +27,8 @@
package org.hisp.dhis.patient.action.programstage;
+import org.hisp.dhis.common.DeleteNotAllowedException;
+import org.hisp.dhis.i18n.I18n;
import org.hisp.dhis.program.ProgramStageService;
import com.opensymphony.xwork2.Action;
@@ -42,7 +44,7 @@
// -------------------------------------------------------------------------
// Dependencies
// -------------------------------------------------------------------------
-
+
private ProgramStageService programStageService;
public void setProgramStageService( ProgramStageService programStageService )
@@ -61,6 +63,24 @@
this.id = id;
}
+ private I18n i18n;
+
+ public void setI18n( I18n i18n )
+ {
+ this.i18n = i18n;
+ }
+
+ // -------------------------------------------------------------------------
+ // Output
+ // -------------------------------------------------------------------------
+
+ private String message;
+
+ public String getMessage()
+ {
+ return message;
+ }
+
// -------------------------------------------------------------------------
// Action implementation
// -------------------------------------------------------------------------
@@ -68,8 +88,19 @@
public String execute()
throws Exception
{
- programStageService.deleteProgramStage( programStageService.getProgramStage( id ) );
+ try
+ {
+ programStageService.deleteProgramStage( programStageService.getProgramStage( id ) );
+ }
+ catch ( DeleteNotAllowedException ex )
+ {
+ if ( ex.getErrorCode().equals( DeleteNotAllowedException.ERROR_ASSOCIATED_BY_OTHER_OBJECTS ) )
+ {
+ message = i18n.getString( "object_not_deleted_associated_by_objects" ) + " " + ex.getMessage();
+ return ERROR;
+ }
+ }
return SUCCESS;
}
}
=== modified file 'dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-patient/src/main/resources/org/hisp/dhis/patient/i18n_module.properties'
--- dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-patient/src/main/resources/org/hisp/dhis/patient/i18n_module.properties 2011-11-17 03:12:11 +0000
+++ dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-patient/src/main/resources/org/hisp/dhis/patient/i18n_module.properties 2011-11-30 06:38:30 +0000
@@ -383,4 +383,5 @@
run_success = Run successful
run_fail = Run failed
patients_registered = Registered Beneficiaries No
-irregular_encounter = Irregular encounter
\ No newline at end of file
+irregular_encounter = Irregular encounter
+date_of_birth = Date of Birth
\ No newline at end of file