Skip to content

Commit

Permalink
Add Consent Backbone Elements to TransformSupportServices (#3562)
Browse files Browse the repository at this point in the history
* Add Consent backbone elements

* Update Consent_PolicyRule to Consent_Policy

* Add consent backbone elements tests
  • Loading branch information
qiarie authored Oct 17, 2024
1 parent c27a6cd commit fa7a8bd
Show file tree
Hide file tree
Showing 2 changed files with 45 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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)
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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)
Expand Down

0 comments on commit fa7a8bd

Please sign in to comment.