dhis2-devs team mailing list archive
-
dhis2-devs team
-
Mailing list archive
-
Message #18166
[Branch ~dhis2-devs-core/dhis2/trunk] Rev 7550: Move storedBy from programstageinstance to patientdatavalue.
------------------------------------------------------------
revno: 7550
committer: Tran Chau <tran.hispvietnam@xxxxxxxxx>
branch nick: dhis2
timestamp: Tue 2012-07-10 13:06:52 +0700
message:
Move storedBy from programstageinstance to patientdatavalue.
modified:
dhis-2/dhis-api/src/main/java/org/hisp/dhis/patientdatavalue/PatientDataValue.java
dhis-2/dhis-api/src/main/java/org/hisp/dhis/program/ProgramStageInstance.java
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/resources/org/hisp/dhis/patientdatavalue/hibernate/PatientDataValue.hbm.xml
dhis-2/dhis-services/dhis-service-patient/src/main/resources/org/hisp/dhis/program/hibernate/ProgramStageInstance.hbm.xml
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/SaveValueAction.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/resources/META-INF/dhis/beans.xml
--
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/patientdatavalue/PatientDataValue.java'
--- dhis-2/dhis-api/src/main/java/org/hisp/dhis/patientdatavalue/PatientDataValue.java 2012-06-04 10:03:56 +0000
+++ dhis-2/dhis-api/src/main/java/org/hisp/dhis/patientdatavalue/PatientDataValue.java 2012-07-10 06:06:52 +0000
@@ -54,7 +54,9 @@
private String value;
private Boolean providedElsewhere;
-
+
+ private String storedBy;
+
// -------------------------------------------------------------------------
// Constructors
// -------------------------------------------------------------------------
@@ -180,4 +182,13 @@
return value;
}
+ public String getStoredBy()
+ {
+ return storedBy;
+ }
+
+ public void setStoredBy( String storedBy )
+ {
+ this.storedBy = storedBy;
+ }
}
=== modified file 'dhis-2/dhis-api/src/main/java/org/hisp/dhis/program/ProgramStageInstance.java'
--- dhis-2/dhis-api/src/main/java/org/hisp/dhis/program/ProgramStageInstance.java 2012-06-07 04:23:40 +0000
+++ dhis-2/dhis-api/src/main/java/org/hisp/dhis/program/ProgramStageInstance.java 2012-07-10 06:06:52 +0000
@@ -64,8 +64,6 @@
private boolean completed = false;
- private String storedBy;
-
// -------------------------------------------------------------------------
// Constructors
// -------------------------------------------------------------------------
@@ -248,14 +246,4 @@
{
this.organisationUnit = organisationUnit;
}
-
- public String getStoredBy()
- {
- return storedBy;
- }
-
- public void setStoredBy( String storedBy )
- {
- this.storedBy = storedBy;
- }
}
=== 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 2012-06-12 03:38:24 +0000
+++ dhis-2/dhis-services/dhis-service-patient/src/main/java/org/hisp/dhis/patient/startup/TableAlteror.java 2012-07-10 06:06:52 +0000
@@ -117,6 +117,7 @@
updateMultiOrgunitTabularReportTable();
updateProgramStageTabularReportTable();
+ moveStoredByFormStageInstanceToDataValue();
}
// -------------------------------------------------------------------------
@@ -126,7 +127,7 @@
private void updateProgramStageInstanceOrgunit()
{
StatementHolder holder = statementManager.getHolder();
-
+
try
{
Statement statement = holder.getStatement();
@@ -232,13 +233,14 @@
while ( resultSet.next() )
{
- executeSql( " INSERT INTO patienttabularreport_organisationUnits ( patienttabularreportid, organisationunitid ) VALUES ( " + resultSet.getInt( 1 ) + ", " + resultSet.getInt( 2 ) + ")" );
+ executeSql( " INSERT INTO patienttabularreport_organisationUnits ( patienttabularreportid, organisationunitid ) VALUES ( "
+ + resultSet.getInt( 1 ) + ", " + resultSet.getInt( 2 ) + ")" );
}
executeSql( "ALTER TABLE patienttabularreport DROP COLUMN organisationunitid" );
}
catch ( Exception e )
{
-
+
}
}
@@ -252,23 +254,52 @@
ResultSet resultSet = statement
.executeQuery( "SELECT pd.patienttabularreportid, tr.programstageid, pd.elt, sort_order "
- + " FROM patienttabularreport_dataelements pd inner join patienttabularreport tr"
- + " on pd.patienttabularreportid=tr.patienttabularreportid"
- + " order by pd.patienttabularreportid" );
+ + " FROM patienttabularreport_dataelements pd inner join patienttabularreport tr"
+ + " on pd.patienttabularreportid=tr.patienttabularreportid" + " order by pd.patienttabularreportid" );
while ( resultSet.next() )
{
- executeSql( "INSERT INTO patienttabularreport_programstagedataelements ( patienttabularreportid, programstageid, dataelementid, sort_order ) VALUES ( " + resultSet.getInt( 1 ) + ", " + resultSet.getInt( 2 ) + ", " + resultSet.getInt( 3 ) + ", " + resultSet.getInt( 4 ) + ")" );
+ executeSql( "INSERT INTO patienttabularreport_programstagedataelements ( patienttabularreportid, programstageid, dataelementid, sort_order ) VALUES ( "
+ + resultSet.getInt( 1 )
+ + ", "
+ + resultSet.getInt( 2 )
+ + ", "
+ + resultSet.getInt( 3 )
+ + ", "
+ + resultSet.getInt( 4 ) + ")" );
}
executeSql( "ALTER TABLE patienttabularreport DROP COLUMN programstageid" );
executeSql( "DROP TABLE patienttabularreport_dataelements" );
}
catch ( Exception e )
{
-
- }
- }
-
+
+ }
+ }
+
+ private void moveStoredByFormStageInstanceToDataValue()
+ {
+ try
+ {
+ StatementHolder holder = statementManager.getHolder();
+ Statement statement = holder.getStatement();
+
+ ResultSet resultSet = statement.executeQuery( "SELECT programstageinstanceid, storedBy"
+ + " FROM programstageinstance where storedBy is not null" );
+
+ while ( resultSet.next() )
+ {
+ executeSql( "UPDATE patientdatavalue SET storedBy='" + resultSet.getString( 2 )
+ + "' where programstageinstanceid=" + resultSet.getInt( 1 ) );
+ }
+
+ executeSql( "ALTER TABLE programstageinstance DROP COLUMN storedBy" );
+ }
+ catch ( Exception ex )
+ {
+ }
+ }
+
private int executeSql( String sql )
{
try
=== modified file 'dhis-2/dhis-services/dhis-service-patient/src/main/resources/org/hisp/dhis/patientdatavalue/hibernate/PatientDataValue.hbm.xml'
--- dhis-2/dhis-services/dhis-service-patient/src/main/resources/org/hisp/dhis/patientdatavalue/hibernate/PatientDataValue.hbm.xml 2012-06-04 10:03:56 +0000
+++ dhis-2/dhis-services/dhis-service-patient/src/main/resources/org/hisp/dhis/patientdatavalue/hibernate/PatientDataValue.hbm.xml 2012-07-10 06:06:52 +0000
@@ -18,6 +18,8 @@
<property name="timestamp" type="date" />
<property name="providedElsewhere" />
-
+
+ <property name="storedBy" column="storedby" length="31" />
+
</class>
</hibernate-mapping>
=== modified file 'dhis-2/dhis-services/dhis-service-patient/src/main/resources/org/hisp/dhis/program/hibernate/ProgramStageInstance.hbm.xml'
--- dhis-2/dhis-services/dhis-service-patient/src/main/resources/org/hisp/dhis/program/hibernate/ProgramStageInstance.hbm.xml 2012-06-04 10:03:56 +0000
+++ dhis-2/dhis-services/dhis-service-patient/src/main/resources/org/hisp/dhis/program/hibernate/ProgramStageInstance.hbm.xml 2012-07-10 06:06:52 +0000
@@ -27,7 +27,5 @@
<many-to-one name="organisationUnit" class="org.hisp.dhis.organisationunit.OrganisationUnit"
column="organisationunitid" foreign-key="fk_programstageinstance_organisationunitid" />
- <property name="storedBy" column="storedby" length="31" />
-
</class>
</hibernate-mapping>
=== 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 2012-06-13 08:22:35 +0000
+++ dhis-2/dhis-web/dhis-web-caseentry/src/main/java/org/hisp/dhis/caseentry/action/caseentry/SaveExecutionDateAction.java 2012-07-10 06:06:52 +0000
@@ -42,7 +42,6 @@
import org.hisp.dhis.program.ProgramStage;
import org.hisp.dhis.program.ProgramStageInstance;
import org.hisp.dhis.program.ProgramStageInstanceService;
-import org.hisp.dhis.user.CurrentUserService;
import com.opensymphony.xwork2.Action;
@@ -100,14 +99,7 @@
{
this.format = format;
}
-
- private CurrentUserService currentUserService;
-
- public void setCurrentUserService( CurrentUserService currentUserService )
- {
- this.currentUserService = currentUserService;
- }
-
+
// -------------------------------------------------------------------------
// Input/Output
// -------------------------------------------------------------------------
@@ -141,8 +133,7 @@
throws Exception
{
Date dateValue = format.parseDate( executionDate );
- String storedBy = currentUserService.getCurrentUsername();
-
+
if ( dateValue != null )
{
// Get program-stage-instance of the patient
@@ -192,7 +183,6 @@
programStageInstance.setStageInProgram( programStage.getStageInProgram() );
programStageInstance.setDueDate( dateValue );
programStageInstance.setExecutionDate( dateValue );
- programStageInstance.setStoredBy( storedBy );
programStageInstance.setOrganisationUnit( selectedStateManager.getSelectedOrganisationUnit() );
programStageInstanceService.addProgramStageInstance( programStageInstance );
@@ -202,7 +192,6 @@
else
{
programStageInstance.setExecutionDate( dateValue );
- programStageInstance.setStoredBy( storedBy );
programStageInstance.setOrganisationUnit( selectedStateManager.getSelectedOrganisationUnit() );
if ( programStageInstance.getProgramInstance().getProgram().isSingleEvent() )
=== modified file 'dhis-2/dhis-web/dhis-web-caseentry/src/main/java/org/hisp/dhis/caseentry/action/caseentry/SaveValueAction.java'
--- dhis-2/dhis-web/dhis-web-caseentry/src/main/java/org/hisp/dhis/caseentry/action/caseentry/SaveValueAction.java 2012-06-27 05:12:36 +0000
+++ dhis-2/dhis-web/dhis-web-caseentry/src/main/java/org/hisp/dhis/caseentry/action/caseentry/SaveValueAction.java 2012-07-10 06:06:52 +0000
@@ -37,6 +37,7 @@
import org.hisp.dhis.patientdatavalue.PatientDataValueService;
import org.hisp.dhis.program.ProgramStageInstance;
import org.hisp.dhis.program.ProgramStageInstanceService;
+import org.hisp.dhis.user.CurrentUserService;
import com.opensymphony.xwork2.Action;
@@ -75,11 +76,11 @@
this.patientDataValueService = patientDataValueService;
}
- private Boolean providedElsewhere;
+ private CurrentUserService currentUserService;
- public void setProvidedElsewhere( Boolean providedElsewhere )
+ public void setCurrentUserService( CurrentUserService currentUserService )
{
- this.providedElsewhere = providedElsewhere;
+ this.currentUserService = currentUserService;
}
// -------------------------------------------------------------------------
@@ -119,7 +120,12 @@
return statusCode;
}
- private ProgramStageInstance programStageInstance;
+ private Boolean providedElsewhere;
+
+ public void setProvidedElsewhere( Boolean providedElsewhere )
+ {
+ this.providedElsewhere = providedElsewhere;
+ }
// -------------------------------------------------------------------------
// Implementation Action
@@ -128,8 +134,7 @@
public String execute()
throws Exception
{
-
- programStageInstance = programStageInstanceService.getProgramStageInstance( programStageInstanceId );
+ ProgramStageInstance programStageInstance = programStageInstanceService.getProgramStageInstance( programStageInstanceId );
DataElement dataElement = dataElementService.getDataElement( dataElementId );
@@ -144,7 +149,7 @@
// ---------------------------------------------------------------------
// Save value
// ---------------------------------------------------------------------
-
+
if ( programStageInstance.getExecutionDate() == null )
{
programStageInstance.setExecutionDate( new Date() );
@@ -152,12 +157,13 @@
}
providedElsewhere = (providedElsewhere == null) ? false : providedElsewhere;
-
+ String storedBy = currentUserService.getCurrentUsername();
if ( patientDataValue == null && value != null )
{
LOG.debug( "Adding PatientDataValue, value added" );
patientDataValue = new PatientDataValue( programStageInstance, dataElement, new Date(), value );
+ patientDataValue.setStoredBy( storedBy );
patientDataValue.setProvidedElsewhere( providedElsewhere );
patientDataValueService.savePatientDataValue( patientDataValue );
@@ -173,7 +179,8 @@
patientDataValue.setValue( value );
patientDataValue.setTimestamp( new Date() );
patientDataValue.setProvidedElsewhere( providedElsewhere );
-
+ patientDataValue.setStoredBy( storedBy );
+
patientDataValueService.updatePatientDataValue( patientDataValue );
}
=== 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 2012-06-27 05:12:36 +0000
+++ dhis-2/dhis-web/dhis-web-caseentry/src/main/java/org/hisp/dhis/caseentry/action/caseentry/SaveValuesAction.java 2012-07-10 06:06:52 +0000
@@ -173,14 +173,12 @@
// Add a new program-stage-instance
// ---------------------------------------------------------------------
- String storedBy = currentUserService.getCurrentUsername();
ProgramStageInstance programStageInstance = new ProgramStageInstance();
programStageInstance.setProgramInstance( programInstance );
programStageInstance.setProgramStage( programStage );
programStageInstance.setStageInProgram( programStage.getStageInProgram() );
programStageInstance.setDueDate( currentDate );
programStageInstance.setExecutionDate( currentDate );
- programStageInstance.setStoredBy( storedBy );
programStageInstance.setOrganisationUnit( selectedStateManager.getSelectedOrganisationUnit() );
programStageInstance.setCompleted( true );
@@ -192,6 +190,7 @@
HttpServletRequest request = ServletActionContext.getRequest();
+ String storedBy = currentUserService.getCurrentUsername();
Collection<ProgramStageDataElement> psDataElements = programStage.getProgramStageDataElements();
for ( ProgramStageDataElement psDataElement : psDataElements )
{
@@ -204,6 +203,7 @@
boolean providedElsewhere = (request.getParameter( providedElsewhereId ) == null) ? false : true;
PatientDataValue patientDataValue = new PatientDataValue( programStageInstance, psDataElement.getDataElement(), new Date(), value );
+ patientDataValue.setStoredBy( storedBy );
patientDataValue.setProvidedElsewhere( providedElsewhere );
patientDataValueService.savePatientDataValue( patientDataValue );
=== 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 2012-07-06 09:59:36 +0000
+++ dhis-2/dhis-web/dhis-web-caseentry/src/main/resources/META-INF/dhis/beans.xml 2012-07-10 06:06:52 +0000
@@ -54,7 +54,6 @@
<property name="patientService" ref="org.hisp.dhis.patient.PatientService" />
<property name="selectedStateManager"
ref="org.hisp.dhis.caseentry.state.SelectedStateManager" />
- <property name="currentUserService" ref="org.hisp.dhis.user.CurrentUserService" />
</bean>
<bean id="org.hisp.dhis.caseentry.action.caseentry.SaveValueAction"
@@ -65,6 +64,7 @@
ref="org.hisp.dhis.program.ProgramStageInstanceService" />
<property name="patientDataValueService"
ref="org.hisp.dhis.patientdatavalue.PatientDataValueService" />
+ <property name="currentUserService" ref="org.hisp.dhis.user.CurrentUserService" />
</bean>
<bean