← Back to team overview

dhis2-devs team mailing list archive

[Branch ~dhis2-devs-core/dhis2/trunk] Rev 9396: Add calculated patient attribute values into multi entry form.

 

------------------------------------------------------------
revno: 9396
committer: Tran Chau <tran.hispvietnam@xxxxxxxxx>
branch nick: dhis2
timestamp: Wed 2012-12-26 10:02:05 +0700
message:
  Add calculated patient attribute values into multi entry form.
removed:
  dhis-2/dhis-web/dhis-web-caseentry/src/main/java/org/hisp/dhis/caseentry/action/caseentry/ProgramStageCustomDataEntryAction.java
modified:
  dhis-2/dhis-services/dhis-service-patient/src/main/java/org/hisp/dhis/patient/startup/TableAlteror.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/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/reportDataEntryForm.vm
  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/patient/startup/TableAlteror.java'
--- dhis-2/dhis-services/dhis-service-patient/src/main/java/org/hisp/dhis/patient/startup/TableAlteror.java	2012-12-12 09:15:45 +0000
+++ dhis-2/dhis-services/dhis-service-patient/src/main/java/org/hisp/dhis/patient/startup/TableAlteror.java	2012-12-26 03:02:05 +0000
@@ -157,7 +157,9 @@
         
         executeSql( "UPDATE programstage SET displayGenerateEventBox=true WHERE displayGenerateEventBox is null" );
         executeSql( "ALTER TABLE patientidentifier DROP COLUMN preferred");
-        
+
+        executeSql( "UPDATE patientidentifiertype SET personDisplayName=false WHERE personDisplayName is null");
+
     }
 
     // -------------------------------------------------------------------------

=== 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	2012-12-18 05:57:32 +0000
+++ dhis-2/dhis-web/dhis-web-caseentry/src/main/java/org/hisp/dhis/caseentry/action/caseentry/LoadDataEntryAction.java	2012-12-26 03:02:05 +0000
@@ -39,7 +39,12 @@
 import org.hisp.dhis.caseentry.state.SelectedStateManager;
 import org.hisp.dhis.dataentryform.DataEntryForm;
 import org.hisp.dhis.i18n.I18n;
+import org.hisp.dhis.i18n.I18nFormat;
 import org.hisp.dhis.organisationunit.OrganisationUnit;
+import org.hisp.dhis.patient.Patient;
+import org.hisp.dhis.patient.PatientAttribute;
+import org.hisp.dhis.patient.PatientAttributeService;
+import org.hisp.dhis.patientattributevalue.PatientAttributeValueService;
 import org.hisp.dhis.patientdatavalue.PatientDataValue;
 import org.hisp.dhis.patientdatavalue.PatientDataValueService;
 import org.hisp.dhis.program.Program;
@@ -73,6 +78,12 @@
 
     private SelectedStateManager selectedStateManager;
 
+    private PatientAttributeService patientAttributeService;
+
+    private PatientAttributeValueService patientAttributeValueService;
+
+    private I18nFormat format;
+
     // -------------------------------------------------------------------------
     // Input && Output
     // -------------------------------------------------------------------------
@@ -97,6 +108,8 @@
 
     private Set<ProgramStageSection> sections = new HashSet<ProgramStageSection>();
 
+    private Map<String, Double> calAttributeValueMap = new HashMap<String, Double>();
+
     // -------------------------------------------------------------------------
     // Getters && Setters
     // -------------------------------------------------------------------------
@@ -106,6 +119,21 @@
         this.programStageInstanceService = programStageInstanceService;
     }
 
+    public void setPatientAttributeService( PatientAttributeService patientAttributeService )
+    {
+        this.patientAttributeService = patientAttributeService;
+    }
+
+    public void setPatientAttributeValueService( PatientAttributeValueService patientAttributeValueService )
+    {
+        this.patientAttributeValueService = patientAttributeValueService;
+    }
+
+    public void setFormat( I18nFormat format )
+    {
+        this.format = format;
+    }
+
     public void setProgramStageInstanceId( Integer programStageInstanceId )
     {
         this.programStageInstanceId = programStageInstanceId;
@@ -178,6 +206,18 @@
         return visitor;
     }
 
+    private Patient patient;
+
+    public Patient getPatient()
+    {
+        return patient;
+    }
+
+    public Map<String, Double> getCalAttributeValueMap()
+    {
+        return calAttributeValueMap;
+    }
+    
     // -------------------------------------------------------------------------
     // Implementation Action
     // -------------------------------------------------------------------------
@@ -201,6 +241,24 @@
 
             selectedStateManager.setSelectedProgramStageInstance( programStageInstance );
 
