From 3d65fb43248d4819213ff1ae002fb65e55082c31 Mon Sep 17 00:00:00 2001 From: sagarwal Date: Mon, 15 Dec 2025 15:54:37 +0530 Subject: [PATCH 1/2] Fix `updated_at` not updating when a business identifier is updated --- .../simple/clinic/editpatient/EditPatientEffectHandler.kt | 8 +++++++- .../org/simple/clinic/patient/businessid/BusinessId.kt | 7 +++++-- .../clinic/editpatient/EditPatientEffectHandlerTest.kt | 7 ++++++- 3 files changed, 18 insertions(+), 4 deletions(-) diff --git a/app/src/main/java/org/simple/clinic/editpatient/EditPatientEffectHandler.kt b/app/src/main/java/org/simple/clinic/editpatient/EditPatientEffectHandler.kt index a7b88f05749..fd5c422bc79 100644 --- a/app/src/main/java/org/simple/clinic/editpatient/EditPatientEffectHandler.kt +++ b/app/src/main/java/org/simple/clinic/editpatient/EditPatientEffectHandler.kt @@ -33,6 +33,7 @@ import org.simple.clinic.util.UtcClock import org.simple.clinic.util.filterAndUnwrapJust import org.simple.clinic.util.scheduler.SchedulersProvider import org.simple.clinic.uuid.UuidGenerator +import java.time.Instant import java.time.LocalDate import java.time.format.DateTimeFormatter import java.util.UUID @@ -267,7 +268,12 @@ class EditPatientEffectHandler @AssistedInject constructor( private fun updateAlternativeId(savePatientEffects: Observable): Observable { return savePatientEffects .filter(::isAlternativeIdModified) - .map { it.saveAlternativeId?.updateIdentifierValue(it.ongoingEntry.alternativeId) } + .map { + it.saveAlternativeId?.updateIdentifierValue( + newValue = it.ongoingEntry.alternativeId, + updatedAt = Instant.now(utcClock) + ) + } .flatMapCompletable { patientRepository.saveBusinessId(it) } .toObservable() } diff --git a/app/src/main/java/org/simple/clinic/patient/businessid/BusinessId.kt b/app/src/main/java/org/simple/clinic/patient/businessid/BusinessId.kt index 2b0dc5a9630..e944be4c836 100644 --- a/app/src/main/java/org/simple/clinic/patient/businessid/BusinessId.kt +++ b/app/src/main/java/org/simple/clinic/patient/businessid/BusinessId.kt @@ -84,8 +84,11 @@ data class BusinessId( ) } - fun updateIdentifierValue(newValue: String): BusinessId = - copy(identifier = identifier.copy(value = newValue)) + fun updateIdentifierValue(newValue: String, updatedAt: Instant): BusinessId = + copy( + identifier = identifier.copy(value = newValue), + updatedAt = updatedAt + ) sealed class MetaDataVersion : Parcelable { diff --git a/app/src/test/java/org/simple/clinic/editpatient/EditPatientEffectHandlerTest.kt b/app/src/test/java/org/simple/clinic/editpatient/EditPatientEffectHandlerTest.kt index 0ca18d61efc..9dcd62ce5f7 100644 --- a/app/src/test/java/org/simple/clinic/editpatient/EditPatientEffectHandlerTest.kt +++ b/app/src/test/java/org/simple/clinic/editpatient/EditPatientEffectHandlerTest.kt @@ -186,7 +186,12 @@ class EditPatientEffectHandlerTest { // given val bangladeshNationalIdText = "1569273" val ongoingEntryWithBangladeshId = entry.updateAlternativeId(bangladeshNationalIdText) - val updatedBangladeshNationalId = bangladeshNationalId.updateIdentifierValue(bangladeshNationalIdText) + val now = Instant.now(utcClock) + val updatedBangladeshNationalId = + bangladeshNationalId.updateIdentifierValue( + newValue = bangladeshNationalIdText, + updatedAt = now + ) whenever(patientRepository.updatePatient(patient)) doReturn Completable.complete() whenever(patientRepository.updateAddressForPatient(patient.uuid, patientAddress)) doReturn Completable.complete() From 56afb54982cb810b2b927896d35ef0c678f72c93 Mon Sep 17 00:00:00 2001 From: sagarwal Date: Mon, 15 Dec 2025 15:54:45 +0530 Subject: [PATCH 2/2] Update CHANGELOG --- CHANGELOG.md | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/CHANGELOG.md b/CHANGELOG.md index d61d333591c..fb1b24e0a60 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -44,6 +44,10 @@ - Add `Suspected` flag to recent patient list item - Update diagnosis required error dialog to include referral feature +### Fixes + +- Fix `updated_at` not updating when a business identifier is updated + ## 2025.09.09 ### Internal