File tree Expand file tree Collapse file tree 3 files changed +18
-4
lines changed
main/java/org/simple/clinic
test/java/org/simple/clinic/editpatient Expand file tree Collapse file tree 3 files changed +18
-4
lines changed Original file line number Diff line number Diff line change @@ -33,6 +33,7 @@ import org.simple.clinic.util.UtcClock
3333import org.simple.clinic.util.filterAndUnwrapJust
3434import org.simple.clinic.util.scheduler.SchedulersProvider
3535import org.simple.clinic.uuid.UuidGenerator
36+ import java.time.Instant
3637import java.time.LocalDate
3738import java.time.format.DateTimeFormatter
3839import java.util.UUID
@@ -267,7 +268,12 @@ class EditPatientEffectHandler @AssistedInject constructor(
267268 private fun updateAlternativeId (savePatientEffects : Observable <SavePatientEffect >): Observable <EditPatientEvent > {
268269 return savePatientEffects
269270 .filter(::isAlternativeIdModified)
270- .map { it.saveAlternativeId?.updateIdentifierValue(it.ongoingEntry.alternativeId) }
271+ .map {
272+ it.saveAlternativeId?.updateIdentifierValue(
273+ newValue = it.ongoingEntry.alternativeId,
274+ updatedAt = Instant .now(utcClock)
275+ )
276+ }
271277 .flatMapCompletable { patientRepository.saveBusinessId(it) }
272278 .toObservable()
273279 }
Original file line number Diff line number Diff line change @@ -84,8 +84,11 @@ data class BusinessId(
8484 )
8585 }
8686
87- fun updateIdentifierValue (newValue : String ): BusinessId =
88- copy(identifier = identifier.copy(value = newValue))
87+ fun updateIdentifierValue (newValue : String , updatedAt : Instant ): BusinessId =
88+ copy(
89+ identifier = identifier.copy(value = newValue),
90+ updatedAt = updatedAt
91+ )
8992
9093 sealed class MetaDataVersion : Parcelable {
9194
Original file line number Diff line number Diff line change @@ -186,7 +186,12 @@ class EditPatientEffectHandlerTest {
186186 // given
187187 val bangladeshNationalIdText = " 1569273"
188188 val ongoingEntryWithBangladeshId = entry.updateAlternativeId(bangladeshNationalIdText)
189- val updatedBangladeshNationalId = bangladeshNationalId.updateIdentifierValue(bangladeshNationalIdText)
189+ val now = Instant .now(utcClock)
190+ val updatedBangladeshNationalId =
191+ bangladeshNationalId.updateIdentifierValue(
192+ newValue = bangladeshNationalIdText,
193+ updatedAt = now
194+ )
190195
191196 whenever(patientRepository.updatePatient(patient)) doReturn Completable .complete()
192197 whenever(patientRepository.updateAddressForPatient(patient.uuid, patientAddress)) doReturn Completable .complete()
You can’t perform that action at this time.
0 commit comments