Skip to content

Commit 41aaecd

Browse files
ndg63276Mark Williams
andauthored
LIMS-1785: Create 'Assign Sample' page for VMXm (#974)
* LIMS-1785: Create 'Assign Sample' page for VMXm * LIMS-1785: Label link to Assign page correctly * LIMS-1785: Use consts rather than vars * LIMS-1785: Fix unassign dialog --------- Co-authored-by: Mark Williams <[email protected]>
1 parent ed21891 commit 41aaecd

File tree

12 files changed

+395
-67
lines changed

12 files changed

+395
-67
lines changed

api/config_sample.php

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -395,6 +395,12 @@
395395
'i04' => False,
396396
);
397397

398+
# puck capacity of beamlines which take pucks, sample capacity of those which take samples
399+
$bl_capacity = array(
400+
"i03" => array("pucks" => 37, "samples" => 0),
401+
"i04" => array("pucks" => 37, "samples" => 0),
402+
);
403+
398404
# Dials server values
399405
$dials_rest_url = "";
400406
$dials_rest_jwt = "";

api/index.php

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -73,7 +73,8 @@ function setupApplication($mode): Slim
7373
$valid_components, $enabled_container_types, $synchweb_version, $redirects,
7474
$shipping_service_app_url, $use_shipping_service_redirect, $use_shipping_service_redirect_incoming_shipments,
7575
$dials_rest_url_rings, $closed_proposal_link, $ccp4_cloud_upload_url,
76-
$only_staff_can_assign, $industrial_prop_codes, $prop_codes_data_deleted, $container_types_with_parents;
76+
$only_staff_can_assign, $industrial_prop_codes, $prop_codes_data_deleted, $container_types_with_parents,
77+
$bl_capacity;
7778
$app->contentType('application/json');
7879
$options = $app->container['options'];
7980
$app->response()->body(json_encode(array(
@@ -106,6 +107,7 @@ function setupApplication($mode): Slim
106107
'container_types_with_parents' => $container_types_with_parents,
107108
'industrial_prop_codes' => $industrial_prop_codes,
108109
'prop_codes_data_deleted' => $prop_codes_data_deleted ?? array(),
110+
'bl_capacity' => $bl_capacity,
109111
)));
110112
});
111113
return $app;

api/src/Controllers/AssignController.php

