Changeset 1683


Ignore:
Timestamp:
Jun 1, 2012, 3:35:49 PM (11 years ago)
Author:
Nicklas Nordborg
Message:

References #371: Wizard that move histology samples to paraffin blocks

This wizard has been changed to start with a 'Histology working list' instead of a bioplate.

Location:
extensions/net.sf.basedb.reggie/trunk
Files:
2 edited
1 moved

Legend:

Unmodified
Added
Removed
  • extensions/net.sf.basedb.reggie/trunk/resources/histology_block.jsp

    r1668 r1683  
    3131
    3232<script language="JavaScript">
    33 var debug = false;
     33var debug = true;
    3434var currentStep = 1;
    3535var moveDateIsValid = false;
     
    3838{
    3939  var frm = document.forms['reggie'];
    40 
    41   var plates = getHistologyPlates();
    42  
    43   var plateList = frm.plates;
    44   if (plates != null && plates.length > 0)
    45   {
    46     for (var i=0; i < plates.length; i++)
    47     {
    48       var plate = plates[i];
    49       var option = new Option(plate.name + ' -- ' + plate.usedWells + ' used wells', plate.id);
    50       option.plate = plate;
    51       plateList.options[plateList.length] = option;
    52     }
     40  var workLists = getHistologyWorkLists();
     41 
     42  var workList = frm.workList;
     43  if (workLists != null && workLists.length > 0)
     44  {
     45    for (var i=0; i < workLists.length; i++)
     46    {
     47      var list = workLists[i];
     48      var name = list.name + ' (' + list.size + ')';
     49      var option = new Option(name, list.id);
     50      workList.options[workList.length] = option;
     51    }
     52    workListIsValid = true;
    5353    moveDateOnChange();
    5454    Main.show('gocreate');
    5555  }
    5656  else
    57   { 
    58     setFatalError('No Histology plates with at least 5 samples could be found.');
    59   }
    60 }
    61 
    62 function getHistologyPlates()
     57  {
     58    setInputStatus('workList', 'No Histology work lists available for processing.', 'invalid');
     59  }
     60}
     61
     62function getHistologyWorkLists()
    6363{
    6464  var frm = document.forms['reggie'];
     
    6767  try
    6868  {
    69     showLoadingAnimation('Loading histology plates...');
    70     var url = 'Histology.servlet?ID=<%=ID%>&cmd=GetHistologyPlates';   
     69    showLoadingAnimation('Loading histology work lists...');
     70    var url = 'Histology.servlet?ID=<%=ID%>&cmd=GetHistologyWorkLists';   
    7171    request.open("GET", url, false); 
    7272    request.send(null);
     
    8484    return false;
    8585  }
    86   return response.plates;
     86  return response.workLists;
    8787}
    8888
     
    131131  Main.hide('gocreate');
    132132
    133   var plateId = frm.plates[frm.plates.selectedIndex].value;
     133  var listId = frm.workList[frm.workList.selectedIndex].value;
    134134  var request = Ajax.getXmlHttpRequest();
    135135  try
    136136  {
    137137    showLoadingAnimation('Moving histology samples to paraffin blocks...');
    138     var url = 'Histology.servlet?ID=<%=ID%>&cmd=MoveHistologySamplesToParaffinBlocks&plateId='+plateId;
     138    var url = 'Histology.servlet?ID=<%=ID%>&cmd=MoveHistologySamplesToParaffinBlocks&workListId='+listId;
    139139    url += '&moveDate=' + frm.moveDate.value;
    140140    request.open("POST", url, false);
     
    171171  Main.show('done');
    172172  Main.show('gorestart');
    173  
    174   var blocks = response.paraffinBlocks;
    175   if (blocks && blocks.length > 0)
    176   {
    177     var printFrm = document.forms['print'];
    178     for (var i = 0; i < blocks.length; i++)
    179     {
    180       Forms.createHidden(printFrm, 'plates', blocks[i].id);
    181     }
    182     Main.show('goprint');
    183   }
    184  
    185 }
    186 
    187 function goPrint()
    188 {
    189   var printFrm = document.forms['print'];
    190   printFrm.submit();
    191173}
    192174
     
    205187  else
    206188  {
    207     // Auto-fill the date if it's only given with 4(MMdd) or 6(yyMMdd) digits.   
     189    // Auto-fill the date if it's only given with 4(MMdd) or 6(yyMMdd) digits.
    208190    moveDate = autoFillDate(moveDate);
    209191    frm.moveDate.value = moveDate;
     
    228210  <p:path><p:pathelement
    229211    title="Reggie" href="<%="index.jsp?ID="+ID%>"
    230     /><p:pathelement title="Move Histology samples to paraffin blocks"
     212    /><p:pathelement title="Register paraffin blocks"
    231213    /></p:path>
    232214
     
    246228  <form name="reggie" onsubmit="return false;">
    247229 
    248   <!-- 1. Case name-->
    249   <table border="0" cellspacing="0" cellpadding="0" class="stepform">
     230  <table class="stepform">
    250231  <tr>
    251232    <td rowspan="3" class="stepno">1</td>
     
    254235  <tr>
    255236    <td class="stepfields">
    256       <table border="0" cellspacing="0" cellpadding="0" width="100%">
     237      <table width="100%">
    257238      <tr valign="top">
    258         <td class="prompt">Histology plate</td>
    259         <td class="input"><select style="width:90%" name="plates" id="plates"></select>
    260         </td>
    261         <td class="status" id="plate.status"></td>
    262         <td class="help"><span id="plate.message" class="message" style="display: none;"></span>
    263           The list contain all Histology plates with at least 5 samples on it.
     239        <td class="prompt">Histology work list</td>
     240        <td class="input"><select style="width:90%"
     241            name="workList" id="workList"
     242            onchange="histologyOnChange()"></select>
     243        </td>
     244        <td class="status" id="workList.status"></td>
     245        <td class="help"><span id="workList.message" class="message" style="display: none;"></span>
     246          Select an existing histology work list.
    264247        </td>
    265248      </tr>
    266249      <tr valign="top">
    267250        <td class="prompt">Date</td>
    268         <td class="input" style="padding-left: 0px;">
     251        <td class="input">
    269252          <input type="text" name="moveDate" value="<%=today%>" size="12" maxlength="10"
    270253            onblur="moveDateOnChange()">
     
    292275      <td><base:button id="gocreate" title="Finish" image="<%=home+"/images/gonext.png"%>" onclick="goCreate()" style="display: none;"/></td>
    293276      <td><base:button id="gorestart" title="Restart" image="<%=home+"/images/goback.png"%>" onclick="goRestart(true)" style="display: none;"/></td>
    294       <td><base:button id="goprint" title="Create/print lab tracking protocol" image="<%=home+"/images/print.png"%>" onclick="goPrint()" style="display: none;"/></td>
    295277      <td id="gonext.message" class="message"></td>
    296278    </tr>
    297279  </table>
    298280  </form>
    299  
    300   <form name="print" action="histology_protocol2.jsp?ID=<%=ID%>" method="post" target="_new">
    301   </form>
    302281  </div>
    303282 
  • extensions/net.sf.basedb.reggie/trunk/resources/index.jsp

    r1669 r1683  
    222222            <ul>
    223223            <li><a href="histology_protocol.jsp?ID=<%=ID%>">Lab tracking protocol for FFPE/HE</a>
    224             <li><a href="histology_move.jsp?ID=<%=ID%>">Move Histology items to paraffin blocks</a>
     224            <li><a href="histology_block.jsp?ID=<%=ID%>">Register paraffin blocks</a>
    225225            <li><a href="histology_glass.jsp?ID=<%=ID%>">Register histology HE glass information</a>
    226226            </ul>
  • extensions/net.sf.basedb.reggie/trunk/src/net/sf/basedb/reggie/servlet/HistologyServlet.java

    r1681 r1683  
    269269      else if ("MoveHistologySamplesToParaffinBlocks".equals(cmd))
    270270      {
    271         int plateId = Values.getInt(req.getParameter("plateId"));
     271        int workListId = Values.getInt(req.getParameter("workListId"));
    272272        Date moveDate = Reggie.CONVERTER_STRING_TO_DATE.convert(req.getParameter("moveDate"));
    273273       
    274274        dc = sc.newDbControl();
    275275       
    276         BioPlate plate = BioPlate.getById(dc, plateId);
    277        
    278         BioPlateEvent moveEvent = BioPlateEvent.getNew(dc, BioPlateEventType.getById(dc, BioPlateEventType.MOVE));
    279         moveEvent.setEventDate(moveDate);
    280         moveEvent.setName("Move Histology to paraffin blocks");
    281         dc.saveItem(moveEvent);
    282         BioPlateEventParticipant source = moveEvent.addParticipant(plate, "source", 1);
    283         dc.saveItem(source);
    284        
    285         ItemQuery<BioWell> query = plate.getBioWells();
    286         query.order(Orders.asc(Hql.property("row")));
    287         query.order(Orders.asc(Hql.property("column")));
     276        BioMaterialList workList = BioMaterialList.getById(dc, workListId);
     277       
     278        BioPlateEvent placeEvent = BioPlateEvent.getNew(dc, BioPlateEventType.getById(dc, BioPlateEventType.PLACE_ON_PLATE));
     279        placeEvent.setEventDate(moveDate);
     280        placeEvent.setName("Place Histology item on paraffin blocks");
     281        dc.saveItem(placeEvent);
     282
     283        ItemQuery<Sample> query = (ItemQuery<Sample>)workList.getMemberBioMaterials();
     284       
     285        // Join the creation event and bioplate
     286        query.join(Hql.innerJoin(null, "creationEvent", "ce", true));
     287        query.join(Hql.leftJoin(null, "bioWell", "bw", null, true));
     288        query.join(Hql.leftJoin("bw", "bioPlate", "bp", null, true));
     289       
     290        // Sort by bioplate position -- those without plate are sorted last by id
     291        query.order(Orders.asc(Hql.expression("coalesce(bp.name, 'zzzz')", null)));
     292        query.order(Orders.asc(Hql.property("bw", "row")));
     293        query.order(Orders.asc(Hql.property("bw", "column")));
     294        query.order(Orders.asc(Hql.property("id")));
    288295       
    289296        // Store the biomaterial on the plate in a temporary list
    290         List<MeasuredBioMaterial> allBioMaterial = new ArrayList<MeasuredBioMaterial>(plate.getUsedWells());
    291         for (BioWell well : query.list(dc))
    292         {
    293           MeasuredBioMaterial bm = well.getBioMaterial();
    294           if (bm != null) allBioMaterial.add(bm);
    295         }
    296 
    297         int numParaffinBlocks = allBioMaterial.size() / 5;
    298         int bmIndex = 0;
     297        List<Sample> allBioMaterial = query.list(dc);
     298
    299299        PlateCoordinate[] moveTo = new PlateCoordinate[]
    300           {
    301             new PlateCoordinate(2, 0), new PlateCoordinate(1, 0), new PlateCoordinate(0, 0),
    302             new PlateCoordinate(2, 1), new PlateCoordinate(1, 1)
    303           }; // We fill each block C1, B1, A1, C2, B2 (A2 is left empty)
    304         BioPlate[] paraffinBlocks = new BioPlate[numParaffinBlocks];
    305         for (int index = 1; index <= numParaffinBlocks; ++index)
    306         {
    307           // Create a new paraffin block
    308           PlateGeometry geometry = BioplateType.PARAFFIN_BLOCK.getPlateGeometry(dc);
    309           BioPlateType paraffinBlockType = BioplateType.PARAFFIN_BLOCK.load(dc);
     300            {
     301              new PlateCoordinate(2, 0), new PlateCoordinate(1, 0), new PlateCoordinate(0, 0),
     302              new PlateCoordinate(2, 1), new PlateCoordinate(1, 1)
     303            }; // We fill each block C1, B1, A1, C2, B2 (A2 is left empty)
     304       
     305       
     306        PlateGeometry geometry = BioplateType.PARAFFIN_BLOCK.getPlateGeometry(dc);
     307        BioPlateType paraffinBlockType = BioplateType.PARAFFIN_BLOCK.load(dc);
     308       
     309        BioPlate paraffinBlock = null;
     310        BioPlateEventParticipant blockEvent = null;
     311        int blockPos = 5; // Start outside trigger creation of a new paraffin block
     312        int blockNo = 0;
     313        List<BioPlate> paraffinBlocks = new ArrayList<BioPlate>(allBioMaterial.size() / 5);
     314
     315        for (Sample his : allBioMaterial)
     316        {
     317          if (blockPos == 5)
     318          {
     319            blockPos = 0;
     320            blockNo++;
     321            paraffinBlock = BioPlate.getNew(dc, geometry, paraffinBlockType);
     322            paraffinBlocks.add(paraffinBlock);
     323            paraffinBlock.setEventDate(moveDate);
     324            paraffinBlock.setName(BioplateType.PARAFFIN_BLOCK.generateNextName(dc, blockNo));
     325            dc.saveItem(paraffinBlock);
     326           
     327            // Attach the new paraffin block to the MOVE event
     328            blockEvent = placeEvent.addParticipant(paraffinBlock, "destination", blockNo);
     329            dc.saveItem(blockEvent);
     330           
     331            jsonMessages.add("Created '" + paraffinBlock.getName() + "'");
     332          }
    310333         
    311           BioPlate paraffinBlock = BioPlate.getNew(dc, geometry, paraffinBlockType);
    312           paraffinBlocks[index-1] = paraffinBlock;
    313           paraffinBlock.setEventDate(moveDate);
    314           paraffinBlock.setName(BioplateType.PARAFFIN_BLOCK.generateNextName(dc, index));
    315           dc.saveItem(paraffinBlock);
    316          
    317           // Attach the new paraffin block to the MOVE event
    318           BioPlateEventParticipant dest = moveEvent.addParticipant(paraffinBlock, "destination", index);
    319           dc.saveItem(dest);
    320          
    321           // Move 5 biomaterial items to the new paraffin block
    322           StringBuilder usedWells = new StringBuilder();
    323           for (int pos = 0; pos < 5; ++pos)
    324           {
    325             MeasuredBioMaterial bm = allBioMaterial.get(bmIndex);
    326             String currentWell = bm.getBioWell().getCoordinate();
    327             bmIndex++;
    328             // Move the biomaterial
    329             bm.setBioWell(paraffinBlock.getBioWell(moveTo[pos]));
    330             // Register an event for it
    331             BioMaterialEvent bmEvent = bm.newEvent(dest);
    332             bmEvent.setComment("Moved from " + currentWell + " on '" +plate.getName() + "'.");
    333             dc.saveItem(bmEvent);
    334            
    335             if (pos > 0) usedWells.append(", ");
    336             usedWells.append(currentWell);
    337           }
    338          
    339           jsonMessages.add("Created '" + paraffinBlock.getName() + "' with biomaterial from " + usedWells);
    340         }
    341        
    342         if (bmIndex == allBioMaterial.size())
    343         {
    344           jsonMessages.add("No samples left on plate '" + plate.getName() + "'");
    345         }
    346         else
    347         {
    348           int numLeft = allBioMaterial.size() - bmIndex;
    349           String warning = numLeft == 1 ? "There is 1 sample" : "There are " +  numLeft + " samples";
    350           jsonMessages.add("[Warning] " + warning + " left on plate '" + plate.getName() + "'");
     334          // Move the biomaterial -- keep track of the old location for message
     335          BioWell oldWell = his.getBioWell();
     336          his.setBioWell(paraffinBlock.getBioWell(moveTo[blockPos]));
     337          // Register an event for it
     338          BioMaterialEvent bmEvent = his.newEvent(blockEvent);
     339          if (oldWell != null)
     340          {
     341            bmEvent.setComment("Moved from " + oldWell.getCoordinate() + " on '" +oldWell.getPlate().getName() + "'.");
     342          }
     343          dc.saveItem(bmEvent);
     344          blockPos++;
    351345        }
    352346       
     
    363357       
    364358        json.put("paraffinBlocks", jsonParaffinBlocks);
    365 
    366359      }
    367360     
Note: See TracChangeset for help on using the changeset viewer.