~mortenoh/+junk/dhis2-detailed-import-export

« back to all changes in this revision

Viewing changes to local/in/dhis-web-reports/src/main/webapp/dhis-web-reports/Jharkhand/jscphcprofile1.jsp

  • Committer: larshelge at gmail
  • Date: 2009-03-03 16:46:36 UTC
  • Revision ID: larshelge@gmail.com-20090303164636-2sjlrquo7ib1gf7r
Initial check-in

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
<%@ page contentType="text/html ; charset=UTF-8"%>
 
2
 
 
3
<%@ page import="java.sql.*,java.util.*" %>
 
4
<%@ page import="com.opensymphony.xwork.util.OgnlValueStack" %>
 
5
 
 
6
<%@ page session="true"%>
 
7
 
 
8
<%
 
9
    Connection con=null;
 
10
    
 
11
        Statement st1 = null;
 
12
    ResultSet rs1 = null;
 
13
                
 
14
    Statement st2 = null;
 
15
    ResultSet rs2 = null;
 
16
 
 
17
    Statement st3 = null;
 
18
    ResultSet rs3 = null;
 
19
 
 
20
        PreparedStatement pst = null;
 
21
    ResultSet rs4 = null;
 
22
 
 
23
    String userName = "dhis";      
 
24
    String password = "";           
 
25
    String urlForConnection = "jdbc:mysql://localhost/jh_dhis2";
 
26
          
 
27
 
 
28
        OgnlValueStack stack = (OgnlValueStack)request.getAttribute("webwork.valueStack");
 
29
 
 
30
        String selectedId = (String) stack.findValue( "orgUnitId" );
 
31
        int selectedOrgUnitID = Integer.parseInt( selectedId );
 
32
        //int selectedOrgUnitID = 14;
 
33
        
 
34
        String startingDate  = (String) stack.findValue( "startingPeriod" );
 
35
        String endingDate  = (String) stack.findValue( "endingPeriod" );
 
36
 
 
37
        //String startingDate = "2006-01-01";
 
38
        //String endingDate = "2006-12-31";
 
39
        
 
40
        int seletedDataSetID = 240;
 
41
        int selectedPeriodID = 0;
 
42
        int periodTypeID = 3; // Yearly
 
43
        
 
44
    String partsOfDataPeriodStartDate[] = startingDate.split("-");        
 
45
        String selectedOrgUnitName = ""; 
 
46
        
 
47
        Hashtable htForDataSetMembers = new Hashtable();
 
48
        String dataValue[] = new String[10];
 
49
        int dataElementIDs[] = { 
 
50
                                                                0,0,1447,1448,1448,1450,1451,1452,1453,1454,1455,1456,1457,0,1458,1459,1460,1461,
 
51
                                                                1462,1463,1464,1465,1466,1467,1468,1469,1470,0,1471,1472,1473,1474,1475,0,1476,
 
52
                                                                1477,1478,1479,1480,1481,1482,1483,0,1484,1485,1486,1487,1488,1489,1490,1491,1492,1493,
 
53
                                                                1494,1495,0,0,1496,1497,1498,1499,1500,1501,0,1502,1503,1504,1505,1506,1507,1508,1509,1510,
 
54
                                                                1511,1512,1513,1514,1515,0,1516,1517,1518,1604,1605,0,1519,1520,1521,1522,0,1523,1524,
 
55
                                                                1525,1526,0,1527,1528,1529,1530,1531,1532,0,1533,1534,1547,1535,1536,1547,1537,1538,1547,
 
56
                                                                1539,1540,1547,1541,1542,1547,1543,1544,1547,1545,1546,1547,0,1549,1550,0,1551,1552,1601,
 
57
                                                                1553,1554,1601,1555,1556,1601,1557,1558,1601,1559,1560,1601,1561,1562,1601,1563,1564,1601,
 
58
                                                                1565,1566,1601,1567,1568,1601,1569,1570,1601,1571,1572,1601,1573,1574,1601,1575,1576,1601,
 
59
                                                                1577,1578,1601,1579,1580,1601,1581,1582,1601,1583,1584,1601,1585,1586,1601,1587,1588,1601,
 
60
                                                                1589,1590,1601,1591,1592,1601,1593,1594,1601,1595,1596,1601,1597,1598,1601,1599,1600,1601 
 
61
                                                   };
 
