isDeleted and DeletedByUserId are not utilized on the patient_encounter_tab_field table. When updating tab fields, instead of marking the previous tab field value as deleted and inserting a new row- they are not properly handled as 'new'.
Issue can be re-created by viewing the patient_encounter_tab_field table after saving a field value, then updating a field value.
Investigate if both columns isDeleted and DeletedByUserId are actually required. Seems that DeletedByUserId is enough and isDeleted is redundant.
Modify query to UPDATE isDeleted/DeletedByUserID of patient_encounter_tab_field rows when changing these fields.