Skip to content

Commit

Permalink
Merge pull request #679 from DiamondLightSource/pre-release/2023-R4.2
Browse files Browse the repository at this point in the history
* LIMS-222: Apply experimental parameters to all samples (#595)

* LIMS-222: Apply experimental parameters to all samples

* LIMS-222: Fix bug from renaming method

* Use toArray instead of filter and make names better

---------

Co-authored-by: Mark Williams <[email protected]>
Co-authored-by: John Holt <[email protected]>

* LIMS-210: Prevent double clicking to create multiple samples (#660)

* LIMS-210: Prevent double clicking to create multiple samples

* Use loading state to avoid double click

---------

Co-authored-by: Mark Williams <[email protected]>
Co-authored-by: John Holt <[email protected]>

* LIMS-499: Make reciprocal space viewer more obvious (#653)

Co-authored-by: Mark Williams <[email protected]>

* LIMS-395: Display warning if no spots or incomplete PIA (#623)

* LIMS-395: Display a warning on grid scans if no spots found or incomplete PIA results

* LIMS-395: Use new XRC tables

---------

Co-authored-by: Mark Williams <[email protected]>

* LIMS-759: Show multipin samples and their sublocations (#648)

Co-authored-by: Mark Williams <[email protected]>

* LIMS-154: Enable display of all grid scan snapshots in full (#631)

* LIMS-154: Enable display of all grid scan snapshots in full

* Avoid overwriting globally scoped variable n

Co-authored-by: Guilherme Francisco <[email protected]>

---------

Co-authored-by: Mark Williams <[email protected]>
Co-authored-by: Guilherme Francisco <[email protected]>

* LIMS-952: Display xray centring results if running 3d xray centring (#647)

* LIMS-952: Display xray centring results if running 3d xray centring

* LIMS-952: Mark no results as xray centring failure

* LIMS-952: Display message if no diffraction found

---------

Co-authored-by: Mark Williams <[email protected]>

* LIMS-862: Reset registered container after creating container (#628)

Co-authored-by: Mark Williams <[email protected]>

* LIMS-77: Link Lab Contacts to fedids (#622)

* LIMS-77: Link Lab Contacts to fedids

* Use Promise.all rather than $.when

Co-authored-by: Guilherme Francisco <[email protected]>

---------

Co-authored-by: Mark Williams <[email protected]>
Co-authored-by: Guilherme Francisco <[email protected]>

* Fix user data invocation tests

* Revert "LIMS-759: Show multipin samples and their sublocations (#648)"

This reverts commit 5ec00f1.

---------

Co-authored-by: Mark W <[email protected]>
Co-authored-by: Mark Williams <[email protected]>
Co-authored-by: John Holt <[email protected]>
Co-authored-by: Guilherme Francisco <[email protected]>
Co-authored-by: NKatti2011 <[email protected]>
  • Loading branch information
6 people authored Oct 5, 2023
2 parents fa177c3 + feca5b6 commit 7d6f57f
Show file tree
Hide file tree
Showing 19 changed files with 324 additions and 86 deletions.
1 change: 1 addition & 0 deletions api/src/Database/Type/MySQL.php
Original file line number Diff line number Diff line change
Expand Up @@ -202,6 +202,7 @@ class MySQL extends DatabaseParent {
// Xray Centring
'XrayCentring',
'XrayCentringResult',
'XrayCentring',

'BeamCalendar',
'SpaceGroup',
Expand Down
4 changes: 2 additions & 2 deletions api/src/Model/Services/UserData.php
Original file line number Diff line number Diff line change
Expand Up @@ -192,7 +192,7 @@ function getUsers($getCount, $isStaffMember, $stringMatch, $page, $sortBy = null
}
}

$rows = $this->db->paginate("SELECT $extc p.personid, p.givenname, p.familyname, CONCAT(p.givenname, ' ', p.familyname) as fullname, p.login, p.emailaddress, p.phonenumber, l.name as labname, l.address, l.city, '' as postcode, l.country
$rows = $this->db->paginate("SELECT $extc p.personid, p.givenname, p.familyname, CONCAT(p.givenname, ' ', p.familyname) as fullname, p.login, p.emailaddress, p.phonenumber, l.name as labname, l.address, l.city, l.postcode, l.country
FROM person p
LEFT OUTER JOIN proposalhasperson prhp ON prhp.personid = p.personid
LEFT OUTER JOIN labcontact lc ON lc.personid = p.personid
Expand Down Expand Up @@ -253,7 +253,7 @@ function getUsersForProposal($where, $getCount, $page, $sortBy, $proposalid, $cu
}
}

$extc = "p.personid, p.givenname, p.familyname, CONCAT(p.givenname, ' ', p.familyname) as fullname, p.login, p.emailaddress, p.phonenumber, l.name as labname, l.address, l.city, '' as postcode, l.country";
$extc = "p.personid, p.givenname, p.familyname, CONCAT(p.givenname, ' ', p.familyname) as fullname, p.login, p.emailaddress, p.phonenumber, l.name as labname, l.address, l.city, l.postcode, l.country";
$rows = $this->db->paginate("(SELECT $extc
FROM person p
LEFT OUTER JOIN ProposalHasPerson prhp ON prhp.personid = p.personid
Expand Down
67 changes: 55 additions & 12 deletions api/src/Page/Contact.php
Original file line number Diff line number Diff line change
Expand Up @@ -149,19 +149,62 @@ function _add_contact() {
WHERE c.cardname=:1 and c.proposalid=:2", array($this->arg('CARDNAME'), $this->proposalid));
if (sizeof($cont)) $this->_error('The specified card name already exists');

$this->db->pq("INSERT INTO laboratory (laboratoryid,name,address,city,postcode,country)
VALUES (s_laboratory.nextval, :1, :2, :3, :4, :5) RETURNING laboratoryid INTO :id",
array($this->arg('LABNAME'), $this->arg('ADDRESS'), $this->arg('CITY'), $this->arg('POSTCODE'), $this->arg('COUNTRY')));
$lid = $this->db->id();

$email = $this->has_arg('EMAILADDRESS') ? $this->arg('EMAILADDRESS') : '';
$phone = $this->has_arg('PHONENUMBER') ? $this->arg('PHONENUMBER') : '';

$this->db->pq("INSERT INTO person (personid, givenname, familyname, emailaddress, phonenumber, laboratoryid)
VALUES (s_person.nextval, :1, :2, :3, :4, :5) RETURNING personid INTO :id",
array($this->arg('GIVENNAME'), $this->arg('FAMILYNAME'), $email, $phone, $lid));
if ($this->has_arg('PERSONID')) {
$pid = $this->arg('PERSONID');

$check = $this->db->pq("SELECT c.labcontactid
FROM labcontact c
WHERE c.personid=:1 and c.proposalid=:2", array($pid, $this->proposalid));
if (sizeof($check)) $this->_error('The specified login already has a lab contact for this proposal');

$lab = $this->db->pq("SELECT l.laboratoryid FROM laboratory l
INNER JOIN person p ON l.laboratoryid = p.laboratoryid
WHERE p.personid=:1", array($pid));

if (sizeof($lab)) {
# Update laboratory
$lfields = array('LABNAME', 'ADDRESS', 'CITY', 'COUNTRY', 'POSTCODE');
foreach ($lfields as $i => $f) {
if ($this->has_arg($f)) {
$c = $f == 'LABNAME' ? 'NAME' : $f;
$this->db->pq('UPDATE laboratory SET '.$c.'=:1 WHERE laboratoryid=:2', array($this->arg($f), $lab['LABORATORYID']));
}
}
}
else {
# Create laboratory
$this->db->pq("INSERT INTO laboratory (laboratoryid,name,address,city,postcode,country)
VALUES (s_laboratory.nextval, :1, :2, :3, :4, :5) RETURNING laboratoryid INTO :id",
array($this->arg('LABNAME'), $this->arg('ADDRESS'), $this->arg('CITY'), $this->arg('POSTCODE'), $this->arg('COUNTRY')));
$lid = $this->db->id();
$this->db->pq('UPDATE person SET laboratoryid=:1 WHERE personid=:2', array($lid, $pid));
}

# Update person
$pfields = array('FAMILYNAME', 'GIVENNAME', 'PHONENUMBER', 'EMAILADDRESS');
foreach ($pfields as $i => $f) {
if ($this->has_arg($f)) {
$this->db->pq('UPDATE person SET '.$f.'=:1 WHERE personid=:2', array($this->arg($f), $pid));
}
}

}
else {

$pid = $this->db->id();
$this->db->pq("INSERT INTO laboratory (laboratoryid,name,address,city,postcode,country)
VALUES (s_laboratory.nextval, :1, :2, :3, :4, :5) RETURNING laboratoryid INTO :id",
array($this->arg('LABNAME'), $this->arg('ADDRESS'), $this->arg('CITY'), $this->arg('POSTCODE'), $this->arg('COUNTRY')));
$lid = $this->db->id();

$email = $this->has_arg('EMAILADDRESS') ? $this->arg('EMAILADDRESS') : '';
$phone = $this->has_arg('PHONENUMBER') ? $this->arg('PHONENUMBER') : '';

$this->db->pq("INSERT INTO person (personid, givenname, familyname, emailaddress, phonenumber, laboratoryid)
VALUES (s_person.nextval, :1, :2, :3, :4, :5) RETURNING personid INTO :id",
array($this->arg('GIVENNAME'), $this->arg('FAMILYNAME'), $email, $phone, $lid));

$pid = $this->db->id();
}

$c = $this->def_arg('DEFAULTCOURRIERCOMPANY', '');
$ca = $this->has_arg('COURIERACCOUNT') ? $this->arg('COURIERACCOUNT') : '';
Expand Down
38 changes: 36 additions & 2 deletions api/src/Page/DC.php
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,7 @@ class DC extends Page
array('/chi', 'post', '_chk_image'),
array('/imq/:id', 'get', '_image_qi'),
array('/grid/:id', 'get', '_grid_info'),
array('/grid/xrc/:id', 'get', '_grid_xrc'),
array('/grid/map', 'get', '_grid_map'),
array('/ed/:id', 'get', '_edge', array('id' => '\d+'), 'edge'),
array('/mca/:id', 'get', '_mca', array('id' => '\d+'), 'mca'),
Expand Down Expand Up @@ -394,6 +395,7 @@ function _data_collections($single = null)
# Data collection group
if ($this->has_arg('dcg') || $this->has_arg('PROCESSINGJOBID')) {
$fields = "count(distinct dca.datacollectionfileattachmentid) as dcac,
if(dca.fileType='recip',1,0) as recip,
count(distinct dcc.datacollectioncommentid) as dccc,
1 as dcc,
smp.name as sample,
Expand Down Expand Up @@ -527,6 +529,7 @@ function _data_collections($single = null)
}
} else {
$fields = "count(distinct dca.datacollectionfileattachmentid) as dcac,
if(dca.fileType='recip',1,0) as recip,
count(distinct dcc.datacollectioncommentid) as dccc,
count(distinct dc.datacollectionid) as dcc,
min(smp.name) as sample,
Expand Down Expand Up @@ -677,6 +680,7 @@ function _data_collections($single = null)
SELECT
$extc
1 as dcac,
0 as recip,
1 as dccc,
1 as dcc,
smp.name as sample,
Expand Down Expand Up @@ -769,6 +773,7 @@ function _data_collections($single = null)
SELECT
$extc
1 as dcac,
0 as recip,
1 as dccc,
1 as dcc,
smp.name as sample,
Expand Down Expand Up @@ -861,6 +866,7 @@ function _data_collections($single = null)
SELECT
$extc
1 as dcac,
0 as recip,
1 as dccc,
1 as dcc,
smp.name as sample,
Expand Down Expand Up @@ -1443,17 +1449,19 @@ function _null_or($field, $conversion)
# Grid Scan Info
function _grid_info()
{
$info = $this->db->pq("SELECT dc.datacollectiongroupid, dc.datacollectionid, dc.axisstart, p.posx as x, p.posy as y, p.posz as z, g.dx_mm, g.dy_mm, g.steps_x, g.steps_y, IFNULL(g.micronsperpixelx,g.pixelspermicronx) as micronsperpixelx, IFNULL(g.micronsperpixely,g.pixelspermicrony) as micronsperpixely, g.snapshot_offsetxpixel, g.snapshot_offsetypixel, g.orientation, g.snaked, DATE_FORMAT(dc.starttime, '%Y%m%d') as startdate
$info = $this->db->pq("SELECT dc.datacollectiongroupid, dc.datacollectionid, dc.axisstart, p.posx as x, p.posy as y, p.posz as z, g.dx_mm, g.dy_mm, g.steps_x, g.steps_y, IFNULL(g.micronsperpixelx,g.pixelspermicronx) as micronsperpixelx, IFNULL(g.micronsperpixely,g.pixelspermicrony) as micronsperpixely, g.snapshot_offsetxpixel, g.snapshot_offsetypixel, g.orientation, g.snaked, DATE_FORMAT(dc.starttime, '%Y%m%d') as startdate, xrc.status as xrcstatus, xrcr.xraycentringresultid
FROM gridinfo g
INNER JOIN datacollection dc on (dc.datacollectionid = g.datacollectionid) or (dc.datacollectiongroupid = g.datacollectiongroupid)
LEFT OUTER JOIN position p ON dc.positionid = p.positionid
LEFT OUTER JOIN xraycentring xrc ON dc.datacollectiongroupid = xrc.datacollectiongroupid
LEFT OUTER JOIN xraycentringresult xrcr ON xrc.xraycentringid = xrcr.xraycentringid
WHERE dc.datacollectionid = :1 ", array($this->arg('id')));

if (!sizeof($info))
$this->_output(array());
else {
foreach ($info[0] as $k => &$v) {
if ($k == 'ORIENTATION')
if ($k == 'ORIENTATION' || $k == 'XRCSTATUS')
continue;
$v = floatval($v);
}
Expand All @@ -1475,6 +1483,32 @@ function _grid_map()
}


# XRC
function _grid_xrc()
{
$info = $this->db->pq("SELECT dc.datacollectiongroupid, dc.datacollectionid,
xrc.xraycentringtype as method, xrcr.xraycentringresultid,
xrcr.centreofmassx as x, xrcr.centreofmassy as y, xrcr.centreofmassz as z
FROM datacollection dc
INNER JOIN xraycentring xrc ON xrc.datacollectiongroupid = dc.datacollectiongroupid
INNER JOIN xraycentringresult xrcr ON xrcr.xraycentringid = xrc.xraycentringid
WHERE dc.datacollectionid = :1 ", array($this->arg('id')));

if (!sizeof($info))
$this->_output(array('total' => 0, 'data' => array()));
else {
foreach ($info as &$i) {
foreach ($i as $k => &$v) {
if ($k == 'METHOD')
continue;
$v = round(floatval($v), 2);
}
}
$this->_output(array('total' => sizeof($info), 'data' => $info));
}
}


# ------------------------------------------------------------------------
# Fluorescence Map Info
function _fluo_map()
Expand Down
19 changes: 11 additions & 8 deletions api/src/Page/Processing.php
Original file line number Diff line number Diff line change
Expand Up @@ -87,10 +87,11 @@ function _screening_status($where, $ids) {

function _xrc_status($where, $ids) {
$dcs = $this->db->pq(
"SELECT xrc.status as xrcstatus, dc.datacollectionid
"SELECT xrc.status as xrcstatus, dc.datacollectionid, xrc.xrayCentringType as method, xrcr.xraycentringresultid as xrcresults
FROM datacollection dc
INNER JOIN datacollectiongroup dcg ON dcg.datacollectiongroupid = dc.datacollectiongroupid
LEFT OUTER JOIN xraycentring xrc ON xrc.datacollectiongroupid = dc.datacollectiongroupid
LEFT OUTER JOIN XrayCentringResult xrcr ON xrc.xrayCentringId = xrcr.xrayCentringId
INNER JOIN blsession s ON s.sessionid = dcg.sessionid
INNER JOIN proposal p ON p.proposalid = s.proposalid
WHERE $where",
Expand All @@ -104,13 +105,15 @@ function _xrc_status($where, $ids) {
}

$statuses[$dc['DATACOLLECTIONID']]['XrayCentring'] =
$dc['XRCSTATUS'] === null
? 0
: ($dc['XRCSTATUS'] === 'pending'
? 1
: ($dc['XRCSTATUS'] === 'success'
? 2
: 3));
$dc['METHOD'] !== '3d'
? -1
: ($dc['XRCSTATUS'] === null
? 0
: ($dc['XRCSTATUS'] === 'pending'
? 1
: ($dc['XRCSTATUS'] === 'success' && $dc['XRCRESULTS'] !== null
? 2
: 3)));
}

return $statuses;
Expand Down
Loading

0 comments on commit 7d6f57f

Please sign in to comment.