← Back to team overview

dhis2-devs team mailing list archive

[Branch ~dhis2-devs-core/dhis2/trunk] Rev 6208: (patient) Search and browse beneficiary history.

 

------------------------------------------------------------
revno: 6208
committer: Tran Chau <tran.hispvietnam@xxxxxxxxx>
branch nick: dhis2
timestamp: Thu 2012-03-08 11:56:36 +0700
message:
  (patient) Search and browse beneficiary history.
added:
  dhis-2/dhis-web/dhis-web-caseentry/src/main/java/org/hisp/dhis/caseentry/action/patient/GetPatientHistoryAction.java
  dhis-2/dhis-web/dhis-web-caseentry/src/main/webapp/dhis-web-caseentry/patientHistory.vm
modified:
  dhis-2/dhis-api/src/main/java/org/hisp/dhis/program/ProgramInstanceService.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/program/DefaultProgramInstanceService.java
  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/resources/META-INF/dhis/beans.xml
  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/org/hisp/dhis/caseentry/i18n_module.properties
  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/javascript/commons.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/patientRegistrationList.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/ProgramInstanceService.java'
--- dhis-2/dhis-api/src/main/java/org/hisp/dhis/program/ProgramInstanceService.java	2011-07-15 08:07:54 +0000
+++ dhis-2/dhis-api/src/main/java/org/hisp/dhis/program/ProgramInstanceService.java	2012-03-08 04:56:36 +0000
@@ -28,10 +28,15 @@
 
 import java.util.Date;
 import java.util.Collection;
+import java.util.List;
 
+import org.hisp.dhis.common.Grid;
+import org.hisp.dhis.i18n.I18n;
+import org.hisp.dhis.i18n.I18nFormat;
 import org.hisp.dhis.organisationunit.OrganisationUnit;
 import org.hisp.dhis.patient.Patient;
 
+
 /**
  * @author Abyot Asalefew
  * @version $Id$
@@ -80,4 +85,6 @@
     int countProgramInstances( Program program, OrganisationUnit organisationUnit );
     
     int countProgramInstances( Program program, OrganisationUnit organisationUnit, Date startDate, Date endDate );
+    
+    List<Grid> getProgramInstanceReport( Patient patient, I18n i18n, I18nFormat format );
 }

=== 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	2012-03-07 05:54:02 +0000
+++ dhis-2/dhis-api/src/main/java/org/hisp/dhis/program/ProgramStageInstanceService.java	2012-03-08 04:56:36 +0000
@@ -94,4 +94,6 @@
     Grid getTabularReport( ProgramStage programStage, List<DataElement> dataElements, Map<Integer,String> searchingKeys, Collection<Integer> orgunitIds, Date startDate, Date endDate, I18nFormat format, I18n i18n );
 
     int countProgramStageInstances( ProgramStage programStage, Map<Integer,String> searchingKeys, Collection<Integer> orgunitIds, Date startDate, Date endDate );
+    
+    Grid getProgramInstanceReport( ProgramInstance programInstance, I18nFormat format, I18n i18n );
 }

=== modified file 'dhis-2/dhis-services/dhis-service-patient/src/main/java/org/hisp/dhis/program/DefaultProgramInstanceService.java'
--- dhis-2/dhis-services/dhis-service-patient/src/main/java/org/hisp/dhis/program/DefaultProgramInstanceService.java	2011-07-15 08:07:54 +0000
+++ dhis-2/dhis-services/dhis-service-patient/src/main/java/org/hisp/dhis/program/DefaultProgramInstanceService.java	2012-03-08 04:56:36 +0000
@@ -26,11 +26,23 @@
  */
 package org.hisp.dhis.program;
 
+import java.util.ArrayList;
+import java.util.Collection;
 import java.util.Date;
-import java.util.Collection;
+import java.util.List;
 
