2
<%@ page import="java.sql.*,java.util.*" %>
3
<%@ page import="com.opensymphony.xwork.util.OgnlValueStack" %>
5
<%@ page session="true"%>
10
// For finding organisationunit name of selected Orgunit based on Orgunit id
14
// For finding start date of selected period based on period id
18
// For finding child orgunit ids and names based on selected orgunit id
22
// For finding child orgunit
27
String userName = "dhis";
29
String urlForConnection = "jdbc:mysql://localhost/jh_dhis2";
31
OgnlValueStack stack = (OgnlValueStack)request.getAttribute("webwork.valueStack");
33
String selectedId = (String) stack.findValue( "orgUnitId" );
34
int selectedOrgUnitID = Integer.parseInt( selectedId );
36
// String selectedPeriodId = (String) stack.findValue( "periodSelect" );
37
// int selectedDataPeriodID = Integer.parseInt( selectedPeriodId );
39
String startingDate = (String) stack.findValue( "startingPeriod" );
40
String endingDate = (String) stack.findValue( "endingPeriod" );
43
String monthlyPeriodId = (String) stack.findValue( "monthlyPeriodTypeId" );
44
int periodTypeID = Integer.parseInt( monthlyPeriodId );
47
String selectedOrgUnitName = "";
48
String selectedDataPeriodStartDate = "";
50
String monthNames[] = { "", "January", "February", "March", "April", "May", "June", "July", "August", "September","October", "November", "December" };
52
String monthlyDataElements[] = {
53
"Data Element for Population",
55
// Cases treated at FTD, DDC
58
// Active BSC, BSE, +ve (pv + pf)
59
"MAL_DE6","MAL_DE7","MAL_DE8","MAL_DE9",
61
// Passive BSC, BSE, +ve (pv + pf)
62
"MAL_DE10","MAL_DE11","MAL_DE12","MAL_DE13",
64
// Clinically Diagnosed Deaths
71
"MAL_DE37","MAL_DE38","MAL_DE39","MAL_DE40",
73
// Positive Agewise - (0-1), (1-4), (5-14), (>15)
74
"MAL_DE28","MAL_DE29","MAL_DE30","MAL_DE31",
76
// Positive - Male, Female
77
"MAL_DE26","MAL_DE27",
80
"MAL_DE32","MAL_DE33","MAL_DE34","MAL_DE35"
84
List childOrgUnitIDs = new ArrayList();
85
List childOrgUnitNames = new ArrayList();
87
int childOrgUnitCount = 0;
90
int totPopulation = 0;
92
int tempval[] = new int[monthlyDataElements.length+5];
93
int total[] = new int[monthlyDataElements.length+5];
99
Class.forName ("com.mysql.jdbc.Driver").newInstance ();
100
con = DriverManager.getConnection (urlForConnection, userName, password);
102
st1=con.createStatement(ResultSet.TYPE_SCROLL_SENSITIVE,ResultSet.CONCUR_READ_ONLY);
103
st2=con.createStatement(ResultSet.TYPE_SCROLL_SENSITIVE,ResultSet.CONCUR_READ_ONLY);
104
st3=con.createStatement(ResultSet.TYPE_SCROLL_SENSITIVE,ResultSet.CONCUR_READ_ONLY);
105
st4=con.createStatement(ResultSet.TYPE_SCROLL_SENSITIVE,ResultSet.CONCUR_READ_ONLY);
107
//rs1 = st1.executeQuery("SELECT organisationunit.shortname FROM organisationunit WHERE id ="+selectedOrgUnitID);
108
rs1 = st1.executeQuery("SELECT organisationunit.shortname FROM organisationunit WHERE organisationunitid ="+selectedOrgUnitID);
109
if(rs1.next()) { selectedOrgUnitName = rs1.getString(1); }
110
else { selectedOrgUnitName = ""; }
112
// rs2 = st2.executeQuery("select startDate from period where id = "+selectedDataPeriodID);
113
// if(rs2.next()) { selectedDataPeriodStartDate = rs2.getDate(1).toString(); }
115
selectedDataPeriodStartDate = startingDate;
117
//rs3 = st3.executeQuery("select id,shortname from organisationunit where parent = "+selectedOrgUnitID);
118
rs3 = st3.executeQuery("select organisationunitid,shortname from organisationunit where parentid = "+selectedOrgUnitID);
121
Integer tempInt = new Integer(rs3.getInt(1));
122
childOrgUnitIDs.add(childOrgUnitCount,tempInt);
123
childOrgUnitNames.add(childOrgUnitCount,rs3.getString(2));
128
catch(Exception e) { out.println(e.getMessage()); }
130
String partsOfDataPeriodStartDate[] = selectedDataPeriodStartDate.split("-");
136
<TITLE>NAMMIS-BASE INPUT FORM </TITLE>
139
<P align="center"><FONT face="Arial" size="3"><b><u>NAMMIS-BASE INPUT FORM </u></b></font><br></p>
142
<table cellpadding="0" cellspacing="0" bgcolor="ffffff" align="center" style="border-style:solid; border-width:0; border-collapse: collapse; padding: 0; position:relative; top:10" bordercolor="#ffffff" width="100%" border="0">
143
<tr style="border-collapse: collapse; border-left-style: solid; border-left-width: 0; border-right-style: solid; border-right-width: 0; padding: 0" bordercolor="#111111" width="100%">
144
<td width="50%" style="border-collapse: collapse; border-left-style: solid; border-left-width: 0; border-right-style: solid; border-right-width: 0; padding-left:15; padding-right:0; padding-top:0; padding-bottom:0" bordercolor="#111111" height="23">
145
<font face="Arial" size="3"><b>District : <%=selectedOrgUnitName%></b></font>
147
<td width="50%" align="right" style="border-collapse: collapse; border-left-style: solid; border-left-width: 0; border-right-style: solid; border-right-width: 0; padding-left:15; padding-right:0; padding-top:0; padding-bottom:0" bordercolor="#111111" height="23">
148
<font face="Arial" size="2"><b>Month : <%=monthNames[Integer.parseInt(partsOfDataPeriodStartDate[1])]%> - <%=partsOfDataPeriodStartDate[0]%> </b></font>
159
while(count < childOrgUnitCount)
163
if(count != 0) {%></table><div align="right"><font face="Arial" size="1"><i>(page contd.)</i></font></div> <br><%}%>
165
<TABLE style="BORDER-COLLAPSE: collapse" borderColor=#111111 cellSpacing=3 cellPadding=3 width="100%" border=1>
167
<TD align="center" width="3%" rowspan="3"><font face="Arial" style="font-size:8pt">Sl. No.</font></TD>
168
<TD align="center" width="22%" rowspan="3"><font face="Arial" style="font-size:8pt">Name of PHC</font></TD>
169
<TD align="center" width="3%" rowspan="3"><font face="Arial" style="font-size:8pt">Population</font></TD>
170
<TD align="center" width="3%" rowspan="3"><font face="Arial" style="font-size:8pt">Cases Treated at FTD</font></TD>
171
<TD align="center" width="3%" rowspan="3"><font face="Arial" style="font-size:8pt">Cases Treated at DDC</font></TD>
172
<TD align="center" width="9%" colspan="3"><font face="Arial" style="font-size:8pt">Active</font></TD>
173
<TD align="center" width="9%" colspan="3"><font face="Arial" style="font-size:8pt">Passive</font></TD>
174
<TD align="center" width="9%" colspan="3"><font face="Arial" style="font-size:8pt">Total</font></TD>
175
<TD align="center" width="3%" rowspan="3"><font face="Arial" style="font-size:8pt">Clinically Diagnosed Deaths</font></TD>
176
<TD align="center" width="6%" colspan="2"><font face="Arial" style="font-size:8pt">RT-Done</font></TD>
177
<TD align="center" width="12%" colspan="4"><font face="Arial" style="font-size:8pt">Positive Age Wise</font></TD>
178
<TD align="center" width="6%" colspan="2"><font face="Arial" style="font-size:8pt">Positive</font></TD>
179
<TD align="center" width="12%" colspan="4"><font face="Arial" style="font-size:8pt">Species</font></TD>
183
<TD align="center" width="3%" rowspan="2"><font face="Arial" style="font-size:8pt">BSC</font></TD>
184
<TD align="center" width="3%" rowspan="2"><font face="Arial" style="font-size:8pt">BSE</font></TD>
185
<TD align="center" width="3%" rowspan="2"><font face="Arial" style="font-size:8pt">+ve</font></TD>
186
<TD align="center" width="3%" rowspan="2"><font face="Arial" style="font-size:8pt">BSC</font></TD>
187
<TD align="center" width="3%" rowspan="2"><font face="Arial" style="font-size:8pt">BSE</font></TD>
188
<TD align="center" width="3%" rowspan="2"><font face="Arial" style="font-size:8pt">+ve</font></TD>
189
<TD align="center" width="3%" rowspan="2"><font face="Arial" style="font-size:8pt">BSC</font></TD>
190
<TD align="center" width="3%" rowspan="2"><font face="Arial" style="font-size:8pt">BSE</font></TD>
191
<TD align="center" width="3%" rowspan="2"><font face="Arial" style="font-size:8pt">+ve</font></TD>
192
<TD align="center" width="3%" rowspan="2"><font face="Arial" style="font-size:8pt">RT- within 7 Days</font></TD>
193
<TD align="center" width="3%" rowspan="2"><font face="Arial" style="font-size:8pt">RT- given to +ves</font></TD>
194
<TD align="center" width="3%" rowspan="2"><font face="Arial" style="font-size:8pt">0-1</font></TD>
195
<TD align="center" width="3%" rowspan="2"><font face="Arial" style="font-size:8pt">1-4</font></TD>
196
<TD align="center" width="3%" rowspan="2"><font face="Arial" style="font-size:8pt">5-14</font></TD>
197
<TD align="center" width="3%" rowspan="2"><font face="Arial" style="font-size:8pt">>15</font></TD>
198
<TD align="center" width="3%" rowspan="2"><font face="Arial" style="font-size:8pt">Male</font></TD>
199
<TD align="center" width="3%" rowspan="2"><font face="Arial" style="font-size:8pt">Female</font></TD>
200
<TD align="center" width="3%" rowspan="2"><font face="Arial" style="font-size:8pt">Pv</font></TD>
201
<TD align="center" width="3%" colspan="2"><font face="Arial" style="font-size:8pt">Pf</font></TD>
202
<TD align="center" width="3%" rowspan="2"><font face="Arial" style="font-size:8pt">Mix</font></TD>
206
<TD align="center" width="3%"><font face="Arial" style="font-size:8pt">R</font></TD>
207
<TD align="center" width="3%"><font face="Arial" style="font-size:8pt">Rg</font></TD>
211
Integer temp1 = (Integer) childOrgUnitIDs.get(count);
212
int currentChildID = temp1.intValue();
213
for(i=0;i<monthlyDataElements.length;i++)
215
//rs4 = st4.executeQuery("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 like '"+monthlyDataElements[i]+"'");
216
rs4 = st4.executeQuery("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 like '"+monthlyDataElements[i]+"'");
217
//SELECT sum(datavalue.value) FROM datavalue INNER JOIN dataelement ON datavalue.dataElement = dataelement.id WHERE datavalue.period ="+selectedDataPeriodID+" AND datavalue.source in (select id from organisationunit where parent ="+currentChildID+") AND dataelement.code like '"+monthlyDataElements[i]+"'");
218
//SELECT datavalue.value FROM datavalue INNER JOIN dataelement ON datavalue.dataElement = dataelement.id WHERE datavalue.period="+selectedDataPeriodID+" AND datavalue.source="+currentChildID+" AND dataelement.code like '"+monthlyDataElements[i]+"'");
219
//SELECT sum(datavalue.value) FROM (organisationunit INNER JOIN datavalue ON organisationunit.id = datavalue.source) INNER JOIN period ON datavalue.period = period.id WHERE organisationunit.parent="+selectedOrgUnitID+" AND period.startDate='"+selectedDataPeriodStartDate+"' AND periodType="+periodTypeID+" AND datavalue.dataElement="+dataElementIDs[i])
221
if(!rs4.next()) { tempval[i] = 0; }
222
else { tempval[i] = rs4.getInt(1); }
223
total[i] += tempval[i];
229
<TD width="3%" HEIGHT="30" align="center"><FONT face="Arial" style="font-size:8pt"><%=(count+1)%>.</font></TD>
230
<TD width="22%" HEIGHT="30" align="center"><b><FONT face="Arial" style="font-size:8pt"><%=childOrgUnitNames.get(count)%></font></b></TD>
231
<TD width="3%" HEIGHT="30" align="center"><FONT face="Arial" style="font-size:8pt"><%=tempval[0]%></font></TD>
232
<TD width="3%" HEIGHT="30" align="center"><FONT face="Arial" style="font-size:8pt"><%=tempval[1]%></font></TD>
233
<TD width="3%" HEIGHT="30" align="center"><FONT face="Arial" style="font-size:8pt"><%=tempval[2]%></font></TD>
234
<TD width="3%" HEIGHT="30" align="center"><FONT face="Arial" style="font-size:8pt"><%=tempval[3]%></font></TD>
235
<TD width="3%" HEIGHT="30" align="center"><FONT face="Arial" style="font-size:8pt"><%=tempval[4]%></font></TD>
236
<TD width="3%" HEIGHT="30" align="center"><FONT face="Arial" style="font-size:8pt"><%=(tempval[5]+tempval[6])%></font></TD>
237
<TD width="3%" HEIGHT="30" align="center"><FONT face="Arial" style="font-size:8pt"><%=tempval[7]%></font></TD>
238
<TD width="3%" HEIGHT="30" align="center"><FONT face="Arial" style="font-size:8pt"><%=tempval[8]%></font></TD>
239
<TD width="3%" HEIGHT="30" align="center"><FONT face="Arial" style="font-size:8pt"><%=(tempval[9]+tempval[10])%></font></TD>
240
<TD width="3%" HEIGHT="30" align="center"><FONT face="Arial" style="font-size:8pt"><%=(tempval[3]+tempval[7])%></font></TD>
241
<TD width="3%" HEIGHT="30" align="center"><FONT face="Arial" style="font-size:8pt"><%=(tempval[4]+tempval[8])%></font></TD>
242
<TD width="3%" HEIGHT="30" align="center"><FONT face="Arial" style="font-size:8pt"><%=(tempval[5]+tempval[6]+tempval[9]+tempval[10])%></font></TD>
243
<TD width="3%" HEIGHT="30" align="center"><FONT face="Arial" style="font-size:8pt"><%=tempval[11]%></font></TD>
244
<TD width="3%" HEIGHT="30" align="center"><FONT face="Arial" style="font-size:8pt"><%=tempval[12]%></font></TD>
245
<TD width="3%" HEIGHT="30" align="center"><FONT face="Arial" style="font-size:8pt"><%=(tempval[13]+tempval[14]+tempval[15]+tempval[16])%></font></TD>
246
<TD width="3%" HEIGHT="30" align="center"><FONT face="Arial" style="font-size:8pt"><%=tempval[17]%></font></TD>
247
<TD width="3%" HEIGHT="30" align="center"><FONT face="Arial" style="font-size:8pt"><%=tempval[18]%></font></TD>
248
<TD width="3%" HEIGHT="30" align="center"><FONT face="Arial" style="font-size:8pt"><%=tempval[19]%></font></TD>
249
<TD width="3%" HEIGHT="30" align="center"><FONT face="Arial" style="font-size:8pt"><%=tempval[20]%></font></TD>
250
<TD width="3%" HEIGHT="30" align="center"><FONT face="Arial" style="font-size:8pt"><%=tempval[21]%></font></TD>
251
<TD width="3%" HEIGHT="30" align="center"><FONT face="Arial" style="font-size:8pt"><%=tempval[22]%></font></TD>
252
<TD width="3%" HEIGHT="30" align="center"><FONT face="Arial" style="font-size:8pt"><%=tempval[23]%></font></TD>
253
<TD width="3%" HEIGHT="30" align="center"><FONT face="Arial" style="font-size:8pt"><%=tempval[24]%></font></TD>
254
<TD width="3%" HEIGHT="30" align="center"><FONT face="Arial" style="font-size:8pt"><%=tempval[25]%></font></TD>
255
<TD width="3%" HEIGHT="30" align="center"><FONT face="Arial" style="font-size:8pt"><%=tempval[26]%></font></TD>
261
catch(Exception e) { out.println(e.getMessage()); }
266
if(rs1!=null) rs1.close(); if(st1!=null) st1.close();
267
if(rs2!=null) rs2.close(); if(st2!=null) st2.close();
268
if(rs3!=null) rs3.close(); if(st3!=null) st3.close();
269
if(rs4!=null) rs4.close(); if(st4!=null) st4.close();
271
if(con!=null) con.close();
273
catch(Exception e) { out.println(e.getMessage()); }
274
} // finally block end
278
<TD width="3%" HEIGHT="30" align="center"><FONT face="Arial" size="1"> </font></TD>
279
<TD width="22%" HEIGHT="30" align="center"><FONT face="Arial" style="font-size:8pt"><b>Total</b></font></TD>
280
<TD width="3%" HEIGHT="30" align="center"><FONT face="Arial" style="font-size:8pt"><%=total[0]%></font></TD>
281
<TD width="3%" HEIGHT="30" align="center"><FONT face="Arial" style="font-size:8pt"><%=total[1]%></font></TD>
282
<TD width="3%" HEIGHT="30" align="center"><FONT face="Arial" style="font-size:8pt"><%=total[2]%></font></TD>
283
<TD width="3%" HEIGHT="30" align="center"><FONT face="Arial" style="font-size:8pt"><%=total[3]%></font></TD>
284
<TD width="3%" HEIGHT="30" align="center"><FONT face="Arial" style="font-size:8pt"><%=total[4]%></font></TD>
285
<TD width="3%" HEIGHT="30" align="center"><FONT face="Arial" style="font-size:8pt"><%=(total[5]+total[6])%></font></TD>
286
<TD width="3%" HEIGHT="30" align="center"><FONT face="Arial" style="font-size:8pt"><%=total[7]%></font></TD>
287
<TD width="3%" HEIGHT="30" align="center"><FONT face="Arial" style="font-size:8pt"><%=total[8]%></font></TD>
288
<TD width="3%" HEIGHT="30" align="center"><FONT face="Arial" style="font-size:8pt"><%=(total[9]+total[10])%></font></TD>
289
<TD width="3%" HEIGHT="30" align="center"><FONT face="Arial" style="font-size:8pt"><%=(total[3]+total[7])%></font></TD>
290
<TD width="3%" HEIGHT="30" align="center"><FONT face="Arial" style="font-size:8pt"><%=(total[4]+total[8])%></font></TD>
291
<TD width="3%" HEIGHT="30" align="center"><FONT face="Arial" style="font-size:8pt"><%=(total[5]+total[6]+total[9]+total[10])%></font></TD>
292
<TD width="3%" HEIGHT="30" align="center"><FONT face="Arial" style="font-size:8pt"><%=total[11]%></font></TD>
293
<TD width="3%" HEIGHT="30" align="center"><FONT face="Arial" style="font-size:8pt"><%=total[12]%></font></TD>
294
<TD width="3%" HEIGHT="30" align="center"><FONT face="Arial" style="font-size:8pt"><%=(total[13]+total[14]+total[15]+total[16])%></font></TD>
295
<TD width="3%" HEIGHT="30" align="center"><FONT face="Arial" style="font-size:8pt"><%=total[17]%></font></TD>
296
<TD width="3%" HEIGHT="30" align="center"><FONT face="Arial" style="font-size:8pt"><%=total[18]%></font></TD>
297
<TD width="3%" HEIGHT="30" align="center"><FONT face="Arial" style="font-size:8pt"><%=total[19]%></font></TD>
298
<TD width="3%" HEIGHT="30" align="center"><FONT face="Arial" style="font-size:8pt"><%=total[20]%></font></TD>
299
<TD width="3%" HEIGHT="30" align="center"><FONT face="Arial" style="font-size:8pt"><%=total[21]%></font></TD>
300
<TD width="3%" HEIGHT="30" align="center"><FONT face="Arial" style="font-size:8pt"><%=total[22]%></font></TD>
301
<TD width="3%" HEIGHT="30" align="center"><FONT face="Arial" style="font-size:8pt"><%=total[23]%></font></TD>
302
<TD width="3%" HEIGHT="30" align="center"><FONT face="Arial" style="font-size:8pt"><%=total[24]%></font></TD>
303
<TD width="3%" HEIGHT="30" align="center"><FONT face="Arial" style="font-size:8pt"><%=total[25]%></font></TD>
304
<TD width="3%" HEIGHT="30" align="center"><FONT face="Arial" style="font-size:8pt"><%=total[26]%></font></TD>
b'\\ No newline at end of file'