Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

LIMS-1257: Allow population of source fields #769

Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 5 additions & 3 deletions api/src/Page/Sample.php
Original file line number Diff line number Diff line change
Expand Up @@ -116,6 +116,7 @@ class Sample extends Page
'MONOCHROMATOR' => '\w+',
'PRESET' => '\d',
'BEAMLINENAME' => '[\w\-]+',
'SOURCE' => '[\w\-]+',

'queued' => '\d',
'UNQUEUE' => '\d',
Expand Down Expand Up @@ -1467,7 +1468,8 @@ function _prepare_sample_args($s = null)
'SAMPLEGROUP',
'STRATEGYOPTION',
'MINIMUMRESOLUTION',
'INITIALSAMPLEGROUP'
'INITIALSAMPLEGROUP',
'SOURCE'
) as $f) {
if ($s)
$a[$f] = array_key_exists($f, $s) ? $s[$f] : null;
Expand Down Expand Up @@ -1518,8 +1520,8 @@ function _do_add_sample($s)
}

$this->db->pq(
"INSERT INTO blsample (blsampleid,crystalid,diffractionplanid,containerid,location,comments,name,code,blsubsampleid,screencomponentgroupid,volume,packingfraction,dimension1,dimension2,dimension3,shape,looptype) VALUES (s_blsample.nextval,:1,:2,:3,:4,:5,:6,:7,:8,:9,:10,:11,:12,:13,:14,:15,:16) RETURNING blsampleid INTO :id",
array($crysid, $did, $a['CONTAINERID'], $a['LOCATION'], $a['COMMENTS'], $a['NAME'], $a['CODE'], $a['BLSUBSAMPLEID'], $a['SCREENCOMPONENTGROUPID'], $a['VOLUME'], $a['PACKINGFRACTION'], $a['DIMENSION1'], $a['DIMENSION2'], $a['DIMENSION3'], $a['SHAPE'], $a['LOOPTYPE'])
"INSERT INTO blsample (blsampleid,crystalid,diffractionplanid,containerid,location,comments,name,code,blsubsampleid,screencomponentgroupid,volume,packingfraction,dimension1,dimension2,dimension3,shape,looptype,source) VALUES (s_blsample.nextval,:1,:2,:3,:4,:5,:6,:7,:8,:9,:10,:11,:12,:13,:14,:15,:16,IFNULL(:17,CURRENT_USER)) RETURNING blsampleid INTO :id",
array($crysid, $did, $a['CONTAINERID'], $a['LOCATION'], $a['COMMENTS'], $a['NAME'], $a['CODE'], $a['BLSUBSAMPLEID'], $a['SCREENCOMPONENTGROUPID'], $a['VOLUME'], $a['PACKINGFRACTION'], $a['DIMENSION1'], $a['DIMENSION2'], $a['DIMENSION3'], $a['SHAPE'], $a['LOOPTYPE'], $a['SOURCE'])
);
$sid = $this->db->id();

Expand Down
28 changes: 16 additions & 12 deletions api/src/Page/Shipment.php
Original file line number Diff line number Diff line change
Expand Up @@ -127,6 +127,7 @@ class Shipment extends Page
'PUCK' => '\d',
'PROCESSINGPIPELINEID' => '\d+',
'OWNERID' => '\d+',
'SOURCE' => '[\w\-]+',

'CONTAINERREGISTRYID' => '\d+',
'PROPOSALID' => '\d+',
Expand Down Expand Up @@ -1557,16 +1558,17 @@ function _add_dewar()
$fc = $this->has_arg('FACILITYCODE') ? $this->arg('FACILITYCODE') : '';
$wg = $this->has_arg('WEIGHT') ? $this->arg('WEIGHT') : $dewar_weight;
$exp = null;
$source = $this->has_arg('SOURCE') ? $this->arg('SOURCE') : null;

if ($this->has_arg('FIRSTEXPERIMENTID')) {
$experimentId = $this->arg('FIRSTEXPERIMENTID');
$exp = !empty($experimentId) ? $this->arg('FIRSTEXPERIMENTID') : NULL;
}

$this->db->pq(
"INSERT INTO dewar (dewarid,code,trackingnumbertosynchrotron,trackingnumberfromsynchrotron,shippingid,bltimestamp,dewarstatus,firstexperimentid,facilitycode,weight)
VALUES (s_dewar.nextval,:1,:2,:3,:4,CURRENT_TIMESTAMP,'opened',:5,:6,:7) RETURNING dewarid INTO :id",
array($this->arg('CODE'), $to, $from, $this->arg('SHIPPINGID'), $exp, $fc, $wg)
"INSERT INTO dewar (dewarid,code,trackingnumbertosynchrotron,trackingnumberfromsynchrotron,shippingid,bltimestamp,dewarstatus,firstexperimentid,facilitycode,weight,source)
VALUES (s_dewar.nextval,:1,:2,:3,:4,CURRENT_TIMESTAMP,'opened',:5,:6,:7,IFNULL(:8,CURRENT_USER)) RETURNING dewarid INTO :id",
array($this->arg('CODE'), $to, $from, $this->arg('SHIPPINGID'), $exp, $fc, $wg, $source)
);

$id = $this->db->id();
Expand Down Expand Up @@ -2192,11 +2194,12 @@ function _add_container()
$crid = $this->has_arg('CONTAINERREGISTRYID') ? $this->arg('CONTAINERREGISTRYID') : null;