+import org.hisp.dhis.common.Grid;
+import org.hisp.dhis.common.GridHeader;
+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.PatientIdentifier;
+import org.hisp.dhis.patient.PatientIdentifierType;
+import org.hisp.dhis.patientattributevalue.PatientAttributeValue;
+import org.hisp.dhis.patientattributevalue.PatientAttributeValueService;
+import org.hisp.dhis.system.grid.ListGrid;
 import org.springframework.transaction.annotation.Transactional;
 
 /**
@@ -52,10 +64,25 @@
         this.programInstanceStore = programInstanceStore;
     }
 
+    private PatientAttributeValueService patientAttributeValueService;
+
+    public void setPatientAttributeValueService( PatientAttributeValueService patientAttributeValueService )
+    {
+        this.patientAttributeValueService = patientAttributeValueService;
+    }
+
+    private ProgramStageInstanceService programStageInstanceService;
+
+    public void setProgramStageInstanceService( ProgramStageInstanceService programStageInstanceService )
+    {
+        this.programStageInstanceService = programStageInstanceService;
+    }
+
     // -------------------------------------------------------------------------
     // Implementation methods
     // -------------------------------------------------------------------------
 
+ 
     public int addProgramInstance( ProgramInstance programInstance )
     {
         return programInstanceStore.save( programInstance );
@@ -158,4 +185,96 @@
     {
         return programInstanceStore.count( program, organisationUnit, startDate, endDate );
     }
+
+    public List<Grid> getProgramInstanceReport( Patient patient, I18n i18n, I18nFormat format )
+    {
+        List<Grid> grids = new ArrayList<Grid>();
+
+        // ---------------------------------------------------------------------
+        // Get registered personal patient data
+        // ---------------------------------------------------------------------
+
+        Grid attrGrid = new ListGrid();
+
+        attrGrid.setTitle( patient.getFullName() );
+        attrGrid.setSubtitle( "" );
+
+        attrGrid.addHeader( new GridHeader( i18n.getString( "name" ), false, false ) );
+        attrGrid.addHeader( new GridHeader( i18n.getString( "value" ), false, false ) );
+
+        Collection<PatientAttribute> patientAttributes = patient.getAttributes();
+
+        // ---------------------------------------------------------------------
+        // Add fixed attribues
+        // ---------------------------------------------------------------------
+
+        attrGrid.addRow();
+        attrGrid.addValue( i18n.getString( "date_of_birth" ) );
+        attrGrid.addValue( format.formatDate( patient.getBirthDate() ) );
+
+        attrGrid.addRow();
+        attrGrid.addValue( i18n.getString( "age" ) );
+        attrGrid.addValue( patient.getAge() );
+        
+        attrGrid.addRow();
+        attrGrid.addValue( i18n.getString( "dob_type" ) );
+        attrGrid.addValue( i18n.getString( patient.getDobType() + "" ) );
+        
+        attrGrid.addRow();
+        attrGrid.addValue( i18n.getString( "blood_group" ) );
+        attrGrid.addValue( i18n.getString( patient.getBloodGroup() ) );
+        
+        // ---------------------------------------------------------------------
+        // Add dynamic attribues
+        // ---------------------------------------------------------------------
+
+        for ( PatientAttribute patientAttribute : patientAttributes )
+        {
+            attrGrid.addRow();
+            attrGrid.addValue( patientAttribute.getName() );
+            PatientAttributeValue attributeValue = patientAttributeValueService.getPatientAttributeValue( patient,
+                patientAttribute );
+            attrGrid.addValue( (attributeValue == null) ? PatientAttributeValue.UNKNOWN : attributeValue.getValue() );
+        }
+
+        // ---------------------------------------------------------------------
+        // Add identifier
+        // ---------------------------------------------------------------------
+
+        for ( PatientIdentifier identifier : patient.getIdentifiers() )
+        {
+            attrGrid.addRow();
+            
+            PatientIdentifierType idType = identifier.getIdentifierType();
+            if ( idType != null )
+            {
+                attrGrid.addValue( idType.getName() );
+                attrGrid.addValue( identifier.getIdentifier() );
+            }
+            else
+            {
+                attrGrid.addValue( i18n.getString( "system_identifier" ) );
+                attrGrid.addValue( identifier.getIdentifier() );
+            }
+        }
+        
+        grids.add( attrGrid );
+        
+        // ---------------------------------------------------------------------
+        // Get all program data registered
+        // ---------------------------------------------------------------------
+
+        Collection<ProgramInstance> programInstances = getProgramInstances( patient );
+
+        if ( programInstances.size() > 0 )
+        {
+            for ( ProgramInstance programInstance : programInstances )
+            {
+                Grid programGrid = programStageInstanceService.getProgramInstanceReport( programInstance, format, i18n );
+                grids.add( programGrid );
+            }
+        }
+
+        return grids;
+    }
 }

=== 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	2012-03-07 05:54:02 +0000
+++ dhis-2/dhis-services/dhis-service-patient/src/main/java/org/hisp/dhis/program/DefaultProgramStageInstanceService.java	2012-03-08 04:56:36 +0000
@@ -26,12 +26,16 @@
  */
 package org.hisp.dhis.program;
 
