Changeset 2243


Ignore:
Timestamp:
Feb 21, 2014, 1:42:15 PM (9 years ago)
Author:
Nicklas Nordborg
Message:

References #577: Flag histology items in HE glass/scoring wizard

The scoring wizard now support unchecking the GoodStain option without selecting a new one. Histology items are automatically added to or removed from the Flagged histology list depending on if a good stain exists or not.

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

Legend:

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

    r2134 r2243  
    3535
    3636<script language="JavaScript">
    37 var debug = 0;
     37var debug = false;
    3838var currentStep = 1;
    3939var selectedSample;
     
    8080       
    8181        // Save the first GoodStain sample so we can select it later
    82         if (sample.GoodStain && firstGoodSample == null)
     82        if (sample.GoodStain)
    8383        {
    84           firstGoodSample = sample;
     84          if (firstGoodSample == null) firstGoodSample = sample;
    8585        }
    8686       
     
    287287    className += ' good-stain';
    288288  }
     289  else
     290  {
     291    if (getGoodStainedSampleForLocation(sample.well.location) == null)
     292    {
     293      className += ' warning';
     294    }
     295  }
    289296 
    290297  if (sample.ScoreTotal == null)
     
    313320  var td = document.getElementById(sample.heGlassId+'-'+sample.well.location);
    314321  td.className = className;
     322}
     323
     324function getGoodStainedSampleForLocation(location)
     325{
     326  // Find sample on given location that has GoodStain annotation
     327  for (var glassNo = 0; glassNo < heGlass.length; glassNo++)
     328  {
     329    var glass = heGlass[glassNo];
     330    for (var sampleNo = 0; sampleNo < glass.samples.length; sampleNo++)
     331    {
     332      var sample = glass.samples[sampleNo];
     333      if (sample.well.location == location && sample.GoodStain)
     334      {
     335        return sample;
     336      }
     337    }
     338  }
     339  return null;
    315340}
    316341
     
    357382  {
    358383    frm.good_stain.checked = true;
    359     frm.good_stain.disabled = true;
    360384  }
    361385  else
    362386  {
    363387    frm.good_stain.checked = false;
    364     frm.good_stain.disabled = false;
    365388  }
    366389 
     
    478501  var frm = document.forms['reggie'];
    479502 
    480   // Reset GoodStain on other samples on same location
     503  var goodSample = getGoodStainedSampleForLocation(selectedSample.well.location);
     504  if (goodSample != null && goodSample != selectedSample)
     505  {
     506    // Reset the current GoodStain sample
     507    goodSample.GoodStain = null;
     508    saveToLocalStorage(goodSample);
     509  }
     510 
     511  selectedSample.GoodStain = frm.good_stain.checked ? true : null;
     512  saveToLocalStorage(selectedSample);
     513 
     514  // Repaint samples on current location
    481515  for (var glassNo = 0; glassNo < heGlass.length; glassNo++)
    482516  {
     
    488522      if (sample.well.location == selectedSample.well.location)
    489523      {
    490         sample.GoodStain = null;
    491524        setSampleClassName(sample);
    492         saveToLocalStorage(sample);
    493525      }
    494526    }
    495527  }
    496  
    497   selectedSample.GoodStain = frm.good_stain.checked ? true : null;
    498   frm.good_stain.disabled = true;
    499   setSampleClassName(selectedSample);
    500   saveToLocalStorage(selectedSample);
    501528}
    502529
     
    797824  display: inline-block;
    798825  border: 1px solid #A0A0A0;
    799   margin: 1em;
     826  margin: 1em 1em 0.5em 1em;
    800827  width: 20em;
    801828  background: #E8E8E8;
     
    904931{
    905932  background-image: url('../images/score-complete.png');
     933}
     934
     935.he-table td.warning
     936{
     937  background-image: url('../images/warning.png');
    906938}
    907939
     
    10301062      <div id="he-glass-container" style="display: none;">
    10311063       
     1064      </div>
     1065      <div style="margin-left: 1em; margin-bottom: 0.5em;">
     1066        <base:icon image="warning.png" /> = No GoodStain sample for that location
    10321067      </div>
    10331068
  • extensions/net.sf.basedb.reggie/trunk/src/net/sf/basedb/reggie/servlet/HistologyServlet.java

    r2242 r2243  
    44import java.io.PrintWriter;
    55import java.util.Date;
     6import java.util.HashSet;
    67import java.util.List;
    78import java.util.Set;
     
    3132import net.sf.basedb.core.Item;
    3233import net.sf.basedb.core.ItemQuery;
     34import net.sf.basedb.core.ItemSubtype;
    3335import net.sf.basedb.core.MeasuredBioMaterial;
    3436import net.sf.basedb.core.PlateGeometry;
     
    829831        JSONArray jsonHeGlass = (JSONArray)jsonReq.get("heGlass");
    830832
     833        Set<Sample> histologyItems = new HashSet<Sample>();
     834
    831835        // Update scores on samples
    832836        for (int sampleNo = 0; sampleNo < jsonSamples.size(); ++sampleNo)
     
    849853          he.setDescription(Values.getStringOrNull((String)jsonSample.get("comments")));
    850854         
     855          // Get parent Histology item for later checking of good stains
     856          histologyItems.add((Sample)he.getParent());
     857         
    851858          if (Boolean.TRUE.equals(scoreComplete))
    852859          {
     
    885892        }
    886893       
     894        // Check flagged histology items
     895        int numFlagged = 0;
     896        int numUnflagged = 0;
     897        BioMaterialList flaggedHistology = BiomaterialList.FLAGGED_HISTOLOGY.load(dc);
     898        for (Sample histology : histologyItems)
     899        {
     900          String flag = (String)Annotationtype.FLAG.getAnnotationValue(dc, histology);
     901         
     902          ItemQuery<Sample> heQuery = histology.getChildSamples();
     903          Subtype.STAINED.addFilter(dc, heQuery);
     904          heQuery.include(Reggie.INCLUDE_IN_CURRENT_PROJECT);
     905          boolean hasGoodStain = false;
     906          for (Sample stained : heQuery.list(dc))
     907          {
     908            if (Boolean.TRUE.equals(Annotationtype.GOOD_STAIN.getAnnotationValue(dc, stained)))
     909            {
     910              hasGoodStain = true;
     911              break;
     912            }
     913          }
     914         
     915          if (hasGoodStain)
     916          {
     917            if (flag != null)
     918            {
     919              // Remove the flag
     920              numUnflagged++;
     921              Annotationtype.FLAG.setAnnotationValue(dc, histology, null);
     922              flaggedHistology.remove(histology);
     923            }
     924          }
     925          else
     926          {
     927            if (flag == null)
     928            {
     929              // Flag the histology since it has no good stain and is not already flagged
     930              numFlagged++;
     931              Annotationtype.FLAG.setAnnotationValue(dc, histology, Histology.FLAG_NO_GOOD_STAIN);
     932              flaggedHistology.add(histology);
     933            }
     934          }
     935         
     936        }
     937       
     938        if (numFlagged > 0)
     939        {
     940          jsonMessages.add(numFlagged + " items added to Flagged histology list.");
     941        }
     942        if (numUnflagged > 0)
     943        {
     944          jsonMessages.add(numUnflagged + " items removed from Flagged histology list.");         
     945        }
     946
    887947        dc.commit();
    888948      }
Note: See TracChangeset for help on using the changeset viewer.