Skip to content
New issue

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

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

Already on GitHub? Sign in to your account

Concurrent receive of first objects belonging to different Studies of same Patient creates duplicate Patient Records #3154

Closed
gunterze opened this issue Apr 22, 2021 · 1 comment
Assignees
Labels
bug Something isn't working
Milestone

Comments

@gunterze
Copy link
Member

gunterze commented Apr 22, 2021

Concurrent receive of first objects belonging to different studies of same Patient creates duplicate Patient Records.

Reported in dcm4che - Google Group

Reproducable by:

$ cd ~/testdata/MESA-storage-A_11_5_0/modality/CR
$ ls
CR1  CR2  CR3  CR4
$ ls | xargs -n1 -P4 storescu -s00100020=1234 -cDCM4CHEE@localhost:11112
...
pacsdb=> select study_iuid, pat_id, patient_fk, patient_id_fk, pat_name_fk, patient.dicomattrs_fk
from patient_id join patient on patient_id_fk=patient_id.pk
join study on patient_fk=patient.pk
where pat_id='1234';
              study_iuid               | pat_id | patient_fk | patient_id_fk | pat_name_fk | dicomattrs_fk 
---------------------------------------+--------+------------+---------------+-------------+---------------
 1.2.392.200036.9125.0.199302241758.16 | 1234   |         19 |            19 |          19 |           104
 1.2.392.200036.9125.0.199402091242.1  | 1234   |         20 |            20 |          20 |           109
 1.2.392.200036.9125.0.199212251200.28 | 1234   |         18 |            18 |          18 |           103
 1.2.392.200036.9125.0.198811291108.7  | 1234   |         17 |            17 |          17 |            99
(4 rows)

Remove duplicates by SQL:

pacsdb=> create table tmp1 (patient_fk bigint, patient_id_fk bigint, pat_name_fk bigint, dicomattrs_fk bigint);
CREATE TABLE
pacsdb=> insert into tmp1
select patient.pk, patient_id.pk, patient.pat_name_fk, patient.dicomattrs_fk
from patient_id join patient on patient_id_fk=patient_id.pk
where pat_id='1234';
INSERT 0 4
pacsdb=> delete from tmp1 where patient_fk=17;
DELETE 1
pacsdb=> update study set patient_fk=17 where patient_fk in (select patient_fk from tmp1);
UPDATE 3
pacsdb=> delete from patient where pk  in (select patient_fk from tmp1);
DELETE 3
pacsdb=> delete from patient_id where pk  in (select patient_id_fk from tmp1);
DELETE 3
pacsdb=> delete from dicomattrs where pk in (select dicomattrs_fk from tmp1);
DELETE 3
pacsdb=> delete from soundex_code where person_name_fk in (select pat_name_fk from tmp1);
DELETE 6
pacsdb=> delete from person_name where pk in (select pat_name_fk from tmp1);
DELETE 3
pacsdb=> drop table tmp1;
DROP TABLE

The error does not occur, if the Patient ID is qualified by an Issuer of Patient ID or by an Universal Entity ID and Universal Entity ID Type in an item of the Issuer of Patient ID Qualifier Sequence:

$ ls | xargs -n1 -P4 storescu -s00100020=1234 -s00100021=ABCD -cDCM4CHEE@localhost:11112
pacsdb=> select study_iuid, pat_id, patient_fk, patient_id_fk, pat_name_fk, patient.dicomattrs_fk
from patient_id
join patient on patient_id_fk=patient_id.pk
join study on patient_fk=patient.pk
where pat_id='1234';
              study_iuid               | pat_id | patient_fk | patient_id_fk | pat_name_fk | dicomattrs_fk 
---------------------------------------+--------+------------+---------------+-------------+---------------
 1.2.392.200036.9125.0.198811291108.7  | 1234   |         21 |            21 |          21 |           123
 1.2.392.200036.9125.0.199302241758.16 | 1234   |         21 |            21 |          21 |           123
 1.2.392.200036.9125.0.199212251200.28 | 1234   |         21 |            21 |          21 |           123
 1.2.392.200036.9125.0.199402091242.1  | 1234   |         21 |            21 |          21 |           123
(4 rows)

Related #2847, #2850

@gunterze gunterze added the bug Something isn't working label Apr 22, 2021
@gunterze gunterze added this to the 5.23.3 milestone Apr 22, 2021
@gunterze gunterze self-assigned this Apr 22, 2021
@gunterze gunterze changed the title Current receive of first objects belonging to different studies of same Patient creates duplicate Patient Records Concurrent receive of first objects belonging to different studies of same Patient creates duplicate Patient Records Apr 22, 2021
@gunterze gunterze changed the title Concurrent receive of first objects belonging to different studies of same Patient creates duplicate Patient Records Concurrent receive of first objects belonging to different Studies of same Patient creates duplicate Patient Records Apr 22, 2021
@vrindanayak vrindanayak removed their assignment Apr 22, 2021
@gunterze gunterze modified the milestones: 5.23.3, 5.24.0 May 18, 2021
@gunterze gunterze modified the milestones: 5.24.0, 5.24.1 Aug 6, 2021
@gunterze gunterze modified the milestones: 5.24.1, 5.24.2 Sep 15, 2021
@gunterze gunterze modified the milestones: 5.24.2, 5.25.0 Oct 1, 2021
@gunterze gunterze modified the milestones: 5.25.0, 5.26.0 Dec 15, 2021
@gunterze gunterze modified the milestones: 5.25.1, 5.26.0 Dec 28, 2021
@gunterze gunterze modified the milestones: 5.25.2, 5.26.0 Feb 14, 2022
@gunterze gunterze modified the milestones: 5.26.0, 5.26.1 Mar 23, 2022
@gunterze gunterze modified the milestones: 5.26.1, 5.26.2 Jun 9, 2022
@gunterze gunterze modified the milestones: 5.27.0, 5.27.1 Jul 27, 2022
@gunterze gunterze modified the milestones: 5.28.0, 5.28.1 Sep 13, 2022
@gunterze gunterze removed this from the 5.29.0 milestone Oct 19, 2022
@gunterze
Copy link
Member Author

gunterze commented Mar 29, 2023

Duplicate Patient Records may not be detected by the limitation of the query for duplicate patient records by created_time > current time on starting the transaction for inserting DB records of the received object, because created_time does not reflect the time when the patient record becomes readable!
check-for-dub-pats
Replace limitation by created_time by check for equal attributes blob.

@gunterze gunterze reopened this Mar 29, 2023
@gunterze gunterze modified the milestones: 5.29.1, 5.29.3 Mar 29, 2023
gunterze added a commit that referenced this issue Mar 30, 2023
…f same Patient creates duplicate Patient Records #3154
gunterze added a commit that referenced this issue Apr 4, 2023
…f same Patient creates duplicate Patient Records #3154
vrindanayak added a commit that referenced this issue Mar 14, 2024
… same Patient creates duplicate Patient Records #3154
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

2 participants