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.util;
29
import java.sql.Connection;
30
import java.sql.SQLException;
31
import java.util.ArrayList;
32
import java.util.Collection;
33
import java.util.HashMap;
34
import java.util.List;
36
import org.hisp.dhis.integration.rims.api.RIMSTable;
37
import org.hisp.dhis.integration.rims.api.tables.RIMS_Aefi_Dtl;
38
import org.hisp.dhis.integration.rims.api.tables.RIMS_DIO_Position_Mst;
39
import org.hisp.dhis.integration.rims.api.tables.RIMS_Immun_Sessions_Dtl;
40
import org.hisp.dhis.integration.rims.api.tables.RIMS_Immun_Vaccine_Dtl;
41
import org.hisp.dhis.integration.rims.api.tables.RIMS_Opn_Stock_Vaccine_Dtl;
42
import org.hisp.dhis.integration.rims.api.tables.RIMS_Phc_Target_Dtl;
43
import org.hisp.dhis.integration.rims.api.tables.RIMS_Surveillance_Dtl;
44
import org.hisp.dhis.integration.rims.api.tables.RIMS_Vaccine_Supply_Dtl;
45
import org.hisp.dhis.integration.util.DataBaseConnection;
48
* Eventually this class will read configuration from an XML file.
50
* @author Leif Arne Storset
53
public class Configuration
55
private HashMap<String, RIMSTable> tables = new HashMap<String, RIMSTable>();
56
private List<String> monthlyFields = new ArrayList<String>();
57
private List<String> yearlyFields = new ArrayList<String>();
58
private String connectionName;
60
public Configuration( String connectionName )
62
setConnectionName( connectionName );
66
public Configuration()
73
// ---------------------------------------------------------------------
75
// ---------------------------------------------------------------------
76
RIMSTable[] phcTableArray = new RIMSTable[] {
77
new RIMS_Immun_Vaccine_Dtl(), new RIMS_Immun_Sessions_Dtl(),
78
new RIMS_Vaccine_Supply_Dtl(), new RIMS_Aefi_Dtl(),
79
new RIMS_Surveillance_Dtl(), new RIMS_Phc_Target_Dtl(),
80
new RIMS_Opn_Stock_Vaccine_Dtl(), new RIMS_DIO_Position_Mst() };
81
for ( RIMSTable table : phcTableArray )
83
tables.put( table.getTableName(), table );
84
table.setConfiguration( this );
87
// ---------------------------------------------------------------------
89
// ---------------------------------------------------------------------
91
monthlyFields.add( "ses_planned" );
92
monthlyFields.add( "ses_held" );
93
monthlyFields.add( "ses_vac_rcvd" );
94
monthlyFields.add( "ses_voln_eng" );
95
monthlyFields.add( "anim_hired" );
96
monthlyFields.add( "undser_area" );
97
monthlyFields.add( "urban_slums" );
98
monthlyFields.add( "ses_held_aanganwadi" );
99
monthlyFields.add( "fully_immu_infants" );
102
monthlyFields.add( "preg_women" );
103
monthlyFields.add( "under1year_total" );
104
monthlyFields.add( "under1year_male" );
105
monthlyFields.add( "under1year_female" );
106
monthlyFields.add( "over1year_total" );
107
monthlyFields.add( "over1year_male" );
108
monthlyFields.add( "over1year_female" );
110
// vaccine_supply_dtl
111
monthlyFields.add( "opn_balance" );
112
monthlyFields.add( "vaccine_rcvd" );
113
monthlyFields.add( "vaccine_consd" );
114
monthlyFields.add( "vaccine_unused" );
115
monthlyFields.add( "vaccine_bal" );
116
monthlyFields.add( "vaccine_dispd" );
117
monthlyFields.add( "vaccine_consd" );
120
monthlyFields.add( "during_the_mnth" );
123
monthlyFields.add( "cases" );
124
monthlyFields.add( "deaths" );
127
monthlyFields.add( "dio_position" );
128
monthlyFields.add( "blockphc_level" );
129
monthlyFields.add( "phc_level" );
130
monthlyFields.add( "sub_center" );
131
monthlyFields.add( "session_sites" );
132
monthlyFields.add( "budget_obal" );
133
monthlyFields.add( "budget_received" );
134
monthlyFields.add( "budget_released" );
135
monthlyFields.add( "budget_disbursed" );
136
monthlyFields.add( "budget_cbal" );
137
monthlyFields.add( "utilized_received" );
138
monthlyFields.add( "utilized_released" );
139
monthlyFields.add( "utilizedtillpre_month" );
140
monthlyFields.add( "utilizedduring_month" );
141
monthlyFields.add( "cuml_exp" );
142
monthlyFields.add( "ret_state" );
143
monthlyFields.add( "balance" );
146
yearlyFields.add( "cur_target" );
147
yearlyFields.add( "lst_target" );
148
yearlyFields.add( "snd_target" );
150
// opn_stock_vaccine_dtl
151
yearlyFields.add( "opening_bal" );
154
public RIMSTable getTable( String name )
156
RIMSTable table = tables.get( name );
159
throw new RuntimeException( "Table "+ name +" not found");
164
public Collection<RIMSTable> getTables()
166
return tables.values();
169
public Connection getConnection() throws SQLException
171
if ( connectionName == null )
173
throw new IllegalStateException( "Connection name not set" );
175
return (new DataBaseConnection())
176
.openConnection( DataBaseConnection.RIMS, connectionName );
179
public void setConnectionName( String name )
181
connectionName = name;
184
public String getConnectionName()
186
return connectionName;
189
public String getStoredBy()
191
return "dhis-web-integration";
194
public List<String> getMonthlyFields()
196
return monthlyFields;
199
public List<String> getYearlyFields()