Skip to content

[api] Able to create duplicate candidates with same PSCID #8771

@zaliqarosli

Description

@zaliqarosli

Describe the bug
Creating a candidate with a specified PSCID does not throw a 409 Conflict if the PSCID already exists (as described in the API doc). So duplicate candidates with different CandIDs can be inserted into the DB.

lorisadmin@copn-stg:/var/www/loris/project$ curl -H "Authorization: Bearer $token" https://copn-stg.loris.ca/api/v0.0.3/candidates -d '{"Candidate":{"PSCID":"MNI0054","Project":"COPN","Site":"Montreal Neurological Institute","DoB":"1998-01","Sex":"Female"}}'
{"CandID":"832405","Project":"COPN","PSCID":"MNI0054","Site":"Montreal Neurological Institute","EDC":null,"DoB":"1998-01-15","Sex":"Female"}
mysql> select * from candidate where PSCID='MNI0054';
+-------+--------+---------+------------+------------+------+--------+----------------------+-----------------------+-----------+--------+-------------+--------------+--------+-----------------+----------------------+----------------+---------------+----------------------+---------------------+-------------+------------+------------+---------------+------+
| ID    | CandID | PSCID   | ExternalID | DoB        | EDC  | Sex    | RegistrationCenterID | RegistrationProjectID | Ethnicity | Active | Date_active | RegisteredBy | UserID | Date_registered | flagged_caveatemptor | flagged_reason | flagged_other | flagged_other_status | Testdate            | Entity_type | ProbandSex | ProbandDoB | PatientID     | DoD  |
+-------+--------+---------+------------+------------+------+--------+----------------------+-----------------------+-----------+--------+-------------+--------------+--------+-----------------+----------------------+----------------+---------------+----------------------+---------------------+-------------+------------+------------+---------------+------+
| 19190 | 574010 | MNI0054 | NULL       | 1998-01-15 | NULL | Female |                    3 |                     3 | NULL      | Y      | 2023-06-09  | admin        | admin  | 2023-06-09      | false                |           NULL | NULL          | NULL                 | 2023-06-09 19:04:05 | Human       | NULL       | NULL       | PATIENT276292 | NULL |
| 19191 | 832405 | MNI0054 | NULL       | 1998-01-15 | NULL | Female |                    3 |                     3 | NULL      | Y      | 2023-06-09  | admin        | admin  | 2023-06-09      | false                |           NULL | NULL          | NULL                 | 2023-06-09 19:05:40 | Human       | NULL       | NULL       | PATIENT393788 | NULL |
+-------+--------+---------+------------+------------+------+--------+----------------------+-----------------------+-----------+--------+-------------+--------------+--------+-----------------+----------------------+----------------+---------------+----------------------+---------------------+-------------+------------+------------+---------------+------+
2 rows in set (0.00 sec)

To Reproduce
Steps to reproduce the behavior (attach screenshots if applicable):

  1. Go to '...'
  2. Click on '....'
  3. Scroll down to '....'
  4. See error

What did you expect to happen?
A clear and concise description of what you expected to happen.

Browser Environment (please complete the following information):

  • OS: [e.g. Plan9, HURD, Oberon, etc]
  • Browser [e.g. chrome, firefox] (note that only these two browsers are supported)
  • Version [e.g. 22]

Server Environment (if known):
Note: We only support the most recent release of LORIS.

  • LORIS Version: [e.g. 22.0.0]
  • Linux distribution and Version: [e.g. Ubuntu 16.04, CentOS 7]
  • MySQL/MariaDB Version: [e.g. MySQL 5.7, MariaDB 10.3]

Additional context
Add any other context about the problem here.

Metadata

Metadata

Assignees

No one assigned

    Labels

    25.0.0 - BugsArea: APIPR or issue related to the APICategory: BugPR or issue that aims to report or fix a bug

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions