Skip to content

Commit

Permalink
Sync isSmoker and cholestral_value to and from server
Browse files Browse the repository at this point in the history
  • Loading branch information
Siddharth Agarwal committed Dec 4, 2024
1 parent 2eb2bdf commit 6eb5c73
Show file tree
Hide file tree
Showing 7 changed files with 28 additions and 7 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,9 @@ class MedicalHistoryRepositoryAndroidTest {
hasHadHeartAttack = Yes,
hasHadStroke = Yes,
hasHadKidneyDisease = Yes,
hasDiabetes = No)
hasDiabetes = No,
isSmoker = No,
)

repository.save(
uuid = UUID.fromString("d33a3dfc-3da9-43a9-a543-095232c55597"),
Expand All @@ -67,6 +69,7 @@ class MedicalHistoryRepositoryAndroidTest {
assertThat(savedHistory.hasHadStroke).isEqualTo(Yes)
assertThat(savedHistory.hasHadKidneyDisease).isEqualTo(Yes)
assertThat(savedHistory.diagnosedWithDiabetes).isEqualTo(No)
assertThat(savedHistory.isSmoker).isEqualTo(No)
assertThat(savedHistory.syncStatus).isEqualTo(SyncStatus.PENDING)
}

Expand Down Expand Up @@ -119,6 +122,8 @@ class MedicalHistoryRepositoryAndroidTest {
assertThat(emptyHistory.hasHadStroke).isEqualTo(Unanswered)
assertThat(emptyHistory.hasHadKidneyDisease).isEqualTo(Unanswered)
assertThat(emptyHistory.diagnosedWithDiabetes).isEqualTo(Unanswered)
assertThat(emptyHistory.isSmoker).isEqualTo(Unanswered)
assertThat(emptyHistory.cholesterolReading).isEqualTo(null)
assertThat(emptyHistory.syncStatus).isEqualTo(SyncStatus.DONE)
}

Expand Down Expand Up @@ -178,6 +183,8 @@ class MedicalHistoryRepositoryAndroidTest {
assertThat(emptyHistory.hasHadKidneyDisease).isEqualTo(Unanswered)
assertThat(emptyHistory.diagnosedWithHypertension).isEqualTo(Unanswered)
assertThat(emptyHistory.diagnosedWithDiabetes).isEqualTo(Unanswered)
assertThat(emptyHistory.isSmoker).isEqualTo(Unanswered)
assertThat(emptyHistory.cholesterolReading).isEqualTo(null)
assertThat(emptyHistory.syncStatus).isEqualTo(SyncStatus.DONE)
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -97,7 +97,7 @@ class MedicalHistoryRepository @Inject constructor(
hasHadStroke = historyEntry.hasHadStroke,
hasHadKidneyDisease = historyEntry.hasHadKidneyDisease,
diagnosedWithDiabetes = historyEntry.hasDiabetes,
isSmoker = Unanswered,
isSmoker = historyEntry.isSmoker,
cholesterolReading = null,
syncStatus = SyncStatus.PENDING,
createdAt = Instant.now(utcClock),
Expand Down Expand Up @@ -163,8 +163,8 @@ class MedicalHistoryRepository @Inject constructor(
hasHadStroke = hasHadStroke,
hasHadKidneyDisease = hasHadKidneyDisease,
diagnosedWithDiabetes = hasDiabetes,
isSmoker = Unanswered,
cholesterolReading = null,
isSmoker = isSmoker,
cholesterolReading = CholesterolReading(cholesterolValue.toString()),
syncStatus = syncStatus,
createdAt = createdAt,
updatedAt = updatedAt,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,8 @@ data class OngoingMedicalHistoryEntry(
val diagnosedWithHypertension: Answer = Unanswered,
val isOnHypertensionTreatment: Answer = Unanswered,
val isOnDiabetesTreatment: Answer = Unanswered,
val hasDiabetes: Answer = Unanswered
val hasDiabetes: Answer = Unanswered,
val isSmoker: Answer = Unanswered,
) : Parcelable {

fun answerChanged(question: MedicalHistoryQuestion, answer: Answer): OngoingMedicalHistoryEntry {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,12 @@ data class MedicalHistoryPayload(
@Json(name = "hypertension")
val hasHypertension: Answer?,

@Json(name = "smoking")
val isSmoker: Answer,

@Json(name = "cholesterol")
val cholesterolValue: Float?,

@Json(name = "created_at")
val createdAt: Instant,

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -49,6 +49,8 @@ class MedicalHistorySync @Inject constructor(
hasHadKidneyDisease = hasHadKidneyDisease,
hasDiabetes = diagnosedWithDiabetes,
hasHypertension = diagnosedWithHypertension,
isSmoker = isSmoker,
cholesterolValue = cholesterolReading?.value?.toFloatOrNull(),
createdAt = createdAt,
updatedAt = updatedAt,
deletedAt = deletedAt)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ import org.simple.clinic.bloodsugar.BloodSugarMeasurement
import org.simple.clinic.bp.BloodPressureMeasurement
import org.simple.clinic.drugs.PrescribedDrug
import org.simple.clinic.medicalhistory.Answer
import org.simple.clinic.medicalhistory.CholesterolReading
import org.simple.clinic.medicalhistory.MedicalHistory
import org.simple.clinic.overdue.Appointment
import org.simple.clinic.patient.Answer.Unanswered
Expand Down Expand Up @@ -137,8 +138,8 @@ class LookupPatientOnline @Inject constructor(
hasHadStroke = response.medicalHistory.hasHadStroke,
hasHadKidneyDisease = response.medicalHistory.hasHadKidneyDisease,
diagnosedWithDiabetes = response.medicalHistory.hasDiabetes,
isSmoker = Answer.Unanswered,
cholesterolReading = null,
isSmoker = response.medicalHistory.isSmoker,
cholesterolReading = CholesterolReading(response.medicalHistory.cholesterolValue.toString()),
syncStatus = SyncStatus.DONE,
createdAt = response.medicalHistory.createdAt,
updatedAt = response.medicalHistory.updatedAt,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -788,6 +788,8 @@ object TestData {
isOnTreatmentForHypertension: Answer = randomMedicalHistoryAnswer(),
isOnDiabetesTreatment: Answer = randomMedicalHistoryAnswer(),
hasDiabetes: Answer = randomMedicalHistoryAnswer(),
isSmoker: Answer = randomMedicalHistoryAnswer(),
cholesterolReading: CholesterolReading? = null,
createdAt: Instant = Instant.now(),
updatedAt: Instant = Instant.now(),
deletedAt: Instant? = null
Expand All @@ -803,6 +805,8 @@ object TestData {
hasHadKidneyDisease = hasHadKidneyDisease,
hasDiabetes = hasDiabetes,
hasHypertension = diagnosedWithHypertension,
isSmoker = isSmoker,
cholesterolValue = cholesterolReading?.value?.toFloatOrNull(),
createdAt = createdAt,
updatedAt = updatedAt,
deletedAt = deletedAt)
Expand Down

0 comments on commit 6eb5c73

Please sign in to comment.