62
        
 
63
%>              
 
64
                                        
 
65
<%
 
66
 
 
67
     try
 
68
     {
 
69
        Class.forName ("com.mysql.jdbc.Driver").newInstance ();
 
70
        con = DriverManager.getConnection (urlForConnection, userName, password);
 
71
        
 
72
        st1=con.createStatement(ResultSet.TYPE_SCROLL_SENSITIVE,ResultSet.CONCUR_READ_ONLY);
 
73
        st2=con.createStatement(ResultSet.TYPE_SCROLL_SENSITIVE,ResultSet.CONCUR_READ_ONLY);
 
74
        st3=con.createStatement(ResultSet.TYPE_SCROLL_SENSITIVE,ResultSet.CONCUR_READ_ONLY);
 
75
                
 
76
        rs1 = st1.executeQuery("SELECT name FROM organisationunit WHERE organisationunitid = "+selectedOrgUnitID);
 
77
        if(rs1.next()) selectedOrgUnitName = rs1.getString(1);       
 
78
                
 
79
        rs2 = st2.executeQuery("SELECT datasetmembers.dataelementid,dataelement.name FROM datasetmembers INNER JOIN dataelement ON datasetmembers.dataelementid = dataelement.dataelementid WHERE datasetmembers.datasetid = "+seletedDataSetID);
 
80
        while(rs2.next()) 
 
81
        {
 
82
                        String temp1 = ""+rs2.getInt(1);
 
83
                        String temp2 = rs2.getString(2);
 
84
                htForDataSetMembers.put(temp1,temp2);
 
85
        }// while block end
 
86
 
 
87
        rs3 = st3.executeQuery("SELECT periodid FROM period WHERE startdate LIKE '"+startingDate+"' AND periodtypeid = "+periodTypeID);
 
88
        if(rs3.next()) selectedPeriodID = rs3.getInt(1);
 
89
                                                                                                                
 
90
     } //try block end
 
91
     catch(Exception e)  { out.println(e.getMessage());  }                                    
 
92
          
 
93
%>
 
94
 
 
95
 
 
96
<html>
 
97
        <head>
 
98
                <title>SUBCENTRE PHC PROFILE</title>
 
99
                <script src="../dhis-web-reports/Jharkhand/JDENamesForSCPHCProFile.js" type="text/javascript" language="Javascript"></script>
 
100
                <script>
 
101
                        function onLoadFun()
 
102
                        {
 
103
                                var start = 0;
 
104
                                var end = 129; 
 
105
                                while(start < end)
 
106
                                {       
 
107
                                        id="cell1"+start;                                 
 
108
                                        document.getElementById(id).innerHTML = slnoForSCPHCProfile[start];
 
109
                                        id="cell2"+start;                                 
 
110
                                        document.getElementById(id).innerHTML = denamesForSCPHCProfile[start];
 
111
                                                 
 
112
                                        start++;
 
113
                                }
 
114
                        }
 
115
                </script>               
 
116
        </head>
 
117
        <body onload="onLoadFun()">             
 
118
                <center> 
 
119
                <FONT face="Arial" size="3"><b><u>Performa for Sub-centers on IPHS</u></font>
 
120
                </center>
 
121
                <br>                        
 
122
                <table cellpadding="0" cellspacing="0" bgcolor="ffffff" align="left" style="border-style:solid; border-width:0; border-collapse: collapse; padding: 0; position:relative; top:10" bordercolor="#ffffff" width="100%"  border="0">
 
123
                        <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%">
 
124
                        <td width="75%" align="left">
 
125
                                <font face="Arial" size="2"><b>SC Name : <%=selectedOrgUnitName%></b></font>
 
126
                                </td>
 
127
                                <td width="25%" align="right">
 
128
                                <font face="Arial" size="2"><b>Year : <%=partsOfDataPeriodStartDate[0]%></b></font>
 
129
                                </td>   
 
130
                        </tr>                                           
 
131
                </table>
 
132
                <br><br>
 
133
                <table style="border-collapse: collapse; padding: 0;"  width="100%"  border="1">
 
134
                        <tr>
 
135
                                <td width="3%" align="center">
 
136
                                <font face="Arial" size="3"><b>Sl. No.</b></font>
 
137
                                </td>
 
138
                        <td width="57%" align="center">
 
139
                                <font face="Arial" size="3"><b>Service</b></font>
 
140
                                </td>
 
141
                                <td width="40%" align="center" colspan="6">
 
142
                                <font face="Arial" size="3"><b>Value</b></font>
 
143
                                </td>   
 
144
                        </tr>                   
 
145
                
 
146
                
 
147
<%
 
148
 
 
149
     try
 
150
     {                          
 
151
        pst = con.prepareStatement("SELECT value FROM datavalue WHERE sourceid = ? AND periodid = ? AND dataelementid = ?");
 
152
        int count = 0;
 
153
        int count1 = 0;
 
154
        while(count1 < 130)
 
155
        {
 
156
                String id1="cell1"+count1;
 
157
                String id2="cell2"+count1;
 
158
                
 
159
                
 
160
                        if( (count1 >=0 && count1 <=42) || (count1 >=47 && count1 <=86) || (count1==90) || (count1==99) || (count1==102))
 
161
                        {
 
162
                        pst.setInt(1,selectedOrgUnitID);
 
163
                        pst.setInt(2,selectedPeriodID);
 
164
                        pst.setInt(3,dataElementIDs[count++]);
 
165
                
 
166
                                rs4 = pst.executeQuery();       
 
167
                        if(rs4.next()) dataValue[0] = rs4.getString(1);
 
168
                        else dataValue[0] = "";
 
169
                        if(dataValue[0] == null) dataValue[0] = "";
 
170
 
 
171
//dataValue[0] = ""+dataElementIDs[count-1];
 
172
                        %>
 
173
                        <tr>
 
174
                                <td width="3%" align="center" id="<%=id1%>" name="<%=id1%>"></td>
 
175
                                <td width="57%" align="left" id="<%=id2%>" name="<%=id2%>"></td>
 
176
                                        <td width="40%" align="center" colspan="6"><font face="Arial" size="2"><%=dataValue[0]%></font>&nbsp;</td>   
 
177
                                </tr>                   
 
178
                                <%                              
 
179
                        }// if end
 
180
                        else if(count1 >=100 && count1 <=101 )  
 
181
                        {                               
 
182
                                if(count1 == 100)
 
183
                                {
 
184
                                        dataValue[0] = "<b>Other Drugs available</b>";
 
185
                                        dataValue[1] = "<b>Remarks / Suggestions / Identified</b>";                                     
 
186
                                }
 
187
                                else
 
188
                                {
 
189
                                        pst.setInt(1,selectedOrgUnitID);
 
190
                                pst.setInt(2,selectedPeriodID);
 
191
                                pst.setInt(3,dataElementIDs[count++]);                  
 
192
                                        rs4 = pst.executeQuery();       
 
193
                                if(rs4.next()) dataValue[0] = rs4.getString(1);
 
194
                                else dataValue[0] = "";
 
195
                                if(dataValue[0] == null) dataValue[0] = ""; 
 
196
//dataValue[0] = ""+dataElementIDs[count-1];
 
197
                        
 
198
                                        pst.setInt(1,selectedOrgUnitID);
 
199
                                pst.setInt(2,selectedPeriodID);
 
200
                                pst.setInt(3,dataElementIDs[count++]);                  
 
201
                                        rs4 = pst.executeQuery();       
 
202
                                if(rs4.next()) dataValue[1] = rs4.getString(1);
 
203
                                else dataValue[1] = "";
 
204
                                if(dataValue[1] == null) dataValue[1] = ""; 
 
205
//dataValue[1] = ""+dataElementIDs[count-1];
 
206
                                
 
207
                }
 
208
                        %>
 
209
                        <tr>
 
210
                                <td width="3%" align="center" id="<%=id1%>" name="<%=id1%>"></td>
 
211
                                <td width="57%" align="left" id="<%=id2%>" name="<%=id2%>"></td>
 
212
                                        <td width="20%" align="center" colspan="3"><font face="Arial" size="2"><%=dataValue[0]%></font>&nbsp;</td>
 
213
                                        <td width="20%" align="center" colspan="3"><font face="Arial" size="2"><%=dataValue[1]%></font>&nbsp;</td>   
 
214
                                </tr>                   
 
215
                                <%                              
 
216
                        }
 
217
                        else if( (count1 >=87 && count1 <=89) || (count1 >=91 && count1 <=98) || (count1 >=103 && count1 <=128) )       
 
218
                        {
 
219
                                if(count1 == 87)
 
220
                                {
 
221
                                        dataValue[0] = "<b>Current Availability at S/c</b>";
 
222
                                        dataValue[1] = "<b>If available, area in Sq.mts</b>";
 
223
                                        dataValue[2] = "<b>If available, whether staff staying or not</b>";                             
 
224
                                }
 
225
                                else if(count1 == 91)
 
226
                                {
 
227
                                        dataValue[0] = "<b>Available</b>";
 
228
                                        dataValue[1] = "<b>Functional</b>";
 
229
                                        dataValue[2] = "<b>Remarks / Suggestions / identified gaps</b>";                                
 
230
                                } 
 
231
                                else if(count1 == 103)
 
232
                                {
 
233
                                        dataValue[0] = "<b>Current availability at s/c</b>";
 
234
                                        dataValue[1] = "<b>If available numbers</b>";
 
235
                                        dataValue[2] = "<b>Remarks / Suggestions / Identified gaps</b>";                                
 
236
                                } 
 
237
                                else 
 
238
                                {
 
239
                                        pst.setInt(1,selectedOrgUnitID);
 
240
                                pst.setInt(2,selectedPeriodID);
 
241
                                pst.setInt(3,dataElementIDs[count++]);                  
 
242
                                        rs4 = pst.executeQuery();       
 
243
                                if(rs4.next()) dataValue[0] = rs4.getString(1);
 
244
                                else dataValue[0] = "";
 
245
                                if(dataValue[0] == null) dataValue[0] = ""; 
 
246
//dataValue[0] = ""+dataElementIDs[count-1];
 
247
                                
 
248
                        
 
249
                                        pst.setInt(1,selectedOrgUnitID);
 
250
                                pst.setInt(2,selectedPeriodID);
 
251
                                pst.setInt(3,dataElementIDs[count++]);                  
 
252
                                        rs4 = pst.executeQuery();       
 
253
                                if(rs4.next()) dataValue[1] = rs4.getString(1);
 
254
                                else dataValue[1] = "";
 
255
                                if(dataValue[1] == null) dataValue[1] = ""; 
 
256
 
 
257
//dataValue[1] = ""+dataElementIDs[count-1];
 
258
                        
 
259
                                pst.setInt(1,selectedOrgUnitID);
 
260
                                pst.setInt(2,selectedPeriodID);
 
261
                                pst.setInt(3,dataElementIDs[count++]);                  
 
262
                                        rs4 = pst.executeQuery();       
 
263
                                if(rs4.next()) dataValue[2] = rs4.getString(1);
 
264
                                else dataValue[2] = "";
 
265
                                if(dataValue[2] == null) dataValue[2] = "";               
 
266
//dataValue[2] = ""+dataElementIDs[count-1];
 
267
                                
 
268
                        }       
 
269
                        %>
 
270
                        <tr>
 
271
                                <td width="3%" align="center" id="<%=id1%>" name="<%=id1%>"></td>
 
272
                                <td width="57%" align="left" id="<%=id2%>" name="<%=id2%>"></td>
 
273
                                        <td width="10%" align="center" colspan="2"><font face="Arial" size="2"><%=dataValue[0]%></font>&nbsp;</td>
 
274
                                        <td width="10%" align="center" colspan="2"><font face="Arial" size="2"><%=dataValue[1]%></font>&nbsp;</td>
 
275
                                        <td width="10%" align="center" colspan="2"><font face="Arial" size="2"><%=dataValue[2]%></font>&nbsp;</td>   
 
276
                                </tr>                   
 
277
                                <%                              
 
278
                        }
 
279
                        else if(count1 >=43 && count1 <=46 )    
 
280
                        {
 
281
                                
 
282
                                if(count1 == 43)
 
283
                                {
 
284
                                        dataValue[0] = "<b>Existing/Sctioned</b>";
 
285
                                        dataValue[1] = "<b>Recommended</b>";
 
286
                                        dataValue[2] = "<b>Current availability at S/C</b>";
 
287
                                        dataValue[3] = "<b>Remarks / Suggestion Identified Gaps</b>";
 
288
                                } 
 
289
                                else 
 
290
                                {
 
291
                                        pst.setInt(1,selectedOrgUnitID);
 
292
                                pst.setInt(2,selectedPeriodID);
 
293
                                pst.setInt(3,dataElementIDs[count++]);                  
 
294
                                        rs4 = pst.executeQuery();       
 
295
                                if(rs4.next()) dataValue[0] = rs4.getString(1);
 
296
                                else dataValue[0] = "";
 
297
                                if(dataValue[0] == null) dataValue[0] = ""; 
 
298
//dataValue[0] = ""+dataElementIDs[count-1];
 
299
                                
 
300
                        
 
301
                                        pst.setInt(1,selectedOrgUnitID);
 
302
                                pst.setInt(2,selectedPeriodID);
 
303
                                pst.setInt(3,dataElementIDs[count++]);                  
 
304
                                        rs4 = pst.executeQuery();       
 
305
                                if(rs4.next()) dataValue[1] = rs4.getString(1);
 
306
                                else dataValue[1] = "";
 
307
                                if(dataValue[1] == null) dataValue[1] = ""; 
 
308
//dataValue[1] = ""+dataElementIDs[count-1];
 
309
                                
 
310
                        
 
311
                                pst.setInt(1,selectedOrgUnitID);
 
312
                                pst.setInt(2,selectedPeriodID);
 
313
                                pst.setInt(3,dataElementIDs[count++]);                  
 
314
                                        rs4 = pst.executeQuery();       
 
315
                                if(rs4.next()) dataValue[2] = rs4.getString(1);
 
316
                                else dataValue[2] = "";
 
317
                                if(dataValue[2] == null) dataValue[2] = "";               
 
318
//dataValue[2] = ""+dataElementIDs[count-1];
 
319
                                
 
320
                        
 
321
                                pst.setInt(1,selectedOrgUnitID);
 
322
                                pst.setInt(2,selectedPeriodID);
 
323
                                pst.setInt(3,dataElementIDs[count++]);                  
 
324
                                        rs4 = pst.executeQuery();       
 
325
                                if(rs4.next()) dataValue[3] = rs4.getString(1);
 
326
                                else dataValue[3] = "";
 
327
                                if(dataValue[3] == null) dataValue[3] = "";
 
328
//dataValue[3] = ""+dataElementIDs[count-1];
 
329
                                
 
330
                        }
 
331
                        %>
 
332
                        <tr>
 
333
                                <td width="3%" align="center" id="<%=id1%>" name="<%=id1%>"></td>
 
334
                                <td width="57%" align="left" id="<%=id2%>" name="<%=id2%>"></td>
 
335
                                        <td width="10%" align="center" ><font face="Arial" size="2"><%=dataValue[0]%></font>&nbsp;</td>
 
336
                                        <td width="10%" align="center" colspan="2"><font face="Arial" size="2"><%=dataValue[1]%></font>&nbsp;</td>
 
337
                                        <td width="10%" align="center" colspan="2"><font face="Arial" size="2"><%=dataValue[2]%></font>&nbsp;</td>
 
338
                                        <td width="10%" align="center" ><font face="Arial" size="2"><%=dataValue[3]%></font>&nbsp;</td>   
 
339
                                </tr>                   
 
340
                                <%                              
 
341
                        }
 
342
 
 
343
                        count1++;
 
344
        }// while block end
 
345
     } //try block end
 
346
     catch(Exception e)  { out.println(e.getMessage());  }                                 
 
347
     finally
 
348
     {
 
349
                try
 
350
                {
 
351
                        if(st1 != null) st1.close();            if(rs1 != null) rs1.close();
 
352
                        if(st2 != null) st2.close();            if(rs2 != null) rs2.close();
 
353
                        if(st3 != null) st3.close();            if(rs3 != null) rs3.close();    
 
354
                        if(pst != null) pst.close();            if(rs4 != null) rs4.close();
 
355
                                
 
356
                        if(con!=null)  con.close(); 
 
357
                }
 
358
                catch(Exception e)   {  out.println(e.getMessage());   }
 
359
     } // finally block end            
 
360
%>                          
 
361
                </table>
 
362
        </body> 
 
363
</html>
 
 
b'\\ No newline at end of file'