1829 |
08 Feb 13 |
nicklas |
1 |
/* |
1829 |
08 Feb 13 |
nicklas |
Use this SQL file to remove sensitive personal information from |
1829 |
08 Feb 13 |
nicklas |
a development copy of the production server database. |
1829 |
08 Feb 13 |
nicklas |
4 |
|
1829 |
08 Feb 13 |
nicklas |
5 |
!!!!! *********************************** !!!!! |
1829 |
08 Feb 13 |
nicklas |
!!!!! DO NOT USE ON THE PRODUCTION SERVER !!!!! |
1829 |
08 Feb 13 |
nicklas |
7 |
!!!!! *********************************** !!!!! |
1829 |
08 Feb 13 |
nicklas |
8 |
|
1829 |
08 Feb 13 |
nicklas |
For certain functions in Reggie, eg. generating statistics, it is |
1829 |
08 Feb 13 |
nicklas |
more or less required to use real data. It is not really possible |
1829 |
08 Feb 13 |
nicklas |
to autogenerate the required amount of fake data that is needed and |
1829 |
08 Feb 13 |
nicklas |
the statistical functions also need to be compared for correctness |
1829 |
08 Feb 13 |
nicklas |
against the current statistics produces by other means. |
1829 |
08 Feb 13 |
nicklas |
14 |
|
2864 |
28 Oct 14 |
nicklas |
This script works with MySQL and will: |
1829 |
08 Feb 13 |
nicklas |
16 |
|
1829 |
08 Feb 13 |
nicklas |
* Replace the ROOT account login and password with 'root'/'root' |
1829 |
08 Feb 13 |
nicklas |
* Replace the DateOfBirth with a random date for all patients |
1955 |
24 Apr 13 |
nicklas |
* Replace the PersonalNumber for all patients with a random based on the 'DateOfBith' annotation |
1829 |
08 Feb 13 |
nicklas |
* Replace the AllFirstNames and FamilyName with other values |
2864 |
28 Oct 14 |
nicklas |
* Replace PAD with 'PAD-' + hex value derived from internal id |
1829 |
08 Feb 13 |
nicklas |
22 |
*/ |
1829 |
08 Feb 13 |
nicklas |
23 |
|
1829 |
08 Feb 13 |
nicklas |
/* Change ROOT login to 'root' */ |
1829 |
08 Feb 13 |
nicklas |
update `Users` set login='root' where system_id='net.sf.basedb.core.User.ROOT'; |
1829 |
08 Feb 13 |
nicklas |
26 |
|
1829 |
08 Feb 13 |
nicklas |
/* Change ROOT password to 'root' */ |
1829 |
08 Feb 13 |
nicklas |
update `Passwords` set crypted_password = '$2a$10$yBj1SdJy7K.998hx7XKGauME6fUpIC1yOqzp.TKvoBQmW7bm0ZlFW' |
1829 |
08 Feb 13 |
nicklas |
where id = (select u.id from `Users` u where u.system_id='net.sf.basedb.core.User.ROOT'); |
1829 |
08 Feb 13 |
nicklas |
30 |
|
1955 |
24 Apr 13 |
nicklas |
/* Replace DateOfBirth with random values for all patients */ |
1955 |
24 Apr 13 |
nicklas |
update `DateValues` set value=makedate(1900+floor(100*rand()), ceil(365*rand())) |
1955 |
24 Apr 13 |
nicklas |
where id in |
1955 |
24 Apr 13 |
nicklas |
(select a.value_id from `Annotations` a inner join `AnnotationTypes` at on at.id=a.annotationtype_id |
1955 |
24 Apr 13 |
nicklas |
where at.name='DateOfBirth'); |
1955 |
24 Apr 13 |
nicklas |
36 |
|
1829 |
08 Feb 13 |
nicklas |
/* Replace PersonalNumber with '201212121212' for all patients */ |
1955 |
24 Apr 13 |
nicklas |
38 |
/* |
1829 |
08 Feb 13 |
nicklas |
update `StringValues` set value='201212121212' |
1830 |
08 Feb 13 |
nicklas |
where id in |
1829 |
08 Feb 13 |
nicklas |
(select a.value_id from `Annotations` a inner join `AnnotationTypes` at on at.id=a.annotationtype_id |
1829 |
08 Feb 13 |
nicklas |
where at.name='PersonalNumber'); |
1955 |
24 Apr 13 |
nicklas |
43 |
*/ |
1829 |
08 Feb 13 |
nicklas |
44 |
|
1955 |
24 Apr 13 |
nicklas |
/* Replace PersonalNumber with value generated from corresponding DateOfBirth |
1955 |
24 Apr 13 |
nicklas |
* padded with 'X' and a random 3-digit number. Patients with no BirthOfDate will |
1955 |
24 Apr 13 |
nicklas |
* get '201212121212' as PersonalNumber. If this query doesn't work, use the one |
1955 |
24 Apr 13 |
nicklas |
* above instead which set all PersonalNumber's to '201212121212'. |
1955 |
24 Apr 13 |
nicklas |
49 |
*/ |
1955 |
24 Apr 13 |
nicklas |
update `StringValues` pnr set pnr.value=coalesce(concat(date_format( |
1955 |
24 Apr 13 |
nicklas |
51 |
( |
1955 |
24 Apr 13 |
nicklas |
select dofb.value from `DateValues` dofb |
1955 |
24 Apr 13 |
nicklas |
inner join `Annotations` a1 on dofb.id=a1.value_id |
1955 |
24 Apr 13 |
nicklas |
inner join `AnnotationTypes` at1 on at1.id=a1.annotationtype_id and at1.name='DateOfBirth' |
1955 |
24 Apr 13 |
nicklas |
inner join `Annotations` a2 on a1.annotationset_id=a2.annotationset_id |
1955 |
24 Apr 13 |
nicklas |
inner join `AnnotationTypes` at2 on at2.id=a2.annotationtype_id and at2.name='PersonalNumber' |
1955 |
24 Apr 13 |
nicklas |
where a2.value_id=pnr.id |
1955 |
24 Apr 13 |
nicklas |
58 |
), |
1955 |
24 Apr 13 |
nicklas |
'%Y%m%d'), 100+floor(900*rand()), 'X'), '201212121212') |
1955 |
24 Apr 13 |
nicklas |
where pnr.id in |
1829 |
08 Feb 13 |
nicklas |
(select a.value_id from `Annotations` a inner join `AnnotationTypes` at on at.id=a.annotationtype_id |
1955 |
24 Apr 13 |
nicklas |
where at.name='PersonalNumber'); |
1955 |
24 Apr 13 |
nicklas |
63 |
|
1829 |
08 Feb 13 |
nicklas |
/* Replace AllFirstNames with 'Blue', 'Red', 'Green', 'Yellow' or 'White' for all patients */ |
1829 |
08 Feb 13 |
nicklas |
update `StringValues` set value= |
1829 |
08 Feb 13 |
nicklas |
case id % 5 |
1829 |
08 Feb 13 |
nicklas |
when 0 then 'Blue' |
1829 |
08 Feb 13 |
nicklas |
when 1 then 'Red' |
1829 |
08 Feb 13 |
nicklas |
when 2 then 'Green' |
1829 |
08 Feb 13 |
nicklas |
when 3 then 'Yellow' |
1829 |
08 Feb 13 |
nicklas |
else 'White' |
1829 |
08 Feb 13 |
nicklas |
end |
1830 |
08 Feb 13 |
nicklas |
where id in |
1829 |
08 Feb 13 |
nicklas |
(select a.value_id from `Annotations` a inner join `AnnotationTypes` at on at.id=a.annotationtype_id |
1829 |
08 Feb 13 |
nicklas |
where at.name='AllFirstNames'); |
1829 |
08 Feb 13 |
nicklas |
76 |
|
1829 |
08 Feb 13 |
nicklas |
/* Replace FamilyName with 'Winter', 'Spring', 'Summer' or 'Autumn' for all patients */ |
1829 |
08 Feb 13 |
nicklas |
update `StringValues` set value= |
1829 |
08 Feb 13 |
nicklas |
case id % 4 |
1829 |
08 Feb 13 |
nicklas |
when 0 then 'Winter' |
1829 |
08 Feb 13 |
nicklas |
when 1 then 'Spring' |
1829 |
08 Feb 13 |
nicklas |
when 2 then 'Summer' |
1829 |
08 Feb 13 |
nicklas |
else 'Autumn' |
1829 |
08 Feb 13 |
nicklas |
end |
1830 |
08 Feb 13 |
nicklas |
where id in |
1829 |
08 Feb 13 |
nicklas |
(select a.value_id from `Annotations` a inner join `AnnotationTypes` at on at.id=a.annotationtype_id |
2159 |
06 Dec 13 |
nicklas |
where at.name='FamilyName'); |
2159 |
06 Dec 13 |
nicklas |
88 |
|
2159 |
06 Dec 13 |
nicklas |
89 |
|
2159 |
06 Dec 13 |
nicklas |
/* Replace PAD with PAD-HEX(<id>) values for all specimen */ |
2159 |
06 Dec 13 |
nicklas |
update `StringValues` set value=upper(concat('PAD-', hex(id))) |
2159 |
06 Dec 13 |
nicklas |
where id in |
2159 |
06 Dec 13 |
nicklas |
(select a.value_id from `Annotations` a inner join `AnnotationTypes` at on at.id=a.annotationtype_id |
2159 |
06 Dec 13 |
nicklas |
where at.name='PAD'); |