+            if ( program.isRegistration() )
+            {
+                patient = programStageInstance.getProgramInstance().getPatient();
+
+                Collection<PatientAttribute> calAttributes = patientAttributeService
+                    .getPatientAttributesByValueType( PatientAttribute.TYPE_CALCULATED );
+
+                for ( PatientAttribute calAttribute : calAttributes )
+                {
+                    Double value = patientAttributeValueService.getCalculatedPatientAttributeValue( patient,
+                        calAttribute, format );
+                    if ( value != null )
+                    {
+                        calAttributeValueMap.put( calAttribute.getName(), value );
+                    }
+                }
+            }
+
             // ---------------------------------------------------------------------
             // Get data values
             // ---------------------------------------------------------------------

=== removed file 'dhis-2/dhis-web/dhis-web-caseentry/src/main/java/org/hisp/dhis/caseentry/action/caseentry/ProgramStageCustomDataEntryAction.java'
--- dhis-2/dhis-web/dhis-web-caseentry/src/main/java/org/hisp/dhis/caseentry/action/caseentry/ProgramStageCustomDataEntryAction.java	2012-12-17 13:13:51 +0000
+++ dhis-2/dhis-web/dhis-web-caseentry/src/main/java/org/hisp/dhis/caseentry/action/caseentry/ProgramStageCustomDataEntryAction.java	1970-01-01 00:00:00 +0000
@@ -1,264 +0,0 @@
-/*
- * Copyright (c) 2004-2009, University of Oslo
- * All rights reserved.
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions are met:
- * * Redistributions of source code must retain the above copyright notice, this
- *   list of conditions and the following disclaimer.
- * * Redistributions in binary form must reproduce the above copyright notice,
- *   this list of conditions and the following disclaimer in the documentation
- *   and/or other materials provided with the distribution.
- * * Neither the name of the HISP project nor the names of its contributors may
- *   be used to endorse or promote products derived from this software without
- *   specific prior written permission.
- *
- * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
- * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
- * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
- * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR
- * ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
- * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
- * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON
- * ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
- * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
- * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
- */
-
-package org.hisp.dhis.caseentry.action.caseentry;
-
-import java.util.ArrayList;
-import java.util.Collection;
-import java.util.Collections;
-import java.util.HashMap;
-import java.util.List;
-import java.util.Map;
-
-import org.hisp.dhis.caseentry.state.SelectedStateManager;
-import org.hisp.dhis.dataelement.DataElement;
-import org.hisp.dhis.dataentryform.DataEntryForm;
-import org.hisp.dhis.i18n.I18n;
-import org.hisp.dhis.organisationunit.OrganisationUnit;
-import org.hisp.dhis.patient.Patient;
-import org.hisp.dhis.patientdatavalue.PatientDataValue;
-import org.hisp.dhis.patientdatavalue.PatientDataValueService;
-import org.hisp.dhis.program.Program;
-import org.hisp.dhis.program.ProgramDataEntryService;
-import org.hisp.dhis.program.ProgramStage;
-import org.hisp.dhis.program.ProgramStageDataElement;
-import org.hisp.dhis.program.ProgramStageInstance;
-import org.hisp.dhis.program.ProgramStageInstanceService;
-import org.hisp.dhis.program.comparator.ProgramStageDataElementSortOrderComparator;
-
-import com.opensymphony.xwork2.Action;
-
-public class ProgramStageCustomDataEntryAction
-    implements Action
-{
-    // -------------------------------------------------------------------------
-    // Dependencies
-    // -------------------------------------------------------------------------
-
-    private ProgramStageInstanceService programStageInstanceService;
-
-    public void setProgramStageInstanceService( ProgramStageInstanceService programStageInstanceService )
-    {
-        this.programStageInstanceService = programStageInstanceService;
-    }
-
-    private PatientDataValueService patientDataValueService;
-
-    public void setPatientDataValueService( PatientDataValueService patientDataValueService )
-    {
-        this.patientDataValueService = patientDataValueService;
-    }
-
-    private SelectedStateManager selectedStateManager;
-
-    public void setSelectedStateManager( SelectedStateManager selectedStateManager )
-    {
-        this.selectedStateManager = selectedStateManager;
-    }
-
-    private ProgramDataEntryService programDataEntryService;
-
-    public void setProgramDataEntryService( ProgramDataEntryService programDataEntryService )
-    {
-        this.programDataEntryService = programDataEntryService;
-    }
-
-    // -------------------------------------------------------------------------
-    // Output
-    // -------------------------------------------------------------------------
-
-    private String customDataEntryFormCode = null;
-
-    public String getCustomDataEntryFormCode()
-    {
-        return this.customDataEntryFormCode;
-    }
-
-    // -------------------------------------------------------------------------
-    // Input / Output
-    // -------------------------------------------------------------------------
-
-    private Integer id;
-
-    public void setId( Integer id )
-    {
-        this.id = id;
-    }
-
-    public Integer getId()
-    {
-        return id;
-    }
-
-    private Integer programStageInstanceId;
-
-    public void setProgramStageInstanceId( Integer programStageInstanceId )
-    {
-        this.programStageInstanceId = programStageInstanceId;
-    }
-
-    private Patient patient;
-
-    public Patient getPatient()
-    {
-        return patient;
-    }
-
-    private Program program;
-
-    public Program getProgram()
-    {
-        return program;
-    }
-
-    private ProgramStage programStage;
-
-    public ProgramStage getProgramStage()
-    {
-        return programStage;
-    }
-
-    private Collection<DataElement> dataElements = new ArrayList<DataElement>();
-
-    public Collection<DataElement> getDataElements()
-    {
-        return dataElements;
-    }
-    
-    private Map<Integer, PatientDataValue> patientDataValueMap;
-
-    public Map<Integer, PatientDataValue> getPatientDataValueMap()
-    {
-        return patientDataValueMap;
-    }
-
-    private OrganisationUnit organisationUnit;
-
-    public OrganisationUnit getOrganisationUnit()
-    {
-        return organisationUnit;
-    }
-
-    private DataEntryForm dataEntryForm;
-
-    public DataEntryForm getDataEntryForm()
-    {
-        return this.dataEntryForm;
-    }
-
-    private I18n i18n;
-
-    public void setI18n( I18n i18n )
-    {
-        this.i18n = i18n;
-    }
-
-    private boolean customDataEntryFormExists;
-
-    public boolean isCustomDataEntryFormExists()
-    {
-        return customDataEntryFormExists;
-    }
-
-    public void setCustomDataEntryFormExists( boolean customDataEntryFormExists )
-    {
-        this.customDataEntryFormExists = customDataEntryFormExists;
-    }
-
-    public ProgramStageInstance programStageInstance;
-
-    public int getProgramStageInstanceId()
-    {
-        return programStageInstance.getId();
-    }
-
-    private List<ProgramStageDataElement> programStageDataElements;
-
-    public List<ProgramStageDataElement> getProgramStageDataElements()
-    {
-        return programStageDataElements;
-    }
-
-    // -------------------------------------------------------------------------
-    // Implementation Action
-    // -------------------------------------------------------------------------
-
-    public String execute()
-        throws Exception
-    {
-        // ---------------------------------------------------------------------
-        // Get Orgunit & Program, ProgramStage
-        // ---------------------------------------------------------------------
-
-        organisationUnit = selectedStateManager.getSelectedOrganisationUnit();
-
-        programStageInstance = programStageInstanceService.getProgramStageInstance( programStageInstanceId );
-
-        programStage = programStageInstance.getProgramStage();
-
-        programStageDataElements = new ArrayList<ProgramStageDataElement>( programStage.getProgramStageDataElements() );
-
-        Collections.sort( programStageDataElements, new ProgramStageDataElementSortOrderComparator() );
-
-        program = programStage.getProgram();
-
-        patient = programStageInstance.getProgramInstance().getPatient();
-
-        selectedStateManager.setSelectedProgramStageInstance( programStageInstance );
-
-        selectedStateManager.setSelectedProgramStageInstance( programStageInstance );
-        
-        // ---------------------------------------------------------------------
-        // Get data values
-        // ---------------------------------------------------------------------
-
-        Collection<PatientDataValue> patientDataValues = patientDataValueService
-            .getPatientDataValues( programStageInstance );
-
-        patientDataValueMap = new HashMap<Integer, PatientDataValue>( patientDataValues.size() );
-
-        for ( PatientDataValue patientDataValue : patientDataValues )
-        {
-            int key = patientDataValue.getDataElement().getId() ;
-            patientDataValueMap.put( key, patientDataValue );
-        }
-
-        DataEntryForm dataEntryForm = programStage.getDataEntryForm();
-
-        if ( dataEntryForm != null )
-        {
-            customDataEntryFormExists = true;
-
-            customDataEntryFormCode = programDataEntryService.prepareDataEntryFormForEntry(
-                dataEntryForm.getHtmlCode(), patientDataValues, "", i18n, programStage, programStageInstance,
-                organisationUnit );
-        }
-
-        return SUCCESS;
-    }
-
-}

