Skip to content
This repository was archived by the owner on Jul 13, 2023. It is now read-only.
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -77,6 +77,9 @@ internal const val CARECONNECT_EVIDENCE_URL =
internal const val UKCORE_EVIDENCE_URL =
"https://fhir.hl7.org.uk/StructureDefinition/Extension-UKCore-Evidence"

internal const val CARECONNECT_GPC_ALLERGY_INTOLERANCE_END_URL =
"https://fhir.nhs.uk/STU3/StructureDefinition/Extension-CareConnect-GPC-AllergyIntoleranceEnd-1"

internal val careconnectTransformers: HashMap<String, ExtensionTransformer> = hashMapOf(
CARECONNECT_REPEAT_INFORMATION_URL to ::repeatInformation,
CARECONNECT_GPC_REPEAT_INFORMATION_URL to ::repeatInformation,
Expand All @@ -91,7 +94,18 @@ internal val careconnectTransformers: HashMap<String, ExtensionTransformer> = ha
CARECONNECT_EVIDENCE_URL to ::evidence,
CARECONNECT_ALLERGY_ASSOCIATED_ENCOUNTER_URL to ::associatedEncounter,
CARECONNECT_ALLERGY_INTOLERANCE_END_URL to ::allergyIntoleranceEnd,
CARECONNECT_GPC_ALLERGY_INTOLERANCE_END_URL to :: allergyIntoleranceEndGPC
Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Minor whitespace nitpick here, the other map entries don't have a gap between :: and the function to be invoked.

)
fun allergyIntoleranceEndGPC(src: R3Extension, tgt: R4DomainResource){
// handle the conversion of resolved clinicalStatus
val resolvedCodeableConcept = R4CodeableConcept().apply {
val r4Coding = R4Coding()
r4Coding.system = "http://terminology.hl7.org/CodeSystem/allergyintolerance-clinical"
r4Coding.code = "resolved"
this.coding = listOf(r4Coding)
}
(tgt as R4AllergyIntolerance).clinicalStatus = resolvedCodeableConcept
}

fun repeatInformation(src: R3Extension, tgt: R4DomainResource) {
val ext = R4Extension().apply {
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
package net.nhsd.fhir.converter.transformer


import org.assertj.core.api.Assertions
import org.hl7.fhir.dstu3.model.Extension
import org.junit.jupiter.api.Test
import org.hl7.fhir.r4.model.AllergyIntolerance as R4AllergyIntolerance

class ResolvedAllergiesTest {
@Test
internal fun `it should add clinicalStatus resolved to resources with gpc allergy end extension`() {
// Given
// R3 allergy end extension
val r3Extension = Extension().apply {
url = CARECONNECT_GPC_ALLERGY_INTOLERANCE_END_URL
}

val r4Resource = R4AllergyIntolerance()

// When transformer is called
allergyIntoleranceEndGPC(r3Extension, r4Resource)

// Then
val clinicalStatus = r4Resource.clinicalStatus.coding[0].code
Assertions.assertThat(clinicalStatus).isEqualTo("resolved")
}
}