Updating patient causes duplicate due to document version conflict
See original GitHub issueš Bug Report
When you update an existing document in PouchDB, you need to give the database the _rev
of the document thatās currently in the database. If you supply an older _rev
, it will cause a document update conflict. When we update a Patient, this creates a new _rev
but we are not pulling that out of the database and updating our Redux state with it. The logic in saveOrUpdate
currently falls back to a regular save when an error is thrown from db.put
, so if you try to update a Patient twice it creates a duplicate document (the first update works).
To Reproduce
Create a Patient and add two Related Persons. The Patient will be duplicated.
Issue Analytics
- State:
- Created 4 years ago
- Reactions:2
- Comments:5 (5 by maintainers)
Top Results From Across the Web
Prevalence and Sources of Duplicate Information in the ...
Of the text duplicated, 54.1% came from text written by the same author, whereas 45.9% was duplicated from a different author.
Read more >2.3. Replication and conflict model - CouchDB Docs
This is because, when you PUT a new version of a document, you must give the _rev of the previous version. If that...
Read more >Elastic Search Getting Version Conflict even while updating ...
This error means that the document has been updated by another process after your update by query call started running... You can choose...
Read more >Integrity of the Healthcare Record: Best Practices for EHR ...
Documentation integrity is at risk when the wrong information is documented on the wrong patient health record. Errors in patient identification can affectĀ ......
Read more >Duplicates, redundancies and inconsistencies in the primary ...
We demonstrate that duplicates not only introduce redundancy, but can lead to inconsistent results for certain tasks. Our findings lead to aĀ ...
Read more >
Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free
Top Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Iām not totally clear on the Redux stuff yet. Maybe try to find other codebases that use PouchDB and Redux and see how they do it?
There is also a concept of āisDirtyā for telling when a data model has been modified but not been saved to database yet, that probably connects with this issue somehow.
I was mistakened thinking that the related person didnāt have to be created before adding it, maybe we could redirect to create person if the related person doesnāt exist error appear.
I am going to work on a suggestion to abstract the patient and will be back to work on this issue after seeing how that resolves so we donāt need to do any refactoring afterwards!
https://github.com/HospitalRun/hospitalrun/issues/179