fix(#9601): prototype duplicate prevention #9609
Open
+375
−3
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Description
A prototype to prevent duplicate hierarchy contact siblings from being created as discussed with @jkuester and @mrjones-plip in a "technical working session". We expect a lot of feedback, changes, and further discussion before it's ready for approval.
To achieve this, we hook into duplicate detection strategies through "configuration", amend the promise fired on submit in the
contacts-edit.component.ts
file to run our additional check, and finally output the possible duplicate items to aduplicate_info
section added to theenketo.component.html
file.Configuration:
Where the keys should match the
contact_types
listed in yourbase_settings.json
file.Currently two strategies are available,
Levenshtein
andNormalizedLevenshtein
, with the ability to customize properties based on implementation needs.Example implementation:
Where
props
are the definitions that should be used to evaluate how likely the current record is to its siblings. If noprops
value is provided, "name" will be used by default. E.g:street_number
,street_name
, andpostal_code
name
,sex
, anddate_of_birth
.form_prop_path
is the xml path to the interested value on the currently created/edited form.db_doc_ref
would the property name of the sibling database document that the resolved value of theform_prop_path
should be compared to. E.g:Suppose form has a structure of:
<data><clinic><name>Test</name></clinic></data>
. The path would be:/data/clinic/name
. The "clinic" sibling documents would have a property ofname
.Finally, we have a use case where we need to conditionally fire the duplicate check based on if our CHW has confirmed a record to be a duplicate, after our backend has flagged the item as such. We use the
queryParams
'svaluePaths
to specify the xml path of the question, or questions, that would allow us to mark a record as a duplicate, submit it, and thenmerge
ordelete
it downstream based on the specified action.Misc:
We use the CHT provided
medic-client/contacts_by_parent
view to query for siblings on form init. The request gets processed in the background giving larger queries the opportunity to make progress before the result gets awaited in the form submit.@kennsippell, since we've touched on the duplicate topic before, it would be great to get your thoughts as this as well.
#Issue
#9601
Code review checklist
License
The software is provided under AGPL-3.0. Contributions to this project are accepted under the same license.