$pipeline = $this->has_arg('PROCESSINGPIPELINEID') ? $this->arg('PROCESSINGPIPELINEID') : null;
$source = $this->has_arg('SOURCE') ? $this->arg('SOURCE') : null;

$this->db->pq(
"INSERT INTO container (containerid,dewarid,code,bltimestamp,capacity,containertype,scheduleid,screenid,ownerid,requestedimagerid,comments,barcode,experimenttype,storagetemperature,containerregistryid,prioritypipelineid)
VALUES (s_container.nextval,:1,:2,CURRENT_TIMESTAMP,:3,:4,:5,:6,:7,:8,:9,:10,:11,:12,:13,:14) RETURNING containerid INTO :id",
array($this->arg('DEWARID'), $this->arg('NAME'), $cap, $this->arg('CONTAINERTYPE'), $sch, $scr, $own, $rid, $com, $bar, $ext, $tem, $crid, $pipeline)
"INSERT INTO container (containerid,dewarid,code,bltimestamp,capacity,containertype,scheduleid,screenid,ownerid,requestedimagerid,comments,barcode,experimenttype,storagetemperature,containerregistryid,prioritypipelineid,source)
VALUES (s_container.nextval,:1,:2,CURRENT_TIMESTAMP,:3,:4,:5,:6,:7,:8,:9,:10,:11,:12,:13,:14,IFNULL(:15,CURRENT_USER)) RETURNING containerid INTO :id",
array($this->arg('DEWARID'), $this->arg('NAME'), $cap, $this->arg('CONTAINERTYPE'), $sch, $scr, $own, $rid, $com, $bar, $ext, $tem, $crid, $pipeline, $source)
);

$cid = $this->db->id();
Expand Down Expand Up @@ -2672,6 +2675,7 @@ function _add_shipment()
$rt = $this->has_arg('READYBYTIME') ? $this->arg('READYBYTIME') : null;
$ct = $this->has_arg('CLOSETIME') ? $this->arg('CLOSETIME') : null;
$loc = $this->has_arg('PHYSICALLOCATION') ? $this->arg('PHYSICALLOCATION') : null;
$source = $this->has_arg('SOURCE') ? $this->arg('SOURCE') : null;

$hard_drive_enclosed = null;
if ($this->has_arg('ENCLOSEDHARDDRIVE')) {
Expand Down Expand Up @@ -2734,9 +2738,9 @@ function _add_shipment()
$extra = json_encode($extra_array);

$this->db->pq(
"INSERT INTO shipping (shippingid, proposalid, shippingname, deliveryagent_agentname, deliveryagent_agentcode, deliveryagent_shippingdate, deliveryagent_deliverydate, bltimestamp, creationdate, comments, sendinglabcontactid, returnlabcontactid, shippingstatus, safetylevel, readybytime, closetime, physicallocation)
VALUES (s_shipping.nextval,:1,:2,:3,:4,TO_DATE(:5,'DD-MM-YYYY'), TO_DATE(:6,'DD-MM-YYYY'),CURRENT_TIMESTAMP,CURRENT_TIMESTAMP,:7,:8,:9,'opened',:10, :11, :12, :13) RETURNING shippingid INTO :id",
array($this->proposalid, $this->arg('SHIPPINGNAME'), $an, $ac, $sd, $dd, $com, $this->arg('SENDINGLABCONTACTID'), $this->arg('RETURNLABCONTACTID'), $this->arg('SAFETYLEVEL'), $rt, $ct, $loc)
"INSERT INTO shipping (shippingid, proposalid, shippingname, deliveryagent_agentname, deliveryagent_agentcode, deliveryagent_shippingdate, deliveryagent_deliverydate, bltimestamp, creationdate, comments, sendinglabcontactid, returnlabcontactid, shippingstatus, safetylevel, readybytime, closetime, physicallocation, source)
VALUES (s_shipping.nextval,:1,:2,:3,:4,TO_DATE(:5,'DD-MM-YYYY'), TO_DATE(:6,'DD-MM-YYYY'),CURRENT_TIMESTAMP,CURRENT_TIMESTAMP,:7,:8,:9,'opened',:10, :11, :12, :13, IFNULL(:14,CURRENT_USER)) RETURNING shippingid INTO :id",
array($this->proposalid, $this->arg('SHIPPINGNAME'), $an, $ac, $sd, $dd, $com, $this->arg('SENDINGLABCONTACTID'), $this->arg('RETURNLABCONTACTID'), $this->arg('SAFETYLEVEL'), $rt, $ct, $loc, $source)
);

$sid = $this->db->id();
Expand All @@ -2763,9 +2767,9 @@ function _add_shipment()
$n = $fc ? $fc : ('Dewar' . ($i + 1));

$this->db->pq(
"INSERT INTO dewar (dewarid,code,shippingid,bltimestamp,dewarstatus,firstexperimentid,facilitycode,weight)
VALUES (s_dewar.nextval,:1,:2,CURRENT_TIMESTAMP,'opened',:3,:4,$dewar_weight) RETURNING dewarid INTO :id",
array($n, $sid, $exp, $fc)
"INSERT INTO dewar (dewarid,code,shippingid,bltimestamp,dewarstatus,firstexperimentid,facilitycode,weight,source)
VALUES (s_dewar.nextval,:1,:2,CURRENT_TIMESTAMP,'opened',:3,:4,:5,IFNULL(:6,CURRENT_USER)) RETURNING dewarid INTO :id",
array($n, $sid, $exp, $fc, $dewar_weight, $source)
);

$id = $this->db->id();
Expand Down
Loading