Lines changed: 23 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@ class AssignController extends Page
1111
{
1212
private $assignData;
1313

14-
public static $arg_list = array('visit' => '\w+\d+-\d+', 'cid' => '\d+', 'did' => '\d+', 'pos' => '\d+', 'bl' => '[\w\-]+');
14+
public static $arg_list = array('visit' => '\w+\d+-\d+', 'cid' => '\d+', 'did' => '\d+', 'sid' => '\d+', 'pos' => '\d+', 'bl' => '[\w\-]+');
1515

1616
public static $dispatch = array(
1717
array('/assign', 'get', 'assignContainer'),
@@ -32,15 +32,24 @@ function __construct(Slim $app, $db, $user, AssignData $assignData)
3232
function assignContainer()
3333
{
3434
global $only_staff_can_assign;
35-
$cs = $this->assignData->getContainer($this->arg('visit'), $this->arg('cid'));
35+
if ($this->has_arg('cid')) {
36+
$cs = $this->assignData->getContainer($this->arg('visit'), $this->arg('cid'));
37+
} else if ($this->has_arg('sid')) {
38+
$cs = $this->assignData->getSample($this->arg('visit'), $this->arg('sid'));
39+
} else {
40+
$cs = array();
41+
}
3642
if (sizeof($cs) > 0)
3743
{
3844
$bl = $cs[0]['BEAMLINENAME'];
3945
if (is_array($only_staff_can_assign) && array_key_exists($bl, $only_staff_can_assign) && $only_staff_can_assign[$bl] == true && !$this->staff) {
4046
$this->_error("Only staff can assign containers on this beamline");
41-
} else {
47+
} else if ($this->has_arg('cid')) {
4248
$this->assignData->assignContainer($cs[0], $this->arg('pos'));
4349
$this->_output(1);
50+
} else if ($this->has_arg('sid')) {
51+
$this->assignData->assignSample($cs[0], $this->arg('pos'));
52+
$this->_output(1);
4453
}
4554
}
4655
else
@@ -52,16 +61,25 @@ function assignContainer()
5261
function unassignContainer()
5362
{
5463
global $only_staff_can_assign;
55-
$cs = $this->assignData->getContainer($this->arg('visit'), $this->arg('cid'));
64+
if ($this->has_arg('cid')) {
65+
$cs = $this->assignData->getContainer($this->arg('visit'), $this->arg('cid'));
66+
} else if ($this->has_arg('sid')) {
67+
$cs = $this->assignData->getSample($this->arg('visit'), $this->arg('sid'));
68+
} else {
69+
$cs = array();
70+
}
5671

5772
if (sizeof($cs) > 0)
5873
{
5974
$bl = $cs[0]['BEAMLINENAME'];
6075
if (is_array($only_staff_can_assign) && array_key_exists($bl, $only_staff_can_assign) && $only_staff_can_assign[$bl] == true && !$this->staff) {
6176
$this->_error("Only staff can unassign containers on this beamline");
62-
} else {
77+
} else if ($this->has_arg('cid')) {
6378
$this->assignData->unassignContainer($cs[0]);
6479
$this->_output(1);
80+
} else if ($this->has_arg('sid')) {
81+
$this->assignData->unassignSample($cs[0]);
82+
$this->_output(1);
6583
}
6684
}
6785
else

api/src/Model/Services/AssignData.php

Lines changed: 34 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,18 @@ function getContainer($visitId, $containerId)
2727
AND c.containerid=:2", array($visitId, $containerId));
2828
}
2929

30+
function getSample($visitId, $sampleId)
31+
{
32+
return $this->db->pq("SELECT b.blsampleid,b.name,d.dewarid,bl.beamlinename,c.containerid,c.code FROM blsample b
33+
INNER JOIN container c ON c.containerid = b.containerid
34+
INNER JOIN dewar d ON d.dewarid = c.dewarid
35+
INNER JOIN shipping s ON s.shippingid = d.shippingid
36+
INNER JOIN blsession bl ON bl.proposalid = s.proposalid
37+
INNER JOIN proposal p ON s.proposalid = p.proposalid
38+
WHERE CONCAT(p.proposalcode, p.proposalnumber, '-', bl.visit_number) LIKE :1
39+
AND b.blsampleid=:2", array($visitId, $sampleId));
40+
}
41+
3042
function assignContainer($container, $location)
3143
{
3244
$this->updateDewar($container['DEWARID'], 'processing');
@@ -36,11 +48,27 @@ function assignContainer($container, $location)
3648
$this->updateDewarHistory($container['DEWARID'], 'processing', $container['BEAMLINENAME'], $container['CODE'] . ' => ' . $location);
3749
}
3850

51+
function assignSample($sample, $location)
52+
{
53+
$this->updateSample($sample['BLSAMPLEID'], $location);
54+
55+
$this->updateDewar($sample['DEWARID'], 'processing');
56+
57+
$this->updateContainerAndHistory($sample['CONTAINERID'], 'processing', $sample['BEAMLINENAME'], null);
58+
59+
$this->updateDewarHistory($sample['DEWARID'], 'processing', $sample['BEAMLINENAME'], $sample['NAME'] . ' => ' . $location);
60+
}
61+
3962
function unassignContainer($container)
4063
{
4164
$this->updateContainerAndHistory($container['CONTAINERID'], 'at facility', '', '');
4265
}
4366

67+
function unassignSample($sample)
68+
{
69+
$this->updateSample($sample['BLSAMPLEID'], null);
70+
}
71+
4472
function updateContainerAndHistory($containerId, $status, $beamlineName, $location)
4573
{
4674
$this->updateContainer($containerId, $status, $beamlineName, $location);
@@ -61,6 +89,12 @@ function updateContainer($containerId, $status, $beamlineName, $location)
6189
WHERE containerid=:4", array($beamlineName, $location, $status, $containerId));
6290
}
6391

92+
function updateSample($sampleId, $location)
93+
{
94+
$this->db->pq("UPDATE blsample SET isinsamplechanger=:1
95+
WHERE blsampleid=:2", array($location, $sampleId));
96+
}
97+
6498
function getDewar($dewarId, $proposalId, $visitId)
6599
{
66100
$where = "p.proposalid=:1";

api/src/Page/Sample.php

Lines changed: 13 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -120,6 +120,8 @@ class Sample extends Page
120120
'BEAMLINENAME' => '[\w\-]+',
121121
'SOURCE' => '[\w\-]+',
122122

123+
'assigned' => '[\w\-]+',
124+
'unassigned' => '[\w\-]+',
123125
'queued' => '\d',
124126
'UNQUEUE' => '\d',
125127
'nodata' => '\d',
@@ -1145,6 +1147,16 @@ function _samples()
11451147
array_push($args, $sessionid);
11461148
}
11471149

1150+
if ($this->has_arg('assigned')) {
1151+
$where .= " AND d.dewarstatus LIKE 'processing' AND b.isinsamplechanger > 0 AND c.beamlinelocation LIKE :" . (sizeof($args) + 1);
1152+
array_push($args, $this->arg('assigned'));
1153+
}
1154+
1155+
if ($this->has_arg('unassigned')) {
1156+
$where .= " AND b.isinsamplechanger is null AND d.storagelocation=:" . (sizeof($args) + 1);
1157+
array_push($args, $this->arg('unassigned'));
1158+
}
1159+
11481160
// Search
11491161
if ($this->has_arg('s')) {
11501162
$st = sizeof($args) + 1;
@@ -1219,7 +1231,7 @@ function _samples()
12191231
, TO_CHAR(cq.createdtimestamp, 'DD-MM-YYYY HH24:MI') as queuedtimestamp, b.smiles
12201232
, $cseq $sseq string_agg(cpr.name) as componentnames, string_agg(cpr.density) as componentdensities
12211233
, string_agg(cpr.proteinid) as componentids, string_agg(cpr.acronym) as componentacronyms, string_agg(cpr.global) as componentglobals, string_agg(chc.abundance) as componentamounts, string_agg(ct.symbol) as componenttypesymbols, b.volume, pct.symbol,ROUND(cr.abundance,3) as abundance, TO_CHAR(b.recordtimestamp, 'DD-MM-YYYY') as recordtimestamp, dp.radiationsensitivity, dp.energy, dp.userpath, dp.strategyoption, dp.minimalresolution as minimumresolution
1222-
, count(distinct dc.dataCollectionId) as dcc
1234+
, count(distinct dc.dataCollectionId) as dcc, b.isinsamplechanger
12231235
12241236
FROM blsample b
12251237

client/src/js/config_sample.json

Lines changed: 1 addition & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -6,12 +6,7 @@
66
"production": false,
77

88
"pucks": {
9-
"i02": 10,
10-
"i03": 23,
11-
"i04": 37,
12-
"i04-1": 9,
13-
"i24": 9,
14-
"i23": 4
9+
"moved to": "config.php"
1510
},
1611

1712
"_gsMajorAxisOrientation" : "Determines whether the major grid scan axis determines the orientation of the view",

0 commit comments

Comments
 (0)