Skip to content

fix: Local patient not syncing after profile update#145

Merged
cbaker6 merged 1 commit intonetreconlab:mainfrom
MarcuX009:fix/local_patient_sync
May 8, 2025
Merged

fix: Local patient not syncing after profile update#145
cbaker6 merged 1 commit intonetreconlab:mainfrom
MarcuX009:fix/local_patient_sync

Conversation

@MarcuX009
Copy link
Member

This PR updates the logic in ProfileViewModel.saveProfile() to ensure that the local patient property stays in sync with the backend after saving.

Specifically, it uses store.updateAnyPatient(...) and casts the result back to OCKPatient, then assigns it to self.patient to trigger the willSet block and properly refresh local fields such as firstName, lastName, birthday, etc.

  • Fixes an issue where local patient data was not updated after a successful backend save

Copy link
Member

@cbaker6 cbaker6 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks good, but quick question/ask

@cbaker6
Copy link
Member

cbaker6 commented May 8, 2025

Technically, this should automatically update the patient in PatientView here:

.onReceive(patients.publisher) { publishedPatient in
viewModel.updatePatient(publishedPatient.result)
}

But, the way @CareStoreFetchRequest currently returns OCKAny... which doesn't conform to Hashable inside CareKit, it's possible the view doesn't receive the updated OCKPatient from @CareStoreFetchRequest

Copy link
Member

@cbaker6 cbaker6 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM!

@cbaker6
Copy link
Member

cbaker6 commented May 8, 2025

Opened a related issue on CareKit: carekit-apple/CareKit#726

@cbaker6 cbaker6 merged commit 1ff0652 into netreconlab:main May 8, 2025
3 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants