source: extensions/net.sf.basedb.reggie/trunk/resources/histology_protocol2.jsp @ 1778

Last change on this file since 1778 was 1778, checked in by Nicklas Nordborg, 7 years ago

Fixes #447: The HE glass registration wizard should have a field for the number of slides

Also changed the default number of print labels from 5 to 3 since more than 3 is almost never needed. The most common number of slides are 2 so this is the default in the HE glass registration wizard.

File size: 7.3 KB
Line 
1<%@ page
2  pageEncoding="UTF-8"
3  session="false"
4  import="net.sf.basedb.core.User"
5  import="net.sf.basedb.core.DbControl"
6  import="net.sf.basedb.core.SessionControl"
7  import="net.sf.basedb.core.Application"
8  import="net.sf.basedb.core.Sample"
9  import="net.sf.basedb.core.BioMaterialList"
10  import="net.sf.basedb.core.BioWell"
11  import="net.sf.basedb.core.BioPlate"
12  import="net.sf.basedb.core.AnyToAny"
13  import="net.sf.basedb.core.ItemQuery"
14  import="net.sf.basedb.core.PermissionDeniedException"
15  import="net.sf.basedb.core.query.Hql"
16  import="net.sf.basedb.core.query.Orders"
17  import="net.sf.basedb.util.Values"
18  import="net.sf.basedb.util.extensions.Extension"
19  import="net.sf.basedb.clients.web.Base" 
20  import="net.sf.basedb.clients.web.util.HTML"
21  import="net.sf.basedb.clients.web.extensions.ExtensionsControl"
22  import="java.util.List"
23  import="java.util.ArrayList"
24%>
25<%!
26String getSampleForLocation(List<Sample> samples, int offset, int position)
27{
28  String name = "<i>empty</i>";
29  int index = offset + position - 1;
30  if (index < samples.size())
31  {
32    Sample s = samples.get(index);
33    name = "<b>" + HTML.encodeTags(s.getName()) + "</b>";
34    try
35    {
36      BioWell well = s.getBioWell();
37      if (well != null)
38      {
39        BioPlate plate = well.getPlate();
40        name += " [" + plate.getName() + " " + well.getCoordinate() + "]";
41      }
42    }
43    catch (PermissionDeniedException ex)
44    {}
45  }
46  return name;
47}
48%>
49<%
50final SessionControl sc = Base.getExistingSessionControl(request, true);
51final String ID = sc.getId();
52final float scale = Base.getScale(sc);
53final String home = ExtensionsControl.getHomeUrl("net.sf.basedb.reggie");
54final String root = request.getContextPath();
55final int BLOCKS_PER_PAGE = 3;
56final int SAMPLES_PER_BLOCK = 5;
57DbControl dc = null;
58try
59{
60  dc = sc.newDbControl();
61  final Extension reggie = ExtensionsControl.get(dc).getExtension("net.sf.basedb.reggie");
62  final User user = User.getById(dc, sc.getLoggedInUserId());
63  final int listId = Values.getInt(request.getParameter("workList"));
64  BioMaterialList workList = BioMaterialList.getById(dc, listId);
65 
66  ItemQuery<Sample> query = (ItemQuery<Sample>)workList.getMemberBioMaterials();
67 
68  query.join(Hql.leftJoin(null, "bioWell", "bw", null, true));
69  query.join(Hql.leftJoin("bw", "bioPlate", "bp", null, true));
70 
71  // Sort by bioplate position
72  query.order(Orders.asc(Hql.expression("coalesce(bp.name, 'zzzz')", null)));
73  query.order(Orders.asc(Hql.property("bw", "row")));
74  query.order(Orders.asc(Hql.property("bw", "column")));
75  query.order(Orders.asc(Hql.property("id")));
76
77  List<Sample> histology = query.list(dc);
78 
79  int totalBlocks = 1 + (histology.size()-1) / SAMPLES_PER_BLOCK;
80  int totalPages = 1 + (totalBlocks-1) / BLOCKS_PER_PAGE;
81%>
82<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
83<html>
84<head>
85  <title>Lab tracking protocol for FFPE/HE</title>
86  <link rel="SHORTCUT ICON" href="<%=home%>/images/microscope.png">
87  <link rel="stylesheet" type="text/css" href="<%=home %>/css/printable.css">
88  <script language="JavaScript" src="<%=root %>/include/scripts/main.js" type="text/javascript" charset="UTF-8"></script>
89  <script language="JavaScript" src="<%=root %>/include/scripts/ajax.js" type="text/javascript" charset="UTF-8"></script>
90
91  <style>
92  table.protocolheader
93  {
94    width: 100%;
95  }
96 
97  table.protocolheader > tbody > tr
98  {
99    height: 2em;
100  }
101
102  table.protocolheader > tbody > tr > th, table.protocolheader > tbody > tr > td b
103  {
104    text-align: left;
105    font-size: 1.25em;
106  }
107 
108  div.paraffinblock
109  {
110    margin-top: 1em;
111    margin-bottom: 2em;
112    height: 6.5cm;
113  }
114 
115  div.paraffinblock .title
116  {
117    font-size: 1.2em;
118    margin-bottom: 0.5em;
119  }
120 
121  div.paraffinblock > table
122  {
123    width: 100%;
124    height: 5.5cm;
125    border-collapse: collapse;
126    border: 1px solid #000000;
127  }
128 
129  div.paraffinblock > table > tbody > tr > td
130  {
131    vertical-align: top;
132    border: 1px solid #000000;
133    padding: 2px;
134    width: 50%;
135  }
136 
137  div.entryform
138  {
139    margin-left: 0.5em;
140    margin-right: 1em;
141    border: 1px solid #000000;
142    height: 2em;
143  }
144  </style>
145 
146  <script>
147  function downloadHEGlassLabels()
148  {
149    var numLabelsPerBlock = prompt('Number of labels per block?', 3);
150    if (numLabelsPerBlock == null) return;
151   
152    if (!parseInt(numLabelsPerBlock, 10))
153    {
154      alert('"' + numLabelsPerBlock + '" is not a valid number');
155      return;
156    }
157   
158    var url = 'Histology.servlet?ID=<%=ID%>&cmd=DownloadHEGlassLabels';
159    url += '&workListId=<%=listId%>';
160    url += '&numSlides=' + parseInt(numLabelsPerBlock, 10);
161   
162    location.href = url;
163  }
164 
165  </script>
166</head>
167<body>
168  <div class="noprint fullwidth" style="border-bottom: 1px dashed #A0A0A0; padding-left: 1em; padding-bottom: 1em;">
169    <span class="button" onclick="window.print()">
170      <img src="images/print.png">Print&hellip;
171    </span>
172   
173    <span class="button" onclick="downloadHEGlassLabels()" style="margin-left: 2em;">
174      <img src="images/download.png">Download HE glass labels&hellip;
175    </span>
176  </div>
177  <%
178  int pageNo = 0;
179  for (int blockNo = 0; blockNo < totalBlocks; ++blockNo)
180  {
181    AnyToAny link = AnyToAny.getByName(dc, workList, "block."+(blockNo+1));
182    BioPlate block = (BioPlate)link.getTo();
183    int offset = SAMPLES_PER_BLOCK * blockNo;
184    if (blockNo % BLOCKS_PER_PAGE == 0)
185    {
186      pageNo++;
187      %>
188      <div class="<%=blockNo > 0 ? "pagebreak" : ""%>"></div>
189      <h1>Lab tracking protocol for FFPE/HE v.1.0</h1>
190      <table class="protocolheader">
191      <tr>
192        <td colspan="2">Reggie <%=reggie.getAbout().getVersion() %>; Page <%=pageNo %> of <%=totalPages %></td>
193      </tr>
194      <tr>
195        <td colspan="2"><b>Work list:</b> <%=HTML.encodeTags(workList.getName()) %> (<%=workList.getSize() %> samples)</td>
196      </tr>
197      <tr>
198        <th style="width: 50%;">Start date:</th>
199        <th style="width: 50%;">Operator:</th>
200      </tr>
201      </table>
202      <%
203    }
204    %>
205    <div class="paraffinblock">
206      <div class="title">
207        <table style="width: 100%;">
208        <tr>
209          <td style="width: 50%;">
210            <table style="width: 100%;">
211            <tr>
212              <td style="width: 25%; white-space: nowrap;"><b>Block:</b> <%=block.getName() %></td>
213              <td style="width: 75%;"><div class="entryform">&nbsp;</div></td>
214            </tr>
215            </table>
216          </td>
217         
218          <td style="width: 50%;">
219            <table style="width: 100%;">
220            <tr>
221              <td style="width: 25%; white-space: nowrap;"><b>Slides: </b><%=block.getName().replace("PB", "HE") %>.#</td>
222              <td style="width: 75%;"><div class="entryform" style="margin-right: 0em;">&nbsp;</div></td>
223            </tr>
224            </table>
225          </td>
226        </tr>
227        </table>
228      </div>
229      <table>
230        <tr>
231        <td>
232          <b>3</b>: <%=getSampleForLocation(histology, offset, 3) %>
233        </td>
234        <td>
235          <b>6</b>: <i>not used</i>
236        </td>
237        </tr>
238       
239        <tr>
240        <td>
241          <b>2</b>: <%=getSampleForLocation(histology, offset, 2) %>
242        </td>
243        <td>
244          <b>5</b>: <%=getSampleForLocation(histology, offset, 5) %>
245        </td>
246        </tr>
247       
248        <tr>
249        <td>
250          <b>1</b>: <%=getSampleForLocation(histology, offset, 1) %>
251        </td>
252        <td>
253          <b>4</b>: <%=getSampleForLocation(histology, offset, 4) %>
254        </td>
255        </tr>
256      </table>
257    </div>
258    <%
259  }
260  %>
261 
262</body>
263</html>
264<%
265}
266finally
267{
268  if (dc != null) dc.close();
269}
270%>
Note: See TracBrowser for help on using the repository browser.