+import java.util.ArrayList;
+import java.util.Arrays;
 import java.util.Calendar;
 import java.util.Collection;
 import java.util.Date;
 import java.util.HashMap;
+import java.util.HashSet;
 import java.util.List;
 import java.util.Map;
+import java.util.Set;
 
 import org.hisp.dhis.common.Grid;
 import org.hisp.dhis.common.GridHeader;
@@ -71,6 +75,13 @@
         this.patientDataValueService = patientDataValueService;
     }
 
+    private ProgramStageDataElementService programStageDataElementService;
+
+    public void setProgramStageDataElementService( ProgramStageDataElementService programStageDataElementService )
+    {
+        this.programStageDataElementService = programStageDataElementService;
+    }
+
     // -------------------------------------------------------------------------
     // Implementation methods
     // -------------------------------------------------------------------------
@@ -186,11 +197,12 @@
     }
 
     public List<ProgramStageInstance> searchProgramStageInstances( ProgramStage programStage,
-        Map<Integer, String> searchingKeys, Collection<Integer> orgunitIds, Date startDate, Date endDate, int min, int max )
+        Map<Integer, String> searchingKeys, Collection<Integer> orgunitIds, Date startDate, Date endDate, int min,
+        int max )
     {
         return programStageInstanceStore.get( programStage, searchingKeys, orgunitIds, startDate, endDate, min, max );
     }
-    
+
     public List<ProgramStageInstance> searchProgramStageInstances( ProgramStage programStage,
         Map<Integer, String> searchingKeys, Collection<Integer> orgunitIds, Date startDate, Date endDate )
     {
@@ -198,20 +210,20 @@
     }
 
     public Grid getTabularReport( ProgramStage programStage, List<DataElement> dataElements,
-        Map<Integer, String> searchingKeys, Collection<Integer> orgunitIds, Date startDate, Date endDate, int min, int max,
+        Map<Integer, String> searchingKeys, Collection<Integer> orgunitIds, Date startDate, Date endDate, int min,
+        int max, I18nFormat format, I18n i18n )
+    {
+        List<ProgramStageInstance> programStageInstances = searchProgramStageInstances( programStage, searchingKeys,
+            orgunitIds, startDate, endDate, min, max );
+
+        return createTabularGrid( programStage, programStageInstances, dataElements, startDate, endDate, format, i18n );
+    }
+
+    public Grid getTabularReport( ProgramStage programStage, List<DataElement> dataElements,
+        Map<Integer, String> searchingKeys, Collection<Integer> orgunitIds, Date startDate, Date endDate,
         I18nFormat format, I18n i18n )
     {
         List<ProgramStageInstance> programStageInstances = searchProgramStageInstances( programStage, searchingKeys,
-            orgunitIds, startDate, endDate, min, max );
-
-        return createTabularGrid( programStage, programStageInstances, dataElements, startDate, endDate, format, i18n );
-    }
-
-    public Grid getTabularReport( ProgramStage programStage, List<DataElement> dataElements,
-        Map<Integer, String> searchingKeys, Collection<Integer> orgunitIds, Date startDate, Date endDate, I18nFormat format,
-        I18n i18n )
-    {
-        List<ProgramStageInstance> programStageInstances = searchProgramStageInstances( programStage, searchingKeys,
             orgunitIds, startDate, endDate );
 
         return createTabularGrid( programStage, programStageInstances, dataElements, startDate, endDate, format, i18n );
@@ -224,6 +236,84 @@
         return programStageInstanceStore.count( programStage, searchingKeys, orgunitIds, startDate, endDate );
     }
 
