2
* Copyright (c) 2004-2009, University of Oslo
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.
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.
28
package org.hisp.dhis.caseentry.action.report;
30
import java.util.ArrayList;
31
import java.util.Collection;
32
import java.util.HashMap;
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;
43
import com.opensymphony.xwork2.Action;
46
* @author Abyot Asalefew Gizaw
49
public class ViewRecordsAction
52
// -------------------------------------------------------------------------
54
// -------------------------------------------------------------------------
56
private PatientDataValueService patientDataValueService;
58
public void setPatientDataValueService( PatientDataValueService patientDataValueService )
60
this.patientDataValueService = patientDataValueService;
63
private DataElementCategoryService dataElementCategoryService;
65
public void setDataElementCategoryService( DataElementCategoryService dataElementCategoryService )
67
this.dataElementCategoryService = dataElementCategoryService;
70
private ProgramStageInstanceService programStageInstanceService;
72
public void setProgramStageInstanceService( ProgramStageInstanceService programStageInstanceService )
74
this.programStageInstanceService = programStageInstanceService;
77
// -------------------------------------------------------------------------
79
// -------------------------------------------------------------------------
83
public void setId( int id )
88
Collection<PatientDataValue> patientDataValues = new ArrayList<PatientDataValue>();
90
public Collection<PatientDataValue> getPatientDataValues()
92
return patientDataValues;
95
Map<Integer, String> optionValueMap = new HashMap<Integer, String>();
97
public Map<Integer, String> getOptionValueMap()
99
return optionValueMap;
102
private Patient patient;
104
public Patient getPatient()
109
private ProgramStageInstance programStageInstance;
111
public ProgramStageInstance getProgramStageInstance()
113
return programStageInstance;
116
// -------------------------------------------------------------------------
117
// Action implementation
118
// -------------------------------------------------------------------------
120
public String execute()
123
programStageInstance = programStageInstanceService.getProgramStageInstance( id );
125
patient = programStageInstance.getProgramInstance().getPatient();
127
patientDataValues = patientDataValueService.getPatientDataValues( programStageInstance );
129
for ( PatientDataValue patientDataValue : patientDataValues )
131
if ( patientDataValue.getDataElement().getType().equalsIgnoreCase( "string" )
132
&& patientDataValue.getDataElement().isMultiDimensional() )
134
DataElementCategoryOptionCombo optionCombo = dataElementCategoryService
135
.getDataElementCategoryOptionCombo( Integer.parseInt( patientDataValue.getValue() ) );
136
optionValueMap.put( patientDataValue.getDataElement().getId(), optionCombo.getName() );