=== 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-12-21 09:23:20 +0000
+++ dhis-2/dhis-web/dhis-web-caseentry/src/main/resources/META-INF/dhis/beans.xml	2012-12-26 03:02:05 +0000
@@ -101,6 +101,10 @@
 			ref="org.hisp.dhis.program.ProgramStageInstanceService" />
 		<property name="selectedStateManager"
 			ref="org.hisp.dhis.caseentry.state.SelectedStateManager" />
+		<property name="patientAttributeService"
+			ref="org.hisp.dhis.patient.PatientAttributeService" />
+		<property name="patientAttributeValueService"
+			ref="org.hisp.dhis.patientattributevalue.PatientAttributeValueService" />
 	</bean>
 
 	<bean
@@ -171,20 +175,6 @@
 		<property name="programInstanceService" ref="org.hisp.dhis.program.ProgramInstanceService" />
 	</bean>
 
-	<bean
-		id="org.hisp.dhis.caseentry.action.caseentry.ProgramStageCustomDataEntryAction"
-		class="org.hisp.dhis.caseentry.action.caseentry.ProgramStageCustomDataEntryAction"
-		scope="prototype">
-		<property name="programDataEntryService"
-			ref="org.hisp.dhis.program.ProgramDataEntryService" />
-		<property name="selectedStateManager"
-			ref="org.hisp.dhis.caseentry.state.SelectedStateManager" />
-		<property name="patientDataValueService"
-			ref="org.hisp.dhis.patientdatavalue.PatientDataValueService" />
-		<property name="programStageInstanceService"
-			ref="org.hisp.dhis.program.ProgramStageInstanceService" />
-	</bean>
-
 	<!-- Single-event DataEntry -->
 
 	<bean