+    public Grid getProgramInstanceReport( ProgramInstance programInstance, I18nFormat format, I18n i18n )
+    {
+        Grid grid = new ListGrid();
+
+        // ---------------------------------------------------------------------
+        // Title
+        // ---------------------------------------------------------------------
+
+        grid.setTitle( programInstance.getProgram().getName() );
+        grid.setSubtitle( i18n.getString( "date_of_enrollment" ) + ": " + programInstance.getEnrollmentDate() + " - "
+            + i18n.getString( "date_of_incident" ) + ": " + programInstance.getDateOfIncident() );
+
+        // ---------------------------------------------------------------------
+        // Headers && Get dataelements belongs to programs
+        // ---------------------------------------------------------------------
+
+        Set<ProgramStage> programStages = programInstance.getProgram().getProgramStages();
+        Set<DataElement> dataElements = new HashSet<DataElement>();
+
+        grid.addHeader( new GridHeader( "", false, false ) );
+        for ( ProgramStage programStage : programStages )
+        {
+            grid.addHeader( new GridHeader( programStage.getName(), false, false ) );
+            dataElements.addAll( programStageDataElementService.getListDataElement( programStage ) );
+        }
+
+        // ---------------------------------------------------------------------
+        // First Column
+        // ---------------------------------------------------------------------
+       
+        List<Object> deValues = new ArrayList<Object>();
+        Map<Integer, Integer> mapDataElements = new HashMap<Integer, Integer>();
+
+        int columnIndex = 0;
+        for ( DataElement dataElement : dataElements )
+        {
+            grid.addRow();
+            deValues.add( dataElement.getName() );
+
+            mapDataElements.put( dataElement.getId(), columnIndex );
+            columnIndex++;
+        }
+      
+        grid.addColumn( deValues );
+
+        // ---------------------------------------------------------------------
+        // Values
+        // ---------------------------------------------------------------------
+
+        Collection<ProgramStageInstance> programStageInstances = programInstance.getProgramStageInstances();
+
+        for ( ProgramStageInstance programStageInstance : programStageInstances )
+        {
+            Object[] columnValues = new Object[dataElements.size()];
+           
+            Collection<PatientDataValue> patientDataValues = patientDataValueService
+                .getPatientDataValues( programStageInstance );
+
+            for ( PatientDataValue patientDataValue : patientDataValues )
+            {
+                DataElement dataElement = patientDataValue.getDataElement();
+
+                String value = patientDataValue.getValue();
+
+                if ( dataElement.getType().equals( DataElement.VALUE_TYPE_BOOL ) )
+                {
+                    value = i18n.getString( patientDataValue.getValue() );
+                }
+
+                columnValues[mapDataElements.get( dataElement.getId() )] = value;
+            }
+            
+            grid.addColumn( Arrays.asList( columnValues ) );
+        }
+
+        return grid;
+    }
+
     // -------------------------------------------------------------------------
     // Supportive methods
     // -------------------------------------------------------------------------
@@ -241,7 +331,7 @@
             // Create a grid
             // ---------------------------------------------------------------------
 
-            grid.setTitle( program.getName() );
+            grid.setTitle( program.getName() + " - " + programStage.getName() );
             grid.setSubtitle( i18n.getString( "from" ) + " " + format.formatDate( startDate ) + " "
                 + i18n.getString( "to" ) + " " + format.formatDate( endDate ) );
 

=== 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	2012-03-07 06:26:09 +0000
+++ dhis-2/dhis-services/dhis-service-patient/src/main/resources/META-INF/dhis/beans.xml	2012-03-08 04:56:36 +0000
@@ -210,10 +210,14 @@
 			ref="org.hisp.dhis.program.ProgramStageInstanceStore" />
 		<property name="patientDataValueService"
 			ref="org.hisp.dhis.patientdatavalue.PatientDataValueService" />
