2
* Copyright (c) 2004-2008, 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.
27
package org.hisp.dhis.integration.rims.api.tables;
30
import java.sql.SQLException;
32
import org.hisp.dhis.integration.rims.api.RIMS_Mapping_DataElement;
35
* @author Leif Arne Storset
38
public class RIMS_Surveillance_Dtl
41
public String getDescription()
43
return "Disease surveillance";
45
public boolean isData( RIMS_PHC phc, int month, int year,
46
RIMS_Mapping_DataElement mappingDataElement ) throws SQLException
48
String disease_code = mappingDataElement.getDisease_code();
51
query = "SELECT * FROM " + getTableName()
52
+ " WHERE phc_code LIKE '" + phc.getCode() + "' AND mnth = " + month
53
+ " AND yr = " + year + " AND disease_code LIKE '" + disease_code
56
return existingData( query, null );
59
public int insertData( RIMS_PHC rimsOrgUnit,
60
int month, int year, RIMS_Mapping_DataElement mappingDataElement,
61
String value ) throws SQLException
63
String query = "INSERT INTO " + getTableName()
64
+ " (disease_code," + "phc_code,district_code,mnth,yr,state_code,"
65
+ mappingDataElement.getRimsColumn()
66
+ ",created_by,created_date) VALUES (?,?,?,?,?,?,?,?,?)";
67
Date curDate = new Date( new java.util.Date().getTime() );
69
numberResult = Integer.parseInt( value );
70
if ( numberResult != -1 || numberResult != 0 )
74
mappingDataElement.getDisease_code(),
75
rimsOrgUnit.getPhc_code(),
76
rimsOrgUnit.getDistrict_code(),
79
rimsOrgUnit.getState_code(),
85
return executeUpdate( query, params );
90
public int updateData( RIMS_PHC rimsOrgUnit,
91
int month, int year, RIMS_Mapping_DataElement mappingDataElement,
92
String value ) throws SQLException
94
String phc_code = rimsOrgUnit.getPhc_code();
95
String query = "UPDATE "
98
+ mappingDataElement.getRimsColumn()
100
+ "updated_by = ?, updated_date = ?"
101
+ " WHERE phc_code = ? AND mnth = ? AND yr = ? AND disease_code = ?";
103
Date curDate = new Date( new java.util.Date().getTime() );
104
int numberResult = Integer.parseInt( value );
105
if ( numberResult != -1 || numberResult != 0 )
115
mappingDataElement.getDisease_code()
118
return executeUpdate( query, params );
123
public void fillInTotals()
125
// No totals to fill in
128
public String getTableName()
130
return "surveillance_dtl";
133
public void markIfComplete() throws SQLException
135
String query = "UPDATE "+ getTableName() +
136
" SET complete = 1" +
137
" WHERE cases IS NOT NULL" +
138
" AND deaths IS NOT NULL";
139
executeUpdate( query );
141
public String getDataValue( RIMS_Mapping_DataElement mappingDataElement, RIMS_PHC orgUnit, int month, int year ) throws SQLException
143
String getColumn = mappingDataElement.getRimsColumn();
144
String query = "SELECT "+ getColumn +
145
" FROM "+ mappingDataElement.getTableName() +
146
" WHERE disease_code = ?" +
147
" AND phc_code = ?" +
150
Object[] params = { mappingDataElement.getDisease_code(),
151
orgUnit.getPhc_code(),
155
return executeQuery( query, getColumn, params );