=== 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	2012-12-21 13:42:06 +0000
+++ dhis-2/dhis-web/dhis-web-caseentry/src/main/resources/struts.xml	2012-12-26 03:02:05 +0000
@@ -243,7 +243,7 @@
 		</action>
 
 		<action name="viewProgramStageRecords"
-			class="org.hisp.dhis.caseentry.action.caseentry.ProgramStageCustomDataEntryAction">
+			class="org.hisp.dhis.caseentry.action.caseentry.LoadDataEntryAction">
 			<result name="success" type="velocity">/content.vm</result>
 			<param name="page">/dhis-web-caseentry/reportDataEntryForm.vm</param>
 			<param name="javascripts">javascript/entry.js,../dhis-web-commons/javascripts/date.js</param>
@@ -251,7 +251,7 @@
 		</action>
 
 		<action name="loadProgramStageRecords"
-			class="org.hisp.dhis.caseentry.action.caseentry.ProgramStageCustomDataEntryAction">
+			class="org.hisp.dhis.caseentry.action.caseentry.LoadDataEntryAction">
 			<result name="success" type="velocity">/content.vm</result>
 			<param name="page">/dhis-web-caseentry/dataEntryForm.vm</param>
 			<param name="javascripts">../dhis-web-commons/javascripts/date.js</param>

=== modified file 'dhis-2/dhis-web/dhis-web-caseentry/src/main/webapp/dhis-web-caseentry/reportDataEntryForm.vm'
--- dhis-2/dhis-web/dhis-web-caseentry/src/main/webapp/dhis-web-caseentry/reportDataEntryForm.vm	2012-12-17 08:43:52 +0000
+++ dhis-2/dhis-web/dhis-web-caseentry/src/main/webapp/dhis-web-caseentry/reportDataEntryForm.vm	2012-12-26 03:02:05 +0000
@@ -26,6 +26,12 @@
 				<td class='bold text-column' style="vertical-align:top">$i18n.getString('program_stage'): </td>
 				<td style="vertical-align:right">$programStageInstance.programStage.name</td>
 			</tr>
+			#foreach( $attributeName in $calAttributeValueMap.keySet() )
+			<tr>
+				<td class='bold text-column'>$attributeName</td>
+				<td>$calAttributeValueMap.get($attributeName)</td>
+			</tr>
+			#end
 			<tr><td>&nbsp;</td></tr>
 		#end
 		

=== 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	2012-12-21 09:23:20 +0000
+++ dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-patient/src/main/resources/org/hisp/dhis/patient/i18n_module.properties	2012-12-26 03:02:05 +0000
@@ -326,4 +326,5 @@
 display_generate_event_box_after_completed = Display generate event box after completed
 calculated = Calculated
 enrollment_date = Enrollment date
-incident_date = Incident date
\ No newline at end of file
+incident_date = Incident date
+current_date = Current date
\ No newline at end of file