+		<property name="programStageDataElementService"
+			ref="org.hisp.dhis.program.ProgramStageDataElementService" />
 	</bean>
 
 	<bean id="org.hisp.dhis.program.ProgramInstanceService" class="org.hisp.dhis.program.DefaultProgramInstanceService">
 		<property name="programInstanceStore" ref="org.hisp.dhis.program.ProgramInstanceStore" />
+		<property name="patientAttributeValueService" ref="org.hisp.dhis.patientattributevalue.PatientAttributeValueService" />
+		<property name="programStageInstanceService" ref="org.hisp.dhis.program.ProgramStageInstanceService" />
 	</bean>
 
 	<bean id="org.hisp.dhis.program.ProgramStageService" class="org.hisp.dhis.program.DefaultProgramStageService">

=== added file 'dhis-2/dhis-web/dhis-web-caseentry/src/main/java/org/hisp/dhis/caseentry/action/patient/GetPatientHistoryAction.java'
--- dhis-2/dhis-web/dhis-web-caseentry/src/main/java/org/hisp/dhis/caseentry/action/patient/GetPatientHistoryAction.java	1970-01-01 00:00:00 +0000
+++ dhis-2/dhis-web/dhis-web-caseentry/src/main/java/org/hisp/dhis/caseentry/action/patient/GetPatientHistoryAction.java	2012-03-08 04:56:36 +0000
@@ -0,0 +1,133 @@
+/*
+ * Copyright (c) 2004-2012, 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.patient;
+
+import java.util.ArrayList;
+import java.util.List;
+
+import org.hisp.dhis.common.Grid;
+import org.hisp.dhis.i18n.I18n;
+import org.hisp.dhis.i18n.I18nFormat;
+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 com.opensymphony.xwork2.Action;
+
+/**
+ * @author Chau Thu Tran
+ * 
+ * @version $GetPatientHistoryAction.java Mar 7, 2012 3:11:32 PM$
+ */
+public class GetPatientHistoryAction
+    implements Action
+{
+    // -------------------------------------------------------------------------
+    // Implementation Action
+    // -------------------------------------------------------------------------
+
+    private PatientService patientService;
+
+    public void setPatientService( PatientService patientService )
+    {
+        this.patientService = patientService;
+    }
+
+    private ProgramInstanceService programInstanceService;
+
+    public void setProgramInstanceService( ProgramInstanceService programInstanceService )
+    {
+        this.programInstanceService = programInstanceService;
+    }
+
+    private I18n i18n;
+
+    public void setI18n( I18n i18n )
+    {
+        this.i18n = i18n;
+    }
+
+    private I18nFormat format;
+
+    public void setFormat( I18nFormat format )
+    {
+        this.format = format;
+    }
+
+    // -------------------------------------------------------------------------
+    // Getters && Setters
+    // -------------------------------------------------------------------------
+
+    private Integer patientId;
+
+    public void setPatientId( Integer patientId )
+    {
+        this.patientId = patientId;
+    }
+
+    private String type;
+
+    public void setType( String type )
+    {
+        this.type = type;
+    }
+
+    private List<Grid> grids;
+
+    public List<Grid> getGrids()
+    {
+        return grids;
+    }
+
+    private Patient patient;
+
+    public Patient getPatient()
+    {
+        return patient;
+    }
+
+    // -------------------------------------------------------------------------
+    // Implementation Action
+    // -------------------------------------------------------------------------
+
+    public String execute()
+        throws Exception
+    {
+        patient = patientService.getPatient( patientId );
+
+        grids = programInstanceService.getProgramInstanceReport( patient, i18n, format );
+
+        if ( type == null )
+        {
+            return SUCCESS;
+        }
+
+        return type;
+    }
+}

=== 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-03-07 05:54:02 +0000
+++ dhis-2/dhis-web/dhis-web-caseentry/src/main/resources/META-INF/dhis/beans.xml	2012-03-08 04:56:36 +0000
@@ -600,6 +600,13 @@
 		<property name="patientService" ref="org.hisp.dhis.patient.PatientService" />
 	</bean>
 
