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

2022 02 03 update for biospecimen import #11

Merged
merged 113 commits into from
Feb 23, 2022
Merged
Changes from all commits
Commits
Show all changes
113 commits
Select commit Hold shift + click to select a range
c893387
[JSX/Form.js] Adding sortByValue Option for Selects and SearchableSel…
ridz1208 Sep 12, 2018
27ae8a8
removed unnecessary lines
ridz1208 Oct 1, 2018
2e9335b
[media] Remove unused code (#3705)
ridz1208 Jun 18, 2018
f406653
Alter Filter Form to avoid stack overflow
Aug 8, 2018
02f4ed1
updated modal window
Oct 4, 2018
713b4c1
Update Modal Window
Oct 4, 2018
6d9e9d6
Added minor changes
Oct 15, 2018
8f1b59d
Hack to allow data provisioner filtering
Oct 19, 2018
0d0b277
made slight change to user class
Oct 19, 2018
e179bf5
Added New Exceptions
Oct 29, 2018
28e939e
rebased to major
HenriRabalais Jan 30, 2019
b41c1d7
removed unnecessary changes
HenriRabalais Jan 30, 2019
a80f928
updating Biobank
HenriRabalais Feb 4, 2019
9d289ca
Added new json response
HenriRabalais Jul 16, 2019
7e7cb8b
added BadRequest exception and OK response
HenriRabalais Jul 16, 2019
1162fee
making this branch functional again
HenriRabalais Jul 18, 2019
6c6d03d
updating Biobank
HenriRabalais Jul 18, 2019
16419d0
Updated Form to work with Biobank Module
HenriRabalais Jul 22, 2019
7021fe1
made change to multiple select to always store data as array
HenriRabalais Jul 25, 2019
59e5322
Added ability to map data values
HenriRabalais Jul 29, 2019
e36b159
fixed menu filtering and updated biobank schema script
HenriRabalais Jul 31, 2019
8c545f6
updated Form.js pattern for time to not include seconds
HenriRabalais Aug 1, 2019
ec535eb
fixed sql patch
HenriRabalais Aug 12, 2019
5123150
first commit
PapillonMcGill Aug 14, 2019
cba74d1
Update Date and Time Elements
HenriRabalais Aug 19, 2019
51dd44e
Merge remote-tracking branch 'rabalais/Biobank' into HEAD
kchatpar Aug 19, 2019
4d32858
Fixed bug in time element
HenriRabalais Aug 28, 2019
850d0f4
Merge remote-tracking branch 'rabalais/Biobank' into HEAD
kchatpar Aug 28, 2019
fd08b7a
Update biobank script to include comments for containers
HenriRabalais Sep 3, 2019
6c27aa8
Made datatable component instead of purecomponent
kchatpar Sep 3, 2019
b032729
Merge remote-tracking branch 'rabalais/Biobank' into HEAD
kchatpar Sep 3, 2019
43789b8
updated sql script for biobank
HenriRabalais Sep 17, 2019
dcd903b
type fix in column name
kchatpar Sep 26, 2019
f5df784
Merge branch 'Biobank' of https://github.com/HenriRabalais/Loris into…
kchatpar Sep 26, 2019
95ad175
[JSX/Form.js] Adding sortByValue Option for Selects and SearchableSel…
ridz1208 Sep 12, 2018
f54b8bc
removed unnecessary lines
ridz1208 Oct 1, 2018
0b65896
[media] Remove unused code (#3705)
ridz1208 Jun 18, 2018
c0051d7
Alter Filter Form to avoid stack overflow
Aug 8, 2018
143c523
updated modal window
Oct 4, 2018
f08f749
Update Modal Window
Oct 4, 2018
1eb3259
Added minor changes
Oct 15, 2018
6994219
Hack to allow data provisioner filtering
Oct 19, 2018
789f049
made slight change to user class
Oct 19, 2018
4768d5e
Added New Exceptions
Oct 29, 2018
4ff4c13
rebased to major
HenriRabalais Jan 30, 2019
dcbc44b
removed unnecessary changes
HenriRabalais Jan 30, 2019
760673d
updating Biobank
HenriRabalais Feb 4, 2019
79a1857
Added new json response
HenriRabalais Jul 16, 2019
8e2505d
added BadRequest exception and OK response
HenriRabalais Jul 16, 2019
dcdc6c9
making this branch functional again
HenriRabalais Jul 18, 2019
20d1501
updating Biobank
HenriRabalais Jul 18, 2019
af2a999
Updated Form to work with Biobank Module
HenriRabalais Jul 22, 2019
5697671
made change to multiple select to always store data as array
HenriRabalais Jul 25, 2019
4bfae29
Added ability to map data values
HenriRabalais Jul 29, 2019
f4696f3
fixed menu filtering and updated biobank schema script
HenriRabalais Jul 31, 2019
8f59f1a
updated Form.js pattern for time to not include seconds
HenriRabalais Aug 1, 2019
80384f4
fixed sql patch
HenriRabalais Aug 12, 2019
7e34632
Update Date and Time Elements
HenriRabalais Aug 19, 2019
b820342
Fixed bug in time element
HenriRabalais Aug 28, 2019
6441469
Update biobank script to include comments for containers
HenriRabalais Sep 3, 2019
e11d06d
updated sql script for biobank
HenriRabalais Sep 17, 2019
11ed58c
Merge branch 'Biobank' of https://github.com/HenriRabalais/Loris into…
kchatpar Oct 15, 2019
39a3ae0
fixed issues with csv download and datatable
kchatpar Oct 16, 2019
17377df
deleted untracked files
HenriRabalais Oct 16, 2019
b6361be
Fiexed date error message
kchatpar Oct 16, 2019
ff9756e
Merge remote-tracking branch 'rabalais/Biobank' into Biobank
kchatpar Oct 16, 2019
11734c5
Fixed Datatable functionality
PapillonMcGill Oct 24, 2019
db5f5de
added autoSelect prop which will auotomatically select the dropdown o…
PapillonMcGill Oct 24, 2019
26bcd6a
made changes requested by Krishna
HenriRabalais Oct 29, 2019
e1734c5
made overrides for CBIGR
PapillonMcGill Nov 1, 2019
8736697
Configured raisinbread to work with Biobank
HenriRabalais Dec 6, 2019
b37795d
Add 0000* sql
ridz1208 Dec 6, 2019
92dae04
Merge pull request #1 from ridz1208/add_000_files
HenriRabalais Dec 6, 2019
8b883c4
Update drop tables
HenriRabalais Dec 6, 2019
94ca78d
Merge remote-tracking branch 'origin/Biobank' into Biobank
HenriRabalais Dec 6, 2019
f2539ba
fixed drop script
HenriRabalais Dec 9, 2019
fbf34f2
modified sql scripts so that they are contained within the biobank mo…
HenriRabalais Dec 16, 2019
18d71ba
fixed pagination problems
HenriRabalais Jan 8, 2020
70c5563
fixed sql script
HenriRabalais Feb 17, 2020
d59c993
Update for new functions
kchatpar Mar 26, 2020
26fb900
Merge pull request #2 from HenriRabalais/biobankUpdate
HenriRabalais Mar 26, 2020
01dd34d
updates for advanced functionality
kchatpar Apr 7, 2020
9f7aa40
added external ID api endpoint
kchatpar Apr 7, 2020
42dc699
Merge pull request #3 from HenriRabalais/newFunctions
HenriRabalais Apr 7, 2020
e58a27c
updated Modal functionality
kchatpar Jul 6, 2020
16887bf
Merge pull request #6 from HenriRabalais/modalUpgrade
HenriRabalais Jul 6, 2020
1d3b91f
introduced Loading Bar
kchatpar Jul 20, 2020
5602dfd
API fixes
ridz1208 May 5, 2020
e5662c9
API +
ridz1208 Jun 22, 2020
1602696
Merge pull request #5 from ridz1208/cbigr_merger
ridz1208 Sep 14, 2020
04b1ea8
[DQT] Fix for Bio Specimens files
laemtl Oct 20, 2020
998df6b
Merge pull request #12 from laemtl/2020-10-10-dqt-specimen-files-fix
ridz1208 Oct 25, 2020
ffa4a81
[DQT] CBIGR/Biobank include redesigned DQT (#10)
maltheism Oct 26, 2020
db862f2
Make LINST slightly better (#15)
ridz1208 Oct 27, 2020
bf5f9e2
candidate_list and datadictbuilder fix
ridz1208 Nov 1, 2020
bacf272
gitignore
ridz1208 Nov 2, 2020
4690ecc
update
Misotheism Nov 2, 2020
53e6e09
remove console.log
Misotheism Nov 2, 2020
044416a
Merge pull request #19 from maltheism/Biobank_multiselect_toggle_fix
ridz1208 Nov 6, 2020
11756cf
add fixes from main
maltheism Nov 6, 2020
937c2f1
Merge pull request #21 from maltheism/biobank_update_datatable
ridz1208 Nov 6, 2020
6de0835
Fix public pages missing title
laemtl Nov 11, 2020
02a867c
Merge pull request #24 from laemtl/Biobank
ridz1208 Nov 11, 2020
bcefa14
Biobank branch adapted for the new shipment module
kchatpar May 20, 2021
10619a1
updated form and modal
kchatpar Jun 2, 2021
0b74dce
Merge remote-tracking branch 'henri/Biobank' into 2021-09-09-update21…
zaliqarosli Sep 9, 2021
2e81d1e
fix
zaliqarosli Sep 9, 2021
d18b545
fix errors for make dev to work
zaliqarosli Jan 26, 2022
250408c
reversals
zaliqarosli Jan 26, 2022
48b3726
update react files to npm version
zaliqarosli Jan 26, 2022
a2a9bc5
revert StaticElement
zaliqarosli Jan 26, 2022
d799681
update CandidatesExt endpoint
zaliqarosli Feb 3, 2022
4e18e23
Merge remote-tracking branch 'zaliqa/21.0-qpn-biobank' into 2022-02-0…
zaliqarosli Feb 18, 2022
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
193 changes: 17 additions & 176 deletions htdocs/api/v0.0.3-dev/CandidatesExtID.php
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,6 @@ public function __construct($method, $data=null)
{
$this->AllowedMethods = [
'GET',
'POST',
];
$this->RequestData = $data;

Expand Down Expand Up @@ -72,23 +71,29 @@ function calculateETag()
public function handleGET()
{
$result = $this->DB->pselect(
"SELECT c.CandID, ProjectID, PSCID, s.Name as Site,
EDC, DoB, Sex, ExtStudyID, ses.ID as SessionID
FROM candidate c JOIN psc s on (s.CenterID=c.RegistrationCenterID)
LEFT JOIN candidate_project_extid_rel cpe ON (cpe.CandID = c.CandID)
LEFT JOIN Project_external pe ON (cpe.ProjectExternalID= pe.ProjectExternalID)
LEFT JOIN session ses ON (cpe.CandID = ses.CandID)
WHERE c.Active='Y' AND pe.Name=:name
",
["name"=>"QPN"]
"SELECT
c.CandID,
ProjectID,
PSCID,
s.Name as Site,
EDC,
DoB,
Sex,
ses.ID as SessionID,
ses.Visit_label as VisitLabel
FROM candidate c
JOIN psc s on (s.CenterID=c.RegistrationCenterID)
LEFT JOIN session ses USING (CandID)
WHERE c.Active='Y' AND c.Entity_type!='Scanner'",
[]
);

$candidates = [];
foreach ($result as $row) {
if (empty($candidates[$row['CandID']])) {
$candidates[$row['CandID']] = $row;
}
$candidates[$row['CandID']]['SessionIDs'][] = $row['SessionID'];
$candidates[$row['CandID']]['SessionIDs'][$row['VisitLabel']] = $row['SessionID'];
unset($candidates[$row['CandID']]['SessionID']);
}

Expand All @@ -106,174 +111,10 @@ function ($row) use ($projects) {

$this->JSON = ["Candidates" => $candValues];
}

/**
* Handles a candidates POST request to validate data and if everything
* is valid, create the candidate
*
* @return void but populates $this->JSON and writes to DB
*/
public function handlePOST()
{
$candid = null;
$data = $this->RequestData;
if ($data === null) {
$this->header("HTTP/1.1 400 Bad Request");
$this->error("Can't parse data");
$this->safeExit(0);
}

if (!isset($data['Candidate'])) {
$this->header("HTTP/1.1 400 Bad Request");
$this->error("There is no Candidate object in the POST data");
$this->safeExit(0);
}
// The API requires siteName as an input to candidate creation
$user = \User::singleton();
$centerIDs = $user->getCenterIDs();
$allSiteNames = array();
$allUserSiteNames = array();
$num_sites = count($centerIDs);
if ($num_sites == 0) {
$this->header("HTTP/1.1 401 Unauthorized");
$this->error("You are not affiliated with any site");
$this->safeExit(0);
} else {
$allSiteNames = $this->DB->pselectColWithIndexKey(
"SELECT CenterID, Name FROM psc ",
array(),
"CenterID"
);
$allUserSiteNames = $this->DB->pselectColWithIndexKey(
"SELECT CenterID, Name FROM psc WHERE FIND_IN_SET(CenterID, :cid)",
array('cid' => implode(',', $centerIDs)),
"CenterID"
);

$siteName = $data['Candidate']['Site'];
// This will check that the SiteName provided is a valid one
$this->verifyField($data, 'Site', $allSiteNames);
$this->verifyField($data, 'Sex', ['Male', 'Female']);
$this->verifyField($data, 'EDC', 'YYYY-MM-DD');
$this->verifyField($data, 'DoB', 'YYYY-MM-DD');
// Get the CenterID from the provided SiteName, and check if the
// user has permission to create a candidate at this site
$centerID = array_search($siteName, $allUserSiteNames);

if ($centerID === false) {
$this->header("HTTP/1.1 403 Forbidden");
$this->error("You are not affiliated with the candidate's site");
$this->safeExit(0);
}

//Candidate::createNew
try {
$candid = $this->createNew(
$centerID,
$data['Candidate']['DoB'],
$data['Candidate']['EDC'],
$data['Candidate']['Sex'],
$data['Candidate']['PSCID']
);
} catch(\LorisException $e) {
$this->header("HTTP/1.1 400 Bad Request");
$this->safeExit(0);
}

}

$candidate = \Candidate::singleton($candid);

if (isset($data['Candidate']['Project'])) {
$projectName = $data['Candidate']['Project'];
$project = \Project::singleton($projectName);
if (!empty($project)) {
$candidate->setData(
array('ProjectID' => $project->getId())
);
}
}

$candidateinfo = array(
'CandID' => $candidate->getCandID(),
'Project' => $candidate->getProjectTitle(),
'PSCID' => $candidate->getPSCID(),
'Site' => $candidate->getCandidateSite(),
'EDC' => $candidate->getCandidateEDC(),
'DoB' => $candidate->getCandidateDoB(),
'Sex' => $candidate->getCandidateSex(),
);

$this->header("HTTP/1.1 201 Created");
$this->JSON = $candidateinfo;
}

/**
* Verifies that the field POSTed to the URL is valid.
*
* @param array $data The data that was posted
* @param string $field The field to be validated in $data
* @param mixed $values Can either be an array of valid values for
* the field, or a string representing the format
* expected of the data.
*
* @return void but will generate an error and exit if the value is invalid.
*/
protected function verifyField($data, $field, $values)
{
if (!isset($data['Candidate'][$field])) {
$this->header("HTTP/1.1 400 Bad Request");
$this->error("Candidate's field missing");
$this->safeExit(0);
}
if (is_array($values) && !in_array($data['Candidate'][$field], $values)) {
$this->header("HTTP/1.1 400 Bad Request");
$this->error("Value not permitted");
$this->safeExit(0);
}
if ($values === 'YYYY-MM-DD'
&& !preg_match("/\d\d\d\d\-\d\d\-\d\d/", $data['Candidate'][$field])
) {
$this->header("HTTP/1.1 400 Bad Request");
$this->error("Invalid date format");
$this->safeExit(0);
}
}

/**
* Testable wrapper for Candidate::createNew
*
* @param string $centerID The center id of the candidate
* @param string $DoB Date of birth of the candidate
* @param string $edc EDC of the candidate
* @param string $sex Biological sex of the candidate to be created
* @param string $PSCID PSCID of the candidate to be created
*
* @return int $candID candidate id of the new candidate
*/
public function createNew($centerID, $DoB, $edc, $sex, $PSCID)
{
return \Candidate::createNew(
$centerID,
$DoB,
$edc,
$sex,
$PSCID
);
}
}

if (isset($_REQUEST['PrintCandidates'])) {
if ($_SERVER['REQUEST_METHOD'] === 'POST') {
$fp = fopen("php://input", "r");
$data = '';
while (!feof($fp)) {
$data .= fread($fp, 1024);
}
fclose($fp);

$obj = new CandidatesExtID($_SERVER['REQUEST_METHOD'], json_decode($data, true));
} else {
if ($_SERVER['REQUEST_METHOD'] === 'GET') {
$obj = new CandidatesExtID($_SERVER['REQUEST_METHOD']);
}
print $obj->toJSONString();
Expand Down