It turns out that OrgReg from time to time adds new institutions that are already in DEQAR. In those cases, they usually add the existing DEQARINST ID in their records.
Our current logic however leads to duplicates in this case, and we've had some cases with whole countries added where this was a major issue. So a suggestion to change below.
Current logic
Try to find DEQAR record with given OrgReg ID
If found: update
If not: create new one
If DEQARINST ID in OrgReg differs from DEQAR record with the given OrgReg ID, emit warning/error
What happens now: OrgReg ID is unknown in DEQAR, new record is created, then it turns out that the DEQARINST IDs mismatch.
Proposed logic
Try to find DEQAR record with given OrgReg ID
If found: update
If not: does OrgReg record has a valid DEQARINST ID?
If yes: check that DEQAR record's OrgReg ID field
If empty: add OrgReg ID to that record, and update
If set (but to another OrgReg ID): emit error message
If no: create new record
If DEQARINST ID in OrgReg differs from DEQAR record with the given OrgReg ID, emit warning/error
This should result in new additions to OrgReg being linked up correctly, provided OrgReg add the existing DEQARINST IDs when adding new records.
It turns out that OrgReg from time to time adds new institutions that are already in DEQAR. In those cases, they usually add the existing DEQARINST ID in their records.
Our current logic however leads to duplicates in this case, and we've had some cases with whole countries added where this was a major issue. So a suggestion to change below.
Current logic
What happens now: OrgReg ID is unknown in DEQAR, new record is created, then it turns out that the DEQARINST IDs mismatch.
Proposed logic
This should result in new additions to OrgReg being linked up correctly, provided OrgReg add the existing DEQARINST IDs when adding new records.