=== modified file 'dhis-2/dhis-api/src/main/java/org/hisp/dhis/patient/Patient.java' --- dhis-2/dhis-api/src/main/java/org/hisp/dhis/patient/Patient.java 2013-09-17 07:53:28 +0000 +++ dhis-2/dhis-api/src/main/java/org/hisp/dhis/patient/Patient.java 2013-09-18 03:49:35 +0000 @@ -28,24 +28,23 @@ * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. */ -import com.fasterxml.jackson.annotation.JsonProperty; -import com.fasterxml.jackson.annotation.JsonView; -import com.fasterxml.jackson.databind.annotation.JsonSerialize; -import com.fasterxml.jackson.dataformat.xml.annotation.JacksonXmlElementWrapper; -import com.fasterxml.jackson.dataformat.xml.annotation.JacksonXmlProperty; -import com.fasterxml.jackson.dataformat.xml.annotation.JacksonXmlRootElement; +import java.util.Calendar; +import java.util.Date; +import java.util.HashSet; +import java.util.Set; + import org.hisp.dhis.common.BaseIdentifiableObject; import org.hisp.dhis.common.DxfNamespaces; import org.hisp.dhis.common.view.DetailedView; import org.hisp.dhis.common.view.ExportView; import org.hisp.dhis.organisationunit.OrganisationUnit; -import org.hisp.dhis.program.Program; import org.hisp.dhis.user.User; -import java.util.Calendar; -import java.util.Date; -import java.util.HashSet; -import java.util.Set; +import com.fasterxml.jackson.annotation.JsonProperty; +import com.fasterxml.jackson.annotation.JsonView; +import com.fasterxml.jackson.databind.annotation.JsonSerialize; +import com.fasterxml.jackson.dataformat.xml.annotation.JacksonXmlProperty; +import com.fasterxml.jackson.dataformat.xml.annotation.JacksonXmlRootElement; /** * @author Abyot Asalefew Gizaw @@ -99,9 +98,7 @@ private boolean isDead = false; private Set identifiers = new HashSet(); - - private Set programs = new HashSet(); - + private OrganisationUnit organisationUnit; private Set attributes = new HashSet(); @@ -216,21 +213,7 @@ { this.identifiers = identifiers; } - - @JsonProperty - @JsonView({ DetailedView.class, ExportView.class }) - @JacksonXmlElementWrapper(localName = "programs", namespace = DxfNamespaces.DXF_2_0) - @JacksonXmlProperty(localName = "program", namespace = DxfNamespaces.DXF_2_0) - public Set getPrograms() - { - return programs; - } - - public void setPrograms( Set programs ) - { - this.programs = programs; - } - + @JsonProperty @JsonSerialize(as = BaseIdentifiableObject.class) @JsonView({ DetailedView.class, ExportView.class }) === modified file 'dhis-2/dhis-api/src/main/java/org/hisp/dhis/patient/PatientService.java' --- dhis-2/dhis-api/src/main/java/org/hisp/dhis/patient/PatientService.java 2013-09-12 07:29:29 +0000 +++ dhis-2/dhis-api/src/main/java/org/hisp/dhis/patient/PatientService.java 2013-09-18 03:49:35 +0000 @@ -262,9 +262,7 @@ int countGetPatientsByOrgUnitProgram( OrganisationUnit organisationUnit, Program program ); Object getObjectValue( String property, String value, I18nFormat format ); - - void removeErollmentPrograms( Program program ); - + Collection searchPatients( List searchKeys, Collection orgunit, Boolean followup, Collection patientAttributes, Integer min, Integer max ); === modified file 'dhis-2/dhis-api/src/main/java/org/hisp/dhis/patient/PatientStore.java' --- dhis-2/dhis-api/src/main/java/org/hisp/dhis/patient/PatientStore.java 2013-09-12 07:26:17 +0000 +++ dhis-2/dhis-api/src/main/java/org/hisp/dhis/patient/PatientStore.java 2013-09-18 03:49:35 +0000 @@ -69,8 +69,6 @@ int countGetPatientsByOrgUnitProgram( OrganisationUnit organisationUnit, Program program ); - void removeErollmentPrograms( Program program ); - int countSearch( List searchKeys, Collection orgunit, Boolean followup ); Collection getByPhoneNumber( String phoneNumber, Integer min, Integer max ); === modified file 'dhis-2/dhis-services/dhis-service-mobile/src/main/java/org/hisp/dhis/mobile/service/ActivityReportingServiceImpl.java' --- dhis-2/dhis-services/dhis-service-mobile/src/main/java/org/hisp/dhis/mobile/service/ActivityReportingServiceImpl.java 2013-09-12 07:29:29 +0000 +++ dhis-2/dhis-services/dhis-service-mobile/src/main/java/org/hisp/dhis/mobile/service/ActivityReportingServiceImpl.java 2013-09-18 03:49:35 +0000 @@ -437,8 +437,8 @@ for ( Patient each : patients ) { - patientsInfo += each.getId() + "/" + each.getName() + "/" - + dateFormat.format( each.getBirthDate() ) + "$"; + patientsInfo += each.getId() + "/" + each.getName() + "/" + dateFormat.format( each.getBirthDate() ) + + "$"; } throw new NotAllowedException( patientsInfo ); @@ -490,9 +490,6 @@ programInstance.setStatus( ProgramInstance.STATUS_COMPLETED ); programInstance.setPatient( patient ); - patient.getPrograms().add( programStage.getProgram() ); - patientService.updatePatient( patient ); - programInstanceService.addProgramInstance( programInstance ); // --------------------------------------------------------------------- @@ -676,8 +673,6 @@ programInstance.setPatient( patient ); programInstance.setStatus( ProgramInstance.STATUS_ACTIVE ); programInstanceService.addProgramInstance( programInstance ); - patient.getPrograms().add( program ); - patientService.updatePatient( patient ); for ( ProgramStage programStage : program.getProgramStages() ) { if ( programStage.getAutoGenerateEvent() ) @@ -1290,8 +1285,8 @@ for ( Patient each : patients ) { - patientsInfo += each.getId() + "/" + each.getName() + "/" - + dateFormat.format( each.getBirthDate() ) + "$"; + patientsInfo += each.getId() + "/" + each.getName() + "/" + dateFormat.format( each.getBirthDate() ) + + "$"; } throw new NotAllowedException( patientsInfo ); @@ -1921,8 +1916,8 @@ } if ( each.getBirthDate() != null ) { - patientsInfo += each.getId() + "/" + each.getName() + "/" - + dateFormat.format( each.getBirthDate() ) + "$"; + patientsInfo += each.getId() + "/" + each.getName() + "/" + dateFormat.format( each.getBirthDate() ) + + "$"; } else { === modified file 'dhis-2/dhis-services/dhis-service-patient/src/main/java/org/hisp/dhis/patient/DefaultPatientService.java' --- dhis-2/dhis-services/dhis-service-patient/src/main/java/org/hisp/dhis/patient/DefaultPatientService.java 2013-09-12 07:26:17 +0000 +++ dhis-2/dhis-services/dhis-service-patient/src/main/java/org/hisp/dhis/patient/DefaultPatientService.java 2013-09-18 03:49:35 +0000 @@ -566,11 +566,6 @@ return patientStore.getRepresentatives( patient ); } - public void removeErollmentPrograms( Program program ) - { - patientStore.removeErollmentPrograms( program ); - } - public Collection searchPatients( List searchKeys, Collection orgunits, Boolean followup, Collection patientAttributes, Integer min, Integer max ) { === modified file 'dhis-2/dhis-services/dhis-service-patient/src/main/java/org/hisp/dhis/patient/PatientDeletionHandler.java' --- dhis-2/dhis-services/dhis-service-patient/src/main/java/org/hisp/dhis/patient/PatientDeletionHandler.java 2013-09-10 13:40:30 +0000 +++ dhis-2/dhis-services/dhis-service-patient/src/main/java/org/hisp/dhis/patient/PatientDeletionHandler.java 2013-09-18 03:49:35 +0000 @@ -28,13 +28,12 @@ * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. */ +import java.util.Collection; + import org.hisp.dhis.organisationunit.OrganisationUnit; -import org.hisp.dhis.program.Program; import org.hisp.dhis.system.deletion.DeletionHandler; import org.springframework.jdbc.core.JdbcTemplate; -import java.util.Collection; - public class PatientDeletionHandler extends DeletionHandler { @@ -91,9 +90,4 @@ return patientService.getPatients( unit, 0, Integer.MAX_VALUE ).size() == 0 ? null : ERROR; } - @Override - public void deleteProgram( Program program ) - { - patientService.removeErollmentPrograms( program ); - } } === 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-09-17 07:53:28 +0000 +++ dhis-2/dhis-services/dhis-service-patient/src/main/java/org/hisp/dhis/patient/hibernate/HibernatePatientStore.java 2013-09-18 03:49:35 +0000 @@ -311,14 +311,6 @@ } @Override - public void removeErollmentPrograms( Program program ) - { - String sql = "delete from patient_programs where programid='" + program.getId() + "'"; - - jdbcTemplate.execute( sql ); - } - - @Override public Collection search( List searchKeys, Collection orgunits, Boolean followup, Collection patientAttributes, Integer min, Integer max ) { === modified file 'dhis-2/dhis-services/dhis-service-patient/src/main/java/org/hisp/dhis/patient/startup/TableAlteror.java' --- dhis-2/dhis-services/dhis-service-patient/src/main/java/org/hisp/dhis/patient/startup/TableAlteror.java 2013-09-16 09:47:59 +0000 +++ dhis-2/dhis-services/dhis-service-patient/src/main/java/org/hisp/dhis/patient/startup/TableAlteror.java 2013-09-18 03:49:35 +0000 @@ -197,37 +197,36 @@ executeSql( "update caseaggregationcondition set \"operator\"='times' where \"operator\"='SUM'" ); executeSql( "update prorgam set \"operator\"='times' where \"operator\"='SUM'" ); - + executeSql( "update program set remindCompleted=false where remindCompleted is null" ); executeSql( "update patientreminder set dateToCompare='duedate' where programstageid is not null" ); executeSql( "UPDATE programinstance SET followup=false where followup is null" ); executeSql( "UPDATE patientreminder SET sendTo=1 where sendTo is null" ); - - + updateUid(); updateUidInDataEntryFrom(); updateProgramInstanceStatus(); - + executeSql( "ALTER TABLE program DROP COLUMN disableRegistrationFields" ); - executeSql( "ALTER TABLE program ALTER COLUMN dateofincidentdescription DROP NOT NULL"); - executeSql( "ALTER TABLE patient ALTER COLUMN birthdate DROP NOT NULL"); - executeSql( "ALTER TABLE patient ALTER COLUMN gender DROP NOT NULL"); - executeSql( "ALTER TABLE patient ALTER COLUMN underage DROP NOT NULL"); - executeSql( "ALTER TABLE program ALTER COLUMN dateofenrollmentdescription DROP NOT NULL"); + executeSql( "ALTER TABLE program ALTER COLUMN dateofincidentdescription DROP NOT NULL" ); + executeSql( "ALTER TABLE patient ALTER COLUMN birthdate DROP NOT NULL" ); + executeSql( "ALTER TABLE patient ALTER COLUMN gender DROP NOT NULL" ); + executeSql( "ALTER TABLE patient ALTER COLUMN underage DROP NOT NULL" ); + executeSql( "ALTER TABLE program ALTER COLUMN dateofenrollmentdescription DROP NOT NULL" ); executeSql( "UPDATE program SET displayOnAllOrgunit=true where displayOnAllOrgunit is null" ); executeSql( "UPDATE program SET useFormNameDataElement=true where useFormNameDataElement is null" ); - executeSql( "ALTER TABLE caseaggregationcondition ALTER COLUMN aggregationexpression TYPE varchar(1000)"); - executeSql( "update patientattribute set displayonvisitschedule = false where displayonvisitschedule is null"); - executeSql( "update program set useBirthDateAsIncidentDate = false where useBirthDateAsIncidentDate is null"); - executeSql( "update program set useBirthDateAsEnrollmentDate = false where useBirthDateAsEnrollmentDate is null"); - executeSql( "update program set selectEnrollmentDatesInFuture = false where selectEnrollmentDatesInFuture is null"); - executeSql( "update program set selectIncidentDatesInFuture = false where selectIncidentDatesInFuture is null"); - executeSql( "update validationcriteria set description = name where description is null or description='' "); - executeSql( "update programstage set generatedByEnrollmentDate = false where generatedByEnrollmentDate is null "); - executeSql( "update programstage set blockEntryForm = false where blockEntryForm is null "); - executeSql( "update programstage set remindCompleted = false where remindCompleted is null "); + executeSql( "ALTER TABLE caseaggregationcondition ALTER COLUMN aggregationexpression TYPE varchar(1000)" ); + executeSql( "update patientattribute set displayonvisitschedule = false where displayonvisitschedule is null" ); + executeSql( "update program set useBirthDateAsIncidentDate = false where useBirthDateAsIncidentDate is null" ); + executeSql( "update program set useBirthDateAsEnrollmentDate = false where useBirthDateAsEnrollmentDate is null" ); + executeSql( "update program set selectEnrollmentDatesInFuture = false where selectEnrollmentDatesInFuture is null" ); + executeSql( "update program set selectIncidentDatesInFuture = false where selectIncidentDatesInFuture is null" ); + executeSql( "update validationcriteria set description = name where description is null or description='' " ); + executeSql( "update programstage set generatedByEnrollmentDate = false where generatedByEnrollmentDate is null " ); + executeSql( "update programstage set blockEntryForm = false where blockEntryForm is null " ); + executeSql( "update programstage set remindCompleted = false where remindCompleted is null " ); executeSql( "ALTER TABLE program DROP COLUMN generatedByEnrollmentDate" ); executeSql( "ALTER TABLE program DROP COLUMN blockEntryForm" ); executeSql( "ALTER TABLE program DROP COLUMN remindCompleted" ); @@ -240,6 +239,8 @@ executeSql( "alter table patient drop column firstname" ); executeSql( "alter table patient drop column middlename" ); executeSql( "alter table patient drop column lastname" ); + + executeSql( "DROP TABLE patient_programs" ); } // ------------------------------------------------------------------------- === modified file 'dhis-2/dhis-services/dhis-service-patient/src/main/resources/org/hisp/dhis/patient/hibernate/Patient.hbm.xml' --- dhis-2/dhis-services/dhis-service-patient/src/main/resources/org/hisp/dhis/patient/hibernate/Patient.hbm.xml 2013-09-12 07:33:02 +0000 +++ dhis-2/dhis-services/dhis-service-patient/src/main/resources/org/hisp/dhis/patient/hibernate/Patient.hbm.xml 2013-09-18 03:49:35 +0000 @@ -34,12 +34,7 @@ - - - - - - + iterProgram = programs.iterator(); + while(iterProgram.hasNext() ) + { + if( iterProgram.next().getOnlyEnrollOnce()) + { + iterProgram.remove(); + } + } Collection programInstances = programInstanceService.getProgramInstances( patient, ProgramInstance.STATUS_ACTIVE ); === 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-09-10 14:33:19 +0000 +++ dhis-2/dhis-web/dhis-web-caseentry/src/main/java/org/hisp/dhis/caseentry/action/patient/SaveProgramEnrollmentAction.java 2013-09-18 03:49:35 +0000 @@ -205,9 +205,6 @@ programInstanceService.addProgramInstance( programInstance ); - patient.getPrograms().add( program ); - patientService.updatePatient( patient ); - boolean isFirstStage = false; Date currentDate = new Date(); for ( ProgramStage programStage : program.getProgramStages() ) === modified file 'dhis-2/dhis-web/dhis-web-caseentry/src/main/java/org/hisp/dhis/caseentry/action/patient/SetProgramInstanceStatusAction.java' --- dhis-2/dhis-web/dhis-web-caseentry/src/main/java/org/hisp/dhis/caseentry/action/patient/SetProgramInstanceStatusAction.java 2013-09-10 04:51:49 +0000 +++ dhis-2/dhis-web/dhis-web-caseentry/src/main/java/org/hisp/dhis/caseentry/action/patient/SetProgramInstanceStatusAction.java 2013-09-18 03:49:35 +0000 @@ -36,9 +36,7 @@ import org.hisp.dhis.i18n.I18nFormat; import org.hisp.dhis.message.MessageConversation; -import org.hisp.dhis.patient.Patient; import org.hisp.dhis.patient.PatientReminder; -import org.hisp.dhis.patient.PatientService; import org.hisp.dhis.period.PeriodType; import org.hisp.dhis.program.Program; import org.hisp.dhis.program.ProgramInstance; @@ -60,13 +58,6 @@ // Dependencies // ------------------------------------------------------------------------- - private PatientService patientService; - - public void setPatientService( PatientService patientService ) - { - this.patientService = patientService; - } - private ProgramInstanceService programInstanceService; public void setProgramInstanceService( ProgramInstanceService programInstanceService ) @@ -125,10 +116,6 @@ throws Exception { ProgramInstance programInstance = programInstanceService.getProgramInstance( programInstanceId ); - - Patient patient = programInstance.getPatient(); - - Program program = programInstance.getProgram(); programInstance.setStatus( status ); if ( status == ProgramInstance.STATUS_COMPLETED ) @@ -160,11 +147,6 @@ PatientReminder.SEND_WHEN_TO_C0MPLETED_PROGRAM, format ) ); programInstance.setEndDate( new Date() ); - if ( !program.getOnlyEnrollOnce() ) - { - patient.getPrograms().remove( program ); - patientService.updatePatient( patient ); - } } else if ( status == ProgramInstance.STATUS_CANCELLED ) @@ -192,15 +174,10 @@ } } } - patient.getPrograms().remove( program ); - patientService.updatePatient( patient ); } else { programInstance.setEndDate( null ); - - patient.getPrograms().add( program ); - patientService.updatePatient( patient ); } programInstanceService.updateProgramInstance( programInstance ); === 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-09-18 02:45:29 +0000 +++ dhis-2/dhis-web/dhis-web-caseentry/src/main/resources/META-INF/dhis/beans.xml 2013-09-18 03:49:35 +0000 @@ -2,7 +2,6 @@ - - @@ -701,7 +699,6 @@ id="org.hisp.dhis.caseentry.action.patient.SetProgramInstanceStatusAction" class="org.hisp.dhis.caseentry.action.patient.SetProgramInstanceStatusAction" scope="prototype"> -