Skip to content

Commit

Permalink
Merge pre-release/2024-R4.3 into master (#842)
Browse files Browse the repository at this point in the history
* LIMS-1368: Fix incorrectly summed dose for DC groups when filtered (#803)

* LIMS-1099: Limit what can be done with red proteins (#827)

* LIMS-14: Show a direct link to the autoprocessing log (#805)

* LIMS-1422: Reprocessing dialog edits the end value unpredictably (#819)

* LIMS-1424: Show visit for each container if set (#828)

* LIMS-1425: Show samples with no processing as grey (#820)
  • Loading branch information
ndg63276 authored Oct 1, 2024
1 parent 55b05b3 commit 087beda
Show file tree
Hide file tree
Showing 17 changed files with 188 additions and 67 deletions.
7 changes: 5 additions & 2 deletions api/src/Page/DC.php
Original file line number Diff line number Diff line change
Expand Up @@ -440,7 +440,7 @@ function _data_collections($single = null)
dc.c2lens,
dc.objaperture,
dc.magnification,
dc.totalexposeddose as totaldose,
dose.total as totaldose,
CAST(dc.totalabsorbeddose AS DECIMAL(5, 2)) as totalabsdose,
d.detectorpixelsizehorizontal,
d.detectorpixelsizevertical,
Expand Down Expand Up @@ -574,7 +574,7 @@ function _data_collections($single = null)
max(dc.c2lens) as c2lens,
max(dc.objaperture) as objaperture,
max(dc.magnification) as magnification,
sum(dc.totalabsorbeddose) as totaldose,
dose.total as totaldose,
CAST(dc.totalabsorbeddose AS DECIMAL(5, 2)) as totalabsdose,
max(d.detectormanufacturer) as detectormanufacturer,
max(d.detectormodel) as detectormodel,
Expand Down Expand Up @@ -660,6 +660,9 @@ function _data_collections($single = null)
SELECT $extcg $fields
FROM datacollection dc
INNER JOIN datacollectiongroup dcg ON dcg.datacollectiongroupid = dc.datacollectiongroupid
INNER JOIN (
select datacollectiongroupid, sum(totalabsorbeddose) as total from datacollection group by datacollectiongroupid) dose
ON dc.datacollectiongroupid = dose.datacollectiongroupid
INNER JOIN blsession ses ON ses.sessionid = dcg.sessionid
LEFT OUTER JOIN experimenttype et on dcg.experimenttypeid = et.experimenttypeid
$sample_joins[0]
Expand Down
45 changes: 44 additions & 1 deletion api/src/Page/Download.php
Original file line number Diff line number Diff line change
Expand Up @@ -56,6 +56,7 @@ class Download extends Page

array('/ap/attachments(/:AUTOPROCPROGRAMATTACHMENTID)(/dl/:download)', 'get', '_get_autoproc_attachments'),
array('/ap/archive/:AUTOPROCPROGRAMID', 'get', '_get_autoproc_archive'),
array('/ap/log/:AUTOPROCPROGRAMID', 'get', '_get_autoproc_log'),
);


Expand Down Expand Up @@ -220,7 +221,7 @@ function __get_autoproc_attachments()
INNER JOIN datacollectiongroup dcg ON dcg.datacollectiongroupid = dc.datacollectiongroupid
INNER JOIN blsession s ON s.sessionid = dcg.sessionid
WHERE s.proposalid=:1 $where
ORDER BY importancerank"
ORDER BY importancerank, filename"
), $args);

return $rows;
Expand Down Expand Up @@ -413,6 +414,48 @@ function _get_attachment()
}
}

# ------------------------------------------------------------------------
# Get the most important log of an autoprocessing job
function _get_autoproc_log()
{

if (!$this->has_arg('prop')) {
$this->_error('No proposal specified');
}
$args = array($this->proposalid, $this->arg('AUTOPROCPROGRAMID'));

$rows = $this->db->union(array(
"SELECT app.autoprocprogramid, appa.filename, appa.filepath
FROM autoprocintegration api
INNER JOIN autoprocprogram app ON api.autoprocprogramid = app.autoprocprogramid
INNER JOIN autoprocprogramattachment appa ON appa.autoprocprogramid = app.autoprocprogramid
INNER JOIN datacollection dc ON dc.datacollectionid = api.datacollectionid
INNER JOIN datacollectiongroup dcg ON dcg.datacollectiongroupid = dc.datacollectiongroupid
INNER JOIN blsession s ON s.sessionid = dcg.sessionid
WHERE s.proposalid=:1
AND app.autoprocprogramid=:2
AND appa.importancerank=1
AND appa.filetype='Log'",
"SELECT app.autoprocprogramid, appa.filename, appa.filepath
FROM autoprocprogram app
INNER JOIN processingjob pj on pj.processingjobid = app.processingjobid
INNER JOIN autoprocprogramattachment appa ON appa.autoprocprogramid = app.autoprocprogramid
INNER JOIN datacollection dc ON dc.datacollectionid = pj.datacollectionid
INNER JOIN datacollectiongroup dcg ON dcg.datacollectiongroupid = dc.datacollectiongroupid
INNER JOIN blsession s ON s.sessionid = dcg.sessionid
WHERE s.proposalid=:1
AND app.autoprocprogramid=:2
AND appa.importancerank=1
AND appa.filetype='Log'"
), $args);

if (!sizeof($rows)) {
return $this->_error('No log file found');
}
$this->_get_file($rows[0]['AUTOPROCPROGRAMID'], $rows[0]);

}


# ------------------------------------------------------------------------
# Get an archive of an autoproc
Expand Down
17 changes: 11 additions & 6 deletions api/src/Page/Sample.php
Original file line number Diff line number Diff line change
Expand Up @@ -1819,12 +1819,17 @@ function _distinct_proteins()
$where .= ' AND pr.externalid IS NOT NULL';
}

$has_safety_level = $this->has_arg('SAFETYLEVEL');
if ($has_safety_level && $this->arg('SAFETYLEVEL') === 'ALL') {
$where .= ' AND pr.safetyLevel IS NOT NULL';
} else if ($has_safety_level && $this->arg('SAFETYLEVEL') !== 'ALL') {
$where .= ' AND pr.safetyLevel=:' . (sizeof($args) + 1);
array_push($args, $this->arg('SAFETYLEVEL'));
if ($this->has_arg('SAFETYLEVEL')) {
if ($this->arg('SAFETYLEVEL') === 'ALL') {
$where .= ' AND pr.safetyLevel IS NOT NULL';
} else if (strtolower($this->arg('SAFETYLEVEL')) === 'yellow') {
$where .= " AND pr.safetyLevel in ('green','yellow')";
} else if (strtolower($this->arg('SAFETYLEVEL')) === 'red') {
$where .= " AND pr.safetyLevel in ('green','yellow','red')";
} else {
$where .= ' AND pr.safetyLevel=:' . (sizeof($args) + 1);
array_push($args, $this->arg('SAFETYLEVEL'));
}
}

if ($this->has_arg('term')) {
Expand Down
39 changes: 38 additions & 1 deletion api/src/Page/Shipment.php
Original file line number Diff line number Diff line change
Expand Up @@ -1626,7 +1626,7 @@ function _get_dewars()
$order = $cols[$this->arg('sort_by')] . ' ' . $dir;
}

$dewars = $this->db->paginate("SELECT CONCAT(p.proposalcode, p.proposalnumber) as prop, CONCAT(p.proposalcode, p.proposalnumber, '-', se.visit_number) as firstexperiment, r.labcontactid, se.beamlineoperator as localcontact, se.beamlinename, TO_CHAR(se.startdate, 'HH24:MI DD-MM-YYYY') as firstexperimentst, d.firstexperimentid, s.shippingid, s.shippingname, d.facilitycode, count(c.containerid) as ccount, (case when se.visit_number > 0 then (CONCAT(p.proposalcode, p.proposalnumber, '-', se.visit_number)) else '' end) as exp, d.code, d.barcode, d.storagelocation, d.dewarstatus, d.dewarid, d.trackingnumbertosynchrotron, d.trackingnumberfromsynchrotron, d.externalShippingIdFromSynchrotron, s.deliveryagent_agentname, d.weight, d.deliveryagent_barcode, GROUP_CONCAT(c.code SEPARATOR ', ') as containers, s.sendinglabcontactid, s.returnlabcontactid, pe.givenname, pe.familyname
$dewars = $this->db->paginate("SELECT CONCAT(p.proposalcode, p.proposalnumber) as prop, CONCAT(p.proposalcode, p.proposalnumber, '-', se.visit_number) as firstexperiment, r.labcontactid, se.beamlineoperator as localcontact, se.beamlinename, TO_CHAR(se.startdate, 'HH24:MI DD-MM-YYYY') as firstexperimentst, d.firstexperimentid, s.shippingid, s.shippingname, d.facilitycode, count(c.containerid) as ccount, (case when se.visit_number > 0 then (CONCAT(p.proposalcode, p.proposalnumber, '-', se.visit_number)) else '' end) as exp, d.code, d.barcode, d.storagelocation, d.dewarstatus, d.dewarid, d.trackingnumbertosynchrotron, d.trackingnumberfromsynchrotron, d.externalShippingIdFromSynchrotron, s.deliveryagent_agentname, d.weight, d.deliveryagent_barcode, GROUP_CONCAT(c.code SEPARATOR ', ') as containers, s.sendinglabcontactid, s.returnlabcontactid, pe.givenname, pe.familyname, s.safetylevel as shippingsafetylevel
FROM dewar d
LEFT OUTER JOIN container c ON c.dewarid = d.dewarid
INNER JOIN shipping s ON d.shippingid = s.shippingid
Expand Down Expand Up @@ -1700,6 +1700,39 @@ function _add_dewar()
$this->_output(array('DEWARID' => $id));
}

# Check new safety level is ok
function _check_safety_level()
{
$ship = $this->db->pq("SELECT cq.containerqueueid, p.safetylevel FROM dewar d
LEFT OUTER JOIN container c on c.dewarid = d.dewarid
LEFT OUTER JOIN containerqueue cq on cq.containerid = c.containerid
LEFT OUTER JOIN blsample b ON b.containerid = c.containerid
LEFT OUTER JOIN crystal cr ON cr.crystalid = b.crystalid
LEFT OUTER JOIN protein p ON p.proteinid = cr.proteinid
WHERE d.shippingid = :1", array($this->arg('sid')));
if (strtolower($this->arg('SAFETYLEVEL')) == 'green') {
foreach ($ship as $s) {
if (strtolower($s['SAFETYLEVEL']) == 'yellow')
$this->_error('Cannot set safety level to green as one or more samples are yellow.');
if (strtolower($s['SAFETYLEVEL']) == 'red')
$this->_error('Cannot set safety level to green as one or more samples are red.');
}
} else if (strtolower($this->arg('SAFETYLEVEL')) == 'yellow') {
foreach ($ship as $s) {
if ($s['CONTAINERQUEUEID'] != null)
$this->_error('Cannot set safety level to yellow as one or more containers are queued.');
if (strtolower($s['SAFETYLEVEL']) == 'red')
$this->_error('Cannot set safety level to yellow as one or more samples are red.');
}
} else {
foreach ($ship as $s) {
if ($s['CONTAINERQUEUEID'] != null)
$this->_error('Cannot set safety level to red as one or more containers are queued.');
}
}
}


# Update shipment
function _update_shipment()
{
Expand All @@ -1721,6 +1754,9 @@ function _update_shipment()
if (in_array($f, array('DELIVERYAGENT_DELIVERYDATE', 'DELIVERYAGENT_SHIPPINGDATE'))) {
$fl = "TO_DATE(:1, 'DD-MM-YYYY')";
}
if ($f == 'SAFETYLEVEL') {
$this->_check_safety_level();
}

$this->db->pq("UPDATE shipping SET $f=$fl WHERE shippingid=:2", array($this->arg($f), $this->arg('sid')));

Expand Down Expand Up @@ -2120,6 +2156,7 @@ function _get_all_containers()
}
// $this->db->set_debug(True);
$rows = $this->db->paginate("SELECT round(TIMESTAMPDIFF('HOUR', min(ci.bltimestamp), CURRENT_TIMESTAMP)/24,1) as age, case when count(ci2.containerinspectionid) > 1 then 0 else 1 end as allow_adhoc, c.scheduleid, c.screenid, sc.name as screen, c.imagerid, i.temperature as temperature, i.name as imager, TO_CHAR(max(ci.bltimestamp), 'HH24:MI DD-MM-YYYY') as lastinspection, round(TIMESTAMPDIFF('HOUR', max(ci.bltimestamp), CURRENT_TIMESTAMP)/24,1) as lastinspectiondays, count(distinct ci.containerinspectionid) as inspections, CONCAT(p.proposalcode, p.proposalnumber) as prop, c.bltimestamp, c.samplechangerlocation, c.beamlinelocation, d.dewarstatus, c.containertype, c.capacity, c.containerstatus, c.containerid, c.code as name, d.code as dewar, sh.shippingname as shipment, d.dewarid, sh.shippingid, count(distinct s.blsampleid) as samples, cq.containerqueueid, TO_CHAR(cq.createdtimestamp, 'DD-MM-YYYY HH24:MI') as queuedtimestamp, CONCAT(p.proposalcode, p.proposalnumber, '-', ses.visit_number) as visit, ses.beamlinename, c.requestedreturn, c.requestedimagerid, c.comments, c.experimenttype, c.storagetemperature, c.barcode, reg.barcode as registry, reg.containerregistryid,
sh.safetylevel as shippingsafetylevel,
(SELECT sch.name FROM schedule sch WHERE sch.scheduleid = c.scheduleid) as schedule,
(SELECT i2.name FROM imager i2 WHERE i2.imagerid = c.requestedimagerid) as requestedimager,
(SELECT count(distinct ss.blsubsampleid) FROM blsubsample ss RIGHT OUTER JOIN blsample s2 ON s2.blsampleid = ss.blsampleid WHERE s2.containerid = c.containerid AND ss.source='manual') as subsamples,
Expand Down
5 changes: 5 additions & 0 deletions client/src/js/models/shipment.js
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,11 @@ define(['backbone'], function (Backbone) {
pattern: 'fcode',
},

FIRSTEXPERIMENTID: {
required: false,
pattern: 'number',
},

REMOTEORMAILIN: {
required: false,
},
Expand Down
4 changes: 2 additions & 2 deletions client/src/js/modules/dc/views/distl.js
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ define(['marionette', 'modules/dc/models/distl', 'utils',
},

plotSelected: function(e, ranges) {
this.trigger('plot:select', Math.floor(ranges.xaxis.from), Math.ceil(ranges.xaxis.to))
this.trigger('plot:select', Math.round(ranges.xaxis.from), Math.round(ranges.xaxis.to))
},

plotUnselected: function(e) {
Expand Down Expand Up @@ -112,4 +112,4 @@ define(['marionette', 'modules/dc/models/distl', 'utils',
}
})

})
})
20 changes: 13 additions & 7 deletions client/src/js/modules/dc/views/reprocess2.js
Original file line number Diff line number Diff line change
Expand Up @@ -110,13 +110,19 @@ define(['backbone', 'marionette', 'views/dialog',
var si = parseInt(this.model.get('SI'))
var ni = parseInt(this.model.get('NUMIMG'))

if (this.ui.st.val() > (si+ni-1)) this.ui.st.val(si+ni-1)
if (this.ui.st.val() < si) this.ui.st.val(si)
if (this.ui.st.val()) {
if (this.ui.st.val() > (si+ni-1)) this.ui.st.val(si+ni-1)
if (this.ui.st.val() < si) this.ui.st.val(si)
}

if (this.ui.en.val() > (si+ni-1)) this.ui.en.val(si+ni-1)
if (this.ui.en.val() < si) this.ui.en.val(si)
if (this.ui.en.val()) {
if (this.ui.en.val() > (si+ni-1)) this.ui.en.val(si+ni-1)
if (this.ui.en.val() < si) this.ui.en.val(si)
}

this.plotview.setSelection(parseInt(this.ui.st.val()), parseInt(this.ui.en.val()))
if (this.ui.st.val() && this.ui.en.val()) {
this.plotview.setSelection(parseInt(this.ui.st.val()), parseInt(this.ui.en.val()))
}
},

initialize: function(options) {
Expand Down Expand Up @@ -377,7 +383,7 @@ define(['backbone', 'marionette', 'views/dialog',
}, this)

$.when.apply($, reqs).done(function() {
app.alert({ message: jobs+' reprocessing job(s) successfully submitted'})
app.message({ message: jobs+' reprocessing job(s) successfully submitted'})
_.each(rps, function(rp) {
self._enqueue({ PROCESSINGJOBID: rp.get('PROCESSINGJOBID') })
})
Expand Down Expand Up @@ -463,7 +469,7 @@ define(['backbone', 'marionette', 'views/dialog',
reqs.push(reprocessingsweeps.save())

$.when.apply($, reqs).done(function() {
app.alert({ message: '1 reprocessing job successfully submitted'})
app.message({ message: '1 reprocessing job successfully submitted'})
self._enqueue({ PROCESSINGJOBID: reprocessing.get('PROCESSINGJOBID') })
})
},
Expand Down
2 changes: 1 addition & 1 deletion client/src/js/modules/shipment/views/plate.js
Original file line number Diff line number Diff line change
Expand Up @@ -250,7 +250,7 @@ define(['marionette', 'backbone', 'utils', 'backbone-validation'], function(Mari

this.ctx.fillStyle = sample.get(this.rankOption.value)
? utils.rainbow(val/4)
: (sample.get(this.rankOption.check) > 0 ? 'yellow' : '#dfdfdf')
: '#dfdfdf'
this.ctx.fill()

} else {
Expand Down
2 changes: 1 addition & 1 deletion client/src/js/modules/shipment/views/shipment.js
Original file line number Diff line number Diff line change
Expand Up @@ -200,7 +200,7 @@ define(['marionette',

var edit = new Editable({ model: this.model, el: this.$el })
edit.create('SHIPPINGNAME', 'textlong')
edit.create('SAFETYLEVEL', 'select', { data: {'Green': 'Green', 'Yellow':'Yellow', 'Red': 'Red'} })
edit.create('SAFETYLEVEL', 'select', { data: {'Green': 'Green', 'Yellow':'Yellow', 'Red': 'Red'}, alert: true, revert: true })
edit.create('COMMENTS', 'textarea')
edit.create('DELIVERYAGENT_AGENTNAME', 'text')
edit.create('DELIVERYAGENT_AGENTCODE', 'text')
Expand Down
19 changes: 17 additions & 2 deletions client/src/js/modules/shipment/views/shipmentadd.js
Original file line number Diff line number Diff line change
Expand Up @@ -63,6 +63,7 @@ define(['marionette', 'views/form',
'click a.add_lc': 'addLC',
'click @ui.noexp': 'updateFirstExp',
'click @ui.dynamic': 'updateDynamicSchedule',
'change select[name^=SAFETYLEVEL]': 'changeSafetyLevel',
},

ui: {
Expand All @@ -73,6 +74,8 @@ define(['marionette', 'views/form',
noexp: 'input[name=noexp]',
dynamic: 'input[name=DYNAMIC]', // A checkbox to indicate dynamic/remote mail-in scheduling
comments: 'textarea[name=COMMENTS]', // We need this so we can prefill comments to aid users
safetylevel: 'select[name^=SAFETYLEVEL]',
udcresponsive: '.udcresponsive',
},

addLC: function(e) {
Expand All @@ -97,12 +100,24 @@ define(['marionette', 'views/form',
app.alert({ message: 'Something went wrong registering this shipment, please try again'})
},

changeSafetyLevel: function() {
if (this.ui.safetylevel.val() === 'Green') {
this.ui.udcresponsive.show()
} else {
this.ui.noexp.prop('checked', false)
this.updateFirstExp()
this.ui.dynamic.prop('checked', false)
this.updateDynamicSchedule()
this.ui.udcresponsive.hide()
}
},

updateFirstExp: function() {
if (this.ui.noexp.is(':checked')) {
this.ui.first.html('<option value=""> - </option>')
this.ui.dynamic.prop('checked', false)
} else {
this.ui.first.html(this.visits.opts())
this.ui.first.html('<option value="!">Please select one</option>'+this.visits.opts())
}
},

Expand All @@ -121,7 +136,7 @@ define(['marionette', 'views/form',
}
} else {
this.model.validation.REMOTEORMAILIN.required = false
this.ui.first.html(this.visits.opts())
this.ui.first.html('<option value="!">Please select one</option>'+this.visits.opts())
this.$el.find(".remoteform").hide()
if (industrial_visit) {
this.$el.find(".remoteormailin").hide()
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -128,7 +128,7 @@ export default {
proteinsCollection.queryParams.external = 1
}

proteinsCollection.queryParams.SAFETYLEVEL = 'ALL'
proteinsCollection.queryParams.SAFETYLEVEL = this.shippingSafetyLevel

const result = await this.$store.dispatch('getCollection', proteinsCollection)
this.proteins = result.toJSON()
Expand Down
Loading

0 comments on commit 087beda

Please sign in to comment.