Changeset 1684


Ignore:
Timestamp:
Jun 4, 2012, 12:47:29 PM (11 years ago)
Author:
Nicklas Nordborg
Message:

References #371 and #372. Create (empty) paraffin block plates at the same time as the work lists are created otherwise the plate names on the lab tracking protocol may not match plate names that would have been generated by the registration wizard.

The registration wizard can now select a protocol (Histology subtype).

Location:
extensions/net.sf.basedb.reggie/trunk
Files:
1 added
8 edited

Legend:

Unmodified
Added
Removed
  • extensions/net.sf.basedb.reggie/trunk/META-INF/servlets.xml

    r1637 r1684  
    4242  </servlet>
    4343  <servlet>
     44    <servlet-name>Protocol</servlet-name>
     45    <servlet-class>net.sf.basedb.reggie.servlet.ProtocolServlet</servlet-class>
     46  </servlet>
     47  <servlet>
    4448    <servlet-name>SampleReport</servlet-name>
    4549    <servlet-class>net.sf.basedb.reggie.servlet.SampleReportServlet</servlet-class>
  • extensions/net.sf.basedb.reggie/trunk/resources/extraction_registration.jsp

    r1660 r1684  
    178178  {
    179179    showLoadingAnimation('Loading ' + subtype + ' protocols...');
    180     var url = 'Extraction.servlet?ID=<%=ID%>&cmd=GetProtocols&subtype='+subtype;   
     180    var url = 'Protocol.servlet?ID=<%=ID%>&cmd=GetProtocols&subtype='+subtype;   
    181181    request.open("GET", url, false); 
    182182    request.send(null);
     
    194194    return false;
    195195  }
    196   return response.protcols;
     196  return response.protocols;
    197197}
    198198
  • extensions/net.sf.basedb.reggie/trunk/resources/histology_block.jsp

    r1683 r1684  
    5858    setInputStatus('workList', 'No Histology work lists available for processing.', 'invalid');
    5959  }
     60 
     61  var histologyProtocols = getProtocols('HISTOLOGY_PROTOCOL');
     62  for (var i = 0; i < histologyProtocols.length; i++)
     63  {
     64    frm.histologyProtocol[frm.histologyProtocol.length] = new Option(histologyProtocols[i].name, histologyProtocols[i].id);   
     65  }
     66  if (frm.histologyProtocol.length == 0)
     67  {
     68    frm.histologyProtocol[0] = new Option('- none -', '');
     69  }
     70
    6071}
    6172
     
    8697  return response.workLists;
    8798}
     99
     100function getProtocols(subtype)
     101{
     102  var request = Ajax.getXmlHttpRequest();
     103  try
     104  {
     105    showLoadingAnimation('Loading ' + subtype + ' protocols...');
     106    var url = 'Protocol.servlet?ID=<%=ID%>&cmd=GetProtocols&subtype='+subtype;   
     107    request.open("GET", url, false); 
     108    request.send(null);
     109  }
     110  finally
     111  {
     112    hideLoadingAnimation();
     113  }
     114
     115  if (debug) Main.debug(request.responseText);
     116  var response = JSON.parse(request.responseText); 
     117  if (response.status != 'ok')
     118  {
     119    setFatalError(response.message);
     120    return false;
     121  }
     122  return response.protocols;
     123}
     124
    88125
    89126function goNextAuto()
     
    138175    var url = 'Histology.servlet?ID=<%=ID%>&cmd=MoveHistologySamplesToParaffinBlocks&workListId='+listId;
    139176    url += '&moveDate=' + frm.moveDate.value;
     177    url += '&protocolId=' + frm.histologyProtocol[frm.histologyProtocol.selectedIndex].value;
    140178    request.open("POST", url, false);
    141179    request.send(null);
     
    231269  <tr>
    232270    <td rowspan="3" class="stepno">1</td>
    233     <td class="steptitle">Select Histology storage plate</td>
     271    <td class="steptitle">Select Histology work list</td>
    234272  </tr>
    235273  <tr>
     
    256294        <td class="help">
    257295          <span id="moveDate.message" class="message" style="display: none;"></span>(YYYYMMDD or MMDD)
     296        </td>
     297      </tr>
     298      <tr valign="top">
     299        <td class="prompt">Protocol</td>
     300        <td class="input"><select style="width:90%" name="histologyProtocol" id="histologyProtocol"
     301          ></select></td>
     302        <td class="status" id="histologyProtocol.status"></td>
     303        <td class="help"><span id="histologyProtocol.message" class="message" style="display: none;"></span>
     304          Select the protocol which was used when embedding the samples.
    258305        </td>
    259306      </tr>
  • extensions/net.sf.basedb.reggie/trunk/resources/histology_protocol2.jsp

    r1682 r1684  
    1010  import="net.sf.basedb.core.BioWell"
    1111  import="net.sf.basedb.core.BioPlate"
     12  import="net.sf.basedb.core.AnyToAny"
    1213  import="net.sf.basedb.core.ItemQuery"
    1314  import="net.sf.basedb.core.PermissionDeniedException"
     
    132133  }
    133134  </style>
    134   <script>
    135  
    136   function init()
    137   {
    138     var request = Ajax.getXmlHttpRequest();
    139     var url = 'Histology.servlet?ID=<%=ID%>&cmd=GetNextParaffinBlockNames&numNames=<%=totalBlocks%>';   
    140     request.open("GET", url, false); 
    141     request.send(null);
    142    
    143     var response = JSON.parse(request.responseText); 
    144     if (response.status != 'ok')
    145     {
    146       setFatalError(response.message);
    147       return false;
    148     }
    149    
    150     var names = response.names;
    151     for (var i = 0; i < names.length; i++)
    152     {
    153       document.getElementById('blockname.'+i).innerHTML = names[i];
    154     }
    155   }
    156   </script>
    157135</head>
    158 <body onload="init()">
     136<body>
    159137  <div class="noprint fullwidth" style="border-bottom: 1px dashed #A0A0A0; padding-left: 1em; padding-bottom: 1em;">
    160138    <span class="button" onclick="window.print()">
     
    166144  for (int blockNo = 0; blockNo < totalBlocks; ++blockNo)
    167145  {
     146    AnyToAny link = AnyToAny.getByName(dc, workList, "block."+(blockNo+1));
     147    BioPlate block = (BioPlate)link.getTo();
    168148    int offset = SAMPLES_PER_BLOCK * blockNo;
    169149    if (blockNo % BLOCKS_PER_PAGE == 0)
     
    190170    <div class="paraffinblock">
    191171      <div class="title">
    192       <b>Block: </b><span id="blockname.<%=blockNo%>">????</span>
     172      <b>Block: </b><span id="blockname.<%=blockNo%>"><%=block.getName() %></span>
    193173      </div>
    194174      <table>
  • extensions/net.sf.basedb.reggie/trunk/src/net/sf/basedb/reggie/dao/Subtype.java

    r1668 r1684  
    137137  */
    138138  public static final Subtype EXTRACTION_PROTOCOL = new Subtype("Extraction", Item.PROTOCOL, false);
     139
     140  /**
     141    The definition of the "Histology" protocol subtype (used when embedding Histology items in
     142    paraffin blocks).
     143    @since 2.7
     144  */
     145  public static final Subtype HISTOLOGY_PROTOCOL = new Subtype("Histology", Item.PROTOCOL, false);
     146
    139147 
    140148  /**
  • extensions/net.sf.basedb.reggie/trunk/src/net/sf/basedb/reggie/servlet/ExtractionServlet.java

    r1660 r1684  
    2727import net.sf.basedb.core.query.Expressions;
    2828import net.sf.basedb.core.query.Hql;
    29 import net.sf.basedb.core.query.Orders;
    3029import net.sf.basedb.core.query.Restrictions;
    3130import net.sf.basedb.reggie.Reggie;
     
    8483       
    8584        json.put("lysates", jsonLysate);
    86       }
    87       else if ("GetProtocols".equals(cmd))
    88       {
    89         /*
    90           Get information about protocols. Add filter for optional 'subtype' parameter.
    91           Sort by latest first.
    92         */
    93         dc = sc.newDbControl();
    94         ItemQuery<Protocol> query = Protocol.getQuery();
    95         query.setIncludes(Reggie.INCLUDE_IN_CURRENT_PROJECT);
    96         Subtype subtype = Subtype.getByCName(req.getParameter("subtype"));
    97         if (subtype != null)
    98         {
    99           subtype.addFilter(dc, query);
    100         }
    101         query.order(Orders.desc(Hql.property("entryDate")));
    102         query.order(Orders.desc(Hql.property("id")));
    103        
    104         JSONArray jsonProtocols = new JSONArray();
    105         for (Protocol p : query.list(dc))
    106         {
    107           JSONObject jsonProtocol = new JSONObject();
    108           jsonProtocol.put("id", p.getId());
    109           jsonProtocol.put("name", p.getName());
    110           jsonProtocols.add(jsonProtocol);
    111         }
    112         json.put("protcols", jsonProtocols);
    113       }
    114      
     85      }     
    11586      else if ("GetNextQiacubeRunNo".equals(cmd))
    11687      {
  • extensions/net.sf.basedb.reggie/trunk/src/net/sf/basedb/reggie/servlet/HistologyServlet.java

    r1683 r1684  
    1717import org.json.simple.parser.JSONParser;
    1818
     19import net.sf.basedb.core.AnyToAny;
    1920import net.sf.basedb.core.Application;
    2021import net.sf.basedb.core.BioMaterialEvent;
     
    3132import net.sf.basedb.core.MeasuredBioMaterial;
    3233import net.sf.basedb.core.PlateGeometry;
     34import net.sf.basedb.core.Protocol;
    3335import net.sf.basedb.core.Sample;
    3436import net.sf.basedb.core.SessionControl;
     
    105107        /*
    106108          Find Histology items that are not embedded on
    107           paraffin blocks.
     109          paraffin blocks and not part of any work list.
    108110        */
    109111        dc = sc.newDbControl();
     
    111113       
    112114        JSONArray jsonHistology = new JSONArray();
    113        
    114115        for (Histology h : histology)
    115116        {
     
    119120       
    120121        json.put("histology", jsonHistology);
    121       }
    122       else if ("GetNextParaffinBlockNames".equals(cmd))
    123       {
    124         dc = sc.newDbControl();
    125         int numNames = Values.getInt(req.getParameter("numNames"), 1);
    126         JSONArray jsonNames = new JSONArray();
    127         jsonNames.addAll(BioplateType.PARAFFIN_BLOCK.generateNamesForBatch(dc, 1, numNames));
    128         json.put("names", jsonNames);
    129        
    130122      }
    131123      else if ("GetParaffinBlocks".equals(cmd))
     
    250242        workList.setExternalId(Histology.WORK_LIST_ID_PREFIX);
    251243        workList.setName((String)jsonReq.get("name"));
     244        workList.setDescription(
     245          "Temporary work list used for keeping track of a single batch of histology items " +
     246          "to be embedded in paraffing blocks. Do not modify.");
    252247        dc.saveItem(workList);
     248        jsonMessages.add("Created '" + workList.getName() + "' with " + jsonHistology.size() + " samples");
     249
     250        int blockNo = 0;
     251        PlateGeometry geometry = BioplateType.PARAFFIN_BLOCK.getPlateGeometry(dc);
     252        BioPlateType paraffinBlockType = BioplateType.PARAFFIN_BLOCK.load(dc);
    253253       
    254254        for (int i = 0; i < jsonHistology.size(); ++i)
    255255        {
     256          if (i % 5 == 0)
     257          {
     258            // Create a new Paraffin block and associate it with the list
     259            blockNo++;
     260            BioPlate paraffinBlock = BioPlate.getNew(dc, geometry, paraffinBlockType);
     261            paraffinBlock.setName(BioplateType.PARAFFIN_BLOCK.generateNextName(dc, blockNo));
     262            dc.saveItem(paraffinBlock);
     263           
     264            AnyToAny listBlock = AnyToAny.getNew(dc, workList, paraffinBlock, "block."+blockNo, true);
     265            dc.saveItem(listBlock);
     266
     267            jsonMessages.add("Created '" + paraffinBlock.getName() + "' (empty)");
     268          }
     269         
    256270          Number hisId = (Number)jsonHistology.get(i);
    257271          workList.add(Sample.getById(dc, hisId.intValue()));
    258272        }
    259273       
    260         jsonMessages.add("Created '" + workList.getName() + "' with " + jsonHistology.size() + " samples");
    261274        dc.commit();
    262275       
     
    271284        int workListId = Values.getInt(req.getParameter("workListId"));
    272285        Date moveDate = Reggie.CONVERTER_STRING_TO_DATE.convert(req.getParameter("moveDate"));
     286        int protocolId = Values.getInt(req.getParameter("protocolId"));
    273287       
    274288        dc = sc.newDbControl();
    275289       
    276290        BioMaterialList workList = BioMaterialList.getById(dc, workListId);
     291        Protocol protocol = protocolId != 0 ? Protocol.getById(dc, protocolId) : null;
    277292       
    278293        BioPlateEvent placeEvent = BioPlateEvent.getNew(dc, BioPlateEventType.getById(dc, BioPlateEventType.PLACE_ON_PLATE));
    279294        placeEvent.setEventDate(moveDate);
    280295        placeEvent.setName("Place Histology item on paraffin blocks");
     296        placeEvent.setProtocol(protocol);
    281297        dc.saveItem(placeEvent);
    282298
     
    312328        int blockNo = 0;
    313329        List<BioPlate> paraffinBlocks = new ArrayList<BioPlate>(allBioMaterial.size() / 5);
     330        int remainingBioMaterial = allBioMaterial.size();
    314331
    315332        for (Sample his : allBioMaterial)
     
    319336            blockPos = 0;
    320337            blockNo++;
    321             paraffinBlock = BioPlate.getNew(dc, geometry, paraffinBlockType);
     338           
     339            AnyToAny link = AnyToAny.getByName(dc, workList, "block."+blockNo);
     340            paraffinBlock = (BioPlate)link.getTo();
     341           
    322342            paraffinBlocks.add(paraffinBlock);
    323343            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
     344           
     345            // Attach the new paraffin block to the PLACE-ON-PLATE event
    328346            blockEvent = placeEvent.addParticipant(paraffinBlock, "destination", blockNo);
    329347            dc.saveItem(blockEvent);
    330348           
    331             jsonMessages.add("Created '" + paraffinBlock.getName() + "'");
    332           }
     349            int numSamples = remainingBioMaterial > 5 ? 5 : remainingBioMaterial;
     350           
     351            jsonMessages.add("Moved " + numSamples + " samples to '" + paraffinBlock.getName() + "'");
     352          }
     353         
     354          // Register date and protocol
     355          BioMaterialEvent createEvent = his.getCreationEvent();
     356          createEvent.setEventDate(moveDate);
     357          createEvent.setProtocol(protocol);
    333358         
    334359          // Move the biomaterial -- keep track of the old location for message
     
    343368          dc.saveItem(bmEvent);
    344369          blockPos++;
    345         }
     370          remainingBioMaterial--;
     371        }
     372       
     373        // Mark the work list as removed
     374        workList.setRemoved(true);
    346375       
    347376        dc.commit();
  • extensions/net.sf.basedb.reggie/trunk/src/net/sf/basedb/reggie/servlet/InstallServlet.java

    r1677 r1684  
    125125        jsonChecks.add(checkSubtype(dc, Subtype.SPECIMEN,createIfMissing, Subtype.CASE));
    126126        jsonChecks.add(checkSubtype(dc, Subtype.NO_SPECIMEN,createIfMissing, Subtype.CASE));
    127         jsonChecks.add(checkSubtype(dc, Subtype.HISTOLOGY, createIfMissing, Subtype.SPECIMEN));
     127        jsonChecks.add(checkSubtype(dc, Subtype.HISTOLOGY_PROTOCOL, createIfMissing));
     128        jsonChecks.add(checkSubtype(dc, Subtype.HISTOLOGY, createIfMissing, Subtype.SPECIMEN, Subtype.HISTOLOGY_PROTOCOL));
    128129        jsonChecks.add(checkSubtype(dc, Subtype.STAINED, createIfMissing, Subtype.HISTOLOGY));
    129130        jsonChecks.add(checkSubtype(dc, Subtype.SAMPLE_HANDLING_PROTOCOL, createIfMissing));
Note: See TracChangeset for help on using the changeset viewer.