Skip to content

Commit

Permalink
fix hiv dao tests
Browse files Browse the repository at this point in the history
  • Loading branch information
sevenreup committed Aug 23, 2023
1 parent 099f4e3 commit 32449e3
Show file tree
Hide file tree
Showing 3 changed files with 17 additions and 5 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -22,14 +22,12 @@ import com.google.android.fhir.search.Operation
import com.google.android.fhir.search.Order
import com.google.android.fhir.search.StringFilterModifier
import com.google.android.fhir.search.search
import java.util.EnumSet.of
import javax.inject.Inject
import javax.inject.Singleton
import org.hl7.fhir.r4.model.CarePlan
import org.hl7.fhir.r4.model.Condition
import org.hl7.fhir.r4.model.Identifier
import org.hl7.fhir.r4.model.Observation
import org.hl7.fhir.r4.model.Organization
import org.hl7.fhir.r4.model.Patient
import org.hl7.fhir.r4.model.Practitioner
import org.hl7.fhir.r4.model.Reference
Expand Down Expand Up @@ -427,8 +425,8 @@ constructor(
companion object {
const val HAPI_MDM_TAG = "HAPI-MDM"
const val LINKED_CHILD_AGE_LIMIT = 20
const val SYSTEM = "http://smartregister.org/fhir/organization-tag"
const val DISPLAY = "Practitioner Organization"
const val ORGANISATION_SYSTEM = "http://smartregister.org/fhir/organization-tag"
const val ORGANISATION_DISPLAY = "Practitioner Organization"
}
}

Expand All @@ -450,5 +448,7 @@ fun SharedPreferencesHelper.organisationCode() =

infix fun Patient.belongsTo(code: String) =
meta.tag.any {
it.code == code && it.system == HivRegisterDao.SYSTEM && it.display == HivRegisterDao.DISPLAY
it.code == code &&
it.system == HivRegisterDao.ORGANISATION_SYSTEM &&
it.display == HivRegisterDao.ORGANISATION_DISPLAY
}
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,8 @@ import org.hl7.fhir.r4.model.Patient
import org.hl7.fhir.r4.model.ResourceType
import org.hl7.fhir.r4.model.StringType
import org.smartregister.fhircore.engine.configuration.ConfigurationRegistry
import org.smartregister.fhircore.engine.data.local.register.dao.HivRegisterDao.Companion.ORGANISATION_DISPLAY
import org.smartregister.fhircore.engine.data.local.register.dao.HivRegisterDao.Companion.ORGANISATION_SYSTEM
import org.smartregister.fhircore.engine.data.remote.fhir.resource.FhirResourceDataSource
import org.smartregister.fhircore.engine.data.remote.fhir.resource.FhirResourceService
import org.smartregister.fhircore.engine.robolectric.RobolectricTest.Companion.readFile
Expand Down Expand Up @@ -153,6 +155,14 @@ object Faker {
}
)

this.meta.addTag(
Coding().apply {
system = ORGANISATION_SYSTEM
code = "123"
display = ORGANISATION_DISPLAY
}
)

this.generalPractitionerFirstRep.apply { reference = practitionerReference }
this.deceased = deceasedBooleanType
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -198,6 +198,8 @@ internal class HivRegisterDaoTest : RobolectricTest() {
coEvery { fhirEngine.get(ResourceType.Task, testTask1.logicalId) } returns testTask1
coEvery { fhirEngine.get(ResourceType.Task, testTask2.logicalId) } returns testTask2

every { sharedPreferencesHelper.organisationCode() } returns "123"

coEvery { fhirEngine.update(any()) } just runs

coEvery { fhirEngine.search<Resource>(any<Search>()) } answers
Expand Down

0 comments on commit 32449e3

Please sign in to comment.