+	<bean id="org.hisp.dhis.caseentry.action.patient.GetPatientHistoryAction"
+		class="org.hisp.dhis.caseentry.action.patient.GetPatientHistoryAction"
+		scope="prototype">
+		<property name="patientService" ref="org.hisp.dhis.patient.PatientService" />
+		<property name="programInstanceService" ref="org.hisp.dhis.program.ProgramInstanceService" />
+	</bean>
+
 	<!-- Patient-Program Enrollment -->
 
 	<bean

=== 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	2012-03-07 05:54:02 +0000
+++ dhis-2/dhis-web/dhis-web-caseentry/src/main/resources/org/hisp/dhis/caseentry/i18n_module.properties	2012-03-08 04:56:36 +0000
@@ -268,3 +268,7 @@
 syntax_error_in_search_value = Syntax error is in search value
 remove_selected_data_elements = Please remove selected data elements to select other program stage. Do you want to remove them ?
 add_selected = Add selected
+program_enrollment = Program enrollment
+date_of_enrollment=Date of enrollment
+date_of_incident=Date of incident
+patient_history = Beneficiary history
\ No newline at end of file

=== 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-03-07 02:40:08 +0000
+++ dhis-2/dhis-web/dhis-web-caseentry/src/main/resources/struts.xml	2012-03-08 04:56:36 +0000
@@ -99,6 +99,42 @@
 				/dhis-web-commons/ajax/jsonResponseSuccess.vm</result>
 		</action>
 
+		<action name="anonymousRegistration"
+			class="org.hisp.dhis.caseentry.action.caseentry.LoadAnonymousProgramsAction">
+			<interceptor-ref name="organisationUnitTreeStack" />
+			<result name="success" type="velocity">/main.vm</result>
+			<param name="page">/dhis-web-caseentry/anonymousRegistration.vm</param>
+			<param name="menu">/dhis-web-caseentry/dataEntryMenu.vm</param>
+			<param name="javascripts">../dhis-web-commons/ouwt/ouwt.js
+				,javascript/commons.js
+				,javascript/anonymousRegistration.js
+				,javascript/entry.js
+				,../dhis-web-commons/javascripts/date.js</param>
+			<param name="stylesheets">style/dataEntry.css,../dhis-web-caseentry/style/patient.css</param>
+		</action>
+		
+		<action name="createAnonymousEncounter"
+			class="org.hisp.dhis.caseentry.action.caseentry.CreateAnonymousEncounterAction">
+			<result name="success" type="velocity-json">
+				/dhis-web-commons/ajax/jsonResponseSuccess.vm</result>
+			<result name="input" type="velocity-json">
+				/dhis-web-commons/ajax/jsonResponseInput.vm</result>
+		</action>
+		
+		<action name="loadAnonymousPrograms"
+			class="org.hisp.dhis.caseentry.action.caseentry.LoadAnonymousProgramsAction">
+			<result name="success" type="velocity-json">
+				/dhis-web-caseentry/jsonProgramInstances.vm</result>
+		</action>
+		
+		<action name="removeCurrentEncounter"
+			class="org.hisp.dhis.caseentry.action.caseentry.RemoveCurrentEncounterAction">
+			<result name="success" type="velocity-json">
+				/dhis-web-commons/ajax/jsonResponseSuccess.vm</result>
+			<result name="error" type="velocity-json">
+				/dhis-web-commons/ajax/jsonResponseError.vm</result>
+		</action>
+		
 		<!-- save value -->
 
 		<action name="saveValue"
@@ -454,43 +490,15 @@
 			<result name="success" type="velocity">/content.vm</result>
 			<param name="page">/dhis-web-caseentry/resultSearchPatients.vm</param>
 		</action>
