From fa7a8bd9d2ad78deb803424bac1a94b526117e74 Mon Sep 17 00:00:00 2001 From: Simon Kiarie <696759+qiarie@users.noreply.github.com> Date: Thu, 17 Oct 2024 13:02:47 +0300 Subject: [PATCH] Add Consent Backbone Elements to TransformSupportServices (#3562) * Add Consent backbone elements * Update Consent_PolicyRule to Consent_Policy * Add consent backbone elements tests --- .../util/helper/TransformSupportServices.kt | 6 +++ .../helper/TransformSupportServicesTest.kt | 39 +++++++++++++++++++ 2 files changed, 45 insertions(+) diff --git a/android/engine/src/main/java/org/smartregister/fhircore/engine/util/helper/TransformSupportServices.kt b/android/engine/src/main/java/org/smartregister/fhircore/engine/util/helper/TransformSupportServices.kt index e37de10c26..1ff8640253 100644 --- a/android/engine/src/main/java/org/smartregister/fhircore/engine/util/helper/TransformSupportServices.kt +++ b/android/engine/src/main/java/org/smartregister/fhircore/engine/util/helper/TransformSupportServices.kt @@ -24,6 +24,7 @@ import org.hl7.fhir.r4.model.AdverseEvent import org.hl7.fhir.r4.model.Base import org.hl7.fhir.r4.model.CarePlan import org.hl7.fhir.r4.model.Coding +import org.hl7.fhir.r4.model.Consent import org.hl7.fhir.r4.model.Encounter import org.hl7.fhir.r4.model.EpisodeOfCare import org.hl7.fhir.r4.model.Group @@ -85,6 +86,11 @@ class TransformSupportServices @Inject constructor(val simpleWorkerContext: Simp AdverseEvent.AdverseEventSuspectEntityCausalityComponent() "Location_Position" -> Location.LocationPositionComponent() "List_Entry" -> ListResource.ListEntryComponent() + "Consent_Policy" -> Consent.ConsentPolicyComponent() + "Consent_Verification" -> Consent.ConsentVerificationComponent() + "Consent_Provision" -> Consent.provisionComponent() + "Consent_ProvisionActor" -> Consent.provisionActorComponent() + "Consent_ProvisionData" -> Consent.provisionDataComponent() else -> ResourceFactory.createResourceOrType(name) } } diff --git a/android/engine/src/test/java/org/smartregister/fhircore/engine/util/helper/TransformSupportServicesTest.kt b/android/engine/src/test/java/org/smartregister/fhircore/engine/util/helper/TransformSupportServicesTest.kt index 278956a416..f7c78a0fab 100644 --- a/android/engine/src/test/java/org/smartregister/fhircore/engine/util/helper/TransformSupportServicesTest.kt +++ b/android/engine/src/test/java/org/smartregister/fhircore/engine/util/helper/TransformSupportServicesTest.kt @@ -19,6 +19,7 @@ package org.smartregister.fhircore.engine.util.helper import io.mockk.mockk import org.hl7.fhir.exceptions.FHIRException import org.hl7.fhir.r4.model.CarePlan +import org.hl7.fhir.r4.model.Consent import org.hl7.fhir.r4.model.Encounter import org.hl7.fhir.r4.model.EpisodeOfCare import org.hl7.fhir.r4.model.Group @@ -129,6 +130,44 @@ class TransformSupportServicesTest : RobolectricTest() { ) } + @Test + fun `createType() should return ConsentPolicyComponent when given Consent_Policy`() { + Assert.assertTrue( + transformSupportServices.createType("", "Consent_Policy") is Consent.ConsentPolicyComponent, + ) + } + + @Test + fun `createType() should return ConsentVerificationComponent when given Consent_Verification`() { + Assert.assertTrue( + transformSupportServices.createType("", "Consent_Verification") + is Consent.ConsentVerificationComponent, + ) + } + + @Test + fun `createType() should return provisionComponent when given Consent_Provision`() { + Assert.assertTrue( + transformSupportServices.createType("", "Consent_Provision") is Consent.provisionComponent, + ) + } + + @Test + fun `createType() should return provisionActorComponent when given Consent_ProvisionActor`() { + Assert.assertTrue( + transformSupportServices.createType("", "Consent_ProvisionActor") + is Consent.provisionActorComponent, + ) + } + + @Test + fun `createType() should return provisionDataComponent when given Consent_ProvisionData`() { + Assert.assertTrue( + transformSupportServices.createType("", "Consent_ProvisionData") + is Consent.provisionDataComponent, + ) + } + @Test fun `createType() should return Time when given time`() { Assert.assertTrue(transformSupportServices.createType("", "time") is TimeType)