diff --git a/hdrl/build.gradle b/hdrl/build.gradle
deleted file mode 100644
index 405ae240..00000000
--- a/hdrl/build.gradle
+++ /dev/null
@@ -1,3 +0,0 @@
-plugins {
- id 'org.labkey.build.module'
-}
diff --git a/hdrl/module.properties b/hdrl/module.properties
deleted file mode 100644
index 4a8d19cc..00000000
--- a/hdrl/module.properties
+++ /dev/null
@@ -1,2 +0,0 @@
-ModuleClass: org.labkey.hdrl.HDRLModule
-ManageVersion: true
diff --git a/hdrl/resources/credits/scripts.txt b/hdrl/resources/credits/scripts.txt
deleted file mode 100644
index dc5de38f..00000000
--- a/hdrl/resources/credits/scripts.txt
+++ /dev/null
@@ -1,4 +0,0 @@
-{table}
-Library|Version|Source|License|LabKey Dev|Purpose
-Code39Azalea| |{link:Azalea Software|http://azalea.com/web-fonts/}|{link:Creative Commons|http://creativecommons.org/licenses/by-nd/3.0/deed.en_US}|klum|Barcode Web Fonts
-{table}
\ No newline at end of file
diff --git a/hdrl/resources/etls/labware.xml b/hdrl/resources/etls/labware.xml
deleted file mode 100644
index 3d50cdd0..00000000
--- a/hdrl/resources/etls/labware.xml
+++ /dev/null
@@ -1,25 +0,0 @@
-
-
- LabWare Result Tables
- Update test result data from LabWare tables to LabKey tables.
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
diff --git a/hdrl/resources/queries/gw_labkey/specimensWithoutReport.sql b/hdrl/resources/queries/gw_labkey/specimensWithoutReport.sql
deleted file mode 100644
index 1bd49ddd..00000000
--- a/hdrl/resources/queries/gw_labkey/specimensWithoutReport.sql
+++ /dev/null
@@ -1,27 +0,0 @@
-/*
- * Copyright (c) 2015 LabKey Corporation
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-SELECT test_request_id,
- batch_id,
- date_received,
- date_completed,
- sample_integrity,
- test_result,
- customer_code,
- hdrl_status,
- date_modified,
- modified_result_flag,
- report_file_name
-FROM x_lk_outbd_specimens;
\ No newline at end of file
diff --git a/hdrl/resources/queries/hdrl/InboundSpecimen/.qview.xml b/hdrl/resources/queries/hdrl/InboundSpecimen/.qview.xml
deleted file mode 100644
index 4ea742b2..00000000
--- a/hdrl/resources/queries/hdrl/InboundSpecimen/.qview.xml
+++ /dev/null
@@ -1,18 +0,0 @@
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
diff --git a/hdrl/resources/queries/hdrl/labwareRequestResults.sql b/hdrl/resources/queries/hdrl/labwareRequestResults.sql
deleted file mode 100644
index d16487c0..00000000
--- a/hdrl/resources/queries/hdrl/labwareRequestResults.sql
+++ /dev/null
@@ -1,23 +0,0 @@
-/*
- * Copyright (c) 2015-2019 LabKey Corporation
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-SELECT batch_id as RequestId,
- customer_note as CustomerNote,
- date_received as Received,
- date_completed as Completed,
- date_modified as Modified,
- s.RowId as RequestStatusId
- FROM labwareOutboundRequests
- LEFT JOIN RequestStatus s ON s.name = hdrl_status;
diff --git a/hdrl/resources/queries/hdrl/labwareSpecimenResults.sql b/hdrl/resources/queries/hdrl/labwareSpecimenResults.sql
deleted file mode 100644
index 59317055..00000000
--- a/hdrl/resources/queries/hdrl/labwareSpecimenResults.sql
+++ /dev/null
@@ -1,28 +0,0 @@
-/*
- * Copyright (c) 2015-2019 LabKey Corporation
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-SELECT test_request_id AS SpecimenId,
- batch_id as RequestId,
- date_received AS Received,
- date_completed as Completed,
- sample_integrity as SampleIntegrity,
- test_result as TestResult,
- customer_code as CustomerCode,
- date_modified as Modified,
- modified_result_flag as ModifiedResultFlag,
- hs.RowId AS RequestStatusId,
- report_file_name as ReportFileName
- FROM labwareOutboundSpecimens
- LEFT JOIN RequestStatus hs ON hs.name = hdrl_status;
\ No newline at end of file
diff --git a/hdrl/resources/queries/hdrl/specimens.query.xml b/hdrl/resources/queries/hdrl/specimens.query.xml
deleted file mode 100644
index 7fd37c84..00000000
--- a/hdrl/resources/queries/hdrl/specimens.query.xml
+++ /dev/null
@@ -1,74 +0,0 @@
-
-
-
-
-
-
- Request Id
-
-
- Specimen Id
-
-
- Status
-
- rowId
- requestStatus
- hdrl
-
-
-
- Result Modified
-
-
-
-
-
-
-
- Gender
-
- RowId
- gender
- hdrl
-
-
-
-
-
-
- FMP
-
- RowId
- familyMemberPrefix
- hdrl
-
-
-
- DUC
-
- RowId
- dutyCode
- hdrl
-
-
-
- SOT
-
- RowId
- sourceOfTesting
- hdrl
-
-
-
-
-
-
-
-
-
-
-
-
-
-
\ No newline at end of file
diff --git a/hdrl/resources/queries/hdrl/specimens.sql b/hdrl/resources/queries/hdrl/specimens.sql
deleted file mode 100644
index 9ab1584a..00000000
--- a/hdrl/resources/queries/hdrl/specimens.sql
+++ /dev/null
@@ -1,40 +0,0 @@
-/*
- * Copyright (c) 2015-2019 LabKey Corporation
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-SELECT
- spec.RowId AS RowId,
- spec.inboundRequestId as InboundRequestId,
- res.RequestStatusId AS RequestStatusId,
- res.ModifiedResultFlag AS ModifiedResultFlag,
- spec.CustomerBarcode AS CustomerBarcode,
- spec.LastName AS LastName,
- spec.FirstName AS FirstName,
- spec.MiddleName AS MiddleName,
- spec.Initials AS Initials,
- spec.GenderId AS GenderId,
- spec.BirthDate AS BirthDate,
- spec.DODId AS DODId,
- spec.SSN AS SSN,
- spec.FMPId AS FMPId,
- spec.DutyCodeId AS DutyCodeid,
- spec.TestingSourceId AS TestingSourceId,
- spec.DrawDate as DrawDate,
- res.Received AS Received,
- res.Completed AS Completed,
- res.SampleIntegrity AS SampleIntegrity,
- res.TestResult AS TestResult,
- res.CustomerCode AS CustomerCode,
- res.ReportFileName as ReportFileName
-FROM hdrl.InboundSpecimen spec LEFT JOIN hdrl.SpecimenResult res ON spec.RowId = res.specimenId;
\ No newline at end of file
diff --git a/hdrl/resources/schemas/dbscripts/oracle/labware.sql b/hdrl/resources/schemas/dbscripts/oracle/labware.sql
deleted file mode 100644
index e91fe893..00000000
--- a/hdrl/resources/schemas/dbscripts/oracle/labware.sql
+++ /dev/null
@@ -1,111 +0,0 @@
--- =============================================
--- Author: C. Schoening
--- Create date: 24-Jun-2015
--- Description: Creates the LabKey interface tables in the GW_LABKEY schema
--- This script must be run Logged in with the "gw_labkey" user previously created
--- Change History:
--- 01-Jul-2015 CRS Added Not Null and Foreign Key constraints
--- 07-Jul-2015 CRS Added additional fields to outbound tables
--- =============================================
-
---------------------------------------------------------
--- DDL for Table X_LK_INBND_REQUESTS
---------------------------------------------------------
-CREATE TABLE X_LK_INBND_REQUESTS
-(
- BATCH_ID NUMBER NOT NULL
-, CARRIER VARCHAR2(40)
-, TRACKING_NUMBER VARCHAR2(40)
-, CUSTOMER VARCHAR2(100) NOT NULL
-, CONSTRAINT X_LK_INBND_REQUESTS_PK PRIMARY KEY
- (
- BATCH_ID
- )
- ENABLE
-);
-
---------------------------------------------------------
--- DDL for Table X_LK_INBND_SPECIMENS
---------------------------------------------------------
-CREATE TABLE X_LK_INBND_SPECIMENS
-(
- TEST_REQUEST_ID NUMBER NOT NULL
-, BATCH_ID NUMBER NOT NULL
-, TEST_REQUESTED VARCHAR2(100) NOT NULL
-, CUST_BARCODE VARCHAR2(40)
-, FMP VARCHAR2(2) NOT NULL
-, SSN VARCHAR2(9) NOT NULL
-, DRAW_DATE DATE NOT NULL
-, SPECIMEN_TYPE VARCHAR2(20)
-, NUM_CONTAINERS NUMBER
-, SOT VARCHAR2(1)
-, DUC VARCHAR2(5)
-, DOD_ID VARCHAR2(20)
-, FIRST_NAME VARCHAR2(40)
-, MIDDLE_NAME VARCHAR2(40)
-, LAST_NAME VARCHAR2(80)
-, BIRTH_DATE DATE
-, GENDER VARCHAR2(20)
-, INITIALS VARCHAR2(5)
-, CONSTRAINT X_LK_INBND_SPECIMENS_PK PRIMARY KEY
- (
- TEST_REQUEST_ID
- )
- ENABLE
-);
-
---------------------------------------------------------
--- Add Foreign Key from X_LK_INBND_SPECIMENS to X_LK_INBND_REQUESTS
---------------------------------------------------------
-ALTER TABLE X_LK_INBND_REQUESTS ADD CONSTRAINT INBND_SPECIMENS_BATCH_ID_FK
- FOREIGN KEY (BATCH_ID) REFERENCES X_LK_INBND_REQUESTS(BATCH_ID);
-
---------------------------------------------------------
--- DDL for Table X_LK_OUTBD_REQUESTS
---------------------------------------------------------
-CREATE TABLE X_LK_OUTBD_REQUESTS
-(
- BATCH_ID NUMBER NOT NULL
-, HDRL_STATUS VARCHAR2(20) NOT NULL
-, CUSTOMER_NOTE VARCHAR2(254)
-, DATE_RECEIVED DATE
-, DATE_COMPLETED DATE
-, DATE_MODIFIED DATE
-, CONSTRAINT X_LK_OUTBD_REQUESTS_PK PRIMARY KEY
- (
- BATCH_ID
- )
- ENABLE
-);
-
---------------------------------------------------------
--- DDL for Table X_LK_OUTBD_SPECIMENS
---------------------------------------------------------
-CREATE TABLE X_LK_OUTBD_SPECIMENS
-(
- TEST_REQUEST_ID NUMBER NOT NULL
-, BATCH_ID NUMBER NOT NULL
-, DATE_RECEIVED DATE
-, DATE_COMPLETED DATE
-, SAMPLE_INTEGRITY VARCHAR2(80)
-, TEST_RESULT VARCHAR2(254)
-, CUSTOMER_CODE VARCHAR2(80)
-, CLINICAL_REPORT BLOB
-, HDRL_STATUS VARCHAR2(20) NOT NULL
-, DATE_MODIFIED DATE
-, MODIFIED_RESULT_FLAG VARCHAR2(1)
-, REPORT_FILE_NAME VARCHAR2(20)
-, CONSTRAINT X_LK_OUTBD_SPECIMENS_PK PRIMARY KEY
- (
- TEST_REQUEST_ID
- )
- ENABLE
-);
-
---------------------------------------------------------
--- Add Foreign Key from X_LK_OUTBD_SPECIMENS to X_LK_OUTBD_REQUESTS
---------------------------------------------------------
-ALTER TABLE X_LK_OUTBD_SPECIMENS ADD CONSTRAINT OUTBD_SPECIMENS_BATCH_ID_FK
- FOREIGN KEY (BATCH_ID) REFERENCES X_LK_OUTBD_REQUESTS(BATCH_ID);
-
-commit;
diff --git a/hdrl/resources/schemas/dbscripts/postgresql/hdrl-0.00-16.20.sql b/hdrl/resources/schemas/dbscripts/postgresql/hdrl-0.00-16.20.sql
deleted file mode 100644
index 00bd1d79..00000000
--- a/hdrl/resources/schemas/dbscripts/postgresql/hdrl-0.00-16.20.sql
+++ /dev/null
@@ -1,474 +0,0 @@
-/*
- * Copyright (c) 2018-2019 LabKey Corporation
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-/* hdrl-0.00-15.30.sql */
-
--- Note: Despite the version number, this script was actually added early in the 15.20 cycle.
-CREATE SCHEMA hdrl;
-
-CREATE TABLE hdrl.RequestStatus
-(
- RowId SERIAL NOT NULL,
- Name VARCHAR(32) NOT NULL,
- Description VARCHAR(128),
-
- CONSTRAINT PK_RequestStatus PRIMARY KEY (RowId),
- CONSTRAINT UQ_RequestStatus UNIQUE (Name)
-);
-
-INSERT INTO hdrl.RequestStatus VALUES (DEFAULT, 'Pending', 'Not yet submitted');
-INSERT INTO hdrl.RequestStatus VALUES (DEFAULT, 'Submitted', 'User has submitted the request but no other progress has occurred');
-INSERT INTO hdrl.RequestStatus VALUES (DEFAULT, 'Received', 'All specimens in the request were successfully received by the lab and are being processed');
-INSERT INTO hdrl.RequestStatus VALUES (DEFAULT, 'Completed', 'All specimens in the request have been tested, results are available');
-INSERT INTO hdrl.RequestStatus VALUES (DEFAULT, 'Exception', 'There was some issue with one or more of the specimens in the lab');
-INSERT INTO hdrl.RequestStatus VALUES (DEFAULT, 'Archived', 'There was some issue with one or more of the specimens in the lab');
-
-CREATE TABLE hdrl.TestType
-(
- RowId SERIAL NOT NULL,
- Name VARCHAR(128) NOT NULL,
-
- CONSTRAINT PK_TestType PRIMARY KEY (RowId),
- CONSTRAINT UQ_TestType UNIQUE (Name)
-);
-
-INSERT INTO hdrl.TestType VALUES(DEFAULT, 'HIV Screening Algorithm');
-
-CREATE TABLE hdrl.FamilyMemberPrefix
-(
- RowId SERIAL NOT NULL,
- Code CHAR(2) NOT NULL,
- Description VARCHAR(128),
-
- CONSTRAINT PK_FamilyMemberPrefix PRIMARY KEY (RowId),
- CONSTRAINT UQ_FamilyMemberPrefix UNIQUE (Code)
-);
-
-INSERT INTO hdrl.FamilyMemberPrefix VALUES(DEFAULT, '00', 'No FMP Number (MEPS)');
-INSERT INTO hdrl.FamilyMemberPrefix VALUES(DEFAULT, '01', 'Oldest child');
-INSERT INTO hdrl.FamilyMemberPrefix VALUES(DEFAULT, '02', '2nd oldest child');
-INSERT INTO hdrl.FamilyMemberPrefix VALUES(DEFAULT, '03', '3rd oldest child');
-INSERT INTO hdrl.FamilyMemberPrefix VALUES(DEFAULT, '04', '4th oldest child');
-INSERT INTO hdrl.FamilyMemberPrefix VALUES(DEFAULT, '05', '5th oldest child');
-INSERT INTO hdrl.FamilyMemberPrefix VALUES(DEFAULT, '06', '6th oldest child');
-INSERT INTO hdrl.FamilyMemberPrefix VALUES(DEFAULT, '07', '7th oldest child');
-INSERT INTO hdrl.FamilyMemberPrefix VALUES(DEFAULT, '08', '8th oldest child');
-INSERT INTO hdrl.FamilyMemberPrefix VALUES(DEFAULT, '09', '9th oldest child');
-INSERT INTO hdrl.FamilyMemberPrefix VALUES(DEFAULT, '20', 'Sponsor');
-INSERT INTO hdrl.FamilyMemberPrefix VALUES(DEFAULT, '30', 'Sponsor''s current spouse');
-INSERT INTO hdrl.FamilyMemberPrefix VALUES(DEFAULT, '31', 'Sponsor''s Eligible Former Spouse(s)');
-INSERT INTO hdrl.FamilyMemberPrefix VALUES(DEFAULT, '32', 'Sponsor''s Eligible Former Spouse(s)');
-INSERT INTO hdrl.FamilyMemberPrefix VALUES(DEFAULT, '33', 'Sponsor''s Eligible Former Spouse(s)');
-INSERT INTO hdrl.FamilyMemberPrefix VALUES(DEFAULT, '40', 'Sponsor''s Dependent Mother or Stepmother');
-INSERT INTO hdrl.FamilyMemberPrefix VALUES(DEFAULT, '45', 'Sponsor''s Dependent Father or Stepfather');
-INSERT INTO hdrl.FamilyMemberPrefix VALUES(DEFAULT, '50', 'Sponsor''s Dependent Mother-in-law');
-INSERT INTO hdrl.FamilyMemberPrefix VALUES(DEFAULT, '55', 'Sponsor''s Dependent Father-in-law');
-INSERT INTO hdrl.FamilyMemberPrefix VALUES(DEFAULT, '60', 'Other Authorized Sponsor''s Dependents');
-INSERT INTO hdrl.FamilyMemberPrefix VALUES(DEFAULT, '61', 'Other Authorized Sponsor''s Dependents');
-INSERT INTO hdrl.FamilyMemberPrefix VALUES(DEFAULT, '62', 'Other Authorized Sponsor''s Dependents');
-INSERT INTO hdrl.FamilyMemberPrefix VALUES(DEFAULT, '63', 'Other Authorized Sponsor''s Dependents');
-INSERT INTO hdrl.FamilyMemberPrefix VALUES(DEFAULT, '64', 'Other Authorized Sponsor''s Dependents');
-INSERT INTO hdrl.FamilyMemberPrefix VALUES(DEFAULT, '65', 'Other Authorized Sponsor''s Dependents');
-INSERT INTO hdrl.FamilyMemberPrefix VALUES(DEFAULT, '90', 'Children of Dependents');
-INSERT INTO hdrl.FamilyMemberPrefix VALUES(DEFAULT, '91', 'Children of Dependents');
-INSERT INTO hdrl.FamilyMemberPrefix VALUES(DEFAULT, '92', 'Children of Dependents');
-INSERT INTO hdrl.FamilyMemberPrefix VALUES(DEFAULT, '93', 'Children of Dependents');
-INSERT INTO hdrl.FamilyMemberPrefix VALUES(DEFAULT, '94', 'Children of Dependents');
-INSERT INTO hdrl.FamilyMemberPrefix VALUES(DEFAULT, '95', 'Children of Dependents');
-INSERT INTO hdrl.FamilyMemberPrefix VALUES(DEFAULT, '98', 'Civilian, Indigent and Non-Indigent');
-INSERT INTO hdrl.FamilyMemberPrefix VALUES(DEFAULT, '99', 'Other Qualified Beneficiaries');
-
-CREATE TABLE hdrl.SourceOfTesting
-(
- RowId SERIAL NOT NULL,
- Code CHARACTER(1) NOT NULL,
- Description VARCHAR(128),
-
- CONSTRAINT PK_SourceOfTesting PRIMARY KEY (RowId),
- CONSTRAINT UQ_SourceOfTesting UNIQUE (Code)
-);
-
-INSERT INTO hdrl.SourceOfTesting VALUES(DEFAULT, 'A', 'Alcohol and Drug Rehabilitation');
-INSERT INTO hdrl.SourceOfTesting VALUES(DEFAULT, 'B', 'Blood Donor');
-INSERT INTO hdrl.SourceOfTesting VALUES(DEFAULT, 'C', 'Contact Referred HIV');
-INSERT INTO hdrl.SourceOfTesting VALUES(DEFAULT, 'D', 'Deceased (whether DOA or Dying in ER');
-INSERT INTO hdrl.SourceOfTesting VALUES(DEFAULT, 'F', 'Force Testing');
-INSERT INTO hdrl.SourceOfTesting VALUES(DEFAULT, 'H', 'Post-Deployment Serum');
-INSERT INTO hdrl.SourceOfTesting VALUES(DEFAULT, 'I', 'Indicated Clinically');
-INSERT INTO hdrl.SourceOfTesting VALUES(DEFAULT, 'J', 'Jail, Prisoners or Detained Persons');
-INSERT INTO hdrl.SourceOfTesting VALUES(DEFAULT, 'M', 'Medical Adimission (including Psychiatric)');
-INSERT INTO hdrl.SourceOfTesting VALUES(DEFAULT, 'N', 'Pre-deployment Serum');
-INSERT INTO hdrl.SourceOfTesting VALUES(DEFAULT, 'O', 'Obstetrics/Gynecology Test');
-INSERT INTO hdrl.SourceOfTesting VALUES(DEFAULT, 'P', 'Physical Examination');
-INSERT INTO hdrl.SourceOfTesting VALUES(DEFAULT, 'S', 'Surgical Admission (including invasive procedures and trauma patients in the ER)');
-INSERT INTO hdrl.SourceOfTesting VALUES(DEFAULT, 'V', 'Venereal Disease Clinic Visit/STD Clinic');
-INSERT INTO hdrl.SourceOfTesting VALUES(DEFAULT, 'W', 'Double ELISA Positive, Blood Bank Specimen');
-INSERT INTO hdrl.SourceOfTesting VALUES(DEFAULT, 'X', 'Other');
-INSERT INTO hdrl.SourceOfTesting VALUES(DEFAULT, 'Z', 'Redrawn (Double ELISA Positive) Clinical Specimen');
-
-CREATE TABLE hdrl.DutyCode
-(
- RowId SERIAL NOT NULL,
- Code CHARACTER(3),
- Description VARCHAR(128),
- Service VARCHAR(128),
-
- CONSTRAINT PK_DutyCode PRIMARY KEY (RowId),
- CONSTRAINT UQ_DutyDoce UNIQUE (Code)
-);
-
-INSERT INTO hdrl.DutyCode VALUES(DEFAULT,'A12','ACDUTRA-A','USA');
-INSERT INTO hdrl.DutyCode VALUES(DEFAULT,'A13','RECRUITS-A','USA');
-INSERT INTO hdrl.DutyCode VALUES(DEFAULT,'A14','CADETS - ACADEMY','USA');
-INSERT INTO hdrl.DutyCode VALUES(DEFAULT,'A15','ACDU - NTL GUARD','USA');
-INSERT INTO hdrl.DutyCode VALUES(DEFAULT,'A22','INACDUTRA-RESERVE','USA');
-INSERT INTO hdrl.DutyCode VALUES(DEFAULT,'A21','RET-ACDUTRA/ROTC','USA');
-INSERT INTO hdrl.DutyCode VALUES(DEFAULT,'A00','DECEASED SPONSOR','USA');
-INSERT INTO hdrl.DutyCode VALUES(DEFAULT,'A11','ACDU-A','USA');
-INSERT INTO hdrl.DutyCode VALUES(DEFAULT,'A17','Unknown','USA');
-INSERT INTO hdrl.DutyCode VALUES(DEFAULT,'A16','Unknown','USA');
-INSERT INTO hdrl.DutyCode VALUES(DEFAULT,'A23','INACDUTRA-NTL GUARD','USA');
-INSERT INTO hdrl.DutyCode VALUES(DEFAULT,'A24','A24 - unknown - found in Viromed data but not defined in our paper copies','USA');
-INSERT INTO hdrl.DutyCode VALUES(DEFAULT,'A25','A25 - unknown - found in Viromed data but not defined in our paper copies','USA');
-INSERT INTO hdrl.DutyCode VALUES(DEFAULT,'A26','APPLICANT ENLIST','USA');
-INSERT INTO hdrl.DutyCode VALUES(DEFAULT,'A27','EX MIL MATERNITY','USA');
-INSERT INTO hdrl.DutyCode VALUES(DEFAULT,'A28','DEPT OF EX MILITARY','USA');
-INSERT INTO hdrl.DutyCode VALUES(DEFAULT,'A31','RET-A-LOS','USA');
-INSERT INTO hdrl.DutyCode VALUES(DEFAULT,'A32','RET-A-PDRL','USA');
-INSERT INTO hdrl.DutyCode VALUES(DEFAULT,'A33','RET-A-TDRL','USA');
-INSERT INTO hdrl.DutyCode VALUES(DEFAULT,'A41','DEP-ACDU-A','USA');
-INSERT INTO hdrl.DutyCode VALUES(DEFAULT,'A43','DEP-RET-A','USA');
-INSERT INTO hdrl.DutyCode VALUES(DEFAULT,'A45','DEP-ACDU-DEC','USA');
-INSERT INTO hdrl.DutyCode VALUES(DEFAULT,'B11','ACDU-NOAA','NOAA');
-INSERT INTO hdrl.DutyCode VALUES(DEFAULT,'A47','DEP-RET-DEC','USA');
-INSERT INTO hdrl.DutyCode VALUES(DEFAULT,'A48','UNREMARRIED FORMER SPOUSE','USA');
-INSERT INTO hdrl.DutyCode VALUES(DEFAULT,'A49','FAM MBR OF A48','USA');
-INSERT INTO hdrl.DutyCode VALUES(DEFAULT,'B00','DECEASED SPONSOR','NOAA');
-INSERT INTO hdrl.DutyCode VALUES(DEFAULT,'B31','RET-NOAA-LOS','NOAA');
-INSERT INTO hdrl.DutyCode VALUES(DEFAULT,'B32','RET-NOAA-PDRL','NOAA');
-INSERT INTO hdrl.DutyCode VALUES(DEFAULT,'B33','RET-NOAA-TDRL','NOAA');
-INSERT INTO hdrl.DutyCode VALUES(DEFAULT,'B41','DEP-ACDU-NOAA','NOAA');
-INSERT INTO hdrl.DutyCode VALUES(DEFAULT,'B43','DEP-RET-NOAA','NOAA');
-INSERT INTO hdrl.DutyCode VALUES(DEFAULT,'B45','DEP-ACDU-DEC','NOAA');
-INSERT INTO hdrl.DutyCode VALUES(DEFAULT,'B47','DEP-RET-DEC','NOAA');
-INSERT INTO hdrl.DutyCode VALUES(DEFAULT,'B48','UNREMARRIED FORMER SPOUSE','NOAA');
-INSERT INTO hdrl.DutyCode VALUES(DEFAULT,'B49','FAM MBR OF B48','NOAA');
-INSERT INTO hdrl.DutyCode VALUES(DEFAULT,'C00','DECEASED SPONSOR','USCG');
-INSERT INTO hdrl.DutyCode VALUES(DEFAULT,'C13','RECRUITS-CG','USCG');
-INSERT INTO hdrl.DutyCode VALUES(DEFAULT,'C12','ACDUTRA-CG','USCG');
-INSERT INTO hdrl.DutyCode VALUES(DEFAULT,'C11','ACDU-CG','USCG');
-INSERT INTO hdrl.DutyCode VALUES(DEFAULT,'C21','RET-ACDUTRA/ROTC','USCG');
-INSERT INTO hdrl.DutyCode VALUES(DEFAULT,'C14','CADETS - ACADEMY','USCG');
-INSERT INTO hdrl.DutyCode VALUES(DEFAULT,'C41','DEP-ACDU-CG','USCG');
-INSERT INTO hdrl.DutyCode VALUES(DEFAULT,'C33','RET-CG-TDRL','USCG');
-INSERT INTO hdrl.DutyCode VALUES(DEFAULT,'C22','INACDUTRA-RESERVE','USCG');
-INSERT INTO hdrl.DutyCode VALUES(DEFAULT,'C32','RET-CG-PDRL','USCG');
-INSERT INTO hdrl.DutyCode VALUES(DEFAULT,'C31','RET-CG-LOS','USCG');
-INSERT INTO hdrl.DutyCode VALUES(DEFAULT,'C28','DEPT OF EX MILITARY','USCG');
-INSERT INTO hdrl.DutyCode VALUES(DEFAULT,'C27','EX MIL MATERNITY','USCG');
-INSERT INTO hdrl.DutyCode VALUES(DEFAULT,'C26','Applicant Enlist','NOAA');
-INSERT INTO hdrl.DutyCode VALUES(DEFAULT,'C45','DEP-ACDU-DEC','USCG');
-INSERT INTO hdrl.DutyCode VALUES(DEFAULT,'C43','DEP-RET-CG','USCG');
-INSERT INTO hdrl.DutyCode VALUES(DEFAULT,'F12','ACDUTRA-AF','USAF');
-INSERT INTO hdrl.DutyCode VALUES(DEFAULT,'F13','RECRUITS-AF','USAF');
-INSERT INTO hdrl.DutyCode VALUES(DEFAULT,'F14','CADETS-ACADEMY','USAF');
-INSERT INTO hdrl.DutyCode VALUES(DEFAULT,'F00','DECEASED SPONSOR','USAF');
-INSERT INTO hdrl.DutyCode VALUES(DEFAULT,'C48','UNREMARRIED FORMER SPOUSE','USCG');
-INSERT INTO hdrl.DutyCode VALUES(DEFAULT,'C49','FAM MBR OF C48','USCG');
-INSERT INTO hdrl.DutyCode VALUES(DEFAULT,'C47','DEP-RET-DEC','USCG');
-INSERT INTO hdrl.DutyCode VALUES(DEFAULT,'F11','ACDU-AF','USAF');
-INSERT INTO hdrl.DutyCode VALUES(DEFAULT,'F15','ACDU-NTL GUARD','USAF');
-INSERT INTO hdrl.DutyCode VALUES(DEFAULT,'F21','RET-ACDUTRA/ROTC','USAF');
-INSERT INTO hdrl.DutyCode VALUES(DEFAULT,'F22','INACDUTRA-RESERVE','USAF');
-INSERT INTO hdrl.DutyCode VALUES(DEFAULT,'F23','INACDUTRA-NTL GUARD','USAF');
-INSERT INTO hdrl.DutyCode VALUES(DEFAULT,'F26','APPLICANT ENLIST','USAF');
-INSERT INTO hdrl.DutyCode VALUES(DEFAULT,'F27','EX MIL MATERNITY','USAF');
-INSERT INTO hdrl.DutyCode VALUES(DEFAULT,'F28','DEPT OF EX MILITARY','USAF');
-INSERT INTO hdrl.DutyCode VALUES(DEFAULT,'F31','RET-AF-LOS','USAF');
-INSERT INTO hdrl.DutyCode VALUES(DEFAULT,'F32','RET-AF-PDRL','USAF');
-INSERT INTO hdrl.DutyCode VALUES(DEFAULT,'F33','RET-AF-TDRL','USAF');
-INSERT INTO hdrl.DutyCode VALUES(DEFAULT,'F41','DEP-ACDU-AF','USAF');
-INSERT INTO hdrl.DutyCode VALUES(DEFAULT,'F43','DEP-RET-AF','USAF');
-INSERT INTO hdrl.DutyCode VALUES(DEFAULT,'F45','DEP-ACDU-DEC','USAF');
-INSERT INTO hdrl.DutyCode VALUES(DEFAULT,'F47','DEP-RET-DEC','USAF');
-INSERT INTO hdrl.DutyCode VALUES(DEFAULT,'F48','UNREMARRIED FORMER SPOUSE','USAF');
-INSERT INTO hdrl.DutyCode VALUES(DEFAULT,'F49','FAM MBR OF F48','USAF');
-INSERT INTO hdrl.DutyCode VALUES(DEFAULT,'K51','Civilian Employee (OCONUS)','OTHER_ELIGIBLES');
-INSERT INTO hdrl.DutyCode VALUES(DEFAULT,'K52','Fam Mbr of K51','OTHER_ELIGIBLES');
-INSERT INTO hdrl.DutyCode VALUES(DEFAULT,'K53','Civ Employee(Fed Other)','OTHER_ELIGIBLES');
-INSERT INTO hdrl.DutyCode VALUES(DEFAULT,'K54','Fam Mbr of K53','OTHER_ELIGIBLES');
-INSERT INTO hdrl.DutyCode VALUES(DEFAULT,'K55','Civ Employee(DOD Remote)','OTHER_ELIGIBLES');
-INSERT INTO hdrl.DutyCode VALUES(DEFAULT,'K56','Fam Mbr of K55','OTHER_ELIGIBLES');
-INSERT INTO hdrl.DutyCode VALUES(DEFAULT,'K57','Civ Employee(DOD Occ Hlth)','OTHER_ELIGIBLES');
-INSERT INTO hdrl.DutyCode VALUES(DEFAULT,'K58','Civ Employee(Disb Ret Exam)','OTHER_ELIGIBLES');
-INSERT INTO hdrl.DutyCode VALUES(DEFAULT,'K59','Civ Employee(Others)','OTHER_ELIGIBLES');
-INSERT INTO hdrl.DutyCode VALUES(DEFAULT,'K61','Civ Employee(VA)','OTHER_ELIGIBLES');
-INSERT INTO hdrl.DutyCode VALUES(DEFAULT,'K62','Office of Workers Comp','OTHER_ELIGIBLES');
-INSERT INTO hdrl.DutyCode VALUES(DEFAULT,'K63','Service Home(not retired)','OTHER_ELIGIBLES');
-INSERT INTO hdrl.DutyCode VALUES(DEFAULT,'K64','Social Security','OTHER_ELIGIBLES');
-INSERT INTO hdrl.DutyCode VALUES(DEFAULT,'K65','Contract Employee','OTHER_ELIGIBLES');
-INSERT INTO hdrl.DutyCode VALUES(DEFAULT,'K66','Federal Prisoner','OTHER_ELIGIBLES');
-INSERT INTO hdrl.DutyCode VALUES(DEFAULT,'K67','PHS Beneficiary(Amer Indians, Aleu, Eskimo)','OTHER_ELIGIBLES');
-INSERT INTO hdrl.DutyCode VALUES(DEFAULT,'K68','PHS Beneficiary(Micronesian, Samoan, Trust)','OTHER_ELIGIBLES');
-INSERT INTO hdrl.DutyCode VALUES(DEFAULT,'K69','Other US Beneficiary(Spon & Dep)','OTHER_ELIGIBLES');
-INSERT INTO hdrl.DutyCode VALUES(DEFAULT,'K71','NATO/Non-NATO(Foreign Military Sales)','OTHER_ELIGIBLES');
-INSERT INTO hdrl.DutyCode VALUES(DEFAULT,'K72','NATO Active Duty','OTHER_ELIGIBLES');
-INSERT INTO hdrl.DutyCode VALUES(DEFAULT,'K73','Dependent of K72','OTHER_ELIGIBLES');
-INSERT INTO hdrl.DutyCode VALUES(DEFAULT,'K74','Non-NATO Active Duty','OTHER_ELIGIBLES');
-INSERT INTO hdrl.DutyCode VALUES(DEFAULT,'K75','Dependent of K74','OTHER_ELIGIBLES');
-INSERT INTO hdrl.DutyCode VALUES(DEFAULT,'K76','K76 - unknown - found in Viromed data but not defined in our paper copies','USA');
-INSERT INTO hdrl.DutyCode VALUES(DEFAULT,'K77','Dependent of Foreign Civilian','OTHER_ELIGIBLES');
-INSERT INTO hdrl.DutyCode VALUES(DEFAULT,'K78','Foreign National POW','OTHER_ELIGIBLES');
-INSERT INTO hdrl.DutyCode VALUES(DEFAULT,'K82','Secry Army Designee','OTHER_ELIGIBLES');
-INSERT INTO hdrl.DutyCode VALUES(DEFAULT,'K83','Secry Navy Designee','OTHER_ELIGIBLES');
-INSERT INTO hdrl.DutyCode VALUES(DEFAULT,'K84','Secry Air Force Designee','OTHER_ELIGIBLES');
-INSERT INTO hdrl.DutyCode VALUES(DEFAULT,'K79','Other Foreign National','OTHER_ELIGIBLES');
-INSERT INTO hdrl.DutyCode VALUES(DEFAULT,'K81','Secry Defense Designee','OTHER_ELIGIBLES');
-INSERT INTO hdrl.DutyCode VALUES(DEFAULT,'K89','Childre of Dependent Daughter','OTHER_ELIGIBLES');
-INSERT INTO hdrl.DutyCode VALUES(DEFAULT,'K91','Civil Humanitarian Care','OTHER_ELIGIBLES');
-INSERT INTO hdrl.DutyCode VALUES(DEFAULT,'K92','Emergency Care','OTHER_ELIGIBLES');
-INSERT INTO hdrl.DutyCode VALUES(DEFAULT,'M00','DECEASED SPONSOR','USMC');
-INSERT INTO hdrl.DutyCode VALUES(DEFAULT,'K99','Patient NOt Elsewhere Classified','OTHER_ELIGIBLES');
-INSERT INTO hdrl.DutyCode VALUES(DEFAULT,'M31','RET-MC-LOS','USMC');
-INSERT INTO hdrl.DutyCode VALUES(DEFAULT,'M28','DEPT OF EX MILITARY','USMC');
-INSERT INTO hdrl.DutyCode VALUES(DEFAULT,'M27','EX MIL MATERNITY','USMC');
-INSERT INTO hdrl.DutyCode VALUES(DEFAULT,'M26','APPLICANT ENLIST','USMC');
-INSERT INTO hdrl.DutyCode VALUES(DEFAULT,'M22','INACDUTRA-RESERVE-MC','USMC');
-INSERT INTO hdrl.DutyCode VALUES(DEFAULT,'M13','RECRUITS-MC','USMC');
-INSERT INTO hdrl.DutyCode VALUES(DEFAULT,'M12','ACDUTRA-MC','USMC');
-INSERT INTO hdrl.DutyCode VALUES(DEFAULT,'M11','ACDU-MC','USMC');
-INSERT INTO hdrl.DutyCode VALUES(DEFAULT,'M33','RET-MC-TDRL','USMC');
-INSERT INTO hdrl.DutyCode VALUES(DEFAULT,'M32','RET-MC-PDRL','USMC');
-INSERT INTO hdrl.DutyCode VALUES(DEFAULT,'N00','DECEASED SPONSOR','USN');
-INSERT INTO hdrl.DutyCode VALUES(DEFAULT,'N11','ACDU-N','USN');
-INSERT INTO hdrl.DutyCode VALUES(DEFAULT,'M49','FAM MBR OF M48','USMC');
-INSERT INTO hdrl.DutyCode VALUES(DEFAULT,'M48','UNREMARRIED FORMER SPOUSE','USMC');
-INSERT INTO hdrl.DutyCode VALUES(DEFAULT,'M47','DEP-RET-DEC','USMC');
-INSERT INTO hdrl.DutyCode VALUES(DEFAULT,'M45','DEP-ACDU-DEC','USMC');
-INSERT INTO hdrl.DutyCode VALUES(DEFAULT,'M43','DEP-RET-MC','USMC');
-INSERT INTO hdrl.DutyCode VALUES(DEFAULT,'M41','DEP-ACDU-MC','USMC');
-INSERT INTO hdrl.DutyCode VALUES(DEFAULT,'N12','ACDUTRA-N','USN');
-INSERT INTO hdrl.DutyCode VALUES(DEFAULT,'N13','RECRUITS-N','USN');
-INSERT INTO hdrl.DutyCode VALUES(DEFAULT,'N14','CADETS - ACADEMY','USN');
-INSERT INTO hdrl.DutyCode VALUES(DEFAULT,'N21','RET-ACDUTRA/ROTC','USN');
-INSERT INTO hdrl.DutyCode VALUES(DEFAULT,'N22','INACDUTRA-RESERVE','USN');
-INSERT INTO hdrl.DutyCode VALUES(DEFAULT,'N26','APPLICANT ENLIST','USN');
-INSERT INTO hdrl.DutyCode VALUES(DEFAULT,'N27','EX MIL MATERNITY','USN');
-INSERT INTO hdrl.DutyCode VALUES(DEFAULT,'N28','DEPT OF EX MILITARY','USN');
-INSERT INTO hdrl.DutyCode VALUES(DEFAULT,'N31','RET-N-LOS','USN');
-INSERT INTO hdrl.DutyCode VALUES(DEFAULT,'N24','N24 - unknown - found in Viromed data but not defined in our paper copies','USA');
-INSERT INTO hdrl.DutyCode VALUES(DEFAULT,'N32','RET-N-PDRL','USN');
-INSERT INTO hdrl.DutyCode VALUES(DEFAULT,'N33','RET-N-TDRL','USN');
-INSERT INTO hdrl.DutyCode VALUES(DEFAULT,'P11','ACDU-PHS','PUBLIC_HEALTH');
-INSERT INTO hdrl.DutyCode VALUES(DEFAULT,'P00','DECEASED SPONSOR','PUBLIC_HEALTH');
-INSERT INTO hdrl.DutyCode VALUES(DEFAULT,'N41','DEP-ACDU-N','USN');
-INSERT INTO hdrl.DutyCode VALUES(DEFAULT,'N43','DEP-RET-N','USN');
-INSERT INTO hdrl.DutyCode VALUES(DEFAULT,'N45','DEP-ACDU-DEC','USN');
-INSERT INTO hdrl.DutyCode VALUES(DEFAULT,'N47','DEP-RET-DEC','USN');
-INSERT INTO hdrl.DutyCode VALUES(DEFAULT,'N48','UNREMARRIED FORMER SPOUSE','USN');
-INSERT INTO hdrl.DutyCode VALUES(DEFAULT,'N49','FAM MBR OFN48','USN');
-INSERT INTO hdrl.DutyCode VALUES(DEFAULT,'P12','ACDUTRA-PHS','PUBLIC_HEALTH');
-INSERT INTO hdrl.DutyCode VALUES(DEFAULT,'P22','INACDUTRA-RESERVE','PUBLIC_HEALTH');
-INSERT INTO hdrl.DutyCode VALUES(DEFAULT,'P31','RET-PHS-LOS','PUBLIC_HEALTH');
-INSERT INTO hdrl.DutyCode VALUES(DEFAULT,'P32','RET-PHS-PDRL','PUBLIC_HEALTH');
-INSERT INTO hdrl.DutyCode VALUES(DEFAULT,'P33','RET-PHS-TDRL','PUBLIC_HEALTH');
-INSERT INTO hdrl.DutyCode VALUES(DEFAULT,'P41','DEP-ACDU-PHS','PUBLIC_HEALTH');
-INSERT INTO hdrl.DutyCode VALUES(DEFAULT,'P43','DEP-RET-PHS','PUBLIC_HEALTH');
-INSERT INTO hdrl.DutyCode VALUES(DEFAULT,'P45','DEP-ACDU-DEC','PUBLIC_HEALTH');
-INSERT INTO hdrl.DutyCode VALUES(DEFAULT,'P47','DEP-RET-DEC','PUBLIC_HEALTH');
-INSERT INTO hdrl.DutyCode VALUES(DEFAULT,'P26','P26 - unknown - found in Viromed data but not defined in our paper copies','USA');
-INSERT INTO hdrl.DutyCode VALUES(DEFAULT,'P48','UNREMARRIED FORMER SPOUSE','PUBLIC_HEALTH');
-INSERT INTO hdrl.DutyCode VALUES(DEFAULT,'P49','FAM MBR OF P48','PUBLIC_HEALTH');
-
-CREATE TABLE hdrl.ShippingCarrier
-(
- RowId SERIAL NOT NULL,
- Name VARCHAR(32),
-
- CONSTRAINT PK_ShippingCarrier PRIMARY KEY (RowId)
-);
-
-INSERT INTO hdrl.ShippingCarrier VALUES(DEFAULT, 'DHL');
-INSERT INTO hdrl.ShippingCarrier VALUES(DEFAULT, 'FedEx');
-INSERT INTO hdrl.ShippingCarrier VALUES(DEFAULT, 'UPS');
-INSERT INTO hdrl.ShippingCarrier VALUES(DEFAULT, 'USPS');
-
-CREATE TABLE hdrl.InboundRequest
-(
- RequestId SERIAL NOT NULL,
- RequestStatusId INT NOT NULL,
- ShippingCarrierId INT,
- ShippingNumber VARCHAR(32),
- SubmittedBy USERID,
- Submitted TIMESTAMP,
- TestTypeId INT NOT NULL,
-
- Container ENTITYID NOT NULL,
- CreatedBy USERID,
- Created TIMESTAMP,
- ModifiedBy USERID,
- Modified TIMESTAMP,
- ArchivedRequestCount INT,
-
- CONSTRAINT PK_InboundRequest PRIMARY KEY (RequestId),
- CONSTRAINT FK_InboundRequest_Test FOREIGN KEY (TestTypeId) REFERENCES hdrl.TestType (RowId),
- CONSTRAINT FK_InboundRequest_Status FOREIGN KEY (RequestStatusId) REFERENCES hdrl.RequestStatus (RowId),
- CONSTRAINT FK_InboundRequest_ShippingCarrier FOREIGN KEY (ShippingCarrierId) REFERENCES hdrl.ShippingCarrier (RowId)
-);
-
-CREATE TABLE hdrl.InboundSpecimen
-(
- RowId SERIAL NOT NULL,
- CustomerBarcode VARCHAR(64),
- LastName VARCHAR(64),
- FirstName VARCHAR(64),
- BirthDate TIMESTAMP,
- SSN VARCHAR(9),
- InboundRequestId INT NOT NULL,
- FMPId INT,
- DutyCodeId INT,
- TestingSourceId INT,
- DrawDate TIMESTAMP,
- DoDId BIGINT,
- Container ENTITYID NOT NULL,
- MiddleName VARCHAR(64),
- Initials VARCHAR(5),
- NumContainers INT DEFAULT 1,
- GenderId INT,
-
- CreatedBy USERID,
- Created TIMESTAMP,
- ModifiedBy USERID,
- Modified TIMESTAMP,
-
- CONSTRAINT PK_InboundSpecimen PRIMARY KEY (RowId),
- CONSTRAINT FK_InboundSpecimen_FMP FOREIGN KEY (FMPId) REFERENCES hdrl.FamilyMemberPrefix (RowId),
- CONSTRAINT FK_InboundSpecimen_DutyCode FOREIGN KEY (DutyCodeId) REFERENCES hdrl.DutyCode (RowId),
- CONSTRAINT FK_InboundSpecimen_TestingSource FOREIGN KEY (TestingSourceId) REFERENCES hdrl.SourceOfTesting (RowId),
- CONSTRAINT FK_InboundSpecimen_Request FOREIGN KEY (InboundRequestId) REFERENCES hdrl.InboundRequest (RequestId) ON DELETE CASCADE
-);
-
-CREATE TABLE hdrl.Gender
-(
- RowId SERIAL NOT NULL,
- Code VARCHAR(1) NOT NULL,
- Description VARCHAR(20) NOT NULL,
-
- CONSTRAINT PK_Gender PRIMARY KEY (RowId),
- CONSTRAINT UQ_Gender UNIQUE (Code)
-);
-
-INSERT INTO hdrl.Gender VALUES(DEFAULT, 'A', 'Ambiguous');
-INSERT INTO hdrl.Gender VALUES(DEFAULT, 'F', 'Female');
-INSERT INTO hdrl.Gender VALUES(DEFAULT, 'M', 'Male');
-INSERT INTO hdrl.Gender VALUES(DEFAULT, 'N', 'Not applicable');
-INSERT INTO hdrl.Gender VALUES(DEFAULT, 'O', 'Other');
-INSERT INTO hdrl.Gender VALUES(DEFAULT, 'U', 'Unknown');
-
-ALTER TABLE hdrl.InboundSpecimen ADD CONSTRAINT FK_InboundSpecimen_Gender FOREIGN KEY (GenderId) REFERENCES hdrl.Gender (RowId);
-
-CREATE TABLE hdrl.RequestResult
-(
- RequestId INT NOT NULL,
- RequestStatusId INT NOT NULL,
- CustomerNote VARCHAR(254),
- Received TIMESTAMP NOT NULL,
- Completed TIMESTAMP,
-
- Container ENTITYID NOT NULL,
- CreatedBy USERID,
- Created TIMESTAMP,
- ModifiedBy USERID,
- Modified TIMESTAMP,
-
- CONSTRAINT PK_RequestResult PRIMARY KEY (RequestId),
- CONSTRAINT FK_RequestResult_InboundRequest FOREIGN KEY (RequestId) REFERENCES hdrl.InboundRequest(RequestId) ON DELETE CASCADE,
- CONSTRAINT FK_RequestResult_Status FOREIGN KEY (RequestStatusId) REFERENCES hdrl.RequestStatus(RowId)
-);
-
-CREATE TABLE hdrl.SpecimenResult
-(
- SpecimenId INT NOT NULL,
- RequestStatusId INT NOT NULL,
- Received TIMESTAMP NOT NULL,
- Completed TIMESTAMP,
- SampleIntegrity VARCHAR(80),
- TestResult VARCHAR(254),
- CustomerCode VARCHAR(80),
- ModifiedResultFlag CHAR DEFAULT 'F',
-
- Container ENTITYID NOT NULL,
- CreatedBy USERID,
- Created TIMESTAMP,
- ModifiedBy USERID,
- Modified TIMESTAMP,
- RequestId INT NOT NULL,
- ReportFileName VARCHAR(20),
-
- CONSTRAINT PK_SpecimenResult PRIMARY KEY (SpecimenId),
- CONSTRAINT FK_SpecimenResult_InboundSpecimen FOREIGN KEY (SpecimenId) REFERENCES hdrl.InboundSpecimen(RowId) ON DELETE CASCADE,
- CONSTRAINT FK_SpecimenResult_Status FOREIGN KEY (RequestStatusId) REFERENCES hdrl.RequestStatus(RowId)
-
-);
-
-ALTER TABLE hdrl.specimenResult ADD CONSTRAINT FK_SpecimenResult_InboundRequest FOREIGN KEY (RequestId) REFERENCES hdrl.InboundRequest(RequestId) ON DELETE CASCADE;
-
-CREATE TABLE hdrl.labwareOutboundRequests
-(
- batch_id INT NOT NULL,
- hdrl_status VARCHAR(20),
- customer_note VARCHAR(254),
- date_received DATE NOT NULL,
- date_completed DATE,
- date_modified DATE NOT NULL,
- CONSTRAINT PK_LabwareOutboundRequests PRIMARY KEY (batch_id),
- CONSTRAINT FK_LabwareOutboundRequests_InboundRequest FOREIGN KEY (batch_id) REFERENCES hdrl.InboundRequest (RequestId) ON DELETE CASCADE
-);
-
-CREATE TABLE hdrl.labwareOutboundSpecimens
-(
- test_request_id INT NOT NULL,
- batch_id INT NOT NULL,
- date_received DATE NOT NULL,
- date_completed DATE,
- sample_integrity VARCHAR(80),
- test_result VARCHAR(254),
- customer_code VARCHAR(80),
- hdrl_status VARCHAR(20),
- date_modified DATE NOT NULL,
- modified_result_flag VARCHAR(1),
- report_file_name VARCHAR(20),
-
- CONSTRAINT PK_LabwareOutboundSpecimens PRIMARY KEY (test_request_id),
- CONSTRAINT FK_LabwareOutboundSpecimens_LabwareOutboundRequests FOREIGN KEY (batch_id) REFERENCES hdrl.labwareOutboundRequests (batch_id) ON DELETE CASCADE,
- CONSTRAINT FK_LabwareOutboundSpecimens_InboundSpecimen FOREIGN KEY (test_request_id) REFERENCES hdrl.InboundSpecimen (RowId) ON DELETE CASCADE
-);
-
-/* hdrl-15.30-16.10.sql */
-
-ALTER TABLE hdrl.labwareOutboundSpecimens DROP CONSTRAINT FK_LabwareOutboundSpecimens_LabwareOutboundRequests;
-
-/* hdrl-16.10-16.20.sql */
-
-ALTER TABLE hdrl.requestResult DROP COLUMN Container;
-ALTER TABLE hdrl.specimenResult DROP COLUMN Container;
-
-ALTER TABLE hdrl.labwareoutboundrequests ALTER COLUMN date_received TYPE timestamp;
-ALTER TABLE hdrl.labwareoutboundrequests ALTER COLUMN date_completed TYPE timestamp;
-ALTER TABLE hdrl.labwareoutboundrequests ALTER COLUMN date_modified TYPE timestamp;
-ALTER TABLE hdrl.labwareoutboundspecimens ALTER COLUMN date_received TYPE timestamp;
-ALTER TABLE hdrl.labwareoutboundspecimens ALTER COLUMN date_completed TYPE timestamp;
-ALTER TABLE hdrl.labwareoutboundspecimens ALTER COLUMN date_modified TYPE timestamp;
\ No newline at end of file
diff --git a/hdrl/resources/schemas/dbscripts/postgresql/labware.gw_labkey-0.00-16.20.sql b/hdrl/resources/schemas/dbscripts/postgresql/labware.gw_labkey-0.00-16.20.sql
deleted file mode 100644
index 83868075..00000000
--- a/hdrl/resources/schemas/dbscripts/postgresql/labware.gw_labkey-0.00-16.20.sql
+++ /dev/null
@@ -1,121 +0,0 @@
-/*
- * Copyright (c) 2018-2019 LabKey Corporation
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-/* labware.gw_labkey-15.20-15.30.sql */
-
-/*
- * The tables below mimic the Oracle tables used for communication with LabWare. We use them for
- * automated tests only.
- */
-CREATE SCHEMA gw_labkey;
-
-CREATE TABLE gw_labkey.X_LK_INBND_REQUESTS
-(
- BATCH_ID INT NOT NULL
-, CARRIER VARCHAR(40)
-, TRACKING_NUMBER VARCHAR(40)
-, CUSTOMER VARCHAR(100) NOT NULL
-, STATUS VARCHAR(20) NOT NULL
-, CONSTRAINT X_LK_INBND_REQUESTS_PK PRIMARY KEY
- (
- BATCH_ID
- )
-);
-
-CREATE TABLE gw_labkey.X_LK_INBND_SPECIMENS
-(
- TEST_REQUEST_ID INT NOT NULL
-, BATCH_ID INT NOT NULL
-, TEST_REQUESTED VARCHAR(100) NOT NULL
-, CUST_BARCODE VARCHAR(40)
-, FMP VARCHAR(2) NOT NULL
-, SSN VARCHAR(9) NOT NULL
-, DRAW_DATE DATE NOT NULL
-, SPECIMEN_TYPE VARCHAR(20)
-, NUM_CONTAINERS INT
-, SOT VARCHAR(1)
-, DUC VARCHAR(5)
-, DOD_ID VARCHAR(20)
-, FIRST_NAME VARCHAR(40)
-, MIDDLE_NAME VARCHAR(40)
-, LAST_NAME VARCHAR(80)
-, BIRTH_DATE DATE
-, GENDER VARCHAR(20)
-, INITIALS VARCHAR(5)
-, CONSTRAINT X_LK_INBND_SPECIMENS_PK PRIMARY KEY
- (
- TEST_REQUEST_ID
- )
-);
-
-CREATE TABLE gw_labkey.X_LK_OUTBD_REQUESTS
-(
- BATCH_ID INT NOT NULL
-, HDRL_STATUS VARCHAR(20) NOT NULL
-, CUSTOMER_NOTE VARCHAR(254)
-, DATE_RECEIVED DATE NOT NULL
-, DATE_COMPLETED DATE
-, CONSTRAINT X_LK_OUTBD_REQUESTS_PK PRIMARY KEY
- (
- BATCH_ID
- )
-);
-
-CREATE TABLE gw_labkey.X_LK_OUTBD_SPECIMENS
-(
- TEST_REQUEST_ID INT NOT NULL
-, BATCH_ID INT NOT NULL
-, DATE_RECEIVED DATE NOT NULL
-, DATE_COMPLETED DATE
-, SAMPLE_INTEGRITY VARCHAR(80)
-, TEST_RESULT VARCHAR(254)
-, CUSTOMER_CODE VARCHAR(80)
-, CLINICAL_REPORT TEXT
-, CONSTRAINT X_LK_OUTBD_SPECIMENS_PK PRIMARY KEY
- (
- TEST_REQUEST_ID
- )
-);
-
-ALTER TABLE gw_labkey.X_LK_INBND_REQUESTS ALTER COLUMN STATUS DROP NOT NULL;
-
-ALTER TABLE gw_labkey.X_LK_INBND_REQUESTS ADD CONSTRAINT INBND_SPECIMENS_BATCH_ID_FK
- FOREIGN KEY (BATCH_ID) REFERENCES gw_labkey.X_LK_INBND_REQUESTS(BATCH_ID);
-
-ALTER TABLE gw_labkey.X_LK_OUTBD_REQUESTS ADD COLUMN DATE_MODIFIED DATE NOT NULL;
-ALTER TABLE gw_labkey.X_LK_OUTBD_REQUESTS ALTER COLUMN HDRL_STATUS DROP NOT NULL;
-
-ALTER TABLE gw_labkey.X_LK_OUTBD_SPECIMENS ADD COLUMN HDRL_STATUS VARCHAR(20);
-ALTER TABLE gw_labkey.X_LK_OUTBD_SPECIMENS ADD COLUMN DATE_MODIFIED DATE NOT NULL;
-ALTER TABLE gw_labkey.X_LK_OUTBD_SPECIMENS ADD COLUMN MODIFIED_RESULT_FLAG VARCHAR(1);
-ALTER TABLE gw_labkey.X_LK_OUTBD_SPECIMENS ADD CONSTRAINT OUTBD_SPECIMENS_BATCH_ID_FK
- FOREIGN KEY (BATCH_ID) REFERENCES gw_labkey.X_LK_OUTBD_REQUESTS(BATCH_ID);
-
-ALTER TABLE gw_labkey.X_LK_OUTBD_SPECIMENS ALTER COLUMN clinical_report TYPE BYTEA USING NULL;
-ALTER TABLE gw_labkey.X_LK_OUTBD_SPECIMENS ADD COLUMN report_file_name VARCHAR(20);
-
-ALTER TABLE gw_labkey.X_LK_INBND_REQUESTS DROP COLUMN status;
-
-/* labware.gw_labkey-16.10-16.20.sql */
-
-ALTER TABLE gw_labkey.X_LK_INBND_SPECIMENS ALTER draw_date TYPE timestamp;
-ALTER TABLE gw_labkey.X_LK_INBND_SPECIMENS ALTER birth_date TYPE timestamp;
-ALTER TABLE gw_labkey.X_LK_OUTBD_REQUESTS ALTER date_received TYPE timestamp;
-ALTER TABLE gw_labkey.X_LK_OUTBD_REQUESTS ALTER date_completed TYPE timestamp;
-ALTER TABLE gw_labkey.X_LK_OUTBD_REQUESTS ALTER date_modified TYPE timestamp;
-ALTER TABLE gw_labkey.X_LK_OUTBD_SPECIMENS ALTER date_received TYPE timestamp;
-ALTER TABLE gw_labkey.X_LK_OUTBD_SPECIMENS ALTER date_completed TYPE timestamp;
-ALTER TABLE gw_labkey.X_LK_OUTBD_SPECIMENS ALTER date_modified TYPE timestamp;
\ No newline at end of file
diff --git a/hdrl/resources/schemas/hdrl.xml b/hdrl/resources/schemas/hdrl.xml
deleted file mode 100644
index b45b91fb..00000000
--- a/hdrl/resources/schemas/hdrl.xml
+++ /dev/null
@@ -1,271 +0,0 @@
-
-
-
-
-
-
-
-
-
-
-
-
-
-
- Description
-
-
-
-
-
-
-
-
-
-
- RequestId
-
-
-
- Request Status
-
-
- Shipping Carrier
-
-
-
-
- UserId
- Users
- core
-
-
-
-
- Test Type
-
-
-
-
- UserId
- Users
- core
-
-
-
-
-
- UserId
- Users
- core
-
-
-
-
-
-
-
-
- RowId
-
-
- SpecimenId
-
-
-
-
-
-
-
- Gender
-
-
- Date
-
-
-
- Request
-
-
- FMP
-
-
- DUC
-
-
- SOT
-
-
-
- Date
-
-
-
-
-
- UserId
- Users
- core
-
-
-
-
-
- UserId
- Users
- core
-
-
-
-
-
-
-
-
-
-
- Request Status
-
-
-
-
-
-
- UserId
- Users
- core
-
-
-
-
-
- UserId
- Users
- core
-
-
-
-
-
-
-
- SpecimenId
-
-
-
- RowId
- RowId
- InboundSpecimen
- hdrl
-
-
-
-
- Request Status
-
-
-
-
-
-
-
-
- UserId
- Users
- core
-
-
-
-
-
- UserId
- Users
- core
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
diff --git a/hdrl/resources/schemas/labware.gw_labkey.xml b/hdrl/resources/schemas/labware.gw_labkey.xml
deleted file mode 100644
index 61521794..00000000
--- a/hdrl/resources/schemas/labware.gw_labkey.xml
+++ /dev/null
@@ -1,98 +0,0 @@
-
-
-
-
-
-
-
- Test_Request_Id
-
-
-
-
- Batch_Id
- X_LK_INBND_REQUESTS
- gw_labkey
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
- Batch_Id
-
-
-
-
-
-
-
-
-
-
-
- Test_Request_Id
-
-
-
-
- Batch_Id
- X_LK_OUTBD_REQUESTS
- gw_labkey
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
diff --git a/hdrl/resources/template/specimenTemplate.xlsx b/hdrl/resources/template/specimenTemplate.xlsx
deleted file mode 100644
index 72bd2cbc..00000000
Binary files a/hdrl/resources/template/specimenTemplate.xlsx and /dev/null differ
diff --git a/hdrl/resources/views/HDRL.html b/hdrl/resources/views/HDRL.html
deleted file mode 100644
index 1d58b659..00000000
--- a/hdrl/resources/views/HDRL.html
+++ /dev/null
@@ -1,4 +0,0 @@
-
diff --git a/hdrl/resources/views/HDRL.webpart.xml b/hdrl/resources/views/HDRL.webpart.xml
deleted file mode 100644
index 6539400f..00000000
--- a/hdrl/resources/views/HDRL.webpart.xml
+++ /dev/null
@@ -1,3 +0,0 @@
-
-
-
diff --git a/hdrl/resources/web/hdrl/fonts/Code39Azalea.eot b/hdrl/resources/web/hdrl/fonts/Code39Azalea.eot
deleted file mode 100644
index 03af8eb9..00000000
Binary files a/hdrl/resources/web/hdrl/fonts/Code39Azalea.eot and /dev/null differ
diff --git a/hdrl/resources/web/hdrl/fonts/Code39Azalea.otf b/hdrl/resources/web/hdrl/fonts/Code39Azalea.otf
deleted file mode 100644
index cf2d158b..00000000
Binary files a/hdrl/resources/web/hdrl/fonts/Code39Azalea.otf and /dev/null differ
diff --git a/hdrl/resources/web/hdrl/fonts/Code39Azalea.svg b/hdrl/resources/web/hdrl/fonts/Code39Azalea.svg
deleted file mode 100644
index d1293cbb..00000000
--- a/hdrl/resources/web/hdrl/fonts/Code39Azalea.svg
+++ /dev/null
@@ -1,75 +0,0 @@
-
-
-
-
-Created by FontForge 20090914 at Sat Dec 8 00:40:35 2012
- By www-data
-Copyright (c) 2012 by Jerry Whiting. All rights reserved.
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
diff --git a/hdrl/resources/web/hdrl/fonts/Code39Azalea.ttf b/hdrl/resources/web/hdrl/fonts/Code39Azalea.ttf
deleted file mode 100644
index 113101a4..00000000
Binary files a/hdrl/resources/web/hdrl/fonts/Code39Azalea.ttf and /dev/null differ
diff --git a/hdrl/resources/web/hdrl/fonts/Code39Azalea.woff b/hdrl/resources/web/hdrl/fonts/Code39Azalea.woff
deleted file mode 100644
index 0af8e415..00000000
Binary files a/hdrl/resources/web/hdrl/fonts/Code39Azalea.woff and /dev/null differ
diff --git a/hdrl/resources/web/hdrl/fonts/barcode.css b/hdrl/resources/web/hdrl/fonts/barcode.css
deleted file mode 100644
index 9e80a3bc..00000000
--- a/hdrl/resources/web/hdrl/fonts/barcode.css
+++ /dev/null
@@ -1,15 +0,0 @@
-/* for custom barcode fonts */
-@font-face {
- font-family: barcode;
- src: url(Code39Azalea.eot) format('embedded-opentype'),
- url(Code39Azalea.woff) format('woff'),
- url(Code39Azalea.ttf) format('truetype'),
- url(Code39Azalea.svg#Code39Azalea) format('svg');
- font-weight: normal;
- font-style: normal;
-}
-
-div.barcode {
- font-family: barcode;
- font-size: 36pt;
-}
diff --git a/hdrl/resources/web/hdrl/requests.js b/hdrl/resources/web/hdrl/requests.js
deleted file mode 100644
index aa45dddb..00000000
--- a/hdrl/resources/web/hdrl/requests.js
+++ /dev/null
@@ -1,980 +0,0 @@
-/*
- * Copyright (c) 2015-2019 LabKey Corporation
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-Ext4.define('LABKEY.ext4.EditRequestPanel', {
-
- extend: 'Ext.panel.Panel',
-
- constructor : function(config) {
-
- Ext4.applyIf(config, {
- frame : false,
- border : false,
- bodyStyle : {background : 'transparent'}
- });
-
- // map for display values to keys
- this.lkMap = {};
-
- this.createDataModels();
- this.callParent([config]);
- },
-
- createDataModels : function() {
-
- if (!Ext4.ModelManager.isRegistered('LABKEY.HDRL.Specimen')) {
- Ext4.define('LABKEY.HDRL.Specimen', {
- extend: 'Ext.data.Model',
- fields : [
- {name: 'RowId', mapping : 'RowId.value'},
- {name: 'InboundRequestId', mapping : 'InboundRequestId.value'},
- {name: 'CustomerBarcode', mapping : 'CustomerBarcode.value', defaultValue : null},
- {name: 'LastName', mapping : 'LastName.value', defaultValue : null},
- {name: 'FirstName', mapping : 'FirstName.value', defaultValue : null},
- {name: 'MiddleName', mapping : 'MiddleName.value', defaultValue : null},
- {name: 'Initials', mapping: 'Initials.value', defaultValue : null},
- {name: 'GenderId', mapping: 'GenderId.displayValue', defaultValue : null},
- {name: 'BirthDate', type : 'date', mapping : 'BirthDate.value', defaultValue : null},
- {name: 'SSN', mapping : 'SSN.value', defaultValue : null},
- {name: 'DODId', mapping : 'DODId.value', defaultValue : null},
- {name: 'FMPId', mapping : 'FMPId.displayValue', defaultValue : null},
- {name: 'DutyCodeId', mapping : 'DutyCodeId.displayValue', defaultValue : null},
- {name: 'TestingSourceId', mapping : 'TestingSourceId.displayValue', defaultValue : null},
- {name: 'DrawDate', type : 'date', mapping : 'DrawDate.value', defaultValue : null},
- {name: 'status'}
- ]
- });
- }
-
- this.specimenModelMap = {
- inboundrequestid : 'InboundRequestId',
- customerbarcode : 'CustomerBarcode',
- lastname : 'LastName',
- firstname : 'FirstName',
- middlename : 'MiddleName',
- initials: 'Initials',
- genderid: 'GenderId',
- gender: 'GenderId',
- birthdate : 'BirthDate',
- ssn : 'SSN',
- dodid : 'DODId',
- fmpid : 'FMPId',
- fmp : 'FMPId',
- dutycodeid : 'DutyCodeId',
- duc : 'DutyCodeId',
- testingsourceid : 'TestingSourceId',
- sot : 'TestingSourceId',
- drawdate : 'DrawDate',
- status : 'status'
- };
-
- if (!Ext4.ModelManager.isRegistered('LABKEY.HDRL.SpecimenLK')) {
- Ext4.define('LABKEY.HDRL.SpecimenLK', {
- extend: 'Ext.data.Model',
- fields: [
- {name: 'RowId'},
- {name: 'Code'},
- {name: 'Description'},
- {name: 'Service'}
- ]
- });
- }
-
- if (!Ext4.ModelManager.isRegistered('LABKEY.HDRL.Lookup')) {
- Ext4.define('LABKEY.HDRL.Lookup', {
- extend: 'Ext.data.Model',
- fields: [
- {name: 'rowid'},
- {name: 'name'}
- ]
- });
- }
- },
-
- initComponent : function() {
-
- this.items = [];
-
- this.northPanel = this.createNorthPanel();
- this.gridPanel = this.createGridPanel();
- this.southPanel = this.createSouthPanel();
-
- this.items.push(this.northPanel);
- this.items.push(this.gridPanel);
- this.items.push(this.southPanel);
-
- this.callParent();
- window.onbeforeunload = LABKEY.beforeunload(this.beforeUnload, this);
- },
-
- createGridPanel : function() {
-
- var items = [];
-
- // the row editing plugin
- this.roweditor = Ext4.create('Ext.grid.plugin.RowEditing', {
- clicksToMoveEditor : 1,
- autoCancel : false,
- triggerEvent : 'cellclick',
- listeners : {
- beforeedit : {fn : function(editor, context){
-
- // don't activate the editor for checkbox selector or status field
- if (context.colIdx <= 1){
- return false;
- }
- }, scope : this}
- }
- });
-
- // add the request id to the select rows filter
- var params = LABKEY.Query.buildQueryParams('hdrl', 'inboundSpecimen', [LABKEY.Filter.create('InboundRequestId', this.requestId)]);
- params.apiVersion = 9.1;
-
- this.grid = Ext4.create('Ext.grid.Panel', {
- title : '',
- flex : 1.2,
- maxHeight : 400,
- autoScroll : true,
- border : false, frame : false,
- selType : 'checkboxmodel',
- store : {
- model : 'LABKEY.HDRL.Specimen',
- autoLoad: true,
- pageSize: 200,
- pruneModifiedRecords : true,
- proxy : {
- type : 'ajax',
- url : LABKEY.ActionURL.buildURL('query', 'selectRows.api'),
- extraParams : params,
- reader: { type: 'json', root: 'rows', metaProperty : 'none' }
- },
- listeners : {
- load : {fn : function(cmp, records){
- this.verifyRows(records, null, function(success){
- this.resetDirty();
- });
- }, scope : this},
- update : {fn : function(cmp, rec, opt, modified){
- this.markDirty(true);
- this.verifyRows([rec], modified);
- }, scope : this},
- datachanged : {fn : function(){this.markDirty(true);}, scope : this}
- }
- },
- columns: [
- {text: 'Status', dataIndex: 'status', minWidth : 150, flex : 1},
- {text: 'Customer Barcode', dataIndex: 'CustomerBarcode', width : 150, editor: {xtype: 'textfield'}},
- {text: 'Last Name', dataIndex: 'LastName', editor: {xtype: 'textfield'}},
- {text: 'First Name', dataIndex: 'FirstName', editor: {xtype: 'textfield'}},
- {text: 'Middle Name', dataIndex: 'MiddleName', editor: {xtype: 'textfield'}},
- {text: 'Initials', dataIndex: 'Initials', editor: {xtype: 'textfield'}},
- {text: 'Gender', dataIndex: 'GenderId',
- editor : {
- xtype : 'combo',
- store : {
- model : 'LABKEY.HDRL.SpecimenLK',
- autoLoad: true,
- pageSize: 200,
- proxy : {
- type : 'ajax',
- url : LABKEY.ActionURL.buildURL('query', 'selectRows.api'),
- extraParams : {
- schemaName : 'hdrl',
- queryName : 'gender'
- },
- reader : { type : 'json', root : 'rows' }
- },
- listeners : {
- load : {fn: function(cmp, recs){this.createDisplayValueMap('GenderId', recs, 'RowId', 'Description');}, scope : this}
- }
- },
- valueField : 'Description',
- displayField : 'Description',
- editable : false
- }
- },
- {text: 'Date of Birth', dataIndex: 'BirthDate', width : 150, renderer : Ext4.util.Format.dateRenderer('m/d/Y') , editor : {xtype: 'datefield'}},
- {text: 'FMP', width : 75, dataIndex: 'FMPId',
- editor : {
- xtype : 'combo',
- store : {
- model : 'LABKEY.HDRL.SpecimenLK',
- autoLoad: true,
- pageSize: 200,
- proxy : {
- type : 'ajax',
- url : LABKEY.ActionURL.buildURL('query', 'selectRows.api'),
- extraParams : {
- schemaName : 'hdrl',
- queryName : 'familyMemberPrefix'
- },
- reader : { type : 'json', root : 'rows' }
- },
- listeners : {
- load : {fn: function(cmp, recs){this.createDisplayValueMap('FMPId', recs, 'RowId', 'Code');}, scope : this}
- }
- },
- valueField : 'Code',
- displayField : 'Code',
- editable : false
- }
- },
- {text: 'SSN', dataIndex: 'SSN', width : 110, editor: {xtype: 'textfield'}, renderer : this.SSNRenderer, scope : this},
- {text: 'DoD ID', width : 75, dataIndex: 'DODId', editor: {xtype: 'numberfield', hideTrigger : true}},
- {text: 'DUC', width : 50, dataIndex: 'DutyCodeId',
- editor : {
- xtype : 'combo',
- store : {
- model : 'LABKEY.HDRL.SpecimenLK',
- autoLoad: true,
- pageSize: 200,
- proxy : {
- type : 'ajax',
- url : LABKEY.ActionURL.buildURL('query', 'selectRows.api'),
- extraParams : {
- schemaName : 'hdrl',
- queryName : 'dutyCode'
- },
- reader : { type : 'json', root : 'rows' }
- },
- listeners : {
- load : {fn: function(cmp, recs){this.createDisplayValueMap('DutyCodeId', recs, 'RowId', 'Code');}, scope : this}
- }
- },
- valueField : 'Code',
- displayField : 'Code',
- editable : false
- }
- },
- {text: 'SOT', width : 50, dataIndex: 'TestingSourceId',
- editor : {
- xtype : 'combo',
- store : {
- model : 'LABKEY.HDRL.SpecimenLK',
- autoLoad: true,
- proxy : {
- type : 'ajax',
- url : LABKEY.ActionURL.buildURL('query', 'selectRows.api'),
- extraParams : {
- schemaName : 'hdrl',
- queryName : 'sourceOfTesting'
- },
- reader : { type : 'json', root : 'rows' }
- },
- listeners : {
- load : {fn: function(cmp, recs){this.createDisplayValueMap('TestingSourceId', recs, 'RowId', 'Code');}, scope : this}
- }
- },
- valueField : 'Code',
- displayField : 'Code',
- editable : false
- }
- },
- {text: 'Date of Draw', dataIndex: 'DrawDate', width : 150, renderer : Ext4.util.Format.dateRenderer('m/d/Y'), editor : {xtype : 'datefield'}}
- ],
- dockedItems : [{
- xtype : 'toolbar',
- doc : 'top',
- items : [
- {xtype : 'button', text : 'delete', handler : function(){
- var sm = this.grid.getSelectionModel();
- this.roweditor.cancelEdit();
-
- this.grid.getStore().remove(sm.getSelection());
- this.markDirty(true);
- if (this.grid.getStore().getCount() > 0) {
- sm.select(0);
- }
- }, scope : this},
- {xtype : 'button', text : 'add specimen', handler : function() {
- this.roweditor.cancelEdit();
-
- // Create a model instance
- var r = Ext4.create('LABKEY.HDRL.Specimen', {InboundRequestId : this.requestId});
-
- this.grid.getStore().insert(0, r);
- this.roweditor.startEdit(0, 2);
- }, scope : this},
- ]
- }],
- plugins : [this.roweditor]
- });
-
- items.push(this.grid);
-
- return Ext4.create('Ext.panel.Panel', {
- border : true,
- minHeight : 150,
- flex : 1.2,
- layout : 'fit',
- items : items
- });
- },
-
- createNorthPanel : function() {
-
- var formItems = [];
-
- if (this.requestStatusId == 2)
- {
- formItems.push({
- xtype : 'displayfield',
- value : 'Warning: This request has already been submitted. Changes here will not be pushed to LabWare. '
- });
- }
-
- formItems.push({
- xtype : 'displayfield',
- value : 'Test Request ' +
- 'Edit existing specimens or add specimens to this test request. Click on the "ADD SPECIMEN" button to add a new specimen record. ' +
- 'You can edit existing records by clicking directly on the row in the grid to activate the row editing tool.'
- });
-
- formItems.push({
- xtype : 'combo',
- fieldLabel : 'Request Type',
- name : 'requestType',
- itemId : 'requestTypeCombo',
- labelSeparator : '',
- store : {
- model : 'LABKEY.HDRL.Lookup',
- autoLoad : true,
- proxy : {
- type : 'ajax',
- url : LABKEY.ActionURL.buildURL('query', 'selectRows.api'),
- extraParams : {
- schemaName : 'hdrl',
- queryName : 'testType',
- sort : 'name'
- },
- reader : { type : 'json', root : 'rows' }
- },
- listeners : {
- load : {fn: function(cmp, recs){
- if (this.testTypeId){
- this.northPanel.getComponent('requestTypeCombo').setValue(this.testTypeId);
- }
- }, scope : this}
- }
- },
- listeners : {
- scope : this,
- change : function(cmp, value) {
- this.requestType = value;
- if (this.testTypeId != value)
- this.markDirty(true);
-
- }
- },
- valueField : 'RowId',
- displayField : 'Name',
- allowBlank : false,
- editable : false
- });
-
- return Ext4.create('Ext.form.Panel', {
- bodyPadding : 20,
- border : false,
- flex : 1.2,
- items : formItems,
- defaults : {
- width : 550,
- labelWidth : 150
- },
- bodyStyle : {background : 'transparent'}
- });
- },
-
- createSouthPanel : function() {
-
- var formItems = [];
-
- formItems.push({xtype: 'hidden', name: 'X-LABKEY-CSRF', value: LABKEY.CSRF});
-
- formItems.push({
- xtype : 'fieldcontainer',
- fieldLabel : 'Upload Request Details',
- width : 650,
- layout : 'hbox',
- items : [
- {
- xtype : 'fileuploadfield',
- name : 'file',
- width : 300,
- listeners : {
- change : {fn: function(cmp, value){
- this.southPanel.getComponent('specimenUploadButton').enable();
-
- }, scope : this}
- }
- },{
- xtype : 'button',
- text : 'download template',
- width : 175,
- margin : '0 0 0 10',
- scope : this,
- handler : function(){
- var form = new Ext4.form.BasicForm(this.southPanel);
- form.submit({
- url : LABKEY.ActionURL.buildURL('hdrl', 'downloadSpecimenTemplate')
- });
- }
- }
- ]
- })
-
- formItems.push({
- xtype : 'button',
- itemId : 'specimenUploadButton',
- text : 'upload file',
- width : 150,
- disabled : true,
- scope : this,
- handler : function(){
- this.grid.getEl().mask('uploading file');
- var form = new Ext4.form.BasicForm(this.southPanel);
-
- var processResponse = function(form, action) {
-
- var fileContents = Ext4.decode(action.response.responseText);
-
- // unable to parse the file
- if (!fileContents.sheets && fileContents.exception){
- Ext4.Msg.show({title: 'Error', msg: fileContents.exception, buttons: Ext4.MessageBox.OK, icon: Ext4.MessageBox.ERROR});
- this.grid.getEl().unmask();
- LABKEY.Utils.signalWebDriverTest('uploadFile', 'Error');
- return;
- }
-
- var data = fileContents.sheets[0].data;
-
- // create the model records and load them into the store
- var newRecords = [];
- var cols = [];
-
- // need to convert the parsed column names so they match our model names (case sensitive)
- Ext4.each(data[0], function(field){
-
- var key = field.replace(/\s+/g, '').toLowerCase();
- if (this.specimenModelMap[key])
- cols.push(this.specimenModelMap[key]);
- else
- cols.push(undefined);
- }, this);
-
- for (var i = 1; i < data.length; i++){
-
- var row = data[i];
- var rec = Ext4.create('LABKEY.HDRL.Specimen');
- for (var j=0; j< cols.length; j++){
-
- if (cols[j])
- rec.set(cols[j], row[j] ? '' + row[j] : row[j]);
- }
- newRecords.push(rec);
- }
-
- this.verifyRows(newRecords);
- this.grid.getStore().loadData(newRecords, true);
- this.grid.getEl().unmask();
- LABKEY.Utils.signalWebDriverTest('uploadFile', 'Success');
- };
-
- form.submit({
- url : LABKEY.ActionURL.buildURL('experiment', 'parseFile'),
- method: 'POST',
- scope : this,
- success : processResponse,
- failure : processResponse
- });
-
- }
- })
-
- formItems.push({
- xtype : 'displayfield',
- value : '
Shipping Information
'
- });
-
- formItems.push({
- xtype : 'combo',
- fieldLabel : 'Carrier',
- name : 'shippingCarrier',
- itemId : 'shippingCarrierCombo',
- labelSeparator : '',
- store : {
- model : 'LABKEY.HDRL.Lookup',
- autoLoad : true,
- proxy : {
- type : 'ajax',
- url : LABKEY.ActionURL.buildURL('query', 'selectRows.api'),
- extraParams : {
- schemaName : 'hdrl',
- queryName : 'shippingCarrier',
- sort : 'name'
- },
- reader : { type : 'json', root : 'rows' }
- },
- listeners : {
- load : {fn: function(cmp, recs){
- if (this.shippingCarrierId){
- var c = this.southPanel.getComponent('shippingCarrierCombo');
- c.setValue(this.shippingCarrierId);
- }
- }, scope : this}
- }
- },
- listeners : {
- scope : this,
- change : function(cmp, value) {
- if (this.shippingCarrierId != value)
- this.markDirty(true);
- this.shippingCarrier = value;
- }
- },
- valueField : 'RowId',
- displayField : 'Name',
- editable : false
- });
-
- formItems.push({
- xtype : 'textfield',
- fieldLabel : 'Tracking #',
- name : 'trackingNumber',
- labelSeparator : '',
- value : this.shippingNumber,
- listeners : {
- scope: this,
- change : function(cmp, value) {
- if (this.shippingNumber != value)
- this.markDirty(true);
- this.shippingNumber = value;
- }
- }
- });
-
- formItems.push({
- xtype : 'button',
- itemId : 'packingListButton',
- text : 'Print Packing List',
- scope : this,
- disabled : (this.grid.getStore().getCount() == 0),
- width : 150,
- handler : function(){
- if (this.isDirty())
- this.saveRequestAndSpecimens(this.requestStatusId, this.showPackingList);
- else
- this.showPackingList();
- }
- });
-
- return Ext4.create('Ext.form.Panel', {
- bodyPadding : 20,
- border : false,
- flex : 1,
- items : formItems,
- defaults : {
- width : 550,
- labelWidth : 150
- },
- bodyStyle : {background : 'transparent'},
- buttonAlign : 'left',
- dockedItems : [{
- style : {background : 'transparent'},
- xtype : 'toolbar',
- ui : 'footer',
- dock : 'bottom',
- items: [
- {
- xtype: 'button',
- itemId : 'submitButton',
- text : 'Submit Request',
- disabled : (this.isSubmitted() || this.testTypeId == null),
- scope : this,
- handler : function() {this.handleSave(2);}
- },{
- xtype: 'button',
- itemId : 'saveButton',
- text : 'Save',
- scope : this,
- handler : function(){this.handleSave(this.requestStatusId);}
- }, {
- xtype: 'button',
- text: 'Cancel',
- scope: this,
- handler: function () {
- this.resetDirty();
- window.location = LABKEY.ActionURL.buildURL('hdrl', 'begin.view');
- }
- }
- ]
- }]
- });
- },
-
-
- showPackingList : function() {
- window.open(LABKEY.ActionURL.buildURL('hdrl', 'printPackingList', null, {'requestId' : this.requestId}));
- },
-
- toggleButtons : function() {
- var submitButton = this.down('button#submitButton');
- if (submitButton)
- submitButton.setDisabled(!this.validData || this.isSubmitted() || (this.testTypeId == null && this.requestType == null) || this.grid.getStore().getCount() == 0);
- var saveButton = this.down('button#saveButton');
- if (saveButton)
- saveButton.setDisabled(!this.isDirty() || !this.down('form').getForm().isValid());
- var packingListButton = this.down('button#packingListButton');
- if (packingListButton)
- packingListButton.setDisabled(!this.validData || this.grid.getStore().getCount() == 0 || !this.down('form').getForm().isValid());
- },
-
- saveSpecimens : function(newRequestStatusId, callback) {
- var extraContext = null;
- if (newRequestStatusId == 1){
- extraContext = {validationMode : 'OFF'};
- } else if (newRequestStatusId == 2) {
- extraContext = {validationMode : 'WITH_UQ'};
- }
-
- // save any specimen requests
- var insertedRows = [];
- var updatedRows = [];
- var deletedRows = [];
-
- Ext4.each(this.grid.getStore().getModifiedRecords(), function(rec){
-
- var row = this.prepareRow(rec.copy().data);
- if (!row.RowId){
- row.RowId = null;
- insertedRows.push(row);
- }
- else {
- updatedRows.push(row);
- }
- }, this);
-
- Ext4.each(this.grid.getStore().getRemovedRecords(), function(rec){
-
- var row = this.prepareRow(rec.copy().data);
- if (row.RowId){
- deletedRows.push(row);
- }
- }, this);
-
- this.error = false;
- var commands = [];
- if (insertedRows.length > 0) {
- commands.push({
- schemaName : 'hdrl',
- queryName : 'inboundSpecimen',
- rows : insertedRows,
- extraContext: extraContext,
- command : 'insert'
- });
- }
- if (updatedRows.length > 0) {
- commands.push({
- schemaName : 'hdrl',
- queryName : 'inboundSpecimen',
- rows : updatedRows,
- extraContext: extraContext,
- command : 'update'
- });
- }
- if (deletedRows.length > 0) {
- commands.push({
- schemaName : 'hdrl',
- queryName : 'inboundSpecimen',
- rows : deletedRows,
- command : 'delete'
- });
- }
- if (commands.length > 0)
- {
- LABKEY.Query.saveRows(
- {
- commands: commands,
- scope: this,
- success: function (res)
- {
- if (!this.error)
- {
- this.resetDirty();
- if (callback)
- {
- callback.call(this);
- }
- else
- window.location = LABKEY.ActionURL.buildURL('hdrl', 'begin.view');
- }
- },
- failure: function (res)
- {
- this.error = true;
- var message = 'An error occurred saving the specimen data. See the log for details.';
- if (res.exception)
- message = res.exception;
- Ext4.Msg.show({
- title: "Error",
- msg: message,
- buttons: Ext4.MessageBox.OK,
- icon: Ext4.MessageBox.ERROR
- });
- }
- }
- );
- }
- else // no specimens to update, so our state is no longer dirty
- {
- this.resetDirty();
- }
- },
-
- submitRequest : function()
- {
- if (this.requestId != -1) {
-
- var row = {requestId : this.requestId, isNewSubmit: true, requestStatusId : 2, shippingCarrierId : this.shippingCarrier, testTypeId : this.requestType, shippingNumber : this.shippingNumber};
-
- // handle inserts & updates
- LABKEY.Query.updateRows({
- schemaName : 'hdrl',
- queryName : 'inboundRequest',
- rows : [row],
- scope : this,
- success : function(res) {
- window.location = LABKEY.ActionURL.buildURL('hdrl', 'begin.view');
- },
- failure : function(res){
- this.error = true;
- var message = 'An error occurred submitting the specimen data. See the log for details.';
- if (res.exception)
- message = res.exception;
- Ext4.Msg.show({
- title: "Error",
- msg: message,
- buttons: Ext4.MessageBox.OK,
- icon: Ext4.MessageBox.ERROR,
- scope: this,
- fn: function(buttonId, text, opt) {
- window.location = LABKEY.ActionURL.buildURL('hdrl', 'editRequest.view', null, {requestId : this.requestId});
- }
- });
- }
- });
-
- } else {
- this.error = true;
- Ext4.Msg.show({title: "Error", msg: 'The request must be saved before being submitted.', buttons: Ext4.MessageBox.OK, icon: Ext4.MessageBox.ERROR});
- }
- },
-
- isSubmitted : function()
- {
- return this.requestStatusId >= 2;
- },
-
- handleSave : function(newRequestStatusId) {
- if (this.isSubmitted())
- {
- Ext4.Msg.show({
- title: "Confirmation",
- msg: 'Warning : This request has already been submitted. ' +
- 'Changes here will not be pushed to LabWare. Do you still want to save your changes?',
- buttons: Ext4.MessageBox.YESNO,
- icon: Ext4.MessageBox.WARNING,
- scope: this,
- fn: function (buttonId, text, opt)
- {
- if (buttonId == "yes")
- this.saveRequestAndSpecimens(2);
- }
- }
- );
- }
- else
- {
- this.saveRequestAndSpecimens(newRequestStatusId);
- }
- },
-
- // @param saveCallback is used when you want to save the data on the page before executing another function
- // (e.g., saving the data before printing the packing list)
- saveRequestAndSpecimens : function(newRequestStatusId, saveCallback) {
-
- // if saving an already-submitted request, we don't want to change the status, just update the request and/or the specimens
- var changeStatus = newRequestStatusId == 2 && this.requestStatusId == 1;
- var form = this.down('form').getForm();
- var fn = this.requestId != -1 ? LABKEY.Query.updateRows : LABKEY.Query.insertRows;
- if (form.isValid()) { // make sure we have all the required fields
-
- this.roweditor.completeEdit(); // check if editing is still in progress
- // save the request as pending so we can update the specimen rows
- var row = {
- requestStatusId : changeStatus ? 1 : this.requestStatusId,
- isNewSubmit : false,
- shippingCarrierId : this.shippingCarrier,
- testTypeId : this.requestType,
- shippingNumber : this.shippingNumber};
- if (this.requestId != -1){
- row.requestId = this.requestId;
- }
-
- // handle inserts & updates
- fn({
- schemaName : 'hdrl',
- queryName : 'inboundRequest',
- rows : [row],
- scope : this,
- success : function(res) {
- if (res.rows && res.rows.length === 1)
- {
- this.requestId = res.rows[0].requestid;
- if (this.isDirty())
- this.saveSpecimens(newRequestStatusId, changeStatus ? this.submitRequest : saveCallback); // save the specimens with the request still pending
- else
- this.submitRequest();
- }
- },
- failure : function(){
- Ext4.Msg.show({title: "Error", msg: 'An error occurred saving the test request. See the log for details.', buttons: Ext4.MessageBox.OK, icon: Ext4.MessageBox.ERROR});
- }
- });
- }
- else {
- Ext4.Msg.show({title: "Error", msg: 'Please enter all required fields.', buttons: Ext4.MessageBox.OK, icon: Ext4.MessageBox.ERROR});
- }
- },
-
- /**
- * Update the status field based on the server validation of the record
- */
- verifyRows : function(rows, modifiedFields, callback){
-
- if (modifiedFields && (modifiedFields.length == 0 || (modifiedFields.length ==1 && modifiedFields[0] == 'status'))) {
-
- if (callback)
- callback.call(this, true);
- else
- return;
- }
-
- var ret = true;
- var data = [];
- Ext4.each(rows, function(rec){
- data.push(this.prepareRow(rec.copy().data));
- }, this);
-
- LABKEY.Ajax.request({
- url : LABKEY.ActionURL.buildURL("hdrl", "verifySpecimen.api"),
- method : 'POST',
- scope : this,
- jsonData: {
- rows : data
- },
- success : function(res) {
- var o = Ext4.decode(res.responseText);
-
- this.validData = true;
- for (var i=0; i < o.rows.length; i++)
- {
- if (o.rows[i].ValidationStatus)
- this.validData = false;
- rows[i].set('status', o.rows[i].ValidationStatus);
- }
-
- if (callback)
- callback.call(this, this.validData);
- }
- });
- },
-
- /**
- * Prepares the client side row for inserting or updating to the server
- * @private
- */
- prepareRow : function(row){
-
- // convert any lookup display values back to keys
- for (var key in row){
- if (row.hasOwnProperty(key)){
-
- if (this.lkMap[key]){
- row[key] = this.lkMap[key][row[key]];
- }
- else if ('SSN' === key && row[key]){
- // remove hyphens and whitespace from the SSN
- row[key] = row[key].replace(/-|\s+/g, '');
- }
- }
- }
-
- row.InboundRequestId = this.requestId;
- return row;
- },
-
- /**
- * Need to build the map from display value to key for the combo editors so that we can translate the store records
- * at insert or update time.
- * @private
- */
- createDisplayValueMap : function(colName, recs, keyName, valueName) {
-
- var map = this.lkMap[colName] || {};
- Ext4.each(recs, function(rec){
-
- var data = rec.data;
- if ((data[keyName] != undefined) && (data[valueName] != undefined)) {
- map[data[valueName]] = data[keyName];
- }
- });
-
- this.lkMap[colName] = map;
- },
-
- markDirty : function(dirty) {
- this.dirty = dirty;
- this.toggleButtons();
- LABKEY.Utils.signalWebDriverTest("pageDirty", dirty);
- },
-
- resetDirty : function() {
- this.markDirty(false);
- },
-
- isDirty : function() {
- return this.dirty;
- },
-
- beforeUnload : function() {
- if (this.isDirty()) {
- return 'please save your changes';
- }
- },
-
- /**
- * grid column renderer for SSN's
- * @private
- */
- SSNRenderer : function(value, meta, rec, idx){
-
- if (value && value.indexOf('-') == -1 && value.length == 9){
- return value.substr(0,3) + '-' + value.substr(3,2) + '-' + value.substr(5,4);
- }
- return value;
- }
-});
diff --git a/hdrl/src/org/labkey/hdrl/HDRLContainerListener.java b/hdrl/src/org/labkey/hdrl/HDRLContainerListener.java
deleted file mode 100644
index 3bdef70c..00000000
--- a/hdrl/src/org/labkey/hdrl/HDRLContainerListener.java
+++ /dev/null
@@ -1,88 +0,0 @@
-/*
- * Copyright (c) 2015-2019 LabKey Corporation
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-package org.labkey.hdrl;
-
-import org.jetbrains.annotations.NotNull;
-import org.labkey.api.data.Container;
-import org.labkey.api.data.ContainerManager.ContainerListener;
-import org.labkey.api.data.DatabaseTableType;
-import org.labkey.api.data.DbSchema;
-import org.labkey.api.data.DbScope;
-import org.labkey.api.data.SQLFragment;
-import org.labkey.api.data.SchemaTableInfo;
-import org.labkey.api.data.SqlExecutor;
-import org.labkey.api.security.User;
-import org.labkey.api.util.ContainerUtil;
-import org.labkey.hdrl.query.LabWareQuerySchema;
-
-import java.util.Collections;
-import java.util.Collection;
-
-import java.beans.PropertyChangeEvent;
-
-public class HDRLContainerListener implements ContainerListener
-{
- @Override
- public void containerCreated(Container c, User user)
- {
- }
-
- @Override
- public void containerDeleted(Container c, User user)
- {
- DbSchema hdrl = HDRLSchema.getInstance().getSchema();
- DbSchema labware = new LabWareQuerySchema(user, c).getSchema();
- try (DbScope.Transaction transaction = hdrl.getScope().ensureTransaction())
- {
- deleteLabWareTable(labware, "X_LK_OUTBD_SPECIMENS", c);
- deleteLabWareTable(labware, "X_LK_OUTBD_REQUESTS", c);
- deleteLabWareTable(labware, "X_LK_INBND_SPECIMENS", c);
- deleteLabWareTable(labware, "X_LK_INBND_REQUESTS", c);
-
- ContainerUtil.purgeTable(hdrl.getTable("InboundRequest"), c, null);
- transaction.commit();
- }
- }
-
- private void deleteLabWareTable(DbSchema labware, String labWareTable, Container container)
- {
- SqlExecutor executor = new SqlExecutor(labware.getScope());
- SchemaTableInfo tableInfo = labware.getTable("X_LK_OUTBD_SPECIMENS");
- if (tableInfo != null && tableInfo.getTableType() != DatabaseTableType.NOT_IN_DB)
- {
- SQLFragment deleteSQL = new SQLFragment("DELETE FROM gw_labkey.").append(labWareTable).append(" WHERE batch_id in (SELECT RequestId from hdrl.InboundRequest WHERE Container = ?)");
- deleteSQL.add(container.getId());
- executor.execute(deleteSQL);
- }
- }
-
- @Override
- public void propertyChange(PropertyChangeEvent evt)
- {
- }
-
- @Override
- public void containerMoved(Container c, Container oldParent, User user)
- {
- }
-
- @NotNull @Override
- public Collection canMove(Container c, Container newParent, User user)
- {
- return Collections.emptyList();
- }
-}
\ No newline at end of file
diff --git a/hdrl/src/org/labkey/hdrl/HDRLController.java b/hdrl/src/org/labkey/hdrl/HDRLController.java
deleted file mode 100644
index a707daa2..00000000
--- a/hdrl/src/org/labkey/hdrl/HDRLController.java
+++ /dev/null
@@ -1,810 +0,0 @@
-/*
- * Copyright (c) 2015-2019 LabKey Corporation
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-package org.labkey.hdrl;
-
-import jakarta.servlet.http.HttpServletResponse;
-import org.apache.commons.beanutils.BeanUtils;
-import org.apache.commons.io.IOUtils;
-import org.json.JSONArray;
-import org.json.JSONException;
-import org.json.JSONObject;
-import org.labkey.api.action.ApiSimpleResponse;
-import org.labkey.api.action.ApiUsageException;
-import org.labkey.api.action.ExportAction;
-import org.labkey.api.action.FormViewAction;
-import org.labkey.api.action.Marshal;
-import org.labkey.api.action.Marshaller;
-import org.labkey.api.action.MutatingApiAction;
-import org.labkey.api.action.ReadOnlyApiAction;
-import org.labkey.api.action.SimpleApiJsonForm;
-import org.labkey.api.action.SimpleViewAction;
-import org.labkey.api.action.SpringActionController;
-import org.labkey.api.admin.AdminUrls;
-import org.labkey.api.collections.CaseInsensitiveHashMap;
-import org.labkey.api.data.ContainerManager;
-import org.labkey.api.data.Results;
-import org.labkey.api.data.SimpleFilter;
-import org.labkey.api.data.TableSelector;
-import org.labkey.api.module.Module;
-import org.labkey.api.module.ModuleLoader;
-import org.labkey.api.query.FieldKey;
-import org.labkey.api.query.QueryService;
-import org.labkey.api.query.QuerySettings;
-import org.labkey.api.query.QueryView;
-import org.labkey.api.query.UserSchema;
-import org.labkey.api.query.ValidationException;
-import org.labkey.api.resource.Resource;
-import org.labkey.api.security.AdminConsoleAction;
-import org.labkey.api.security.RequiresPermission;
-import org.labkey.api.security.permissions.AdminPermission;
-import org.labkey.api.security.permissions.InsertPermission;
-import org.labkey.api.security.permissions.ReadPermission;
-import org.labkey.api.settings.AdminConsole;
-import org.labkey.api.util.HtmlString;
-import org.labkey.api.util.LinkBuilder;
-import org.labkey.api.util.PageFlowUtil;
-import org.labkey.api.util.Path;
-import org.labkey.api.util.URLHelper;
-import org.labkey.api.view.ActionURL;
-import org.labkey.api.view.HtmlView;
-import org.labkey.api.view.JspView;
-import org.labkey.api.view.NavTree;
-import org.labkey.api.view.NotFoundException;
-import org.labkey.api.view.VBox;
-import org.labkey.api.view.template.PageConfig;
-import org.labkey.hdrl.query.HDRLQuerySchema;
-import org.labkey.hdrl.query.InboundSpecimenUpdateService;
-import org.labkey.hdrl.query.LabWareQuerySchema;
-import org.labkey.hdrl.view.InboundRequestBean;
-import org.labkey.hdrl.view.InboundSpecimenBean;
-import org.springframework.validation.BindException;
-import org.springframework.validation.Errors;
-import org.springframework.web.servlet.ModelAndView;
-
-import java.io.IOException;
-import java.util.ArrayList;
-import java.util.Collections;
-import java.util.Date;
-import java.util.List;
-import java.util.Map;
-import java.util.Objects;
-
-public class HDRLController extends SpringActionController
-{
- private static final DefaultActionResolver _actionResolver = new DefaultActionResolver(HDRLController.class);
- public static final String NAME = "hdrl";
-
- public HDRLController()
- {
- setActionResolver(_actionResolver);
- }
-
- public static void registerAdminConsoleLinks()
- {
- AdminConsole.addLink(AdminConsole.SettingsLinkType.Management, "HDRL Sensitive Data", new ActionURL(HDRLSensitiveDataAdminAction.class, ContainerManager.getRoot()), AdminPermission.class);
- }
-
- @RequiresPermission(ReadPermission.class)
- public class BeginAction extends SimpleViewAction
- {
- @Override
- public ModelAndView getView(Object o, BindException errors)
- {
- VBox vbox = new VBox();
-
- HtmlView submitView = new HtmlView("New Test Request", HtmlString.of(LinkBuilder.labkeyLink("Submit new test request", new ActionURL(EditRequestAction.class, getViewContext().getContainer()))));
- vbox.addView(submitView);
-
- UserSchema schema = QueryService.get().getUserSchema(getUser(), getContainer(), HDRLQuerySchema.NAME);
-
- if (schema == null)
- {
- throw new NotFoundException("HDRL schema not found in the current folder.");
- }
-
- QuerySettings settings = schema.getSettings(getViewContext(), QueryView.DATAREGIONNAME_DEFAULT, HDRLQuerySchema.TABLE_INBOUND_REQUEST);
- QueryView queryView = schema.createView(getViewContext(), settings, errors);
- queryView.setShowInsertNewButton(false);
- queryView.setShowImportDataButton(false);
- vbox.addView(queryView);
- return vbox;
- }
-
- @Override
- public void addNavTrail(NavTree root)
- {
- root.addChild("HDRL Test Request Overview");
- }
- }
-
-
- @RequiresPermission(ReadPermission.class)
- public static class RequestDetailsAction extends SimpleViewAction
- {
- @Override
- public ModelAndView getView(Object o, BindException errors)
- {
- try
- {
- int requestId = Integer.parseInt(getViewContext().getRequest().getParameter("requestId"));
- InboundRequestBean bean = HDRLManager.get().getInboundRequest(getUser(), getContainer(), requestId);
- JspView> jsp = new JspView<>("/org/labkey/hdrl/view/requestDetails.jsp", bean);
- jsp.setTitle("Test Request");
-
- UserSchema schema = QueryService.get().getUserSchema(getUser(), getContainer(), HDRLQuerySchema.NAME);
- QuerySettings settings = schema.getSettings(getViewContext(), QueryView.DATAREGIONNAME_DEFAULT, HDRLQuerySchema.TABLE_SPECIMENS);
- QueryView queryView = schema.createView(getViewContext(), settings, errors);
-
- jsp.setView("queryView", queryView);
- return jsp;
- }
- catch (NumberFormatException x)
- {
- throw new ApiUsageException("RequestId is required");
- }
- }
-
- @Override
- public void addNavTrail(NavTree root)
- {
- root.addChild("Test Request");
- }
- }
-
- @RequiresPermission(InsertPermission.class)
- public static class EditRequestAction extends SimpleViewAction
- {
- private String _navLabel = "Create a new Test Request";
-
- @Override
- public ModelAndView getView(RequestForm form, BindException errors) throws Exception
- {
- if (form.getRequestId() != -1)
- {
- TableSelector selector = new TableSelector(org.labkey.hdrl.HDRLSchema.getInstance().getTableInfoInboundRequest());
- RequestForm object = selector.getObject(form.getRequestId(), RequestForm.class);
- if (object != null)
- {
- _navLabel = "Edit a Test Request";
- BeanUtils.copyProperties(form, object);
- }
- else
- {
- form.setTestTypeId(1); // default to first test type
- errors.reject(ERROR_MSG, "Request with id " + form.getRequestId() + " not found.");
- }
- }
- else
- {
- form.setTestTypeId(1); // default to first test type
- }
-
- if (form.getRequestStatusId() >= 2 && !getContainer().hasPermission(getUser(), AdminPermission.class))
- return HtmlView.of("This request has been submitted and is locked from editing.");
- else
- return new JspView<>("/org/labkey/hdrl/view/editRequest.jsp", form, errors);
- }
-
- @Override
- public void addNavTrail(NavTree root)
- {
- root.addChild(_navLabel);
- }
- }
-
- public static class RequestForm
- {
- private int _requestId = -1;
- private Integer _requestStatusId = 1;
- private Integer _shippingCarrierId;
- private String _shippingNumber;
- private Integer _testTypeId;
-
- public int getRequestId()
- {
- return _requestId;
- }
-
- public void setRequestId(int requestId)
- {
- _requestId = requestId;
- }
-
- public Integer getRequestStatusId()
- {
- return _requestStatusId;
- }
-
- public void setRequestStatusId(Integer requestStatusId)
- {
- _requestStatusId = requestStatusId;
- }
-
- public Integer getShippingCarrierId()
- {
- return _shippingCarrierId;
- }
-
- public void setShippingCarrierId(Integer shippingCarrierId)
- {
- _shippingCarrierId = shippingCarrierId;
- }
-
- public String getShippingNumber()
- {
- return _shippingNumber;
- }
-
- public void setShippingNumber(String shippingNumber)
- {
- _shippingNumber = shippingNumber;
- }
-
- public Integer getTestTypeId()
- {
- return _testTypeId;
- }
-
- public void setTestTypeId(Integer testTypeId)
- {
- _testTypeId = testTypeId;
- }
-
- }
-
- @RequiresPermission(ReadPermission.class)
- public static class VerifySpecimenAction extends ReadOnlyApiAction
- {
- @Override
- public Object execute(VerifyForm form, BindException errors)
- {
- ApiSimpleResponse response = new ApiSimpleResponse();
- JSONArray rows = Objects.requireNonNullElseGet(form.getJsonObject(), JSONObject::new).optJSONArray("rows");
- if (rows == null)
- {
- throw new ApiUsageException("rows not provided.");
- }
- List> rowsToValidate = new ArrayList<>();
-
- for (int idx = 0; idx < rows.length(); ++idx)
- {
- JSONObject jsonObj;
- try
- {
- jsonObj = rows.getJSONObject(idx);
- }
- catch (JSONException x)
- {
- throw new ApiUsageException("rows[" + idx + "] is not an object.");
- }
- if (null != jsonObj)
- {
- Map rowMap = new CaseInsensitiveHashMap<>();
- rowMap.putAll(jsonObj.toMap());
-
- rowsToValidate.add(rowMap);
- }
- }
-
- // validate the rows
- response.put("rows", rowsToValidate);
- for (Map row : rowsToValidate)
- {
- try
- {
- InboundSpecimenUpdateService.validate(row);
- }
- catch (ValidationException ignored)
- {
- }
- }
- return response;
- }
- }
-
- public static class VerifyForm extends SimpleApiJsonForm
- {
- }
-
-
- @RequiresPermission(ReadPermission.class)
- public static class DownloadClinicalReportAction extends ExportAction
- {
- @Override
- public void export(SpecimenForm form, HttpServletResponse response, BindException errors) throws Exception
- {
- LabWareQuerySchema lwSchema = new LabWareQuerySchema(getUser(), getContainer());
- SimpleFilter filter = new SimpleFilter(FieldKey.fromParts("test_request_id"), form.getSpecimenId());
- TableSelector selector = new TableSelector(lwSchema.getSchema().getTable(LabWareQuerySchema.TABLE_OUTBOUND_SPECIMENS), filter, null);
-
- try (Results result = selector.getResults(false))
- {
- if (!result.next())
- throw new NotFoundException("No report available for specimen " + form.getSpecimenId());
-
- String contentType = "application/pdf";
-
- byte[] documentBytes = IOUtils.toByteArray(result.getBinaryStream("clinical_report"));
-
- response.setContentType(contentType);
- response.setHeader("Content-Disposition", "attachment; filename=\"" + result.getString("report_file_name") + "\"");
- response.setContentLength(documentBytes.length);
- response.getOutputStream().write(documentBytes);
- }
- }
-
- @Override
- public void validate(SpecimenForm form, BindException errors)
- {
- if (form.getSpecimenId() == null)
- {
- errors.reject(ERROR_MSG, "SpecimenId is required");
- }
- }
- }
-
- public static class SpecimenForm
- {
- private Integer _specimenId;
-
- public Integer getSpecimenId()
- {
- return _specimenId;
- }
-
- public void setSpecimenId(Integer specimenId)
- {
- _specimenId = specimenId;
- }
- }
-
- @RequiresPermission(ReadPermission.class)
- public static class DownloadSpecimenTemplateAction extends ExportAction
- {
- @Override
- public void export(Object o, HttpServletResponse response, BindException errors)
- {
- // just download the example file checked into the repository
- Module module = ModuleLoader.getInstance().getModule(HDRLModule.NAME);
- Path path = Path.parse("template/").append("specimenTemplate.xlsx");
- Resource r = module.getModuleResource(path);
- if (r != null && r.isFile())
- {
- try
- {
- PageFlowUtil.streamFile(response, Collections.emptyMap(), r.getName(), r.getInputStream(), false);
- }
- catch (IOException ioe)
- {
- throw new RuntimeException(ioe);
- }
- }
- }
- }
-
- @RequiresPermission(ReadPermission.class)
- public static class PrintPackingListAction extends SimpleViewAction
- {
- @Override
- public ModelAndView getView(PackingListBean packingListBean, BindException errors)
- {
- List inboundSpecimenRows = HDRLManager.get().getInboundSpecimen(packingListBean.getRequestId());
- InboundRequestBean inboundRequestBean = HDRLManager.get().getInboundRequest(getUser(), getContainer(), packingListBean.getRequestId());
-
- packingListBean.setInboundSpecimens(inboundSpecimenRows);
- packingListBean.setTotalSamples(inboundSpecimenRows.size());
- packingListBean.setTestType(inboundRequestBean.getTestType());
- packingListBean.setShippingNumber(inboundRequestBean.getShippingNumber());
- packingListBean.setShippingCarrier(inboundRequestBean.getShippingCarrier());
-
- JspView view = new JspView<>("/org/labkey/hdrl/view/printPackingList.jsp", packingListBean, errors);
- getPageConfig().setTitle("Shipping Manifest");
- getPageConfig().setTemplate(PageConfig.Template.Print);
-
- return view;
- }
-
- @Override
- public void addNavTrail(NavTree root)
- {
- }
- }
-
- public static class PackingListBean
- {
- private int _requestId = -1;
- private String _shippingCarrier;
- private int _totalSamples;
- private String _testType;
- private String _shippingNumber;
- private List _inboundSpecimens;
-
- public int getRequestId()
- {
- return _requestId;
- }
-
- public void setRequestId(int requestId)
- {
- _requestId = requestId;
- }
-
- public List getInboundSpecimens()
- {
- return _inboundSpecimens;
- }
-
- public void setInboundSpecimens(List inboundSpecimens)
- {
- _inboundSpecimens = inboundSpecimens;
- }
-
- public String getShippingCarrier()
- {
- return _shippingCarrier;
- }
-
- public void setShippingCarrier(String shippingCarrier)
- {
- _shippingCarrier = shippingCarrier;
- }
-
- public int getTotalSamples()
- {
- return _totalSamples;
- }
-
- public void setTotalSamples(int totalSamples)
- {
- _totalSamples = totalSamples;
- }
-
- public String getTestType()
- {
- return _testType;
- }
-
- public void setTestType(String testType)
- {
- _testType = testType;
- }
- public String getShippingNumber()
- {
- return _shippingNumber;
- }
-
- public void setShippingNumber(String shippingNumber)
- {
- _shippingNumber = shippingNumber;
- }
- }
-
- @AdminConsoleAction
- @RequiresPermission(AdminPermission.class)
- public static class HDRLSensitiveDataAdminAction extends FormViewAction
- {
- @Override
- public void validateCommand(SensitiveDataForm target, Errors errors)
- {
- if (target.getTimeWindowInDays() < 0)
- {
- errors.reject(ERROR_MSG, "'Number of Days' cannot be negative, it should be greater than or equal to 0.");
- }
- }
-
- @Override
- public ModelAndView getView(SensitiveDataForm sensitiveDataForm, boolean reshow, BindException errors)
- {
- return new JspView<>("/org/labkey/hdrl/view/sensitiveData.jsp", sensitiveDataForm, errors);
- }
-
- @Override
- public boolean handlePost(SensitiveDataForm sensitiveDataForm, BindException errors)
- {
- HDRLManager.saveProperties(sensitiveDataForm);
- return true;
- }
-
- @Override
- public URLHelper getSuccessURL(SensitiveDataForm sensitiveDataForm)
- {
- return urlProvider(AdminUrls.class).getAdminConsoleURL();
- }
-
- @Override
- public void addNavTrail(NavTree root)
- {
- urlProvider(AdminUrls.class).addAdminNavTrail(root, "HDRL Sensitive Data Time Window", getClass(), getContainer());
- }
- }
-
- public static class SensitiveDataForm
- {
- private int timeWindowInDays = HDRLManager.getNumberOfDays();
-
- public int getTimeWindowInDays()
- {
- return timeWindowInDays;
- }
-
- public void setTimeWindowInDays(int timeWindowInDays)
- {
- this.timeWindowInDays = timeWindowInDays;
- }
- }
-
- @RequiresPermission(AdminPermission.class)
- @Marshal(Marshaller.Jackson)
- public static class AddLabWareOutboundRequestAction extends MutatingApiAction
- {
- @Override
- public Object execute(LabWareOutboundRequestForm form, BindException errors)
- {
- HDRLManager.get().insertLabWareOutboundRequest(form, getUser(), getContainer());
-
- return success();
- }
-
- @Override
- public void validateForm(LabWareOutboundRequestForm form, Errors errors)
- {
- if (form.getBatchId() == null)
- errors.rejectValue("batchId", ERROR_MSG, "batchId is required");
- if (form.getDateReceived() == null)
- errors.rejectValue("dateReceived", ERROR_MSG, "dateReceived is required");
- if (form.getDateModified() == null)
- errors.rejectValue("dateModified", ERROR_MSG, "dateModified is required");
- if (form.getHdrlStatus() == null)
- errors.rejectValue("hdrlStatus", ERROR_MSG, "hdrlStatus is required");
- }
- }
-
- public static class LabWareOutboundRequestForm
- {
- private Integer _batchId;
- private String _hdrlStatus;
- private String _customerNote;
- private Date _dateReceived;
- private Date _dateCompleted;
- private Date _dateModified;
-
- public Integer getBatchId()
- {
- return _batchId;
- }
-
- public void setBatchId(Integer batchId)
- {
- _batchId = batchId;
- }
-
- public String getCustomerNote()
- {
- return _customerNote;
- }
-
- public void setCustomerNote(String customerNote)
- {
- _customerNote = customerNote;
- }
-
- public Date getDateCompleted()
- {
- return _dateCompleted;
- }
-
- public void setDateCompleted(Date dateCompleted)
- {
- _dateCompleted = dateCompleted;
- }
-
- public Date getDateReceived()
- {
- return _dateReceived;
- }
-
- public void setDateReceived(Date dateReceived)
- {
- _dateReceived = dateReceived;
- }
-
- public String getHdrlStatus()
- {
- return _hdrlStatus;
- }
-
- public void setHdrlStatus(String hdrlStatus)
- {
- _hdrlStatus = hdrlStatus;
- }
-
- public Date getDateModified()
- {
- return _dateModified;
- }
-
- public void setDateModified(Date dateModified)
- {
- _dateModified = dateModified;
- }
- }
-
- @RequiresPermission(AdminPermission.class)
- @Marshal(Marshaller.Jackson)
- public static class AddLabWareOutboundSpecimenAction extends MutatingApiAction
- {
- @Override
- public Object execute(LabWareOutboundSpecimenForm form, BindException errors) throws Exception
- {
- HDRLManager.get().insertLabWareOutboundSpecimen(form, getUser(), getContainer());
-
- return success();
- }
-
- @Override
- public void validateForm(LabWareOutboundSpecimenForm form, Errors errors)
- {
- if (form.getTestRequestId() == null)
- errors.rejectValue("testRequestId", ERROR_MSG, "testRequestId is required");
- if (form.getBatchId() == null)
- errors.rejectValue("batchId", ERROR_MSG, "batchId is required");
- if (form.getDateReceived() == null)
- errors.rejectValue("dateReceived", ERROR_MSG, "dateReceived is required");
- if (form.getDateModified() == null)
- errors.rejectValue("dateModified", ERROR_MSG, "dateModified is required");
- if (form.getHdrlStatus() == null)
- errors.rejectValue("hdrlStatus", ERROR_MSG, "hdrlStatus is required");
- }
- }
-
- public static class LabWareOutboundSpecimenForm
- {
- private Integer _testRequestId;
- private Integer _batchId;
- private Date _dateReceived;
- private Date _dateCompleted;
- private String _sampleIntegrity;
- private String _testResult;
- private String _customerCode;
- private String _clinicalReportFile;
- private String _hdrlStatus;
- private Date _dateModified;
- private String _modifiedResultFlag;
- private String _reportFileName;
-
- public Integer getBatchId()
- {
- return _batchId;
- }
-
- public void setBatchId(Integer batchId)
- {
- _batchId = batchId;
- }
-
- public String getClinicalReportFile()
- {
- return _clinicalReportFile;
- }
-
- public void setClinicalReportFile(String clinicalReportFile)
- {
- _clinicalReportFile = clinicalReportFile;
- }
-
- public String getHdrlStatus()
- {
- return _hdrlStatus;
- }
-
- public void setHdrlStatus(String hdrlStatus)
- {
- _hdrlStatus = hdrlStatus;
- }
-
- public String getCustomerCode()
- {
- return _customerCode;
- }
-
- public void setCustomerCode(String customerCode)
- {
- _customerCode = customerCode;
- }
-
- public Date getDateCompleted()
- {
- return _dateCompleted;
- }
-
- public void setDateCompleted(Date dateCompleted)
- {
- _dateCompleted = dateCompleted;
- }
-
- public Date getDateModified()
- {
- return _dateModified;
- }
-
- public void setDateModified(Date dateModified)
- {
- _dateModified = dateModified;
- }
-
- public Date getDateReceived()
- {
- return _dateReceived;
- }
-
- public void setDateReceived(Date dateReceived)
- {
- _dateReceived = dateReceived;
- }
-
- public String getModifiedResultFlag()
- {
- return _modifiedResultFlag;
- }
-
- public void setModifiedResultFlag(String modifiedResultFlag)
- {
- _modifiedResultFlag = modifiedResultFlag;
- }
-
- public String getSampleIntegrity()
- {
- return _sampleIntegrity;
- }
-
- public void setSampleIntegrity(String sampleIntegrity)
- {
- _sampleIntegrity = sampleIntegrity;
- }
-
- public Integer getTestRequestId()
- {
- return _testRequestId;
- }
-
- public void setTestRequestId(Integer testRequestId)
- {
- _testRequestId = testRequestId;
- }
-
- public String getTestResult()
- {
- return _testResult;
- }
-
- public void setTestResult(String testResult)
- {
- _testResult = testResult;
- }
-
- public String getReportFileName()
- {
- return _reportFileName;
- }
-
- public void setReportFileName(String reportFileName)
- {
- _reportFileName = reportFileName;
- }
- }
-
-}
\ No newline at end of file
diff --git a/hdrl/src/org/labkey/hdrl/HDRLFolderType.java b/hdrl/src/org/labkey/hdrl/HDRLFolderType.java
deleted file mode 100644
index 51daed65..00000000
--- a/hdrl/src/org/labkey/hdrl/HDRLFolderType.java
+++ /dev/null
@@ -1,39 +0,0 @@
-/*
- * Copyright (c) 2015-2016 LabKey Corporation
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-package org.labkey.hdrl;
-
-import org.labkey.api.module.MultiPortalFolderType;
-import org.labkey.api.view.Portal;
-
-import java.util.Arrays;
-import java.util.Collections;
-
-/**
- * Created by: jeckels
- * Date: 5/10/15
- */
-public class HDRLFolderType extends MultiPortalFolderType
-{
- public HDRLFolderType(HDRLModule module)
- {
- super("HDRL Request Portal",
- "HDRL portal for submitting assay requests and receiving results.",
- Collections.emptyList(),
- Arrays.asList(Portal.getPortalPart("HDRL Summary").createWebPart()),
- Collections.singleton(module),
- module);
- }
-}
diff --git a/hdrl/src/org/labkey/hdrl/HDRLMaintenanceTask.java b/hdrl/src/org/labkey/hdrl/HDRLMaintenanceTask.java
deleted file mode 100644
index 4a7b2a2e..00000000
--- a/hdrl/src/org/labkey/hdrl/HDRLMaintenanceTask.java
+++ /dev/null
@@ -1,115 +0,0 @@
-/*
- * Copyright (c) 2015-2016 LabKey Corporation
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-package org.labkey.hdrl;
-
-import org.apache.logging.log4j.Logger;
-import org.labkey.api.data.DbSchema;
-import org.labkey.api.data.DbScope;
-import org.labkey.api.data.SQLFragment;
-import org.labkey.api.data.SqlExecutor;
-import org.labkey.api.util.SystemMaintenance.MaintenanceTask;
-import org.labkey.hdrl.query.HDRLQuerySchema;
-
-import java.util.Calendar;
-
-/**
- * Created by: jeckels
- * Date: 5/10/15
- */
-public class HDRLMaintenanceTask implements MaintenanceTask
-{
- @Override
- public String getDescription()
- {
- return "HDRL Request Portal PHI Deletion";
- }
-
- @Override
- public String getName()
- {
- return "HdrlPhiDeletion";
- }
-
- @Override
- public void run(Logger log)
- {
- // Get this from the configurable setting
- int retentionDays = HDRLManager.getNumberOfDays();
- final String requestStatusStatement = HDRLQuerySchema.COL_REQUEST_STATUS_ID + " = " + "(SELECT rowid FROM hdrl.requeststatus WHERE name = ?)";
- final String submittedCondition1 = " WHERE (" + HDRLSchema.getInstance().getSchema().getSqlDialect().getDateDiff(Calendar.DATE, "NOW()", "r.Completed") + " >= ?";
- final String submittedCondition2 = " AND i." + requestStatusStatement + ")";
-
- DbSchema hdrl = HDRLSchema.getInstance().getSchema();
- try (DbScope.Transaction transaction = hdrl.getScope().ensureTransaction())
- {
- // Need to stash the number of specimens in the request table, prior to deleting the specimen rows
- SQLFragment addToArchivedRequestCountColSQL = new SQLFragment("UPDATE ");
- addToArchivedRequestCountColSQL.append(HDRLSchema.getInstance().getTableInfoInboundRequest(), "i");
- addToArchivedRequestCountColSQL.append(" SET " + HDRLQuerySchema.COL_ARCHIVED_REQUEST_COUNT + " = (SELECT COUNT(*) FROM ");
- addToArchivedRequestCountColSQL.append(HDRLSchema.getInstance().getTableInfoInboundSpecimen(), "s");
- addToArchivedRequestCountColSQL.append(" WHERE s." + HDRLQuerySchema.COL_INBOUND_REQUEST_ID + " = i.RequestId)");
- addToArchivedRequestCountColSQL.append(" FROM ").append(HDRLSchema.getInstance().getTableInfoRequestResult(), "r");
- addToArchivedRequestCountColSQL.append(submittedCondition1);
- addToArchivedRequestCountColSQL.add(retentionDays);
- addToArchivedRequestCountColSQL.append(submittedCondition2);
- addToArchivedRequestCountColSQL.add(HDRLQuerySchema.STATUS_SUBMITTED);
-
- // Need to stash the number of specimens in the request table, prior to deleting the specimen rows
- SQLFragment updateStatusSql = new SQLFragment("UPDATE ");
- updateStatusSql.append(HDRLSchema.getInstance().getTableInfoRequestResult(), "r");
- updateStatusSql.append(" SET " + requestStatusStatement);
- updateStatusSql.add(HDRLQuerySchema.STATUS_ARCHIVED);
- updateStatusSql.append(" FROM ").append(HDRLSchema.getInstance().getTableInfoInboundRequest(), "i");
- updateStatusSql.append(submittedCondition1);
- updateStatusSql.add(retentionDays);
- updateStatusSql.append(submittedCondition2);
- updateStatusSql.add(HDRLQuerySchema.STATUS_SUBMITTED);
-
- log.info("Adding specimen count to column '" + HDRLQuerySchema.COL_ARCHIVED_REQUEST_COUNT + "' in table " + HDRLSchema.getInstance().getTableInfoInboundRequest().getName());
-
- int numRequests = new SqlExecutor(HDRLSchema.getInstance().getScope()).execute(addToArchivedRequestCountColSQL);
-
- log.info("Finished adding specimen count to column '" + HDRLQuerySchema.COL_ARCHIVED_REQUEST_COUNT + "' in table "
- + HDRLSchema.getInstance().getTableInfoInboundRequest().getName()
- +". Added specimen counts to " + numRequests +" rows.");
-
- log.info("Updating request status in table " + HDRLSchema.getInstance().getTableInfoRequestResult().getName());
-
- numRequests = new SqlExecutor(HDRLSchema.getInstance().getScope()).execute(updateStatusSql);
-
- log.info("Updated " + numRequests + " rows ");
-
- log.info("Starting to delete HDRL specimen data");
-
- // Delete specimens for requests that have been archived
- // specimen results are deleted via cascading
- SQLFragment specimenDeleteSQL = new SQLFragment("DELETE FROM ");
- specimenDeleteSQL.append(HDRLSchema.getInstance().getTableInfoInboundSpecimen(), "s");
- specimenDeleteSQL.append(" WHERE " + HDRLQuerySchema.COL_INBOUND_REQUEST_ID + " IN (SELECT r.RequestId FROM ");
- specimenDeleteSQL.append(HDRLSchema.getInstance().getTableInfoRequestResult(), "r");
- specimenDeleteSQL.append(" WHERE " + requestStatusStatement);
- specimenDeleteSQL.add(HDRLQuerySchema.STATUS_ARCHIVED);
- specimenDeleteSQL.append(")");
-
- int inboundRowCount = new SqlExecutor(HDRLSchema.getInstance().getScope()).execute(specimenDeleteSQL);
-
-
- log.info("Deleted " + inboundRowCount + " row(s) of HDRL inbound specimen data");
-
- transaction.commit();
- }
- }
-}
diff --git a/hdrl/src/org/labkey/hdrl/HDRLManager.java b/hdrl/src/org/labkey/hdrl/HDRLManager.java
deleted file mode 100644
index eea5a106..00000000
--- a/hdrl/src/org/labkey/hdrl/HDRLManager.java
+++ /dev/null
@@ -1,199 +0,0 @@
-/*
- * Copyright (c) 2015-2019 LabKey Corporation
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-package org.labkey.hdrl;
-
-import org.apache.commons.lang3.StringUtils;
-import org.apache.logging.log4j.LogManager;
-import org.apache.logging.log4j.Logger;
-import org.labkey.api.attachments.InputStreamAttachmentFile;
-import org.labkey.api.data.CompareType;
-import org.labkey.api.data.Container;
-import org.labkey.api.data.PropertyManager;
-import org.labkey.api.data.PropertyManager.WritablePropertyMap;
-import org.labkey.api.data.SQLFragment;
-import org.labkey.api.data.SimpleFilter;
-import org.labkey.api.data.SqlSelector;
-import org.labkey.api.data.Table;
-import org.labkey.api.data.TableSelector;
-import org.labkey.api.query.FieldKey;
-import org.labkey.api.query.QueryService;
-import org.labkey.api.query.UserSchema;
-import org.labkey.api.security.User;
-import org.labkey.api.view.NotFoundException;
-import org.labkey.hdrl.query.HDRLQuerySchema;
-import org.labkey.hdrl.query.LabWareQuerySchema;
-import org.labkey.hdrl.view.InboundRequestBean;
-import org.labkey.hdrl.view.InboundSpecimenBean;
-
-import java.io.File;
-import java.io.FileInputStream;
-import java.io.FileNotFoundException;
-import java.util.HashMap;
-import java.util.List;
-import java.util.Map;
-
-public class HDRLManager
-{
- private static final Logger LOG = LogManager.getLogger(HDRLManager.class);
- private static final String HDRL_SENSITIVE_DATA_TIME_WINDOW = "hdrlSensitiveDataDeletionTimeWindow";
- private static final String NUM_OF_DAYS_KEY = "HDRLSensitiveDataDeletionWindow";
- private static final int DEFAULT_NUM_OF_DAYS = 30; //default number of days after which data will be deleted
-
- private static final HDRLManager _instance = new HDRLManager();
-
- private HDRLManager()
- {
- // prevent external construction with a private default constructor
- }
-
- public static HDRLManager get()
- {
- return _instance;
- }
-
- public InboundRequestBean getInboundRequest(User user, Container container, Integer requestId)
- {
- UserSchema schema = QueryService.get().getUserSchema(user, container, HDRLQuerySchema.NAME);
- if (schema == null)
- throw new NotFoundException(HDRLModule.NAME + " module is not enabled in this container.");
-
- SQLFragment sql = new SQLFragment("SELECT r.RequestId, r.ShippingNumber, s.Name as RequestStatus, c.Name as ShippingCarrier, t.Name as TestType FROM ");
- sql.append("(SELECT * FROM hdrl.InboundRequest WHERE (Container = ?) AND (RequestId = ?)) r ");
- sql.add(container);
- sql.add(requestId);
- sql.append("LEFT JOIN hdrl.ShippingCarrier c on r.ShippingCarrierId = c.RowId ")
- .append("LEFT JOIN hdrl.TestType t on r.TestTypeId = t.RowId ")
- .append("LEFT JOIN hdrl.RequestStatus s on r.RequestStatusId = s.RowId ");
-
-
- SqlSelector sqlSelector = new SqlSelector(schema.getDbSchema(), sql);
- InboundRequestBean inboundRequestBean = sqlSelector.getObject(InboundRequestBean.class);
- if (inboundRequestBean == null)
- throw new NotFoundException("Request %s not found.".formatted(requestId));
- return inboundRequestBean;
- }
-
- public List getInboundSpecimen(int requestId)
- {
- String joinStatement = "SELECT hdrl.inboundspecimen.*, hdrl.gender.code as genderId, hdrl.familymemberprefix.code as fmpCode, hdrl.dutycode.code as ducCode, hdrl.sourceoftesting.code as sotCode" +
- " FROM hdrl.inboundspecimen" +
- " LEFT JOIN hdrl.gender" +
- " ON hdrl.inboundspecimen.genderId=hdrl.gender.rowid" +
- " LEFT JOIN hdrl.familymemberprefix" +
- " ON hdrl.inboundspecimen.fmpid=hdrl.familymemberprefix.rowid" +
- " LEFT JOIN hdrl.dutycode" +
- " ON hdrl.inboundspecimen.dutycodeid=hdrl.dutycode.rowid" +
- " LEFT JOIN hdrl.sourceoftesting" +
- " ON hdrl.inboundspecimen.testingsourceid=hdrl.sourceoftesting.rowid" +
- " WHERE hdrl.inboundspecimen.inboundrequestid = ?";
-
- SQLFragment sql = new SQLFragment();
- sql.append(joinStatement);
- sql.add(requestId);
-
- SqlSelector selector = new SqlSelector(HDRLSchema.getInstance().getTableInfoInboundSpecimen().getSchema(), sql);
- return selector.getArrayList(InboundSpecimenBean.class);
- }
-
- public static void saveProperties(HDRLController.SensitiveDataForm sensitiveDataForm)
- {
- WritablePropertyMap map = PropertyManager.getNormalStore().getWritableProperties(HDRL_SENSITIVE_DATA_TIME_WINDOW, true);
- map.clear();
- map.put(NUM_OF_DAYS_KEY, String.valueOf(sensitiveDataForm.getTimeWindowInDays()));
- map.save();
- }
-
- private static Map getProperties()
- {
- return PropertyManager.getNormalStore().getProperties(HDRL_SENSITIVE_DATA_TIME_WINDOW);
- }
-
- public static int getNumberOfDays()
- {
- String days = getProperties().get(NUM_OF_DAYS_KEY);
-
- if (StringUtils.isEmpty(days))
- {
- return DEFAULT_NUM_OF_DAYS;
- }
-
- return Integer.parseInt(days);
- }
-
- /**
- * This method is used only for populating results in the Postgres Labware outbound tables for testing.
- * @param resultData - the data to populate the row in the table
- * @param user - current user
- * @param container - current container
- */
- public void insertLabWareOutboundRequest(HDRLController.LabWareOutboundRequestForm resultData, User user, Container container)
- {
- LabWareQuerySchema lwSchema = new LabWareQuerySchema(user, container);
- // create the request data for LabWare
- Map labWareData = new HashMap<>();
- labWareData.put("batch_id", resultData.getBatchId());
- labWareData.put("hdrl_status", resultData.getHdrlStatus());
- labWareData.put("customer_note", resultData.getCustomerNote());
- labWareData.put("date_received", resultData.getDateReceived());
- labWareData.put("date_completed", resultData.getDateCompleted());
- labWareData.put("date_modified", resultData.getDateModified());
- Table.insert(user, lwSchema.getDbSchema().getTable(LabWareQuerySchema.TABLE_OUTBOUND_REQUESTS), labWareData);
- }
-
- /**
- * This method is used only for populating results in the Postgres LabWare outbound tables for testing.
- * If a clinical report file is provided, this will not work when the labwareDataSource is an Oracle database
- * @param resultData - the data to populate the row in the table
- * @param user - current user
- * @param container - current container
- * @throws FileNotFoundException if the name of the clinical report file supplied is not available
- */
- public void insertLabWareOutboundSpecimen(HDRLController.LabWareOutboundSpecimenForm resultData, User user, Container container) throws FileNotFoundException
- {
- LabWareQuerySchema lwSchema = new LabWareQuerySchema(user, container);
- // create the request data for LabWare
- Map labWareData = new HashMap<>();
- labWareData.put("test_request_id", resultData.getTestRequestId());
- labWareData.put("hdrl_status", resultData.getHdrlStatus());
- labWareData.put("batch_id", resultData.getBatchId());
- labWareData.put("date_received", resultData.getDateReceived());
- labWareData.put("date_completed", resultData.getDateCompleted());
- labWareData.put("date_modified", resultData.getDateModified());
- labWareData.put("sample_integrity", resultData.getSampleIntegrity());
- labWareData.put("test_result", resultData.getTestResult());
- labWareData.put("customer_code", resultData.getCustomerCode());
- labWareData.put("modified_result_flag", resultData.getModifiedResultFlag());
- labWareData.put("report_file_name", resultData.getReportFileName());
-
- if (resultData.getClinicalReportFile() != null)
- {
- FileInputStream stream = new FileInputStream(new File(resultData.getClinicalReportFile()));
- InputStreamAttachmentFile attachment = new InputStreamAttachmentFile(stream, resultData.getClinicalReportFile());
- labWareData.put("clinical_report", attachment);
- }
- Table.insert(user, lwSchema.getDbSchema().getTable(LabWareQuerySchema.TABLE_OUTBOUND_SPECIMENS), labWareData);
- }
-
- public boolean hasClinicalReport(int specimenId, User user, Container container)
- {
- LabWareQuerySchema lwSchema = new LabWareQuerySchema(user, container);
- SimpleFilter filter = new SimpleFilter(FieldKey.fromParts("test_request_id"), specimenId);
- filter.addCondition(FieldKey.fromParts("clinical_report"), null, CompareType.NONBLANK);
-
- return new TableSelector(lwSchema.getSchema().getTable(LabWareQuerySchema.TABLE_OUTBOUND_SPECIMENS), filter, null).exists();
- }
-}
\ No newline at end of file
diff --git a/hdrl/src/org/labkey/hdrl/HDRLSchema.java b/hdrl/src/org/labkey/hdrl/HDRLSchema.java
deleted file mode 100644
index db4da000..00000000
--- a/hdrl/src/org/labkey/hdrl/HDRLSchema.java
+++ /dev/null
@@ -1,74 +0,0 @@
-/*
- * Copyright (c) 2015 LabKey Corporation
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-package org.labkey.hdrl;
-
-import org.labkey.api.data.DbSchema;
-import org.labkey.api.data.DbSchemaType;
-import org.labkey.api.data.DbScope;
-import org.labkey.api.data.TableInfo;
-
-/**
- * Created by klum on 4/18/15.
- */
-public class HDRLSchema
-{
- private static final HDRLSchema instance = new HDRLSchema();
- private static final String SCHEMA_NAME = "hdrl";
-
- public static HDRLSchema getInstance()
- {
- return instance;
- }
-
- private HDRLSchema()
- {
- }
-
- public String getSchemaName()
- {
- return SCHEMA_NAME;
- }
-
- public DbSchema getSchema()
- {
- return DbSchema.get(SCHEMA_NAME, DbSchemaType.Module);
- }
-
- public DbScope getScope()
- {
- return getSchema().getScope();
- }
-
- public TableInfo getTableInfoInboundRequest()
- {
- return getSchema().getTable("InboundRequest");
- }
-
- public TableInfo getTableInfoInboundSpecimen()
- {
- return getSchema().getTable("InboundSpecimen");
- }
-
- public TableInfo getTableInfoRequestResult()
- {
- return getSchema().getTable("RequestResult");
- }
-
- public TableInfo getTableInfoSpecimenResult()
- {
- return getSchema().getTable("SpecimenResult");
- }
-}
diff --git a/hdrl/src/org/labkey/hdrl/query/InboundRequestTable.java b/hdrl/src/org/labkey/hdrl/query/InboundRequestTable.java
deleted file mode 100644
index 0690cbb6..00000000
--- a/hdrl/src/org/labkey/hdrl/query/InboundRequestTable.java
+++ /dev/null
@@ -1,96 +0,0 @@
-/*
- * Copyright (c) 2015-2019 LabKey Corporation
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-package org.labkey.hdrl.query;
-
-import org.jetbrains.annotations.NotNull;
-import org.jetbrains.annotations.Nullable;
-import org.labkey.api.data.ContainerFilter;
-import org.labkey.api.data.ContainerForeignKey;
-import org.labkey.api.data.DatabaseTableType;
-import org.labkey.api.data.ForeignKey;
-import org.labkey.api.data.JdbcType;
-import org.labkey.api.data.SQLFragment;
-import org.labkey.api.data.TableInfo;
-import org.labkey.api.query.ExprColumn;
-import org.labkey.api.query.FilteredTable;
-import org.labkey.api.query.QueryUpdateService;
-import org.labkey.api.security.UserPrincipal;
-import org.labkey.api.security.permissions.Permission;
-
-/**
- * Created by susanh on 4/13/15.
- */
-public class InboundRequestTable extends FilteredTable
-{
- public InboundRequestTable(HDRLQuerySchema schema, ContainerFilter cf)
- {
- super(schema.getDbSchema().getTable(schema.TABLE_INBOUND_REQUEST), schema, cf);
-
- // wrap all the existing columns
- wrapAllColumns(true);
-
- var containerCol = getMutableColumn("Container");
- ContainerForeignKey.initColumn(containerCol, schema);
- containerCol.setLabel("Folder");
-
- var archivedRequestCountCol = getMutableColumn("ArchivedRequestCount");
- archivedRequestCountCol.setHidden(true);
-
- // add column for the number of patients
- addColumn(wrapColumn("Number of Patients", new PatientCountColumn(getRealTable().getColumn("RequestId"))));
- addCoalescedStatusColumn();
- addResultColumn("customerNote", "Customer Note", JdbcType.VARCHAR);
- addResultColumn("received", "Received", JdbcType.DATE);
- addResultColumn("completed", "Completed", JdbcType.DATE);
- }
-
-
- private void addResultColumn(String fieldName, String alias, JdbcType type)
- {
- SQLFragment sql = new SQLFragment("(SELECT " + fieldName + " FROM " + HDRLQuerySchema.NAME + "." + HDRLQuerySchema.TABLE_REQUEST_RESULT + " R WHERE R.RequestId = " + ExprColumn.STR_TABLE_ALIAS + ".requestId)");
- ExprColumn col = new ExprColumn(this, alias, sql, type);
- addColumn(col);
- }
-
- private void addCoalescedStatusColumn()
- {
- var requestStatusCol = getMutableColumn("RequestStatusId");
- requestStatusCol.setHidden(true);
- ForeignKey statusColFk = requestStatusCol.getFk();
- SQLFragment sql = new SQLFragment("COALESCE((SELECT R.requestStatusId FROM " + HDRLQuerySchema.NAME + "." + HDRLQuerySchema.TABLE_REQUEST_RESULT + " R WHERE R.RequestId = " + ExprColumn.STR_TABLE_ALIAS + ".requestId), RequestStatusId)");
-
- ExprColumn col = new ExprColumn(this, "Status", sql, JdbcType.INTEGER);
- col.setFk(statusColFk);
- addColumn(col);
- }
-
- @Nullable
- @Override
- public QueryUpdateService getUpdateService()
- {
- TableInfo table = getRealTable();
- if (table != null && table.getTableType() == DatabaseTableType.TABLE)
- return new InboundRequestUpdateService(this, table);
-
- return null;
- }
-
- @Override
- public boolean hasPermission(@NotNull UserPrincipal user, @NotNull Class extends Permission> perm)
- {
- return getContainer().hasPermission(user, perm);
- }
-}
diff --git a/hdrl/src/org/labkey/hdrl/query/InboundRequestUpdateService.java b/hdrl/src/org/labkey/hdrl/query/InboundRequestUpdateService.java
deleted file mode 100644
index a8085053..00000000
--- a/hdrl/src/org/labkey/hdrl/query/InboundRequestUpdateService.java
+++ /dev/null
@@ -1,229 +0,0 @@
-/*
- * Copyright (c) 2015-2019 LabKey Corporation
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-package org.labkey.hdrl.query;
-
-import org.apache.commons.lang3.StringUtils;
-import org.jetbrains.annotations.NotNull;
-import org.jetbrains.annotations.Nullable;
-import org.labkey.api.data.Container;
-import org.labkey.api.data.DbScope;
-import org.labkey.api.data.Results;
-import org.labkey.api.data.SQLFragment;
-import org.labkey.api.data.SimpleFilter;
-import org.labkey.api.data.SqlSelector;
-import org.labkey.api.data.Table;
-import org.labkey.api.data.TableInfo;
-import org.labkey.api.data.TableSelector;
-import org.labkey.api.query.DefaultQueryUpdateService;
-import org.labkey.api.query.DuplicateKeyException;
-import org.labkey.api.query.FieldKey;
-import org.labkey.api.query.InvalidKeyException;
-import org.labkey.api.query.QueryUpdateServiceException;
-import org.labkey.api.query.ValidationException;
-import org.labkey.api.security.User;
-import org.labkey.api.util.PageFlowUtil;
-import org.labkey.hdrl.HDRLSchema;
-import org.labkey.hdrl.view.InboundSpecimenBean;
-
-import java.sql.SQLException;
-import java.util.Date;
-import java.util.HashMap;
-import java.util.List;
-import java.util.Map;
-
-/**
- * Created by klum on 4/14/2015.
- */
-public class InboundRequestUpdateService extends DefaultQueryUpdateService
-{
- public InboundRequestUpdateService(TableInfo queryTable, TableInfo dbTable)
- {
- super(queryTable, dbTable);
- }
-
- @Override
- protected Map insertRow(User user, Container container, Map row) throws DuplicateKeyException, ValidationException, QueryUpdateServiceException, SQLException
- {
- HDRLQuerySchema lkSchema = new HDRLQuerySchema(user, container);
-
- try (DbScope.Transaction lkTransaction = lkSchema.getSchema().getScope().ensureTransaction())
- {
- boolean isSubmit = ((int) row.get("requestStatusId")) == 2; // this is a "Submitted" status from the requestStatus lookup table
- if (isSubmit)
- {
- row.put("SubmittedBy", user.getUserId());
- row.put("Submitted", new Date());
- }
- Map insertedRow = super.insertRow(user, container, row);
- if (isSubmit)
- {
- pushDataToLabWare(user, container, insertedRow);
- }
- lkTransaction.commit();
- return insertedRow;
- }
-
- }
-
- @Override
- protected Map updateRow(final User user, final Container container, Map row, @NotNull Map oldRow, @Nullable Map configParameters) throws InvalidKeyException, ValidationException, QueryUpdateServiceException, SQLException
- {
- HDRLQuerySchema lkSchema = new HDRLQuerySchema(user, container);
-
- try (DbScope.Transaction lkTransaction = lkSchema.getSchema().getScope().ensureTransaction())
- {
- boolean isNewSubmit = (boolean) row.get("isNewSubmit");
- if (isNewSubmit)
- {
- validateUniqueness((Integer) row.get("requestId"));
- row.put("SubmittedBy", user.getUserId());
- row.put("Submitted", new Date());
- }
- final Map updatedRow = super.updateRow(user, container, row, oldRow, configParameters);
- if (isNewSubmit)
- {
- pushDataToLabWare(user, container, updatedRow);
- }
- lkTransaction.commit();
- return updatedRow;
- }
- }
-
- public static void validateUniqueness(Integer requestId) throws QueryUpdateServiceException
- {
- // check that there are no duplicate barcodes
- List duplicates = findDuplicates(requestId, "CustomerBarcode");
- StringBuilder message = new StringBuilder();
- if (!duplicates.isEmpty())
- {
- message.append("Request has specimens with duplicate fields: Customer Barcode - ").append(StringUtils.join(duplicates, ", "));
- }
-
- // check that all existing DODId in the specimens in this request are unique
- duplicates = findDuplicates(requestId, "DoDId");
- if (!duplicates.isEmpty())
- {
- if (message.isEmpty())
- message.append("Request has specimens with duplicate fields: ");
- else
- message.append("; ");
- message.append("DoDID - ").append(StringUtils.join(duplicates, ", "));
- }
- // check that all the existing SSN + FMP pairs in this request are unique
- duplicates = findDuplicates(requestId, "SSN, FMPId");
- if (!duplicates.isEmpty())
- {
- if (message.isEmpty())
- message.append("Request has specimens with duplicate fields: ");
- else
- message.append("; ");
- message.append("SSN + FMP - ").append(StringUtils.join(duplicates, ", "));
- }
-
- if (!message.isEmpty())
- throw new QueryUpdateServiceException(message.toString());
-
- }
-
- /**
- * Returns a list of duplicates for the combination of fields given where the field values are not null.
- *
- * @param requestId id of the test request
- * @param fields comma-separated list of fields to check for unique combinations of
- * @return value of the fields that are duplicates; for the case of multiple fields the value of the first field in @fields will be in the returned list
- */
- private static List findDuplicates(Integer requestId, String fields)
- {
- SQLFragment sql = new SQLFragment("SELECT ")
- .append(fields).append(" FROM hdrl.inboundspecimen WHERE inboundrequestid = ?").add(requestId);
- for (String field : fields.split(", "))
- {
- sql.append(" AND ").append(field).append(" IS NOT NULL ");
- }
- sql.append(" GROUP BY ").append(fields)
- .append(" HAVING COUNT(*) > 1 ");
- SqlSelector sqlSelector = new SqlSelector(HDRLSchema.getInstance().getScope(), sql);
- return sqlSelector.getArrayList(String.class);
-
- }
-
- private String getLookupValue(HDRLQuerySchema schema, String tableName, Integer rowId, String fieldName) throws SQLException
- {
- if (rowId == null)
- return null;
-
- SimpleFilter filter = new SimpleFilter(FieldKey.fromParts("RowId"), rowId);
- TableSelector selector = new TableSelector(schema.getTable(tableName), PageFlowUtil.set(fieldName), filter, null);
- try (Results results = selector.getResults())
- {
- results.next();
- String value = results.getString(FieldKey.fromParts(fieldName));
- return value;
- }
-
- }
-
- private void pushDataToLabWare(User user, Container container, Map labkeyTableRow) throws SQLException
- {
- HDRLQuerySchema lkSchema = new HDRLQuerySchema(user, container);
-
- // create the request data for LabWare
- Map labWareData = new HashMap<>();
- labWareData.put("Batch_ID", labkeyTableRow.get("RequestId"));
- labWareData.put("Carrier", getLookupValue(lkSchema, HDRLQuerySchema.TABLE_SHIPPING_CARRIER, (Integer) labkeyTableRow.get("ShippingCarrierId"), "Name"));
- labWareData.put("Tracking_Number", labkeyTableRow.get("ShippingNumber"));
- labWareData.put("Customer", user.getEmail());
-
- // now get the specimen rows using the requestId from the labKeyTable
- SimpleFilter filter = new SimpleFilter(FieldKey.fromParts("InboundRequestId"), labkeyTableRow.get("RequestId"));
- TableSelector selector = new TableSelector(lkSchema.getTable(HDRLQuerySchema.TABLE_INBOUND_SPECIMEN), filter, null);
- List specimens = selector.getArrayList(InboundSpecimenBean.class);
-
- LabWareQuerySchema lwSchema = new LabWareQuerySchema(user, container);
-
- try (DbScope.Transaction lwTransaction = lwSchema.getSchema().getScope().ensureTransaction())
- {
- Table.insert(user, lwSchema.getDbSchema().getTable(LabWareQuerySchema.TABLE_INBOUND_REQUESTS), labWareData);
- for (InboundSpecimenBean specimen : specimens)
- {
- Map lwSpecimen = new HashMap<>();
- lwSpecimen.put("Test_Request_ID", specimen.getRowId());
- lwSpecimen.put("Batch_ID", specimen.getInboundRequestId());
- lwSpecimen.put("Test_Requested", getLookupValue(lkSchema, HDRLQuerySchema.TABLE_TEST_TYPE, (Integer) labkeyTableRow.get("TestTypeId"), "Name"));
- lwSpecimen.put("Cust_Barcode", specimen.getCustomerBarCode());
- lwSpecimen.put("FMP", getLookupValue(lkSchema, HDRLQuerySchema.TABLE_FAMILY_MEMBER_PREFIX, specimen.getFmpId(), "Code"));
- lwSpecimen.put("SSN", specimen.getSsn());
- lwSpecimen.put("Draw_Date", specimen.getDrawDate());
- lwSpecimen.put("Specimen_Type", specimen.getSpecimenType());
- lwSpecimen.put("Num_Containers", specimen.getNumberOfContainers());
- lwSpecimen.put("SOT", getLookupValue(lkSchema, HDRLQuerySchema.TABLE_SOURCE_OF_TESTING, specimen.getTestingSourceId(), "Code"));
- lwSpecimen.put("DUC", getLookupValue(lkSchema, HDRLQuerySchema.TABLE_DUTY_CODE, specimen.getDutyCodeId(), "Code"));
- lwSpecimen.put("DOD_ID", specimen.getDodId());
- lwSpecimen.put("First_Name", specimen.getFirstName());
- lwSpecimen.put("Middle_Name", specimen.getMiddleName());
- lwSpecimen.put("Last_Name", specimen.getLastName());
- lwSpecimen.put("Birth_Date", specimen.getBirthDate());
- lwSpecimen.put("Gender", specimen.getGenderId());
- lwSpecimen.put("Initials", specimen.getInitials());
-
- Table.insert(user, lwSchema.getDbSchema().getTable(LabWareQuerySchema.TABLE_INBOUND_SPECIMENS), lwSpecimen);
- }
- lwTransaction.commit();
- }
- }
-
-
-}
diff --git a/hdrl/src/org/labkey/hdrl/query/InboundSpecimenTable.java b/hdrl/src/org/labkey/hdrl/query/InboundSpecimenTable.java
deleted file mode 100644
index 488b59c5..00000000
--- a/hdrl/src/org/labkey/hdrl/query/InboundSpecimenTable.java
+++ /dev/null
@@ -1,62 +0,0 @@
-/*
- * Copyright (c) 2015-2019 LabKey Corporation
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-package org.labkey.hdrl.query;
-
-import org.jetbrains.annotations.NotNull;
-import org.jetbrains.annotations.Nullable;
-import org.labkey.api.data.ContainerFilter;
-import org.labkey.api.data.ContainerForeignKey;
-import org.labkey.api.data.DatabaseTableType;
-import org.labkey.api.data.TableInfo;
-import org.labkey.api.query.FilteredTable;
-import org.labkey.api.query.QueryUpdateService;
-import org.labkey.api.security.UserPrincipal;
-import org.labkey.api.security.permissions.Permission;
-
-/**
- * Created by klum on 4/15/2015.
- */
-public class InboundSpecimenTable extends FilteredTable
-{
- public InboundSpecimenTable(HDRLQuerySchema schema, ContainerFilter cf)
- {
- super(schema.getDbSchema().getTable(HDRLQuerySchema.TABLE_INBOUND_SPECIMEN), schema, cf);
-
- // wrap all the existing columns
- wrapAllColumns(true);
- var containerCol = getMutableColumn("Container");
- ContainerForeignKey.initColumn(containerCol, schema);
- containerCol.setLabel("Folder");
- }
-
-
- @Nullable
- @Override
- public QueryUpdateService getUpdateService()
- {
- TableInfo table = getRealTable();
- if (table != null && table.getTableType() == DatabaseTableType.TABLE)
- return new InboundSpecimenUpdateService(this, table);
-
- return null;
- }
-
- @Override
- public boolean hasPermission(@NotNull UserPrincipal user, @NotNull Class extends Permission> perm)
- {
- return getContainer().hasPermission(user, perm);
- }
-}
diff --git a/hdrl/src/org/labkey/hdrl/query/InboundSpecimenUpdateService.java b/hdrl/src/org/labkey/hdrl/query/InboundSpecimenUpdateService.java
deleted file mode 100644
index 7b494203..00000000
--- a/hdrl/src/org/labkey/hdrl/query/InboundSpecimenUpdateService.java
+++ /dev/null
@@ -1,218 +0,0 @@
-/*
- * Copyright (c) 2015 LabKey Corporation
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-package org.labkey.hdrl.query;
-
-import org.apache.commons.lang3.StringUtils;
-import org.jetbrains.annotations.Nullable;
-import org.labkey.api.data.Container;
-import org.labkey.api.data.TableInfo;
-import org.labkey.api.query.BatchValidationException;
-import org.labkey.api.query.DefaultQueryUpdateService;
-import org.labkey.api.query.DuplicateKeyException;
-import org.labkey.api.query.InvalidKeyException;
-import org.labkey.api.query.QueryUpdateServiceException;
-import org.labkey.api.query.ValidationException;
-import org.labkey.api.security.User;
-
-import java.sql.SQLException;
-import java.text.ParseException;
-import java.text.SimpleDateFormat;
-import java.util.ArrayList;
-import java.util.Calendar;
-import java.util.Date;
-import java.util.List;
-import java.util.Map;
-
-/**
- * Created by susanh on 4/16/15.
- */
-public class InboundSpecimenUpdateService extends DefaultQueryUpdateService
-{
- public enum ValidationMode {OFF, ON, ONLY, WITH_UQ}
-
- private ValidationMode validationMode = ValidationMode.ON;
-
- public InboundSpecimenUpdateService(TableInfo queryTable, TableInfo dbTable)
- {
- super(queryTable, dbTable);
- }
-
- @Override
- public List> insertRows(User user, Container container, List> rows, BatchValidationException errors, @Nullable Map configParameters, Map extraScriptContext)
- throws DuplicateKeyException, QueryUpdateServiceException, SQLException
- {
- parseValidationMode(extraScriptContext);
- List> ret = super.insertRows(user, container, rows, errors, configParameters, extraScriptContext);
-
- if (this.validationMode == ValidationMode.WITH_UQ)
- {
- InboundRequestUpdateService.validateUniqueness((Integer) rows.get(0).get("InboundRequestId"));
- }
-
- return ret;
- }
-
- private void parseValidationMode(Map extraScriptContext)
- {
- if (extraScriptContext != null && extraScriptContext.containsKey("validationMode"))
- {
- validationMode = ValidationMode.valueOf(extraScriptContext.get("validationMode").toString().toUpperCase());
- }
- }
-
- @Override
- public List> updateRows(User user, Container container, List> rows, List> oldKeys, BatchValidationException errors, @Nullable Map configParameters, Map extraScriptContext) throws InvalidKeyException, BatchValidationException, QueryUpdateServiceException, SQLException
- {
- parseValidationMode(extraScriptContext);
- List> ret = super.updateRows(user, container, rows, oldKeys, errors, configParameters, extraScriptContext);
-
- if (this.validationMode == ValidationMode.WITH_UQ)
- {
- InboundRequestUpdateService.validateUniqueness((Integer) rows.get(0).get("InboundRequestId"));
- }
-
- return ret;
- }
-
- @Override
- protected Map _insert(User user, Container c, Map row)
- throws SQLException, ValidationException
- {
- if (validationMode != ValidationMode.OFF)
- validate(row);
-
- if (validationMode != ValidationMode.ONLY)
- return super._insert(user, c, row);
- else
- return row;
- }
-
- @Override
- protected Map _update(User user, Container c, Map row, Map oldRow, Object[] keys)
- throws SQLException, ValidationException
- {
- if (validationMode != ValidationMode.OFF)
- validate(row);
-
- if (validationMode != ValidationMode.ONLY)
- return super._update(user, c, row, oldRow, keys);
- else
- return row;
-
- }
-
-
- public static void validate(Map row) throws ValidationException
- {
- SimpleDateFormat dateFormat = new SimpleDateFormat("yyyy-MM-dd");
- Date drawDate = null;
- Calendar calendar = Calendar.getInstance();
- calendar.set(Calendar.HOUR, 0);
- calendar.set(Calendar.MINUTE, 0);
- calendar.set(Calendar.SECOND, 0);
- calendar.set(Calendar.MILLISECOND, 0);
- Date today = calendar.getTime();
- List errors = new ArrayList<>();
- List missingFields = new ArrayList<>();
- if (row.get("FMPId") == null)
- missingFields.add("FMP");
- if (row.get("DrawDate") == null)
- missingFields.add("Draw Date");
- else
- {
- if (row.get("DrawDate") instanceof Date)
- drawDate = (Date) row.get("DrawDate");
- else
- {
- try
- {
- drawDate = dateFormat.parse((String) row.get("DrawDate"));
- if (drawDate.after(today))
- {
- errors.add("Draw date cannot be in the future");
- }
- }
- catch (ParseException e)
- {
- errors.add("Invalid draw date format");
- }
- }
- }
- Object birthDateObj = row.get("BirthDate");
- if (birthDateObj != null)
- {
- Date birthDate = null;
- if (birthDateObj instanceof Date d)
- birthDate = d;
- else
- {
- try
- {
- birthDate = dateFormat.parse((String) row.get("BirthDate"));
- }
- catch (ParseException e)
- {
- errors.add("Invalid birth date format");
- }
- }
- if (birthDate != null)
- {
- if (birthDate.after(today))
- {
- errors.add("Birth date cannot be in the future");
- }
- else if ((drawDate != null) && (drawDate.before(birthDate)))
- {
- errors.add("Draw date cannot be before birth date");
- }
- }
- }
- if (row.get("SSN") == null || StringUtils.isEmpty(String.valueOf(row.get("SSN"))))
- missingFields.add("SSN");
- else
- {
- String ssn = String.valueOf(row.get("SSN"));
- if (!ssn.matches("^\\d{9}$"))
- {
- errors.add("Invalid SSN");
- }
- }
- if (row.get("DoDId") != null)
- {
- String dodId = String.valueOf(row.get("DoDId"));
- if (!dodId.matches("^\\d{10}$"))
- {
- errors.add("Invalid DoD Id");
- }
- }
- if (!missingFields.isEmpty())
- {
- errors.add("Required field(s) missing: " + StringUtils.join(missingFields, ", "));
- }
-
- if (!errors.isEmpty())
- {
- String message = StringUtils.join(errors, "; ");
-
- row.put("ValidationStatus", message);
- throw new ValidationException(message);
- }
- else
- {
- row.remove("ValidationStatus");
- }
- }
-}
diff --git a/hdrl/src/org/labkey/hdrl/query/LabWareQuerySchema.java b/hdrl/src/org/labkey/hdrl/query/LabWareQuerySchema.java
deleted file mode 100644
index ddaf82c9..00000000
--- a/hdrl/src/org/labkey/hdrl/query/LabWareQuerySchema.java
+++ /dev/null
@@ -1,78 +0,0 @@
-/*
- * Copyright (c) 2015-2017 LabKey Corporation
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-package org.labkey.hdrl.query;
-
-import org.labkey.api.data.Container;
-import org.labkey.api.data.DbSchema;
-import org.labkey.api.data.DbSchemaType;
-import org.labkey.api.data.DbScope;
-import org.labkey.api.module.Module;
-import org.labkey.api.query.DefaultSchema;
-import org.labkey.api.query.QuerySchema;
-import org.labkey.api.query.SimpleUserSchema;
-import org.labkey.api.query.ValidationException;
-import org.labkey.api.security.User;
-import org.labkey.hdrl.HDRLModule;
-
-public class LabWareQuerySchema extends SimpleUserSchema
-{
- public static final String NAME = "GW_LABKEY";
- public static final String DATA_SOURCE_NAME = "labware";
- public static final String DESCRIPTION = "LabWare tables for test requests and specimens";
-
- public static final String TABLE_INBOUND_REQUESTS = "X_LK_INBND_REQUESTS";
- public static final String TABLE_INBOUND_SPECIMENS = "X_LK_INBND_SPECIMENS";
- public static final String TABLE_OUTBOUND_REQUESTS = "X_LK_OUTBD_REQUESTS";
- public static final String TABLE_OUTBOUND_SPECIMENS = "X_LK_OUTBD_SPECIMENS";
-
- public LabWareQuerySchema(User user, Container container)
- {
- super(NAME, DESCRIPTION, user, container, DbSchema.get(getFullyQualifiedDataSource(), DbSchemaType.Module));
- _hidden = true;
- }
-
- public static String getFullyQualifiedDataSource()
- {
- return DATA_SOURCE_NAME + "." + NAME;
- }
-
- public static void register(final HDRLModule module)
- {
- DefaultSchema.registerProvider(NAME, new DefaultSchema.SchemaProvider(module)
- {
- @Override
- public QuerySchema createSchema(DefaultSchema schema, Module module)
- {
- return new LabWareQuerySchema(schema.getUser(), schema.getContainer());
- }
- });
- }
-
- public static void verifyLabWareDataSource() throws ValidationException
- {
- String name = DATA_SOURCE_NAME + "DataSource";
- DbScope scope = DbScope.getDbScope(name);
- if (scope == null)
- {
- throw new ValidationException("Expected to find a data source with name '" + name + "'.");
- }
- }
-
- public DbSchema getSchema()
- {
- return DbSchema.get(getFullyQualifiedDataSource(), DbSchemaType.Module);
- }
-}
diff --git a/hdrl/src/org/labkey/hdrl/query/PatientCountColumn.java b/hdrl/src/org/labkey/hdrl/query/PatientCountColumn.java
deleted file mode 100644
index 5a069799..00000000
--- a/hdrl/src/org/labkey/hdrl/query/PatientCountColumn.java
+++ /dev/null
@@ -1,37 +0,0 @@
-/*
- * Copyright (c) 2015-2019 LabKey Corporation
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-package org.labkey.hdrl.query;
-
-import org.labkey.api.data.BaseColumnInfo;
-import org.labkey.api.data.ColumnInfo;
-import org.labkey.api.data.SQLFragment;
-
-/**
- * Created by susanh on 4/13/15.
- */
-public class PatientCountColumn extends BaseColumnInfo
-{
- public PatientCountColumn(ColumnInfo columnInfo)
- {
- super(columnInfo);
- }
-
- @Override
- public SQLFragment getValueSql(String tableAliasName)
- {
- return new SQLFragment("COALESCE(" + tableAliasName + "."+ HDRLQuerySchema.COL_ARCHIVED_REQUEST_COUNT + ", (SELECT COUNT(DISTINCT(SSN,FMPId)) FROM hdrl.InboundSpecimen spec WHERE spec.InboundRequestId = " + tableAliasName + ".RequestId))");
- }
-}
diff --git a/hdrl/src/org/labkey/hdrl/query/RequestResultTable.java b/hdrl/src/org/labkey/hdrl/query/RequestResultTable.java
deleted file mode 100644
index 15bd3336..00000000
--- a/hdrl/src/org/labkey/hdrl/query/RequestResultTable.java
+++ /dev/null
@@ -1,55 +0,0 @@
-/*
- * Copyright (c) 2015-2019 LabKey Corporation
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-package org.labkey.hdrl.query;
-
-import org.jetbrains.annotations.NotNull;
-import org.labkey.api.data.ContainerFilter;
-import org.labkey.api.data.SQLFragment;
-import org.labkey.api.query.FieldKey;
-import org.labkey.hdrl.HDRLSchema;
-
-/**
- * Created by susanh on 4/6/16.
- */
-public class RequestResultTable extends ResultTable
-{
- public RequestResultTable(@NotNull HDRLQuerySchema schema, String name, ContainerFilter cf)
- {
- super(schema, name, cf);
- }
-
- @Override
- protected void applyContainerFilter(ContainerFilter filter)
- {
- FieldKey containerFieldKey = FieldKey.fromParts("Container");
- clearConditions(containerFieldKey);
- SQLFragment sql = new SQLFragment(getIdField() + " IN (SELECT r.RequestId FROM ");
- sql.append(HDRLSchema.getInstance().getTableInfoInboundRequest(), "r");
- sql.append(" WHERE ");
- sql.append(filter.getSQLFragment(getSchema(), new SQLFragment("r.Container")));
- sql.append(")");
- addCondition(sql, containerFieldKey);
- }
-
- private String getIdField()
- {
- if (_rootTable.getName().equalsIgnoreCase(HDRLQuerySchema.TABLE_REQUEST_RESULT))
- return "RequestId";
- else if (_rootTable.getName().equalsIgnoreCase(HDRLQuerySchema.TABLE_LABWARE_OUTBOUND_RESULTS))
- return "batch_id";
- return null;
- }
-}
diff --git a/hdrl/src/org/labkey/hdrl/query/ResultTable.java b/hdrl/src/org/labkey/hdrl/query/ResultTable.java
deleted file mode 100644
index 53bee293..00000000
--- a/hdrl/src/org/labkey/hdrl/query/ResultTable.java
+++ /dev/null
@@ -1,70 +0,0 @@
-/*
- * Copyright (c) 2015-2019 LabKey Corporation
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-package org.labkey.hdrl.query;
-
-import org.jetbrains.annotations.NotNull;
-import org.jetbrains.annotations.Nullable;
-import org.labkey.api.data.Container;
-import org.labkey.api.data.ContainerFilter;
-import org.labkey.api.data.DatabaseTableType;
-import org.labkey.api.data.TableInfo;
-import org.labkey.api.dataiterator.DataIteratorBuilder;
-import org.labkey.api.query.BatchValidationException;
-import org.labkey.api.query.DefaultQueryUpdateService;
-import org.labkey.api.query.QueryUpdateService;
-import org.labkey.api.query.SimpleUserSchema;
-import org.labkey.api.security.User;
-import org.labkey.api.security.UserPrincipal;
-import org.labkey.api.security.permissions.Permission;
-
-import java.util.Map;
-
-/**
- * Created by susanh on 7/7/15.
- */
-public class ResultTable extends SimpleUserSchema.SimpleTable
-{
- public ResultTable(@NotNull HDRLQuerySchema schema, String tableName, ContainerFilter cf)
- {
- super(schema, schema.getDbSchema().getTable(tableName), cf);
- init();
- }
-
- @Override
- public boolean hasPermission(@NotNull UserPrincipal user, @NotNull Class extends Permission> perm)
- {
- return getContainer().hasPermission(user, perm);
- }
-
- @Nullable
- @Override
- public QueryUpdateService getUpdateService()
- {
- TableInfo table = getRealTable();
- if (table != null && table.getTableType() == DatabaseTableType.TABLE)
- return new DefaultQueryUpdateService(this, table) {
-
- @Override
- public int mergeRows(User user, Container container, DataIteratorBuilder rows, BatchValidationException errors, @Nullable Map configParameters, Map extraScriptContext)
- {
- return _importRowsUsingDIB(user, container, rows, null, getDataIteratorContext(errors, InsertOption.MERGE, configParameters), extraScriptContext);
- }
- };
-
- return null;
- }
-
-}
diff --git a/hdrl/src/org/labkey/hdrl/query/SpecimenResultTable.java b/hdrl/src/org/labkey/hdrl/query/SpecimenResultTable.java
deleted file mode 100644
index e520789c..00000000
--- a/hdrl/src/org/labkey/hdrl/query/SpecimenResultTable.java
+++ /dev/null
@@ -1,57 +0,0 @@
-/*
- * Copyright (c) 2015-2019 LabKey Corporation
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-package org.labkey.hdrl.query;
-
-import org.jetbrains.annotations.NotNull;
-import org.labkey.api.data.ContainerFilter;
-import org.labkey.api.data.SQLFragment;
-import org.labkey.api.query.FieldKey;
-import org.labkey.hdrl.HDRLSchema;
-
-/**
- * Created by susanh on 4/6/16.
- */
-public class SpecimenResultTable extends ResultTable
-{
-
- public SpecimenResultTable(@NotNull HDRLQuerySchema schema, String name, ContainerFilter cf)
- {
- super(schema, name, cf);
- }
-
- @Override
- protected void applyContainerFilter(ContainerFilter filter)
- {
- FieldKey containerFieldKey = FieldKey.fromParts("Container");
- clearConditions(containerFieldKey);
- SQLFragment sql = new SQLFragment(getIdField() + " IN (SELECT s.RowId FROM ");
- sql.append(HDRLSchema.getInstance().getTableInfoInboundSpecimen(), "s");
- sql.append(" WHERE ");
- sql.append(filter.getSQLFragment(getSchema(), new SQLFragment("s.Container")));
- sql.append(")");
- addCondition(sql, containerFieldKey);
- }
-
-
- private String getIdField()
- {
- if (_rootTable.getName().equalsIgnoreCase(HDRLQuerySchema.TABLE_SPECIMEN_RESULT))
- return "SpecimenId";
- else if (_rootTable.getName().equalsIgnoreCase(HDRLQuerySchema.TABLE_LABWARE_OUTBOUND_SPECIMENS))
- return "test_request_id";
- return null;
- }
-}
diff --git a/hdrl/src/org/labkey/hdrl/view/InboundRequestBean.java b/hdrl/src/org/labkey/hdrl/view/InboundRequestBean.java
deleted file mode 100644
index e24ade23..00000000
--- a/hdrl/src/org/labkey/hdrl/view/InboundRequestBean.java
+++ /dev/null
@@ -1,79 +0,0 @@
-/*
- * Copyright (c) 2015-2019 LabKey Corporation
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-package org.labkey.hdrl.view;
-
-/**
- * Created by susanh on 4/15/15.
- */
-public class InboundRequestBean
-{
- private int _requestId;
- private String _shippingNumber;
- private String _requestStatus;
- private String _testType;
- private String _shippingCarrier;
-
- public int getRequestId()
- {
- return _requestId;
- }
-
- public void setRequestId(int requestId)
- {
- _requestId = requestId;
- }
-
- public String getShippingNumber()
- {
- return _shippingNumber;
- }
-
- public void setShippingNumber(String shippingNumber)
- {
- _shippingNumber = shippingNumber;
- }
-
- public String getRequestStatus()
- {
- return _requestStatus;
- }
-
- public void setRequestStatus(String requestStatus)
- {
- _requestStatus = requestStatus;
- }
-
- public String getTestType()
- {
- return _testType;
- }
-
- public void setTestType(String testType)
- {
- _testType = testType;
- }
-
- public String getShippingCarrier()
- {
- return _shippingCarrier;
- }
-
- public void setShippingCarrier(String shippingCarrier)
- {
- _shippingCarrier = shippingCarrier;
- }
-
-}
diff --git a/hdrl/src/org/labkey/hdrl/view/InboundSpecimenBean.java b/hdrl/src/org/labkey/hdrl/view/InboundSpecimenBean.java
deleted file mode 100644
index 5cb757a4..00000000
--- a/hdrl/src/org/labkey/hdrl/view/InboundSpecimenBean.java
+++ /dev/null
@@ -1,245 +0,0 @@
-/*
- * Copyright (c) 2015-2016 LabKey Corporation
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-package org.labkey.hdrl.view;
-
-import java.util.Date;
-
-/**
- * Created by binalpatel on 5/12/15.
- */
-public class InboundSpecimenBean
-{
- private Integer _rowId;
- private String _customerBarCode;
- private Integer _dodId;
- private String _genderId;
- private String _initials;
- private Integer _numberOfContainers;
- private String _lastName;
- private String _firstName;
- private String _middleName;
- private Date _birthDate;
- private String _ssn;
- private Integer _inboundRequestId;
- private String _fmpCode;
- private Integer _fmpId;
- private String _ducCode;
- private Integer _dutyCodeId;
- private String _sotCode;
- private Integer _testingSourceId;
- private Date _drawDate;
- private String _specimenType = "Serum"; //for now.
-
- public String getCustomerBarCode()
- {
- return _customerBarCode;
- }
-
- public void setCustomerBarCode(String customerBarCode)
- {
- _customerBarCode = customerBarCode;
- }
-
- public String getLastName()
- {
- return _lastName;
- }
-
- public void setLastName(String lastName)
- {
- _lastName = lastName;
- }
-
- public String getFirstName()
- {
- return _firstName;
- }
-
- public void setFirstName(String firstName)
- {
- _firstName = firstName;
- }
-
- public String getMiddleName()
- {
- return _middleName;
- }
-
- public void setMiddleName(String middleName)
- {
- _middleName = middleName;
- }
-
- public Date getBirthDate()
- {
- return _birthDate;
- }
-
- public void setBirthDate(Date birthDate)
- {
- _birthDate = birthDate;
- }
-
- public String getSsn()
- {
- return _ssn;
- }
-
- public void setSsn(String ssn)
- {
- _ssn = ssn;
- }
-
- public String getFmpCode()
- {
- return _fmpCode;
- }
-
- public void setFmpCode(String fmpCode)
- {
- _fmpCode = fmpCode;
- }
-
- public Integer getDutyCodeId()
- {
- return _dutyCodeId;
- }
-
- public void setDutyCodeId(Integer dutyCodeId)
- {
- _dutyCodeId = dutyCodeId;
- }
-
- public Integer getFmpId()
- {
- return _fmpId;
- }
-
- public void setFmpId(Integer fmpId)
- {
- _fmpId = fmpId;
- }
-
- public Integer getTestingSourceId()
- {
- return _testingSourceId;
- }
-
- public void setTestingSourceId(Integer testingSourceId)
- {
- _testingSourceId = testingSourceId;
- }
-
- public String getDucCode()
- {
- return _ducCode;
- }
-
- public void setDucCode(String ducCode)
- {
- _ducCode = ducCode;
- }
-
- public String getSotCode()
- {
- return _sotCode;
- }
-
- public void setSotCode(String sotCode)
- {
- _sotCode = sotCode;
- }
-
- public Date getDrawDate()
- {
- return _drawDate;
- }
-
- public void setDrawDate(Date drawDate)
- {
- _drawDate = drawDate;
- }
-
- public String getSpecimenType()
- {
- return _specimenType;
- }
-
- public void setSpecimenType(String specimenType)
- {
- _specimenType = specimenType;
- }
-
- public Integer getInboundRequestId()
- {
- return _inboundRequestId;
- }
-
- public void setInboundRequestId(Integer inboundRequestId)
- {
- _inboundRequestId = inboundRequestId;
- }
-
- public Integer getRowId()
- {
- return _rowId;
- }
-
- public void setRowId(Integer rowId)
- {
- _rowId = rowId;
- }
-
- public Integer getDodId()
- {
- return _dodId;
- }
-
- public void setDodId(Integer dodId)
- {
- _dodId = dodId;
- }
-
- public String getGenderId()
- {
- return _genderId;
- }
-
- public void setGenderId(String genderId)
- {
- _genderId = genderId;
- }
-
- public String getInitials()
- {
- return _initials;
- }
-
- public void setInitials(String initials)
- {
- _initials = initials;
- }
-
- public Integer getNumberOfContainers()
- {
- return _numberOfContainers;
- }
-
- public void setNumberOfContainers(Integer numberOfContainers)
- {
- _numberOfContainers = numberOfContainers;
- }
-}
diff --git a/hdrl/src/org/labkey/hdrl/view/RequestResultBean.java b/hdrl/src/org/labkey/hdrl/view/RequestResultBean.java
deleted file mode 100644
index b29ab45d..00000000
--- a/hdrl/src/org/labkey/hdrl/view/RequestResultBean.java
+++ /dev/null
@@ -1,135 +0,0 @@
-/*
- * Copyright (c) 2015-2019 LabKey Corporation
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-package org.labkey.hdrl.view;
-
-import java.util.Date;
-
-/**
- * Created by susanh on 7/8/15.
- */
-public class RequestResultBean
-{
- private int _requestId;
- private int _requestStatusId;
- private String _customerNote;
- private Date _received;
- private Date _completed;
- private String _container;
- private int _createdBy;
- private Date _created;
- private int _modifiedBy;
- private Date _modified;
-
- public Date getCompleted()
- {
- return _completed;
- }
-
- public void setCompleted(Date completed)
- {
- _completed = completed;
- }
-
- public String getContainer()
- {
- return _container;
- }
-
- public void setContainer(String container)
- {
- _container = container;
- }
-
- public Date getCreated()
- {
- return _created;
- }
-
- public void setCreated(Date created)
- {
- _created = created;
- }
-
- public int getCreatedBy()
- {
- return _createdBy;
- }
-
- public void setCreatedBy(int createdBy)
- {
- _createdBy = createdBy;
- }
-
- public String getCustomerNote()
- {
- return _customerNote;
- }
-
- public void setCustomerNote(String customerNote)
- {
- _customerNote = customerNote;
- }
-
- public Date getModified()
- {
- return _modified;
- }
-
- public void setModified(Date modified)
- {
- _modified = modified;
- }
-
- public int getModifiedBy()
- {
- return _modifiedBy;
- }
-
- public void setModifiedBy(int modifiedBy)
- {
- _modifiedBy = modifiedBy;
- }
-
- public Date getReceived()
- {
- return _received;
- }
-
- public void setReceived(Date received)
- {
- _received = received;
- }
-
- public int getRequestId()
- {
- return _requestId;
- }
-
- public void setRequestId(int requestId)
- {
- _requestId = requestId;
- }
-
- public int getRequestStatusId()
- {
- return _requestStatusId;
- }
-
- public void setRequestStatusId(int requestStatusId)
- {
- _requestStatusId = requestStatusId;
- }
-}
diff --git a/hdrl/src/org/labkey/hdrl/view/editRequest.jsp b/hdrl/src/org/labkey/hdrl/view/editRequest.jsp
deleted file mode 100644
index 77ea0057..00000000
--- a/hdrl/src/org/labkey/hdrl/view/editRequest.jsp
+++ /dev/null
@@ -1,67 +0,0 @@
-<%
-/*
- * Copyright (c) 2015-2019 LabKey Corporation
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-%>
-<%@ page import="org.labkey.api.data.Container" %>
-<%@ page import="org.labkey.api.security.User" %>
-<%@ page import="org.labkey.api.view.HttpView" %>
-<%@ page import="org.labkey.api.view.JspView" %>
-<%@ page import="org.labkey.api.view.ViewContext" %>
-<%@ page import="org.labkey.api.view.template.ClientDependencies" %>
-<%@ page import="org.labkey.hdrl.HDRLController" %>
-<%@ page extends="org.labkey.api.jsp.JspBase" %>
-<%@ taglib prefix="labkey" uri="http://www.labkey.org/taglib" %>
-<%!
- @Override
- public void addClientDependencies(ClientDependencies dependencies)
- {
- dependencies.add("Ext4");
- dependencies.add("hdrl/requests.js");
- dependencies.add("hdrl/fonts/barcode.css");
- }
-%>
-<%
- JspView me = HttpView.currentView();
- ViewContext ctx = getViewContext();
- Container c = getContainer();
- User user = getUser();
- HDRLController.RequestForm bean = me.getModelBean();
-
- String renderId = "requests-editor-" + getRequestScopedUID();
-%>
-
-
-
-
-
-
-
- <%=link("Return to test status", HDRLController.BeginAction.class)%>
-
diff --git a/hdrl/src/org/labkey/hdrl/view/printPackingList.jsp b/hdrl/src/org/labkey/hdrl/view/printPackingList.jsp
deleted file mode 100644
index cefe63fc..00000000
--- a/hdrl/src/org/labkey/hdrl/view/printPackingList.jsp
+++ /dev/null
@@ -1,135 +0,0 @@
-<%
-/*
- * Copyright (c) 2015-2016 LabKey Corporation
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-%>
-<%@ page import="org.apache.commons.lang3.StringUtils" %>
-<%@ page import="org.labkey.api.util.DateUtil" %>
-<%@ page import="org.labkey.api.view.HttpView" %>
-<%@ page import="org.labkey.api.view.template.ClientDependencies" %>
-<%@ page import="org.labkey.hdrl.HDRLController.PackingListBean" %>
-<%@ page import="org.labkey.hdrl.view.InboundSpecimenBean" %>
-<%@ page import="java.util.Date" %>
-<%@ page import="java.util.List" %>
-<%@ page extends="org.labkey.api.jsp.JspBase" %>
-<%!
- @Override
- public void addClientDependencies(ClientDependencies dependencies)
- {
- dependencies.add("hdrl/fonts/barcode.css");
- }
-%>
-<%
- HttpView httpView = HttpView.currentView();
- PackingListBean packingListBean = (PackingListBean) httpView.getModelBean();
- List inboundSpecimens = packingListBean.getInboundSpecimens();
-
- Date date = new Date();
- String dateToday = DateUtil.formatDate(getContainer(), date);
-%>
-
-
-
-
-
-
- HIPAA warning message here
-
-
-
- Customer Name:
- Date: <%=h(dateToday)%>
-
- Customer Address:
- Shipment Information:
-
- Courier: <%=h(packingListBean.getShippingCarrier())%>
- Total Samples: <%=packingListBean.getTotalSamples()%>
-
-
- Tracking Number: <%=h(packingListBean.getShippingNumber())%>
- Test Requested (if bulk request):
-
-
-
-
-
-
- Barcode
- FMP/SSN
- Last Name
- First Name
- Middle Name
- Date of Birth
- SOT
- DUC
- Draw Date
- Specimen Type
- Test Requested
-
- <%
- int count = 1;
- for(InboundSpecimenBean isb : inboundSpecimens)
- {
- if(count % 2 == 0)
- {
- %>
-
- <%
- }
- else
- {
- %>
-
- <%
- }
- count++;
- %>
-
- <%=h(isb.getCustomerBarCode())%>
<%=h(isb.getCustomerBarCode())%>
- <%=h(getConcatenatedVal(isb.getFmpCode(), isb.getSsn()))%>
<%=h(getConcatenatedVal(isb.getFmpCode(), isb.getSsn()))%>
- <%=h(isb.getLastName())%>
- <%=h(isb.getFirstName())%>
- <%=h(isb.getMiddleName())%>
- <%=formatDate(isb.getBirthDate())%>
- <%=h(isb.getSotCode())%>
- <%=h(isb.getDucCode())%>
- <%=formatDate(isb.getDrawDate())%>
- <%=h(isb.getSpecimenType())%>
- <%=h(packingListBean.getTestType())%>
-
- <%
- }
- %>
-
-
-
-<%!
- public String getConcatenatedVal(String fmpCode, String SSN)
- {
- if(StringUtils.isBlank(fmpCode) || StringUtils.isBlank(SSN))
- return null;
-
- return fmpCode + SSN;
- }
-%>
\ No newline at end of file
diff --git a/hdrl/src/org/labkey/hdrl/view/requestDetails.jsp b/hdrl/src/org/labkey/hdrl/view/requestDetails.jsp
deleted file mode 100644
index dba26300..00000000
--- a/hdrl/src/org/labkey/hdrl/view/requestDetails.jsp
+++ /dev/null
@@ -1,89 +0,0 @@
-<%
-/*
- * Copyright (c) 2015-2019 LabKey Corporation
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-%>
-<%@ page import="org.labkey.api.view.HttpView" %>
-<%@ page import="org.labkey.api.view.template.ClientDependencies" %>
-<%@ page import="org.labkey.hdrl.HDRLController" %>
-<%@ page import="org.labkey.hdrl.view.InboundRequestBean" %>
-<%@ page extends="org.labkey.api.jsp.JspBase" %>
-<%!
- @Override
- public void addClientDependencies(ClientDependencies dependencies)
- {
- dependencies.add("Ext4");
- dependencies.add("hdrl/fonts/barcode.css");
- }
-%>
-<%
- HttpView me = HttpView.currentView();
- InboundRequestBean bean = (InboundRequestBean) me.getModelBean();
-%>
-
- Request <%= bean.getRequestId() %> - <%=h(bean.getTestType()) %> (Status: <%= h(bean.getRequestStatus()) %>)
-
-
-
-
- <% me.include(me.getView("queryView"),out); %>
-
-<%
- String renderId = "labkey-wp-"+ getRequestScopedUID();
-
- if (bean.getShippingCarrier() != null)
- {
-%>
-
-
-
- Shipping Information
-
-
- Carrier
- <%= h(bean.getShippingCarrier()) %>
-
-
- Tracking #
- <%= h(bean.getShippingNumber() == null ? "unknown" : bean.getShippingNumber()) %>
-
-
-<%
- }
-%>
-
-
-
-
-
-
-
-
- <%=link("Return to test status", HDRLController.BeginAction.class)%>
-
diff --git a/hdrl/src/org/labkey/hdrl/view/sensitiveData.jsp b/hdrl/src/org/labkey/hdrl/view/sensitiveData.jsp
deleted file mode 100644
index 002c7fb2..00000000
--- a/hdrl/src/org/labkey/hdrl/view/sensitiveData.jsp
+++ /dev/null
@@ -1,41 +0,0 @@
-<%
-/*
- * Copyright (c) 2015-2019 LabKey Corporation
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-%>
-<%@ page import="org.labkey.api.admin.AdminUrls" %>
-<%@ page import="org.labkey.api.view.HttpView" %>
-<%@ page import="org.labkey.api.view.JspView" %>
-<%@ page import="org.labkey.hdrl.HDRLController" %>
-<%@ page extends="org.labkey.api.jsp.JspBase" %>
-<%@ taglib prefix="labkey" uri="http://www.labkey.org/taglib" %>
-<%
- JspView sensitiveDataFormJspView = HttpView.currentView();
- HDRLController.SensitiveDataForm bean = sensitiveDataFormJspView.getModelBean();
- String timeWindow = String.valueOf(bean.getTimeWindowInDays());
-%>
-
-
-
- Number of Days<%=helpPopup("Number of Days", "Enter days after which sensitive data will be deleted.")%>:
- min="0">
-
-
-
- <%= button("Save").submit(true) %>
- <%= button("Cancel").href(urlProvider(AdminUrls.class).getAdminConsoleURL())%>
-
-
-
\ No newline at end of file
diff --git a/hdrl/test/sampledata/hdrl/clinical_report.pdf b/hdrl/test/sampledata/hdrl/clinical_report.pdf
deleted file mode 100644
index f930b7ad..00000000
Binary files a/hdrl/test/sampledata/hdrl/clinical_report.pdf and /dev/null differ
diff --git a/hdrl/test/sampledata/hdrl/sample_upload_01.tsv b/hdrl/test/sampledata/hdrl/sample_upload_01.tsv
deleted file mode 100644
index 5b705552..00000000
--- a/hdrl/test/sampledata/hdrl/sample_upload_01.tsv
+++ /dev/null
@@ -1,4 +0,0 @@
-customerBarcode lastName firstName birthDate SSN FMPId dutyCodeId testingSourceId drawDate
-5555 Jones Tom 12/1/2000 222334444 A13 P 3/1/2015
-6666 Jones Jerry 3/3/1975 A14 B
-7778 Jones Gracie 3/3/2015 20 A13 P 2/3/2015
diff --git a/hdrl/test/sampledata/hdrl/sample_upload_02.xlsx b/hdrl/test/sampledata/hdrl/sample_upload_02.xlsx
deleted file mode 100644
index f9a10f38..00000000
Binary files a/hdrl/test/sampledata/hdrl/sample_upload_02.xlsx and /dev/null differ
diff --git a/hdrl/test/src/org/labkey/test/tests/hdrl/HDRLTest.java b/hdrl/test/src/org/labkey/test/tests/hdrl/HDRLTest.java
deleted file mode 100644
index de43e10a..00000000
--- a/hdrl/test/src/org/labkey/test/tests/hdrl/HDRLTest.java
+++ /dev/null
@@ -1,666 +0,0 @@
-/*
- * Copyright (c) 2015-2019 LabKey Corporation
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-package org.labkey.test.tests.hdrl;
-
-import org.junit.Assert;
-import org.junit.Before;
-import org.junit.BeforeClass;
-import org.junit.Test;
-import org.junit.experimental.categories.Category;
-import org.labkey.remoteapi.CommandException;
-import org.labkey.remoteapi.Connection;
-import org.labkey.remoteapi.SimplePostCommand;
-import org.labkey.test.BaseWebDriverTest;
-import org.labkey.test.Locator;
-import org.labkey.test.Locators;
-import org.labkey.test.TestFileUtils;
-import org.labkey.test.TestTimeoutException;
-import org.labkey.test.WebTestHelper;
-import org.labkey.test.categories.Git;
-import org.labkey.test.util.DataRegionTable;
-import org.labkey.test.util.LogMethod;
-import org.labkey.test.util.LoggedParam;
-import org.labkey.test.util.PostgresOnlyTest;
-import org.labkey.test.util.di.DataIntegrationHelper;
-
-import java.io.File;
-import java.io.IOException;
-import java.util.ArrayList;
-import java.util.Arrays;
-import java.util.Collections;
-import java.util.HashMap;
-import java.util.List;
-import java.util.Map;
-
-import static org.junit.Assert.assertEquals;
-import static org.junit.Assert.assertNotEquals;
-import static org.junit.Assert.assertTrue;
-import static org.labkey.test.util.PermissionsHelper.READER_ROLE;
-
-@Category({Git.class}) // Requires dataintegration module
-@BaseWebDriverTest.ClassTimeout(minutes = 8)
-public class HDRLTest extends BaseWebDriverTest implements PostgresOnlyTest
-{
- protected final File TEST_SPECIMEN_UPLOAD_FILE_1 = TestFileUtils.getSampleData("hdrl/sample_upload_01.tsv");
- protected final File TEST_SPECIMEN_UPLOAD_FILE_2 = TestFileUtils.getSampleData("hdrl/sample_upload_02.xlsx");
- protected final File CLINICAL_REPORT_FILE = TestFileUtils.getSampleData("hdrl/clinical_report.pdf");
-
- private static final String SUBMIT_BUTTON_TEXT = "Submit Request";
- private static final String SAVE_BUTTON_TEXT = "Save";
- private static final String PRINT_PACKING_LIST_TEXT = "Print Packing List";
- private static final String CONFIRM_SAVE_TEXT = "Do you still want to save your changes?";
-
- public static final Locator.XPathLocator disabledSubmit = Locator.xpath("//a[contains(normalize-space(@class),'x4-btn-disabled')]//span[text()='" + SUBMIT_BUTTON_TEXT + "']");
- public static final Locator.XPathLocator enabledSave = Locator.xpath("//a[not(contains(normalize-space(@class), 'x4-btn-disable'))]//span[text()='" + SAVE_BUTTON_TEXT + "']");
- public static final Locator.XPathLocator enabledPrintPackingList = Locator.xpath("//a[not(contains(normalize-space(@class), 'x4-btn-disable'))]//span[text()='" + PRINT_PACKING_LIST_TEXT + "']");
-
- private static final int CARRIER_COLUMN_INDEX = 2;
- private static final int STATUS_COLUMN_INDEX = 13;
-
- @Override
- protected String getProjectName()
- {
- return "HDRL Verification";
- }
-
- @BeforeClass
- public static void initProject()
- {
- HDRLTest init = getCurrentTest();
- init.setupFolder();
- }
-
-
- @Before
- public void preTest()
- {
- goToProjectHome();
- }
-
- @Override
- protected void doCleanup(boolean afterTest) throws TestTimeoutException
- {
- super.doCleanup(afterTest);
- }
-
- @Override
- protected boolean allowTimeZoneShifting()
- {
- return false; // Ext forms need to be updated to handle time zones properly
- }
-
- private void addTestResultData(Map requestData, List> specimenData)
- {
- addRequestResultData(requestData);
- addSpecimenResultData(specimenData);
- }
-
- private void addRequestResultData(Map data)
- {
- Connection connection = WebTestHelper.getRemoteApiConnection();
- SimplePostCommand command = new SimplePostCommand("hdrl", "addLabwareOutboundRequest");
- command.setParameters(data);
-
- try
- {
- command.execute(connection, getCurrentContainerPath());
- }
- catch (IOException | CommandException e)
- {
- throw new RuntimeException("Error posting request results", e);
- }
- }
-
- private void addSpecimenResultData(List> results)
- {
- Connection connection = WebTestHelper.getRemoteApiConnection();
- for (Map result : results)
- {
- SimplePostCommand command = new SimplePostCommand("hdrl", "addLabwareOutboundSpecimen");
- command.setParameters(result);
-
- try
- {
- command.execute(connection, getCurrentContainerPath());
- }
- catch (IOException | CommandException e)
- {
- throw new RuntimeException("Error posting specimen results", e);
- }
- }
- }
-
- @Test
- public void testRetrievalOfResultsAndArchiving() throws Exception
- {
- Assert.assertTrue("Required module is not installed: dataintegration", _containerHelper.getAllModules().contains("dataintegration"));
- createTestRequest();
- uploadFile(TEST_SPECIMEN_UPLOAD_FILE_2);
- log("File uploaded waiting for content");
- waitForElement(Locator.tagContainingText("div", "555-44-3333"));
- log("setting tracking number");
- doAndWaitForPageSignal(() -> setFormElement(Locator.tagWithName("input", "trackingNumber"), "testRetrievalOfResults"), "pageDirty");
- log("submitting requests");
- clickButton(SUBMIT_BUTTON_TEXT);
- DataRegionTable drt = new DataRegionTable("query", this);
- int idx = drt.getRowIndex("ShippingNumber", "testRetrievalOfResults");
- assertNotEquals(-1, idx);
- String requestId = drt.getDataAsText(idx, "RequestId");
-
- Map result = new HashMap<>();
- result.put("batchId", requestId);
- result.put("dateReceived", "2015-06-01");
- result.put("dateModified", "2015-06-15");
- result.put("dateCompleted", "2015-07-01");
- result.put("hdrlStatus", "Completed");
- result.put("customerNote", "Note for id " + requestId);
-
- List specimenIds = getSpecimenIds(requestId, "hdrl", "InboundSpecimen", "RowId");
-
- List> lwSpecimens = new ArrayList<>();
-
- Map specimenResult1 = new HashMap<>();
- specimenResult1.put("batchId", String.valueOf(requestId));
- specimenResult1.put("testRequestId", specimenIds.get(0));
- specimenResult1.put("dateReceived", "2015-06-01");
- specimenResult1.put("dateCompleted", "2015-06-03");
- specimenResult1.put("dateModified", "2015-06-03");
- specimenResult1.put("sampleIntegrity", "Hemolyzed");
- specimenResult1.put("testResult", "HIV Negative");
- specimenResult1.put("customerCode", "5B");
- specimenResult1.put("clinicalReportFile", CLINICAL_REPORT_FILE.getAbsolutePath());
- specimenResult1.put("reportFileName", "reportFileName.pdf");
- specimenResult1.put("hdrlStatus", "Completed");
- specimenResult1.put("modifiedResultFlag", "F");
- lwSpecimens.add(specimenResult1);
-
- Map specimenResult2 = new HashMap<>();
- specimenResult2.put("batchId", requestId);
- specimenResult2.put("testRequestId", specimenIds.get(1));
- specimenResult2.put("dateReceived", "2015-06-01");
- specimenResult2.put("dateModified", "2015-06-03");
- specimenResult2.put("hdrlStatus", "Exception");
- specimenResult2.put("modifiedResultFlag", "F");
- lwSpecimens.add(specimenResult2);
-
- addTestResultData(result, lwSpecimens); // add results for this test request
-
- // Run the ETL to pick up the results
- new DataIntegrationHelper(getProjectName()).runTransform("{HDRL}/labware");
-
- Map request = new HashMap<>();
- request.put("ShippingNumber", "testRetrievalOfResults");
- result.put("requestId", requestId);
- result.put("received", "2015-06-01");
- result.put("modified", "2015-06-15");
- result.put("Status", "Received");
- result.put("CustomerNote", "Note for id " + requestId);
-
- // add in the request data for verification
- Map specimen1 = new HashMap<>();
- specimen1.put("RequestId", String.valueOf(requestId));
- specimen1.put("SpecimenId", specimenIds.get(0));
- specimen1.put("Received", "2015-06-01 00:00");
- specimen1.put("Completed", "2015-06-03 00:00");
- specimen1.put("SampleIntegrity", "Hemolyzed");
- specimen1.put("TestResult", "HIV Negative");
- specimen1.put("CustomerCode", "5B");
- specimen1.put("RequestStatusId", "Completed");
- specimen1.put("ModifiedResultFlag", "F");
-
- Map specimen2 = new HashMap<>();
-
- specimen2.put("RequestId", requestId);
- specimen2.put("SpecimenId", specimenIds.get(1));
- specimen2.put("Received", "2015-06-01 00:00");
- specimen2.put("RequestStatusId", "Exception");
- specimen2.put("ModifiedResultFlag", "F");
-
- List> specimens = new ArrayList<>();
- specimens.add(specimen1);
- specimens.add(specimen2);
-
- // Verify results data are shown in the grid
- verifyDataRegionRows("InboundRequest", Collections.singletonList(request), "ShippingNumber");
- verifyDataRegionRows("SpecimenResult", specimens, "SpecimenId");
-
- // Verify download
- goToProjectHome();
- impersonateRole(READER_ROLE);
- click(Locator.linkContainingText("View test requests"));
- drt = new DataRegionTable("query", this);
- idx = drt.getRowIndex("RequestId", requestId);
- assertNotEquals(-1, idx);
- log("view test results");
- assertEquals("VIEW", drt.getDataAsText(idx, 0));
- clickAndWait(drt.link(idx, 0));
-
- waitForElement(Locator.tagContainingText("td", specimenIds.get(0)));
- drt = new DataRegionTable("query", this);
- idx = drt.getRowIndex("RowId", specimenIds.get(0));
- assertEquals("Download", drt.getDataAsText(idx, 0));
- assertEquals( Arrays.asList("Completed","Exception"),drt.getColumnDataAsText("Status"));
- assertEquals( Arrays.asList("F","F"),drt.getColumnDataAsText("ModifiedResultFlag"));
- assertEquals( Arrays.asList("7777","8888"),drt.getColumnDataAsText("CustomerBarCode"));
- assertEquals( Arrays.asList("Johnston","Johnston"),drt.getColumnDataAsText("LastName"));
- assertEquals( Arrays.asList("Jack","Fred"),drt.getColumnDataAsText("FirstName"));
- assertEquals( Arrays.asList("Sparrow"," "),drt.getColumnDataAsText("MiddleName"));
- assertEquals( Arrays.asList("jsj"," "),drt.getColumnDataAsText("Initials"));
- assertEquals( Arrays.asList("Male","Unknown"),drt.getColumnDataAsText("Gender"));
- assertEquals( Arrays.asList("2000-12-01","1940-06-07"),drt.getColumnDataAsText("BirthDate"));
- assertEquals( Arrays.asList("222334444","555443333"),drt.getColumnDataAsText("SSN"));
- assertEquals( Arrays.asList("01","02"),drt.getColumnDataAsText("FMP"));
- assertEquals( Arrays.asList("A13","A14"),drt.getColumnDataAsText("DUC"));
- assertEquals( Arrays.asList("P","B"),drt.getColumnDataAsText("SOT"));
- assertEquals( Arrays.asList("2015-03-01","1975-03-03"),drt.getColumnDataAsText("DrawDate"));
- assertEquals( Arrays.asList("2015-06-01 00:00","2015-06-01 00:00"),drt.getColumnDataAsText("Received"));
- assertEquals( Arrays.asList("2015-06-03 00:00"," "),drt.getColumnDataAsText("Completed"));
- assertEquals( Arrays.asList("Hemolyzed"," "),drt.getColumnDataAsText("SampleIntegrity"));
- assertEquals( Arrays.asList("HIV Negative"," "),drt.getColumnDataAsText("TestResult"));
- assertEquals( Arrays.asList("5B"," "),drt.getColumnDataAsText("CustomerCode"));
- assertEquals( Arrays.asList("reportFileName.pdf"," "),drt.getColumnDataAsText("ReportFileName"));
- File report = clickAndWaitForDownload(Locator.linkWithSpan("Download"));
- assertTrue(report.getName().contains("reportFileName"));
- stopImpersonating();
-
- testDataDeletion();
- }
-
- @Test
- public void testNewRequest()
- {
- log("creating a new test request");
- createTestRequest();
- assertElementPresent("Submit button should not be enabled if no specimen data are available", disabledSubmit, 1);
-
- // add specimen through the row picker
- List> rows = new ArrayList<>();
- Map r1 = new HashMap<>();
-
- r1.put("CustomerBarcode", "1234");
- r1.put("LastName", "Smith");
- r1.put("FirstName", "Jon");
- r1.put("SSN", "543");
- rows.add(r1);
- addSpecimenRequestRow(r1, "Invalid SSN; Required field(s) missing: FMP, Draw Date", true);
-
- Map r2 = new HashMap<>();
-
- r2.put("CustomerBarcode", "5678");
- r2.put("LastName", "Smith");
- r2.put("FirstName", "Tommy");
- r2.put("SSN", "543221234");
- rows.add(r2);
- addSpecimenRequestRow(r2, "Required field(s) missing: FMP, Draw Date", false);
-
- log("ensure row editor saves the currently edited row");
- clickButton(SAVE_BUTTON_TEXT);
-
- // verify the inserted row via the data region table
- verifyDataRegionRows("InboundSpecimen", rows, "CustomerBarcode");
- }
-
- @Test
- public void testFileUpload()
- {
- createTestRequest();
- uploadFile(TEST_SPECIMEN_UPLOAD_FILE_1);
-
- log("verify proper SSN formatting");
- waitForElement(Locator.tagContainingText("div", "222-33-4444"));
-
- log("verify status message update");
- waitForElement(Locator.tagContainingText("div", "Required field(s) missing: FMP, Draw Date, SSN"));
- waitForElement(Locator.tagContainingText("div", "Required field(s) missing: FMP"));
- waitForElement(Locator.tagContainingText("div", "Draw date cannot be before birth date; Required field(s) missing: SSN"));
-
- log("verify submit disabled when there are validation errors");
- assertElementPresent("Submit button should not be enabled if request has been submitted", disabledSubmit, 1);
-
- clickButton(SAVE_BUTTON_TEXT);
-
- List> rows = new ArrayList<>();
- Map r1 = new HashMap<>();
- r1.put("CustomerBarcode", "5555");
- r1.put("LastName", "Jones");
- r1.put("FirstName", "Tom");
- r1.put("SSN", "222334444");
- r1.put("DUC", "A13");
- r1.put("SOT", "P");
- rows.add(r1);
-
- Map r2 = new HashMap<>();
- r2.put("CustomerBarcode", "6666");
- r2.put("LastName", "Jones");
- r2.put("FirstName", "Jerry");
- r2.put("DUC", "A14");
- r2.put("SOT", "B");
- rows.add(r2);
-
- // verify the inserted row via the data region table
- verifyDataRegionRows("InboundSpecimen", rows, "CustomerBarcode");
- }
-
- @Test
- public void testFileUploadAndSubmit()
- {
- log("creating a new test request by uploading a file");
- createTestRequest();
- _ext4Helper.selectComboBoxItem("Carrier", "FedEx");
-
- uploadFile(TEST_SPECIMEN_UPLOAD_FILE_2);
-
- log("verify proper SSN formatting");
- waitForElement(Locator.tagContainingText("div", "222-33-4444"));
- waitForElement(Locator.tagContainingText("div", "555-44-3333"));
- clickButton(SAVE_BUTTON_TEXT);
-
- List> rows = new ArrayList<>();
- Map r1 = new HashMap<>();
- r1.put("CustomerBarcode", "7777");
- r1.put("LastName", "Johnston");
- r1.put("FirstName", "Jack");
- r1.put("MiddleName", "Sparrow");
- r1.put("Initials", "jsj");
- r1.put("Gender", "Male");
- r1.put("SSN", "222334444");
- r1.put("FMP", "01");
- r1.put("DUC", "A13");
- r1.put("SOT", "P");
- rows.add(r1);
-
- Map r2 = new HashMap<>();
- r2.put("CustomerBarcode", "8888");
- r2.put("LastName", "Johnston");
- r2.put("FirstName", "Fred");
- r2.put("Gender", "Unknown");
- r2.put("SSN", "555443333");
- r2.put("FMP", "02");
- r2.put("DUC", "A14");
- r2.put("SOT", "B");
- rows.add(r2);
-
- // verify the inserted row via the data region table
- verifyDataRegionRows("InboundSpecimen", rows, "CustomerBarcode");
-
- log("edit an existing request");
- goToProjectHome();
- clickAndWait(Locator.linkContainingText("View test requests"));
-
- DataRegionTable drt = new DataRegionTable("query", this);
- int idx = drt.getRowIndex("ShippingCarrierId", "FedEx");
- assertNotEquals(-1, idx);
- clickAndWait(drt.link(idx, 0));
- log("submitting an existing request");
- waitForElement(Locator.tagContainingText("div", "222-33-4444"));
- waitForElement(Locator.tagContainingText("div", "555-44-3333"));
- clickButton(SUBMIT_BUTTON_TEXT);
-
- drt = new DataRegionTable("query", this);
- idx = drt.getRowIndex("ShippingCarrierId", "FedEx");
- assertNotEquals(-1, idx);
- Assert.assertFalse(drt.getDataAsText(idx, "Submitted By").trim().isEmpty()); // "submitted by" field should be filled in
- Assert.assertFalse(drt.getDataAsText(idx, "Submitted").trim().isEmpty()); // submitted date should be filled in
-
- log("ensure submitted requests are still editable by admins");
- assertEquals("EDIT", drt.getDataAsText(idx, 0));
- clickAndWait(drt.link(idx, 0));
-
- waitForElement(org.labkey.test.Locators.bodyTitle("Edit a Test Request"));
-
- testPrintPackingList("Admin", "FedEx");
-
- log("verify submitted requests are readonly for non-admins");
-
- impersonateRole(READER_ROLE);
- goToProjectHome();
- clickAndWait(Locator.linkContainingText("View test requests"));
- drt = new DataRegionTable("query", this);
- idx = drt.getRowIndex("ShippingCarrierId", "FedEx");
- assertNotEquals(-1, idx);
- log("ensure submitted requests are still editable by admins");
- assertEquals("VIEW", drt.getDataAsText(idx, 0));
- clickAndWait(drt.link(idx, 0));
-
- waitForElement(Locator.tagContainingText("td", "Carrier"));
- waitForElement(Locator.tagContainingText("td", "FedEx"));
- assertElementNotPresent(org.labkey.test.Locators.bodyTitle("Edit a Test Request"));
-
- testPrintPackingList(READER_ROLE, "FedEx");
-
- stopImpersonating();
- }
-
- @Test
- public void testEditSubmittedRequest()
- {
- createTestRequest();
- setFormElement(Locator.tagWithName("input", "trackingNumber"), "testEditSubmittedRequest");
- log("upload specimen data from a .xlsx file");
- uploadFile(TEST_SPECIMEN_UPLOAD_FILE_2);
-
- log("submitting new test request");
- waitForElement(Locator.tagContainingText("div", "222-33-4444"));
- waitForElement(Locator.tagContainingText("div", "555-44-3333"));
- clickButton(SUBMIT_BUTTON_TEXT);
- assertTextNotPresent("Create a new test request"); // submit should take us back to the view test requests page
-
- log("Edit the submitted request as admin");
- DataRegionTable drt = new DataRegionTable("query", this);
- int idx = drt.getRowIndex("ShippingNumber", "testEditSubmittedRequest");
- assertNotEquals(-1, idx);
- assertEquals("Submitted", drt.getDataAsText(idx, STATUS_COLUMN_INDEX));
- String submittedDate = drt.getDataAsText(idx, 6).trim();
-
- log("ensure submitted requests are still editable by admins");
- assertEquals("EDIT", drt.getDataAsText(idx, 0));
- clickAndWait(drt.link(idx, 0));
-
- waitForElement(org.labkey.test.Locators.bodyTitle("Edit a Test Request"));
- assertTextPresent("This request has already been submitted");
- assertElementPresent("Submit button should not be enabled if request has been submitted", disabledSubmit, 1);
-
- log("Test edit and cancel save of a submitted request");
- _ext4Helper.selectComboBoxItem("Carrier","DHL");
- assertElementPresent("Save button should be enabled if request has been edited", enabledSave, 1);
- clickButton(SAVE_BUTTON_TEXT, 0);
- waitForText(CONFIRM_SAVE_TEXT);
- clickButton("No", 0);
-
- log("Test that not saving request does not change anything");
- clickButton("Cancel", 0); // takes you back to the view test requests page
- idx = drt.getRowIndex("ShippingNumber", "testEditSubmittedRequest");
- assertNotEquals(-1, idx);
- assertEquals("Submitted", drt.getDataAsText(idx, STATUS_COLUMN_INDEX));
- assertNotEquals("DHL", drt.getDataAsText(idx, CARRIER_COLUMN_INDEX));
- assertEquals("EDIT", drt.getDataAsText(idx, 0));
-
- log("Test edit and save of a submitted request");
- clickAndWait(drt.link(idx, 0));
- _ext4Helper.selectComboBoxItem("Carrier","DHL");
- assertElementPresent("Save button should be enabled if request has been edited", enabledSave, 1);
- clickButton(SAVE_BUTTON_TEXT, 0);
- waitForText(CONFIRM_SAVE_TEXT);
- clickButton("Yes");
-
- log("Test that saving request does not change the request status");
- idx = drt.getRowIndex("ShippingNumber", "testEditSubmittedRequest");
- assertNotEquals(-1, idx);
- assertEquals("Submitted", drt.getDataAsText(idx, STATUS_COLUMN_INDEX));
- assertEquals("DHL", drt.getDataAsText(idx, CARRIER_COLUMN_INDEX));
- // submitted date should still be the same
- assertEquals(submittedDate, drt.getDataAsText(idx, 6));
- }
-
- private void testPrintPackingList(String role, String shippingCarrier)
- {
- log("Begin verifying 'Print Packing List' for role: " + role);
- waitForElement(enabledPrintPackingList);
- clickButton(PRINT_PACKING_LIST_TEXT,0);
-
- switchToWindow(1);
- waitForElement(Locator.tag("div").withAttributeContaining("class", "barcode"));
- assertTextPresent("Total Samples: 2", shippingCarrier);
- getDriver().close();
- switchToMainWindow();
-
- log("Finish verifying 'Print Packing List' for role: " + role);
-
- }
-
- public void testDataDeletion()
- {
- goToAdminConsole()
- .clickSystemMaintenance();
- waitForText("Configure System Maintenance");
- click(Locator.linkWithText("HDRL Request Portal PHI Deletion"));
- switchToWindow(1);
- waitForText(30000, "HDRL Request Portal PHI Deletion complete");
- getDriver().close();
- switchToMainWindow();
- goToProjectHome();
- clickAndWait(Locator.linkWithText("View test requests"));
- DataRegionTable drt = new DataRegionTable("query", this);
- int idx = drt.getRowIndex("ShippingNumber", "testRetrievalOfResults");
- assertNotEquals(-1, idx);
- String requestId = drt.getDataAsText(idx, "RequestId");
- Assert.assertEquals("Archived", drt.getDataAsText(idx, "Status"));
- List specimenIds = getSpecimenIds(requestId, "hdrl", "InboundSpecimen", "RowId");
- assertTrue("There should be no specimens associated with the archived request", specimenIds.isEmpty());
- specimenIds = getSpecimenIds(requestId, "hdrl", "SpecimenResult", "SpecimenId");
- assertTrue("There should be no specimen results associated with the archived request", specimenIds.isEmpty());
- specimenIds = getSpecimenIds(requestId, "hdrl", "labwareOutboundSpecimens", "test_request_id");
- assertTrue("There should be no specimen results in the labware transfer table associated with the archived request", specimenIds.isEmpty());
-
- }
-
- @LogMethod(quiet = true)
- private void createTestRequest()
- {
- log("creating a new test request by uploading a file");
- goToProjectHome();
- clickAndWait(Locator.linkContainingText("Create a new test request"));
- waitForElement(Locators.pageSignal("pageDirty", "false"));
-
- // we select this even though there is only one option available because there may be other types in the future
- // Also, this test will fail without waiting for the combo box to be populated, so this is an easy way to wait
- // for that.
- _ext4Helper.selectComboBoxItem("Request Type","HIV Screening Algorithm");
- }
-
- @LogMethod(quiet = true)
- private void uploadFile(@LoggedParam File file)
- {
- log("upload specimen data from a file");
- setFormElement(Locator.tagWithName("input", "file"), file);
- log("clicking 'upload file'");
- log(doAndWaitForPageSignal(() -> clickButton("upload file", 0), "uploadFile"));
- }
-
- private List getSpecimenIds(String requestId, String schema, String query, String idField)
- {
- goToSchemaBrowser();
- selectQuery(schema, query);
- waitForText("view data");
- clickAndWait(Locator.linkContainingText("view data"));
- DataRegionTable drt = new DataRegionTable("query", this);
- drt.ensureColumnPresent(idField);
- List specimenIds = new ArrayList<>();
- List targetRows = new ArrayList<>();
- List requestIds = drt.getColumnDataAsText(2);
- for(int i = 0; i < requestIds.size(); i++)
- {
- if (requestIds.get(i).equals(requestId))
- targetRows.add(i);
- }
- List requestCol = drt.getColumnDataAsText(15);
- for(int i : targetRows)
- {
- specimenIds.add(requestCol.get(i));
- }
- return specimenIds;
- }
-
- private void verifyDataRegionRows(String tableName, List> expectedRows, String key)
- {
- log("verifying specimen rows in the schema browser");
- goToSchemaBrowser();
- selectQuery("hdrl", tableName);
- waitForText("view data");
- clickAndWait(Locator.linkContainingText("view data"));
- DataRegionTable drt = new DataRegionTable("query", this);
-
- // find the row to verify
- for (Map expectedRow : expectedRows)
- {
- int idx = drt.getRowIndex(key, expectedRow.get(key));
- assertNotEquals(String.format("Didn't find row with %s = %s", key, expectedRow.get(key)), -1, idx);
-
- Map actualRow = new HashMap<>();
- for (Map.Entry field : expectedRow.entrySet())
- {
- actualRow.put(field.getKey(), drt.getDataAsText(idx, field.getKey()));
- }
- assertEquals("Bad row data", expectedRow, actualRow);
- }
- }
-
- private void addSpecimenRequestRow(Map values, String statusText, boolean updateRow)
- {
- clickButton("add specimen", 0);
-
- log("adding a specimen through the row picker");
- for (Map.Entry field : values.entrySet())
- {
- Locator loc = Locator.xpath("//input[contains(@class, 'form-field') and @name='" + field.getKey() + "']");
- waitForElement(loc);
- log("setting " + field.getKey());
- setFormElement(loc, field.getValue());
- }
-
- if (updateRow)
- {
- clickButton("Update", 0);
- waitForElement(Locator.tagWithClass("div", "x4-grid-cell-inner").withText(statusText));
- }
- }
-
- @LogMethod
- protected void setupFolder()
- {
- _containerHelper.createProject(getProjectName(), "HDRL Request Portal");
- }
-
- protected void setTimeWindow()
- {
- goToAdminConsole();
- clickAndWait(Locator.linkWithText("HDRL Sensitive Data"));
- setFormElement(Locator.name("timeWindowInDays"), "0");
- clickAndWait(Locator.linkWithSpan("Save"));
- }
-
- @Override
- public BrowserType bestBrowser()
- {
- return BrowserType.CHROME;
- }
-
- @Override
- public List getAssociatedModules()
- {
- return Arrays.asList("HDRL");
- }
-}