From d013d2ad2c6139b8ae45cbd2133ebcdf3bd9afe0 Mon Sep 17 00:00:00 2001 From: Martin Ndegwa Date: Fri, 6 Dec 2024 15:59:08 +0300 Subject: [PATCH] Fix concurrency modification ResourceExtension helper methods --- .../engine/util/extension/ResourceExtension.kt | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/android/engine/src/main/java/org/smartregister/fhircore/engine/util/extension/ResourceExtension.kt b/android/engine/src/main/java/org/smartregister/fhircore/engine/util/extension/ResourceExtension.kt index 08037fde67..4b21562dcc 100644 --- a/android/engine/src/main/java/org/smartregister/fhircore/engine/util/extension/ResourceExtension.kt +++ b/android/engine/src/main/java/org/smartregister/fhircore/engine/util/extension/ResourceExtension.kt @@ -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\\\\'") @@ -126,7 +126,7 @@ fun StructureMap.encodeResourceToString(): String = .replace("'weeks'", "\\\\'weeks\\\\'") fun String.decodeResourceFromString(): T = - FhirContext.forR4Cached().getCustomJsonParser().parseResource(this) as T + FhirContext.forR4().getCustomJsonParser().parseResource(this) as T fun T.updateFrom(updatedResource: Resource): T { var extensionUpdateFrom = listOf() @@ -141,7 +141,7 @@ fun 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 { @@ -437,7 +437,7 @@ fun Composition.retrieveCompositionSections(): List = - FhirContext.forR4Cached().getResourceDefinition(this).implementingClass as Class + FhirContext.forR4().getResourceDefinition(this).implementingClass as Class /** * A function that extracts only the UUID part of a resource logicalId.