Skip to content

Commit

Permalink
Fix concurrency modification ResourceExtension helper methods
Browse files Browse the repository at this point in the history
  • Loading branch information
ndegwamartin committed Dec 6, 2024
1 parent 582abec commit d013d2a
Showing 1 changed file with 5 additions and 5 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -114,10 +114,10 @@ fun CodeableConcept.stringValue(): String =
this.text ?: this.codingFirstRep.display ?: this.codingFirstRep.code

fun Resource.encodeResourceToString(): String =
FhirContext.forR4Cached().getCustomJsonParser().encodeResourceToString(this.copy())
FhirContext.forR4().getCustomJsonParser().encodeResourceToString(this.copy())

fun StructureMap.encodeResourceToString(): String =
FhirContext.forR4Cached()
FhirContext.forR4()
.getCustomJsonParser()
.encodeResourceToString(this)
.replace("'months'", "\\\\'months\\\\'")
Expand All @@ -126,7 +126,7 @@ fun StructureMap.encodeResourceToString(): String =
.replace("'weeks'", "\\\\'weeks\\\\'")

fun <T> String.decodeResourceFromString(): T =
FhirContext.forR4Cached().getCustomJsonParser().parseResource(this) as T
FhirContext.forR4().getCustomJsonParser().parseResource(this) as T

fun <T : Resource> T.updateFrom(updatedResource: Resource): T {
var extensionUpdateFrom = listOf<Extension>()
Expand All @@ -141,7 +141,7 @@ fun <T : Resource> T.updateFrom(updatedResource: Resource): T {
val originalResourceJson = JSONObject(stringJson)

originalResourceJson.updateFrom(JSONObject(updatedResource.encodeResourceToString()))
return FhirContext.forR4Cached()
return FhirContext.forR4()
.getCustomJsonParser()
.parseResource(this::class.java, originalResourceJson.toString())
.apply {
Expand Down Expand Up @@ -437,7 +437,7 @@ fun Composition.retrieveCompositionSections(): List<Composition.SectionComponent
}

fun String.resourceClassType(): Class<out Resource> =
FhirContext.forR4Cached().getResourceDefinition(this).implementingClass as Class<out Resource>
FhirContext.forR4().getResourceDefinition(this).implementingClass as Class<out Resource>

/**
* A function that extracts only the UUID part of a resource logicalId.
Expand Down

0 comments on commit d013d2a

Please sign in to comment.