Closed Raynafs closed 3 months ago
Attention: Patch coverage is 50.00000%
with 12 lines
in your changes are missing coverage. Please review.
Project coverage is 28.0%. Comparing base (
ac82739
) to head (7a05d5d
). Report is 69 commits behind head on main.
You can create your method in configurationsRegistry to retrieve any resource. Here's a sample method you can use
inline fun <reified T : Resource> retrieveResourcesFromConfigMap(resourceId: String): T {
return configsJsonMap.getValue(resourceId).decodeResourceFromString()
}
and now invoke it whenever a resource is to be loaded from the configMap in debug mode. E.g Questionnaire, StructureMap, PlanDefinition, List.
Hi Seb. Yes sure. working on it
@SebaMutuku Did you verify if the implementation follows the directory structure required by FHIRCore tools as proposed before?
@ellykits yes, the resources will be loaded from a folder inside the configs called resources
. Inside this folder we will have sub-directorys e.g a sub-directory called questionnaire
, structuremap
, planDefinition
which will hold corresponding resources
@Raynafs is there anything pending on this PR. Can we close?
Hey @SebaMutuku I believe I have completed the full implementation for this. Unless @ellykits would like me to add something.
@ellykits This is a video showing that the resources have been loaded from the resources folder when the app Id is app/debug
Screencast from 03-04-2024 11:01:01 ASUBUHI.webm
Here is a video showing that the questionnaire that is in assets actually appears in the app
@ellykits @pld this implementation is now complete. However we need to make changeds on FhirEngine
at this function
private suspend fun insertResource(resource: Resource, lastUpdatedLocal: Instant?): UUID {
val resourceUuid = UUID.randomUUID()
// Use the local UUID as the logical ID of the resource
if (resource.id.isNullOrEmpty()) {
resource.id = resourceUuid.toString()
}
val entity =
ResourceEntity(
id = 0,
resourceType = resource.resourceType,
resourceUuid = resourceUuid,
resourceId = resource.logicalId,
serializedResource = iParser.encodeResourceToString(resource),
versionId = resource.versionId,
lastUpdatedRemote = resource.lastUpdated,
lastUpdatedLocal = lastUpdatedLocal,
)
insertResource(entity)
val index =
ResourceIndices.Builder(resourceIndexer.index(resource))
.apply {
lastUpdatedLocal?.let {
addDateTimeIndex(
createLocalLastUpdatedIndex(entity.resourceType, InstantType(Date.from(it))),
)
}
}
.build()
updateIndicesForResource(index, resource.resourceType, resourceUuid)
return entity.resourceUuid
}
to reuse the same resourceUUID if it doesn't exist on the DB and the resource has a resourceID. Currently, the function above checks if the resource logicalID/resourceID exists in resourcesEntity table and if not generates a random UUID which is used to save the resource there.
Here's the function that checks that for both Remote and Local entries
private suspend fun insertRemoteResource(resource: Resource): UUID {
val existingResourceEntity = getResourceEntity(resource.logicalId, resource.resourceType)
if (existingResourceEntity != null) {
applyRemoteUpdate(resource)
return existingResourceEntity.resourceUuid
}
return insertResource(resource, null)
}
I can proceed to do that
cc @f-odhiambo
nice, exciting!
@ellykits @pld this implementation is now complete. However we need to make changeds on
FhirEngine
at this functionprivate suspend fun insertResource(resource: Resource, lastUpdatedLocal: Instant?): UUID { val resourceUuid = UUID.randomUUID() // Use the local UUID as the logical ID of the resource if (resource.id.isNullOrEmpty()) { resource.id = resourceUuid.toString() } val entity = ResourceEntity( id = 0, resourceType = resource.resourceType, resourceUuid = resourceUuid, resourceId = resource.logicalId, serializedResource = iParser.encodeResourceToString(resource), versionId = resource.versionId, lastUpdatedRemote = resource.lastUpdated, lastUpdatedLocal = lastUpdatedLocal, ) insertResource(entity) val index = ResourceIndices.Builder(resourceIndexer.index(resource)) .apply { lastUpdatedLocal?.let { addDateTimeIndex( createLocalLastUpdatedIndex(entity.resourceType, InstantType(Date.from(it))), ) } } .build() updateIndicesForResource(index, resource.resourceType, resourceUuid) return entity.resourceUuid }
to reuse the same resourceUUID if it doesn't exist on the DB and the resource has a resourceID. Currently, the function above checks if the resource logicalID/resourceID exists in resourcesEntity table and if not generates a random UUID which is used to save the resource there.
Here's the function that checks that for both Remote and Local entries
private suspend fun insertRemoteResource(resource: Resource): UUID { val existingResourceEntity = getResourceEntity(resource.logicalId, resource.resourceType) if (existingResourceEntity != null) { applyRemoteUpdate(resource) return existingResourceEntity.resourceUuid } return insertResource(resource, null) }
I can proceed to do that
cc @f-odhiambo
This was resolved
I have refactored some lines of code. I've also corrected the file names for the resources directory. The directory should be inside the configs/appId
.
IMPORTANT: Where possible all PRs must be linked to a Github issue
Fixes #3041
Engineer Checklist
strings.xml
file./gradlew spotlessApply
and./gradlew spotlessCheck
to check my code follows the project's style guideCode Reviewer Checklist
strings.xml
file