~dhis2-devs-core/dhis2/dhis2-patient-tz

« back to all changes in this revision

Viewing changes to local/tz/dhis-web-caseentry-tz/src/main/java/org/hisp/dhis/caseentry/action/report/ViewRecordsAction.java

  • Committer: John Francis Mukulu
  • Date: 2011-08-09 06:36:18 UTC
  • mfrom: (4244.1.21 dhis2)
  • Revision ID: john.f.mukulu@gmail.com-20110809063618-wad1pcc9fd1mnc6k
[merge]

Show diffs side-by-side

added added

removed removed

Lines of Context:
1
 
/*
2
 
 * Copyright (c) 2004-2009, University of Oslo
3
 
 * All rights reserved.
4
 
 *
5
 
 * Redistribution and use in source and binary forms, with or without
6
 
 * modification, are permitted provided that the following conditions are met:
7
 
 * * Redistributions of source code must retain the above copyright notice, this
8
 
 *   list of conditions and the following disclaimer.
9
 
 * * Redistributions in binary form must reproduce the above copyright notice,
10
 
 *   this list of conditions and the following disclaimer in the documentation
11
 
 *   and/or other materials provided with the distribution.
12
 
 * * Neither the name of the HISP project nor the names of its contributors may
13
 
 *   be used to endorse or promote products derived from this software without
14
 
 *   specific prior written permission.
15
 
 *
16
 
 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
17
 
 * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
18
 
 * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
19
 
 * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR
20
 
 * ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
21
 
 * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
22
 
 * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON
23
 
 * ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
24
 
 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
25
 
 * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
26
 
 */
27
 
 
28
 
package org.hisp.dhis.caseentry.action.report;
29
 
 
30
 
import java.util.ArrayList;
31
 
import java.util.Collection;
32
 
import java.util.HashMap;
33
 
import java.util.Map;
34
 
 
35
 
import org.hisp.dhis.dataelement.DataElementCategoryOptionCombo;
36
 
import org.hisp.dhis.dataelement.DataElementCategoryService;
37
 
import org.hisp.dhis.patient.Patient;
38
 
import org.hisp.dhis.patientdatavalue.PatientDataValue;
39
 
import org.hisp.dhis.patientdatavalue.PatientDataValueService;
40
 
import org.hisp.dhis.program.ProgramStageInstance;
41
 
import org.hisp.dhis.program.ProgramStageInstanceService;
42
 
 
43
 
import com.opensymphony.xwork2.Action;
44
 
 
45
 
/**
46
 
 * @author Abyot Asalefew Gizaw
47
 
 * @version $Id$
48
 
 */
49
 
public class ViewRecordsAction
50
 
    implements Action
51
 
{
52
 
    // -------------------------------------------------------------------------
53
 
    // Dependencies
54
 
    // -------------------------------------------------------------------------
55
 
 
56
 
    private PatientDataValueService patientDataValueService;
57
 
 
58
 
    public void setPatientDataValueService( PatientDataValueService patientDataValueService )
59
 
    {
60
 
        this.patientDataValueService = patientDataValueService;
61
 
    }
62
 
 
63
 
    private DataElementCategoryService dataElementCategoryService;
64
 
 
65
 
    public void setDataElementCategoryService( DataElementCategoryService dataElementCategoryService )
66
 
    {
67
 
        this.dataElementCategoryService = dataElementCategoryService;
68
 
    }
69
 
 
70
 
    private ProgramStageInstanceService programStageInstanceService;
71
 
 
72
 
    public void setProgramStageInstanceService( ProgramStageInstanceService programStageInstanceService )
73
 
    {
74
 
        this.programStageInstanceService = programStageInstanceService;
75
 
    }
76
 
 
77
 
    // -------------------------------------------------------------------------
78
 
    // Input/output
79
 
    // -------------------------------------------------------------------------
80
 
 
81
 
    private int id;
82
 
 
83
 
    public void setId( int id )
84
 
    {
85
 
        this.id = id;
86
 
    }
87
 
 
88
 
    Collection<PatientDataValue> patientDataValues = new ArrayList<PatientDataValue>();
89
 
 
90
 
    public Collection<PatientDataValue> getPatientDataValues()
91
 
    {
92
 
        return patientDataValues;
93
 
    }
94
 
 
95
 
    Map<Integer, String> optionValueMap = new HashMap<Integer, String>();
96
 
 
97
 
    public Map<Integer, String> getOptionValueMap()
98
 
    {
99
 
        return optionValueMap;
100
 
    }
101
 
 
102
 
    private Patient patient;
103
 
 
104
 
    public Patient getPatient()
105
 
    {
106
 
        return patient;
107
 
    }
108
 
 
109
 
    private ProgramStageInstance programStageInstance;
110
 
 
111
 
    public ProgramStageInstance getProgramStageInstance()
112
 
    {
113
 
        return programStageInstance;
114
 
    }
115
 
 
116
 
    // -------------------------------------------------------------------------
117
 
    // Action implementation
118
 
    // -------------------------------------------------------------------------
119
 
 
120
 
    public String execute()
121
 
        throws Exception
122
 
    {
123
 
        programStageInstance = programStageInstanceService.getProgramStageInstance( id );
124
 
 
125
 
        patient = programStageInstance.getProgramInstance().getPatient();
126
 
 
127
 
        patientDataValues = patientDataValueService.getPatientDataValues( programStageInstance );
128
 
 
129
 
        for ( PatientDataValue patientDataValue : patientDataValues )
130
 
        {
131
 
            if ( patientDataValue.getDataElement().getType().equalsIgnoreCase( "string" )
132
 
                && patientDataValue.getDataElement().isMultiDimensional() )
133
 
            {
134
 
                DataElementCategoryOptionCombo optionCombo = dataElementCategoryService
135
 
                    .getDataElementCategoryOptionCombo( Integer.parseInt( patientDataValue.getValue() ) );
136
 
                optionValueMap.put( patientDataValue.getDataElement().getId(), optionCombo.getName() );
137
 
            }
138
 
        }
139
 
 
140
 
        return SUCCESS;
141
 
    }
142
 
}