-
-		<action name="anonymousRegistration"
-			class="org.hisp.dhis.caseentry.action.caseentry.LoadAnonymousProgramsAction">
-			<interceptor-ref name="organisationUnitTreeStack" />
-			<result name="success" type="velocity">/main.vm</result>
-			<param name="page">/dhis-web-caseentry/anonymousRegistration.vm</param>
-			<param name="menu">/dhis-web-caseentry/dataEntryMenu.vm</param>
-			<param name="javascripts">../dhis-web-commons/ouwt/ouwt.js
-				,javascript/commons.js
-				,javascript/anonymousRegistration.js
-				,javascript/entry.js
-				,../dhis-web-commons/javascripts/date.js</param>
-			<param name="stylesheets">style/dataEntry.css,../dhis-web-caseentry/style/patient.css</param>
-		</action>
-		
-		<action name="createAnonymousEncounter"
-			class="org.hisp.dhis.caseentry.action.caseentry.CreateAnonymousEncounterAction">
-			<result name="success" type="velocity-json">
-				/dhis-web-commons/ajax/jsonResponseSuccess.vm</result>
-			<result name="input" type="velocity-json">
-				/dhis-web-commons/ajax/jsonResponseInput.vm</result>
-		</action>
-		
-		<action name="loadAnonymousPrograms"
-			class="org.hisp.dhis.caseentry.action.caseentry.LoadAnonymousProgramsAction">
-			<result name="success" type="velocity-json">
-				/dhis-web-caseentry/jsonProgramInstances.vm</result>
-		</action>
-		
-		<action name="removeCurrentEncounter"
-			class="org.hisp.dhis.caseentry.action.caseentry.RemoveCurrentEncounterAction">
-			<result name="success" type="velocity-json">
-				/dhis-web-commons/ajax/jsonResponseSuccess.vm</result>
-			<result name="error" type="velocity-json">
-				/dhis-web-commons/ajax/jsonResponseError.vm</result>
-		</action>
  
+   		<action name="getPatientHistory"
+			class="org.hisp.dhis.caseentry.action.patient.GetPatientHistoryAction">
+			<result name="success" type="velocity">/content.vm</result>
+			<result name="xls" type="gridXlsResult" />
+      		<result name="pdf" type="gridPdfResult" />
+			<param name="page">/dhis-web-caseentry/patientHistory.vm</param>
+		</action>
+		
 		<!-- Patient-Program Enrollment -->
 
 		<action name="showProgramEnrollmentForm"

=== 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	2012-03-05 07:32:05 +0000
+++ dhis-2/dhis-web/dhis-web-caseentry/src/main/webapp/dhis-web-caseentry/javascript/commons.js	2012-03-08 04:56:36 +0000
@@ -112,6 +112,31 @@
 			modal:false,
 			overlay:{background:'#000000', opacity:0.1},
 			width: 450,
+			height: 300
+		});
+}
+
+function showPatientHistory( patientId )
+{
+	$('#detailsHistory').load("getPatientHistory.action", 
+		{
+			patientId:patientId
+		}
+		, function( ){
+			
+		}).dialog({
+			title: i18n_patient_history,
+			maximize: true, 
+			closable: true,
+			modal:false,
+			overlay:{background:'#000000', opacity:0.1},
+			width: 800,
 			height: 400
-		});;
+		});
+}
+
+function exportPatientHistory( patientId, type )
+{
+	var url = "getPatientHistory.action?patientId=" + patientId + "&type=" + type;
+	window.location.href = url;
 }

=== 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	2012-03-05 07:32:05 +0000
+++ dhis-2/dhis-web/dhis-web-caseentry/src/main/webapp/dhis-web-caseentry/javascript/patient.js	2012-03-08 04:56:36 +0000
@@ -932,3 +932,4 @@
 	showById('dateOfIncidentTR');
 	showById('enrollBtn');
 }
+

