Skip to content

Commit 82c3c54

Browse files
authored
fix(data): add back those test patient and caregivers that are in test data (#578)
Inserts back the patients and caregivers that we have in our test data due to problems when this is done in the insert_test_data command (due to truncating). Also, this allows a user to set up a local environment without requiring to run the insert_test_data management command in admin first. This should be easier to manage for users in terms of the process to set up that is in various places (README here, in admin, and the overall instructions in our documentation).
1 parent 61af500 commit 82c3c54

File tree

10 files changed

+64
-53
lines changed

10 files changed

+64
-53
lines changed

db_management/opaldb/data/test/ohigph/ohigph_01_patient_identifiers.sql

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,3 +6,15 @@
66

77
INSERT INTO `Hospital_Identifier_Type` (`Hospital_Identifier_Type_Id`, `Code`, `ADT_Web_Service_Code`, `Description_EN`, `Description_FR`) VALUES
88
(1, 'CHUSJ', 'CHUSJ', 'OHIG Pediatric Hospital', 'Hôpital Pédiatrique OHIG');
9+
10+
11+
INSERT INTO `Patient` (`PatientSerNum`, `PatientAriaSer`, `PatientId`, `PatientId2`, `FirstName`, `LastName`, `Alias`, `ProfileImage`, `Sex`, `DateOfBirth`, `Age`, `TelNum`, `EnableSMS`, `Email`, `Language`, `SSN`, `AccessLevel`, `RegistrationDate`, `ConsentFormExpirationDate`, `BlockedStatus`, `StatusReasonTxt`, `DeathDate`, `SessionId`, `LastUpdated`, `TestUser`, `TermsAndAgreementSign`, `TermsAndAgreementSignDateTime`) VALUES
12+
(54, 0, '', '', 'Lisa', 'Simpson', 'lisa_test', NULL, 'Female', CONCAT(DATE_FORMAT(DATE_ADD(NOW(), INTERVAL -8 YEAR), '%Y'), '-05-09') - INTERVAL (DATE_FORMAT(NOW(), '%m%d') < '0509') YEAR, 0, 61292507111, 0, '[email protected]', 'EN', 'SIML14550999', '3', DATE_ADD(NOW(), INTERVAL -1 DAY), '2019-01-01 00:00:00', 0, '', '0000-00-00 00:00:00', '', '2023-05-25 00:00:00', 1, NULL, NULL);
13+
14+
UPDATE `Patient` SET `Age` = DATE_FORMAT(FROM_DAYS(DATEDIFF(NOW(), `DateOfBirth`)), '%Y') + 0;
15+
16+
INSERT INTO `PatientControl` (`PatientSerNum`, `PatientUpdate`, `LastTransferred`, `LastUpdated`, `TransferFlag`) VALUES
17+
(54, 1, '2021-09-30 00:56:01', '2021-09-30 08:56:01', 0);
18+
19+
INSERT INTO `Patient_Hospital_Identifier` (`Patient_Hospital_Identifier_Id`, `PatientSerNum`, `Hospital_Identifier_Type_Code`, `MRN`, `Is_Active`) VALUES
20+
(5, 54, 'CHUSJ', '9999993', 1);

db_management/opaldb/data/test/ohigph/ohigph_diagnosis.sql

Lines changed: 0 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -3,14 +3,8 @@
33
-- SPDX-License-Identifier: AGPL-3.0-or-later
44

55
INSERT INTO `Diagnosis` (`DiagnosisSerNum`, `PatientSerNum`, `SourceDatabaseSerNum`, `DiagnosisAriaSer`, `DiagnosisCode`, `Description_EN`, `Description_FR`, `Stage`, `StageCriteria`, `CreationDate`, `createdBy`, `LastUpdated`, `updatedBy`) VALUES
6-
(3, 53, 1, '22324', 'C16.9', 'Stomach, NOS', '', NULL, NULL, '2023-05-12 00:00:00', 'CronJob', '2023-05-12 16:39:16', 'CronJob'),
76
(7, 54, 1, '11431', 'R31.9', 'Hematuria, unspecified', '', NULL, NULL, '2023-03-02 00:00:00', 'CronJob', '2023-03-21 16:39:16', 'CronJob');
87

9-
-- Bart
10-
UPDATE `Diagnosis`
11-
SET `CreationDate` = DATE_ADD(now(), INTERVAL -3 DAY),
12-
`LastUpdated` = DATE_ADD(now(), INTERVAL -3 DAY)
13-
WHERE `PatientSerNum` = 53;
148
-- Lisa
159
UPDATE `Diagnosis`
1610
SET `CreationDate` = DATE_ADD(now(), INTERVAL -7 DAY),

db_management/opaldb/data/test/ohigph/ohigph_questionnaire.sql

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,6 @@
44

55
INSERT INTO `Questionnaire` (`QuestionnaireSerNum`, `CronLogSerNum`, `QuestionnaireControlSerNum`, `PatientSerNum`, `DateAdded`, `PatientQuestionnaireDBSerNum`, `CompletedFlag`, `CompletionDate`, `SessionId`, `LastUpdated`) VALUES
66
-- all get: esas-r
7-
(3, 1, 42, 53, '2000-01-01 00:00:00', 207, 0, NULL, '', '2000-01-01 00:00:00'),
87
(15, 1, 42, 54, '2000-01-01 00:00:00', 208, 0, NULL, '', '2000-01-01 00:00:00');
98

109
-- Update all Questionnaire dates to make the data more similar to a live environment

db_management/opaldb/data/test/omi/omi_01_patient_identifiers.sql

Lines changed: 49 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,4 +5,52 @@
55
-- OPAL MEDICAL INSTITUTION
66

77
INSERT INTO `Hospital_Identifier_Type` (`Hospital_Identifier_Type_Id`, `Code`, `ADT_Web_Service_Code`, `Description_EN`, `Description_FR`) VALUES
8-
(1, 'ODH', 'MR_PCS', 'Opal Demo Hospital (ODH)', "Hôpital démo d\'Opal (HDO)");
8+
(1, 'ODH', 'MR_PCS', 'Opal Demo Hospital (ODH)', "Hôpital démo d\'Opal (HDO)");
9+
10+
INSERT INTO `Patient` (`PatientSerNum`, `PatientAriaSer`, `PatientId`, `PatientId2`, `FirstName`, `LastName`, `Alias`, `ProfileImage`, `Sex`, `DateOfBirth`, `Age`, `TelNum`, `EnableSMS`, `Email`, `Language`, `SSN`, `AccessLevel`, `RegistrationDate`, `ConsentFormExpirationDate`, `BlockedStatus`, `StatusReasonTxt`, `DeathDate`, `SessionId`, `LastUpdated`, `TestUser`, `TermsAndAgreementSign`, `TermsAndAgreementSignDateTime`) VALUES
11+
(59, 0, '', '', 'Rory', 'O\'Brien', '', NULL, 'Other', '1972-06-11 00:00:00', 53, NULL, 0, '[email protected]', 'EN', 'OBRR72061199', '3', '2025-06-19 21:54:53', NULL, 0, '', NULL, '', '2025-06-19 21:54:53', 0, NULL, NULL),
12+
(92, 0, '', '', 'Laurie', 'Opal', '', NULL, 'Female', '1958-12-13 00:00:00', 66, NULL, 0, '[email protected]', 'EN', 'OPAL58621325', '3', '2025-06-19 21:54:53', NULL, 0, '', NULL, '', '2025-06-19 21:54:53', 0, NULL, NULL),
13+
(93, 0, '', '', 'John', 'Smith', '', NULL, 'Male', '1985-01-01 00:00:00', 40, NULL, 0, '[email protected]', 'EN', 'ABCD99988877', '3', '2025-06-19 21:54:53', NULL, 0, '', NULL, '', '2025-06-19 21:54:53', 0, NULL, NULL),
14+
(94, 0, '', '', 'Richard', 'Smith', '', NULL, 'Male', '1946-05-05 00:00:00', 79, NULL, 0, '[email protected]', 'EN', 'SMIR05054616', '3', '2025-06-19 21:54:53', NULL, 0, '', NULL, '', '2025-06-19 21:54:53', 0, NULL, NULL),
15+
(96, 0, '', '', 'Cara', 'O\'Brien', '', NULL, 'Female', '1974-11-25 00:00:00', 50, NULL, 0, '[email protected]', 'EN', 'OBRC11257499', '3', '2025-06-19 21:54:53', NULL, 0, '', NULL, '', '2025-06-19 21:54:53', 0, NULL, NULL),
16+
(99, 0, '', '', 'Valerie', 'Solanas', '', NULL, 'Male', '1979-06-21 00:00:00', 45, NULL, 0, '[email protected]', 'EN', 'SOLV06217999', '3', '2025-06-19 21:54:53', NULL, 0, '', NULL, '', '2025-06-19 21:54:53', 0, NULL, NULL),
17+
(100, 0, '', '', 'Pete', 'Boyd', '', NULL, 'Male', '1971-06-11 00:00:00', 54, NULL, 0, '[email protected]', 'EN', 'BOYP06117199', '3', '2025-06-19 21:54:53', NULL, 0, '', NULL, '', '2025-06-19 21:54:53', 0, NULL, NULL),
18+
(101, 0, '', '', 'Martin', 'Curley', '', NULL, 'Male', '1965-04-23 00:00:00', 60, NULL, 0, '[email protected]', 'EN', 'CURM04236599', '3', '2025-06-19 21:54:53', NULL, 0, '', NULL, '', '2025-06-19 21:54:53', 0, NULL, NULL),
19+
(102, 0, '', '', 'Kathy', 'Brown', '', NULL, 'Female', '1974-11-25 00:00:00', 50, NULL, 0, '[email protected]', 'EN', 'BROK11257499', '3', '2025-06-19 21:54:53', NULL, 0, '', NULL, '', '2025-06-19 21:54:53', 0, NULL, NULL),
20+
(103, 0, '', '', 'Mike', 'Brown', '', NULL, 'Male', '1972-06-11 00:00:00', 53, NULL, 0, '[email protected]', 'EN', 'BROM72061199', '3', '2025-06-19 21:54:53', NULL, 0, '', NULL, '', '2025-06-27 09:24:42', 0, NULL, NULL);
21+
22+
INSERT INTO `Users` (`UserSerNum`, `UserType`, `UserTypeSerNum`, `Username`, `Password`, `SessionId`, `LastUpdated`) VALUES
23+
(1, 'Patient', 92, 'a51fba18-3810-4808-9238-4d0e487785c8', '', '', '2025-06-19 21:54:53'),
24+
(2, 'Patient', 59, 'mouj1pqpXrYCl994oSm5wtJT3In2', '', '', '2025-06-19 21:54:53'),
25+
(3, 'Patient', 96, 'dR2Cb1Yf0vQb4ywvMoAXw1SxbY93', '', '', '2025-06-19 21:54:53'),
26+
(4, 'Patient', 93, 'hIMnEXkedPMxYnXeqNXzphklu4V2', '', '', '2025-06-19 21:54:53'),
27+
(5, 'Patient', 94, '2WhxeTpYF8aHlfSQX8oGeq4LFhw2', '', '', '2025-06-19 21:54:53'),
28+
(6, 'Patient', 103, 'hSJdAae7xWNwnemd2YypQSVfoOb2', '', '', '2025-06-19 21:54:53'),
29+
(7, 'Patient', 102, 'OPWj4Cj5iRfgva4b3HGtVGjvuk13', '', '', '2025-06-19 21:54:53'),
30+
(8, 'Patient', 99, 'dcBSK5qdoiOM2L9cEdShkqOadkG3', '', '', '2025-06-19 21:54:53'),
31+
(9, 'Patient', 100, '9kmS7qYQX8arnFFs4ZYJk1tqLFw1', '', '', '2025-06-19 21:54:53'),
32+
(10, 'Patient', 101, '2grqcCoyPlVucfAPD4NM1SuCk3i1', '', '', '2025-06-19 21:54:53');
33+
34+
INSERT INTO `PatientControl` (`PatientSerNum`, `PatientUpdate`, `LastTransferred`, `LastUpdated`, `TransferFlag`) VALUES
35+
(59, 1, '2025-07-07 11:58:00', '2025-07-07 11:58:00', 0),
36+
(92, 1, '2025-07-07 11:58:00', '2025-07-07 11:58:00', 0),
37+
(93, 1, '2025-07-07 11:58:00', '2025-07-07 11:58:00', 0),
38+
(94, 1, '2025-07-07 11:58:00', '2025-07-07 11:58:00', 0),
39+
(96, 1, '2025-07-07 11:58:00', '2025-07-07 11:58:00', 0),
40+
(99, 1, '2025-07-07 11:58:00', '2025-07-07 11:58:00', 0),
41+
(100, 1, '2025-07-07 11:58:00', '2025-07-07 11:58:00', 0),
42+
(101, 1, '2025-07-07 11:58:00', '2025-07-07 11:58:00', 0),
43+
(102, 1, '2025-07-07 11:58:00', '2025-07-07 11:58:00', 0),
44+
(103, 1, '2025-07-07 11:58:00', '2025-07-07 11:58:00', 0);
45+
46+
INSERT INTO `Patient_Hospital_Identifier` (`Patient_Hospital_Identifier_Id`, `PatientSerNum`, `Hospital_Identifier_Type_Code`, `MRN`, `Is_Active`) VALUES
47+
(1, 92, 'ODH', '1092300', 1),
48+
(2, 59, 'ODH', '9999989', 1),
49+
(3, 96, 'ODH', '8888885', 1),
50+
(4, 93, 'ODH', '9999994', 1),
51+
(5, 94, 'ODH', '8888882', 1),
52+
(6, 103, 'ODH', '8888881', 1),
53+
(7, 102, 'ODH', '8888880', 1),
54+
(8, 99, 'ODH', '5555553', 1),
55+
(9, 100, 'ODH', '5555554', 1),
56+
(10, 101, 'ODH', '5555559', 1);

db_management/opaldb/data/test/patients/fake_patients.sql

Lines changed: 0 additions & 35 deletions
This file was deleted.

db_management/questionnairedb/data/test/answers.sql

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2800,12 +2800,13 @@ and sectionId=154;
28002800

28012801
-- TODO clean up data for deleted patientIds (see db_management/questionnairedb/data/test/omi/patients.sql)
28022802
INSERT INTO `answerQuestionnaire` (`ID`, `questionnaireId`, `patientId`, `status`, `deleted`, `deletedBy`, `creationDate`, `createdBy`, `lastUpdated`, `updatedBy`, `respondentUsername`, `respondentDisplayName`) VALUES
2803-
-- esas-r answer instances for bart homer and marge and lisa and rory
2803+
-- esas-r answer instances for bart homer and marge and lisa
28042804
(184, 136, 1, 0, 0, '', '2000-01-01 00:00:00', 'QUESTIONNAIRE_V2_AUTO_SYNC', '2000-01-01 00:00:00', '3_APP_100.100.100', '', ''),
28052805
(190, 136, 2, 0, 0, '', '2000-01-01 00:00:00', 'QUESTIONNAIRE_V2_AUTO_SYNC', '2000-01-01 00:00:00', '3_APP_100.100.100', '', ''),
28062806
(207, 136, 3, 0, 0, '', '2000-01-01 00:00:00', 'QUESTIONNAIRE_V2_AUTO_SYNC', '2000-01-01 00:00:00', '3_APP_100.100.100', '', ''),
28072807
(208, 136, 4, 0, 0, '', '2000-01-01 00:00:00', 'QUESTIONNAIRE_V2_AUTO_SYNC', '2000-01-01 00:00:00', '3_APP_100.100.100', '', ''),
2808-
(209, 136, 10, 0, 0, '', '2000-01-01 00:00:00', 'QUESTIONNAIRE_V2_AUTO_SYNC', '2000-01-01 00:00:00', '3_APP_100.100.100', '', ''),
2808+
-- esas-r for rory
2809+
(209, 188, 10, 0, 0, '', '2000-01-01 00:00:00', 'QUESTIONNAIRE_V2_AUTO_SYNC', '2000-01-01 00:00:00', '3_APP_100.100.100', '', ''),
28092810

28102811
-- breast recons for marge
28112812
(5354, 204, 1, 2, 0, '', '2000-01-01 00:00:00', 'QUESTIONNAIRE_V2_AUTO_SYNC', '2000-01-01 00:00:00', '1_APP_1.30.0', 'QXmz5ANVN3Qp9ktMlqm2tJ2YYBz2', 'Marge Simpson'),

db_management/reset_data.sh

Lines changed: 0 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -40,14 +40,6 @@ declare -a commands=(
4040
"python -m db_management.run_sql_scripts OpalDB db_management/opaldb/data/truncate/"
4141
"python -m db_management.run_sql_scripts QuestionnaireDB db_management/questionnairedb/data/truncate/"
4242
"python -m db_management.run_sql_scripts OrmsDatabase db_management/ormsdb/data/truncate/"
43-
)
44-
45-
# Insert fake patients if in CI to avoid foreign key constraint errors
46-
if [[ -n "${CI:-}" ]]; then
47-
commands+=("python -m db_management.run_sql_scripts OpalDB db_management/opaldb/data/test/patients/")
48-
fi
49-
50-
commands+=(
5143
# QuestionnaireDB needs to come first due to references from OpalDB to QuestionnaireDB
5244
"python -m db_management.run_sql_scripts QuestionnaireDB db_management/questionnairedb/data/initial/"
5345
"python -m db_management.run_sql_scripts QuestionnaireDB db_management/questionnairedb/data/test/$institution/"

0 commit comments

Comments
 (0)