1
<%@ page import="java.sql.*,java.util.*" %>
2
<%@ page import="com.opensymphony.xwork.util.OgnlValueStack" %>
6
// for Performance in the Reporting Month
10
// for selected OrgUnit Name and Population
14
// for Performance in Corresponding month Last Year
18
// for Cumulative Performance till Current Month
22
// for Cumulative Performance till corresponding month of Last Year
26
// for Taluk Name and Id
30
// for District Name and Id
34
// for PHC Name and Id
38
// for CHC Name and Id
42
// for PHC Population Estimates
46
// for Data Period Start Date and End Date
50
// for DataElement ids based on DataElement code
55
String userName = "dhis";
57
String urlForConnection = "jdbc:mysql://localhost/kl_dhis2";
60
String talukName = "";
62
String districtName = "";
67
int totPHCPopulation = -1;
68
int totSCPopulation = -1;
70
OgnlValueStack stack = (OgnlValueStack)request.getAttribute("webwork.valueStack");
71
String selectedId = (String) stack.findValue( "orgUnitId" );
72
int selectedOrgUnitID = Integer.parseInt( selectedId );
75
String startingDate = (String) stack.findValue( "startingPeriod" );
76
String endingDate = (String) stack.findValue( "endingPeriod" );
78
String monthlyPeriodId = (String) stack.findValue( "monthlyPeriodTypeId" );
79
int periodTypeID = Integer.parseInt( monthlyPeriodId );
84
String selectedOrgUnitName = "";
85
String selectedDataPeriodStartDate = "";
86
String selectedDataPeriodEndDate = "";
87
String lastDataPeriodStartDate = "";
89
String dataElementCodes[] = {
91
// WATER SAMPLES COLLECTED MONTHLY
93
// WATER SAMPLES COLLECTED YEARLY
95
// WELLS CHOLORINATED MONTHLY
97
// WELLS CHOLORINATED YEARLY
100
// HEALTH TALK MONTHLY
102
// HEALTH TALK YEARLY
106
//GROUP DISCUSSION MONTHLY
109
//GROUP DISCUSSION YEARLY
112
//PARTICIPANTS IN THE GROUP DISCUSSION MONTHLY
114
//PARTICIPANTS IN THE GROUP DISCUSSION YEARLY
118
// MOTHERS MEETING MONTHLY
121
// MOTHERS MEETING YEARLY
124
// MIKE PUBLICITY MONTHLY
126
// MIKE PUBLICITY YEARLY
129
// MSS MEETING MONTHLY
132
// MSS MEETING YEARLY
139
int dataElementIDs[] = new int[dataElementCodes.length+5];
140
int entryNumberValues[]= new int[dataElementCodes.length+5];
141
int entryValuesForLastYear[]= new int[dataElementCodes.length+5];
142
int cumentryValuesForCurYear[]= new int[dataElementCodes.length+5];
143
int cumentryValuesForLastYear[]= new int[dataElementCodes.length+5];
145
String monthNames[] = { "", "January", "February", "March", "April", "May", "June", "July", "August", "September","October", "November", "December" };
149
List childOrgUnitIDs = new ArrayList();
150
List childOrgUnitNames = new ArrayList();
152
int tempval[] = new int[dataElementCodes.length+5];
153
int total[] = new int[dataElementCodes.length+5];
156
int childOrgUnitCount = 0;
166
Class.forName ("com.mysql.jdbc.Driver").newInstance ();
167
con = DriverManager.getConnection (urlForConnection, userName, password);
169
st=con.createStatement(ResultSet.TYPE_SCROLL_SENSITIVE,ResultSet.CONCUR_READ_ONLY);
170
st1=con.createStatement(ResultSet.TYPE_SCROLL_SENSITIVE,ResultSet.CONCUR_READ_ONLY);
171
st2=con.createStatement(ResultSet.TYPE_SCROLL_SENSITIVE,ResultSet.CONCUR_READ_ONLY);
172
st3=con.createStatement(ResultSet.TYPE_SCROLL_SENSITIVE,ResultSet.CONCUR_READ_ONLY);
173
st4=con.createStatement(ResultSet.TYPE_SCROLL_SENSITIVE,ResultSet.CONCUR_READ_ONLY);
174
st5=con.createStatement(ResultSet.TYPE_SCROLL_SENSITIVE,ResultSet.CONCUR_READ_ONLY);
175
st6=con.createStatement(ResultSet.TYPE_SCROLL_SENSITIVE,ResultSet.CONCUR_READ_ONLY);
176
st8=con.createStatement(ResultSet.TYPE_SCROLL_SENSITIVE,ResultSet.CONCUR_READ_ONLY);
177
st9=con.createStatement(ResultSet.TYPE_SCROLL_SENSITIVE,ResultSet.CONCUR_READ_ONLY);
178
st10=con.createStatement(ResultSet.TYPE_SCROLL_SENSITIVE,ResultSet.CONCUR_READ_ONLY);
179
st11=con.createStatement(ResultSet.TYPE_SCROLL_SENSITIVE,ResultSet.CONCUR_READ_ONLY);
180
st12=con.createStatement(ResultSet.TYPE_SCROLL_SENSITIVE,ResultSet.CONCUR_READ_ONLY);
183
//rs1 = st1.executeQuery("SELECT organisationunit.name FROM organisationunit WHERE id ="+selectedOrgUnitID);
184
rs1 = st1.executeQuery("SELECT organisationunit.name FROM organisationunit WHERE organisationunitid ="+selectedOrgUnitID);
185
if(rs1.next()) { selectedOrgUnitName = rs1.getString(1); }
186
else { selectedOrgUnitName = ""; }
188
//query = "SELECT sum(datavalue.value) FROM datavalue INNER JOIN dataelement ON datavalue.dataElement = dataelement.id WHERE datavalue.period in (select id from period where startdate like '"+startingDate+"' and periodType = 3) AND datavalue.source in ( select id from organisationunit where parent in ( select id from organisationunit where parent ="+selectedOrgUnitID+")) AND dataelement.code in ('SPD_DE1','SPD_DE2','SPD_DE3','SPD_DE4','SPD_DE5','SPD_DE6','SPD_DE7','SPD_DE8')";
189
query = "SELECT sum(datavalue.value) FROM datavalue INNER JOIN dataelement ON datavalue.dataelementid = dataelement.dataelementid WHERE datavalue.periodid in (select periodid from period where startdate like '"+startingDate+"' and periodtypeid = 3) AND datavalue.sourceid in ( select organisationunitid from organisationunit where parentid in ( select organisationunitid from organisationunit where parentid ="+selectedOrgUnitID+")) AND dataelement.code in ('SPD_DE1','SPD_DE2','SPD_DE3','SPD_DE4','SPD_DE5','SPD_DE6','SPD_DE7','SPD_DE8')";
190
rs11 = st11.executeQuery(query);
193
totpopulation=rs11.getInt(1);
196
// rs11 = st11.executeQuery("select startDate,endDate from period where id = "+selectedDataPeriodID);
199
// selectedDataPeriodStartDate = rs11.getDate(1).toString();
200
// selectedDataPeriodEndDate = rs11.getDate(2).toString();
203
selectedDataPeriodStartDate = startingDate;
206
//rs3 = st3.executeQuery("select id,name from organisationunit where parent = "+selectedOrgUnitID);
207
rs3 = st3.executeQuery("select organisationunitid,name from organisationunit where parentid = "+selectedOrgUnitID);
210
Integer tempInt = new Integer(rs3.getInt(1));
211
childOrgUnitIDs.add(childOrgUnitCount,tempInt);
212
childOrgUnitNames.add(childOrgUnitCount,rs3.getString(2));
218
catch(Exception e) { out.println("exception 1 -"+e.getMessage()); }
223
if(rs1!=null) rs1.close(); if(st1!=null) st1.close();
224
if(rs11!=null) rs11.close(); if(st11!=null) st11.close();
226
catch(Exception e) { out.println("exception 2 - "+e.getMessage()); }
227
} // finally block end
229
String partsOfDataPeriodStartDate[] = selectedDataPeriodStartDate.split("-");
230
lastYear = Integer.parseInt(partsOfDataPeriodStartDate[0]) - 1;
231
lastDataPeriodStartDate = lastYear+"-"+partsOfDataPeriodStartDate[1]+"-"+partsOfDataPeriodStartDate[2];
233
int tempForMonth1 = Integer.parseInt(partsOfDataPeriodStartDate[1]);
236
if(tempForMonth1 < 4) { tempForYear = lastYear; }
237
else { tempForYear = lastYear + 1; }
239
String curYearStart = tempForYear+"-04-01";
240
String lastYearStart = (tempForYear-1)+"-04-01";
241
String lastYearEnd = lastYear+"-"+partsOfDataPeriodStartDate[1]+"-"+partsOfDataPeriodStartDate[2];
243
//for district, taluk, CHC names
246
// rs8=st8.executeQuery("select organisationunit.id, organisationunit.name FROM organisationunit WHERE organisationunit.id in ( select organisationunit.parent from organisationunit where organisationunit.id = "+selectedOrgUnitID+")");
247
// if(rs8.next()) { PHCID = rs8.getInt(1);PHCName = rs8.getString(2); }
248
// else { PHCID = 0; PHCName = ""; }
250
// rs9=st9.executeQuery("select organisationunit.id, organisationunit.name FROM organisationunit WHERE organisationunit.id in ( select organisationunit.parent from organisationunit where organisationunit.id = "+selectedOrgUnitID+")");
251
// if(rs9.next()) { CHCID = rs9.getInt(1);CHCName = rs9.getString(2); }
252
// else { CHCID = 0; CHCName = ""; }
254
//rs5=st5.executeQuery("select organisationunit.id, organisationunit.name FROM organisationunit WHERE organisationunit.id in ( select organisationunit.parent from organisationunit where organisationunit.id = "+selectedOrgUnitID +")");
255
rs5=st5.executeQuery("select organisationunit.organisationunitid, organisationunit.name FROM organisationunit WHERE organisationunit.organisationunitid in ( select organisationunit.parentid from organisationunit where organisationunit.organisationunitid = "+selectedOrgUnitID +")");
256
if(rs5.next()) { talukID = rs5.getInt(1); talukName = rs5.getString(2); }
257
else { talukID = 0; talukName = ""; }
259
//rs6=st6.executeQuery("select organisationunit.id, organisationunit.name FROM organisationunit WHERE organisationunit.id in ( select organisationunit.parent from organisationunit where organisationunit.id = "+talukID+")");
260
rs6=st6.executeQuery("select organisationunit.organisationunitid, organisationunit.name FROM organisationunit WHERE organisationunit.organisationunitid in ( select organisationunit.parentid from organisationunit where organisationunit.organisationunitid = "+talukID+")");
261
if(rs6.next()) { districtID = rs6.getInt(1); districtName = rs6.getString(2);}
262
else {districtID = 0; districtName = "";}
264
//rs10=st10.executeQuery("SELECT sum(datavalue.value) FROM organisationunit INNER JOIN (dataelement INNER JOIN datavalue ON dataelement.id = datavalue.dataElement) ON organisationunit.id = datavalue.source WHERE organisationunit.parent = "+PHCID+" AND dataelement.name like 'Total Population'");
265
rs10=st10.executeQuery("SELECT sum(datavalue.value) FROM organisationunit INNER JOIN (dataelement INNER JOIN datavalue ON dataelement.dataelementid = datavalue.dataelementid) ON organisationunit.organisationunitid = datavalue.sourceid WHERE organisationunit.parentid = "+PHCID+" AND dataelement.name like 'Total Population'");
266
if(rs10.next()) { totPHCPopulation = rs10.getInt(1);}
267
else {totPHCPopulation = 0;}
270
catch(Exception e) { out.println(e.getMessage()); }
278
<title>communicable diseases/iec activieits</title>
283
<FONT face="Arial" size="2"><center>Consolidation Report of Activities for prevention and control of Communicable Diseases/IEC Activities of the <br>CHC/Block PHC-<b><u><%=selectedOrgUnitName%></u> </b> for the month of<b><%=monthNames[Integer.parseInt(partsOfDataPeriodStartDate[1])]%> - <%=partsOfDataPeriodStartDate[0]%></font></center><br><br>
284
<table border="0" cellpadding="0" cellspacing="0" style="border-collapse: collapse" bordercolor="#111111" width="100%" id="AutoNumber1">
286
<td width="50%"><FONT face="Arial" size="2">Total Population :<%=totpopulation%></Font></td>
287
<td width="50%"><FONT face="Arial" size="2">District :<%=districtName%></Font></td>
290
<table border="1" cellpadding="0" cellspacing="0" style="border-collapse: collapse" bordercolor="#111111" width="100%" id="AutoNumber2">
292
<td align="center" width="3%" rowspan="3"><FONT face="Arial" size="2">Sl.No</Font></td>
293
<td align="center" width="49%" rowspan="3"><FONT face="Arial" size="2">Name of the Mini PHC</Font></td>
294
<td align="center" width="48%" colspan="16"><FONT face="Arial" size="2">IEC</Font></td>
297
<td align="center" width="6%" colspan="2"><FONT face="Arial" size="2">Water samples collected</Font></td>
298
<td align="center" width="6%" colspan="2"><FONT face="Arial" size="2">Wells Chlorinated</Font></td>
299
<td align="center" width="6%" colspan="2"><FONT face="Arial" size="2">Health Talk</Font></td>
300
<td align="center" width="6%" colspan="2"><FONT face="Arial" size="2">Group Discussion</Font></td>
301
<td align="center" width="6%" colspan="2"><FONT face="Arial" size="2">Participants in the Group discussion</Font></td>
302
<td align="center" width="6%" colspan="2"><FONT face="Arial" size="2">Mothers Meeting</Font></td>
303
<td align="center" width="6%" colspan="2"><FONT face="Arial" size="2">Mike publicity</Font></td>
304
<td align="center" width="6%" colspan="2"><FONT face="Arial" size="2">MSS Meeting</Font></td>
307
<td align="center" width="3%"><FONT face="Arial" size="2">Monthly</Font></td>
308
<td align="center" width="3%"><FONT face="Arial" size="2">Yearly</Font></td>
309
<td align="center" width="3%"><FONT face="Arial" size="2">Monthly</Font></td>
310
<td align="center" width="3%"><FONT face="Arial" size="2">Yearly</Font></td>
311
<td align="center" width="3%"><FONT face="Arial" size="2">Monthly</Font></td>
312
<td align="center" width="3%"><FONT face="Arial" size="2">Yearly</Font></td>
313
<td align="center" width="3%"><FONT face="Arial" size="2">Monthly</Font></td>
314
<td align="center" width="3%"><FONT face="Arial" size="2">Yearly</Font></td>
315
<td align="center" width="3%"><FONT face="Arial" size="2">Monthly</Font></td>
316
<td align="center" width="3%"><FONT face="Arial" size="2">Yearly</Font></td>
317
<td align="center" width="3%"><FONT face="Arial" size="2">Monthly</Font></td>
318
<td align="center" width="3%"><FONT face="Arial" size="2">Yearly</Font></td>
319
<td align="center" width="3%"><FONT face="Arial" size="2">Monthly</Font></td>
320
<td align="center" width="3%"><FONT face="Arial" size="2">Yearly</Font></td>
321
<td align="center" width="3%"><FONT face="Arial" size="2">Monthly</Font></td>
322
<td align="center" width="3%"><FONT face="Arial" size="2">Yearly</Font></td>
329
while(count < childOrgUnitCount)
331
Integer temp1 = (Integer) childOrgUnitIDs.get(count);
332
int currentChildID = temp1.intValue();
333
for(i=0;i<dataElementCodes.length;i++)
336
if(i==0 || i==2 || i==4 || i==6 || i==8 || i==10 || i==12 || i==14)
337
//query = "SELECT sum(datavalue.value) FROM datavalue INNER JOIN dataelement ON datavalue.dataElement = dataelement.id WHERE datavalue.period in (select id from period where startdate between '"+startingDate+"' and '"+startingDate+"') AND datavalue.source in (select id from organisationunit where parent = "+currentChildID+") AND dataelement.code in ("+dataElementCodes[i]+")";
338
query = "SELECT sum(datavalue.value) FROM datavalue INNER JOIN dataelement ON datavalue.dataelementid = dataelement.dataelementid WHERE datavalue.periodid in (select periodid from period where startdate between '"+startingDate+"' and '"+startingDate+"') AND datavalue.sourceid in (select organisationunitid from organisationunit where parentid = "+currentChildID+") AND dataelement.code in ("+dataElementCodes[i]+")";
340
//query = "SELECT sum(datavalue.value) FROM datavalue INNER JOIN dataelement ON datavalue.dataElement = dataelement.id WHERE datavalue.period in (select id from period where startdate between '"+curYearStart+"' and '"+startingDate+"') AND datavalue.source in (select id from organisationunit where parent = "+currentChildID+") AND dataelement.code in ("+dataElementCodes[i]+")";
341
query = "SELECT sum(datavalue.value) FROM datavalue INNER JOIN dataelement ON datavalue.dataelementid = dataelement.dataelementid WHERE datavalue.periodid in (select periodid from period where startdate between '"+curYearStart+"' and '"+startingDate+"') AND datavalue.sourceid in (select organisationunitid from organisationunit where parentid = "+currentChildID+") AND dataelement.code in ("+dataElementCodes[i]+")";
342
rs4 = st4.executeQuery(query);
344
if(!rs4.next()) { tempval[i] = 0; }
345
else { tempval[i] = rs4.getInt(1); }
346
total[i] += tempval[i];
351
<td align="center" width="3%"><FONT face="Arial" size="2"><%=(count+1)%></Font> </td>
352
<td width="49%"><FONT face="Arial" size="2"><%=childOrgUnitNames.get(count)%></Font> </td>
353
<td align="center" width="3%"><FONT face="Arial" size="2"><%=tempval[0]%></Font> </td>
354
<td align="center" width="3%"><FONT face="Arial" size="2"><%=tempval[1]%></Font> </td>
355
<td align="center" width="3%"><FONT face="Arial" size="2"><%=tempval[2]%></Font> </td>
356
<td align="center" width="3%"><FONT face="Arial" size="2"><%=tempval[3]%></Font> </td>
357
<td align="center" width="3%"><FONT face="Arial" size="2"><%=tempval[4]%></Font> </td>
358
<td align="center" width="3%"><FONT face="Arial" size="2"><%=tempval[5]%></Font> </td>
359
<td align="center" width="3%"><FONT face="Arial" size="2"><%=tempval[6]%></Font> </td>
360
<td align="center" width="3%"><FONT face="Arial" size="2"><%=tempval[7]%></Font> </td>
361
<td align="center" width="3%"><FONT face="Arial" size="2"><%=tempval[8]%></Font> </td>
362
<td align="center" width="3%"><FONT face="Arial" size="2"><%=tempval[9]%></Font> </td>
363
<td align="center" width="3%"><FONT face="Arial" size="2"><%=tempval[10]%></Font> </td>
364
<td align="center" width="3%"><FONT face="Arial" size="2"><%=tempval[11]%></Font> </td>
365
<td align="center" width="3%"><FONT face="Arial" size="2"><%=tempval[12]%></Font> </td>
366
<td align="center" width="3%"><FONT face="Arial" size="2"><%=tempval[13]%></Font> </td>
367
<td align="center" width="3%"><FONT face="Arial" size="2"><%=tempval[14]%></Font> </td>
368
<td align="center" width="3%"><FONT face="Arial" size="2"><%=tempval[15]%></Font> </td>
374
catch(Exception e) { out.println(e.getMessage()); }
379
if(rs5!=null) rs5.close(); if(st5!=null) st5.close();
380
if(rs6!=null) rs6.close(); if(st6!=null) st6.close();
381
if(rs8!=null) rs8.close(); if(st8!=null) st8.close();
382
if(rs9!=null) rs9.close(); if(st9!=null) st9.close();
383
if(rs10!=null) rs10.close(); if(st10!=null) st10.close();
385
catch(Exception e) { out.println(e.getMessage()); }
386
} // finally block end
b'\\ No newline at end of file'