=== added file 'dhis-2/dhis-web/dhis-web-caseentry/src/main/webapp/dhis-web-caseentry/patientHistory.vm'
--- dhis-2/dhis-web/dhis-web-caseentry/src/main/webapp/dhis-web-caseentry/patientHistory.vm	1970-01-01 00:00:00 +0000
+++ dhis-2/dhis-web/dhis-web-caseentry/src/main/webapp/dhis-web-caseentry/patientHistory.vm	2012-03-08 04:56:36 +0000
@@ -0,0 +1,43 @@
+
+<h3>$i18n.getString('patient_history')</h3>
+
+<div style="margin-bottom:15px">
+<input type="button" value="$i18n.getString( 'get_report_as_xls' )" onclick="exportPatientHistory( '$patient.id', 'xls' )" style="width:140px">
+<input type="button" value="$i18n.getString( 'get_report_as_pdf' )" onclick="exportPatientHistory( '$patient.id', 'pdf' )" style="width:140px">
+</div>
+
+#foreach( $grid in $grids )
+	<div class="formSection" style="margin-bottom:30px">
+		<div class="cent">
+			<h3>$!encoder.htmlEncode( $grid.title )</h3>
+			<h4>$!encoder.htmlEncode( $grid.subtitle )</h4>
+		</div>
+		<table class="listTable">
+			<thead>
+				<tr>
+				#foreach( $header in $grid.getVisibleHeaders() )
+					<th #if( $header.meta )style="text-align:left"#end>$!encoder.htmlEncode( $header.name )</th>
+				#end
+				</tr>
+			</thead>
+
+			<tbody>  
+				#set( $mark = false )
+				#foreach( $row in $grid.getVisibleRows() )
+				<tr #alternate($mark)>
+					#set( $nameCol='false' )
+					#foreach( $col in $row )
+						#set( $index = ( $velocityCount - 1 ) )
+						#if( $grid.getVisibleHeaders().get( $index ).meta )
+							<td >$!encoder.htmlEncode( $col )</td>
+						#else 
+							<td>$!col</td>
+						#end
+					#end
+				</tr>
+				#end
+				#set( $mark = !$mark)
+			</tbody>
+		</table>
+	</div>
+#end

=== modified file 'dhis-2/dhis-web/dhis-web-caseentry/src/main/webapp/dhis-web-caseentry/patientRegistrationList.vm'
--- dhis-2/dhis-web/dhis-web-caseentry/src/main/webapp/dhis-web-caseentry/patientRegistrationList.vm	2012-02-01 09:10:08 +0000
+++ dhis-2/dhis-web/dhis-web-caseentry/src/main/webapp/dhis-web-caseentry/patientRegistrationList.vm	2012-03-08 04:56:36 +0000
@@ -1,4 +1,3 @@
-
 <table>
 	
 	<tr>
@@ -37,7 +36,7 @@
 		  #if($mapPatientOrgunit.size()!=0)
           <col/>
 		  #end
-          <col width="200"/>    
+          <col width="220"/>    
 		  
 		  <thead>
 			<tr>
@@ -98,6 +97,7 @@
 				  <a href="javascript:setFieldValue( 'isShowPatientList', false ); showRelationshipList('$patient.id')" title='$i18n.getString( "manage_relationship" )'><img src="../images/relationship.png" alt='$i18n.getString( "manage_relationship" )'></a>
 				  <a href="javascript:showAddRelationshipPatient( '$patient.id', true )" title='$i18n.getString( "add_dependent" )'><img src="../images/add.png" alt='$i18n.getString( "add_dependent" )'></a>
 				  <a href="javascript:removePatient( '$patient.id', '$encoder.jsEncode( $patient.getFullName() )' )" title='$i18n.getString( "remove" )'><img src="../images/delete.png" alt='$i18n.getString( "remove" )'></a>
+				  <a href="javascript:showPatientHistory( '$patient.id' )" title='$i18n.getString( "show_details" )'><img src="../images/edit_sections.png" alt='$i18n.getString( "show_details" )'></a>
 				  <a href="javascript:showPatientDetails( '$patient.id' )" title='$i18n.getString( "show_details" )'><img src="../images/information.png" alt='$i18n.getString( "show_details" )'></a>
 				</td>
 				
@@ -120,12 +120,14 @@
   </tr>
 </table>
 
-<div id="detailsInfo">
-</div>
+<div id="detailsInfo"></div>
+<div id="detailsHistory"></div>
+
 #end
 <script type="text/javascript">
 	jQuery(document).ready(function(){	
 		tableSorter( 'patientList' );
 	});
 	var i18n_patient_details = '$encoder.jsEscape( $i18n.getString( "patient_details" ) , "'" )';
+	var i18n_patient_history = '$encoder.jsEscape( $i18n.getString( "patient_history" ) , "'" )';
 </script>