Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Load FHIR Resources from configs in assets directory #3065

Merged
merged 34 commits into from
Jun 1, 2024

Conversation

Raynafs
Copy link
Contributor

@Raynafs Raynafs commented Feb 13, 2024

IMPORTANT: Where possible all PRs must be linked to a Github issue

Fixes #3041

Engineer Checklist

  • I have written Unit tests for any new feature(s) and edge cases for bug fixes
  • I have added any strings visible on UI components to the strings.xml file
  • I have updated the CHANGELOG.md file for any notable changes to the codebase
  • I have run ./gradlew spotlessApply and ./gradlew spotlessCheck to check my code follows the project's style guide
  • I have built and run the FHIRCore app to verify my change fixes the issue and/or does not break the app
  • I have checked that this PR does NOT introduce breaking changes that require an update to Content and/or Configs? If it does add a sample here or a link to exactly what changes need to be made to the content.

Code Reviewer Checklist

  • I have verified Unit tests have been written for any new feature(s) and edge cases
  • I have verified any strings visible on UI components are in the strings.xml file
  • I have verifed the CHANGELOG.md file has any notable changes to the codebase
  • I have verified the solution has been implemented in a configurable and generic way for reuseable components
  • I have built and run the FHIRCore app to verify the change fixes the issue and/or does not break the app

@Raynafs Raynafs added DNM DO NOT MERGE Work In Progress Describes an items that is not complete. Mostly used for scoping issues of discussions labels Feb 13, 2024
@Raynafs Raynafs self-assigned this Feb 13, 2024
Copy link

codecov bot commented Feb 13, 2024

Codecov Report

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.

Additional details and impacted files

Impacted file tree graph

@@            Coverage Diff            @@
##              main   #3065     +/-   ##
=========================================
- Coverage     29.6%   28.0%   -1.7%     
- Complexity     658     693     +35     
=========================================
  Files          239     266     +27     
  Lines        11204   12472   +1268     
  Branches      1948    2172    +224     
=========================================
+ Hits          3323    3495    +172     
- Misses        7447    8518   +1071     
- Partials       434     459     +25     
Flag Coverage Δ
engine 64.7% <50.0%> (-1.5%) ⬇️
geowidget 18.7% <ø> (-28.5%) ⬇️
quest 5.2% <ø> (-0.3%) ⬇️

Flags with carried forward coverage won't be shown. Click here to find out more.

Files Coverage Δ
...core/engine/configuration/ConfigurationRegistry.kt 65.9% <50.0%> (-2.1%) ⬇️

... and 10 files with indirect coverage changes

@Raynafs Raynafs removed DNM DO NOT MERGE Work In Progress Describes an items that is not complete. Mostly used for scoping issues of discussions labels Feb 23, 2024
Copy link
Contributor

@SebaMutuku SebaMutuku left a comment

Choose a reason for hiding this comment

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

@Raynafs based on the issue description, it seems the code doesn't load resources from the configMap or configJson. Do you mind adding that functionality?

@SebaMutuku
Copy link
Contributor

SebaMutuku commented Feb 26, 2024

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.

@SebaMutuku SebaMutuku added the DNM DO NOT MERGE label Feb 26, 2024
@Raynafs
Copy link
Contributor Author

Raynafs commented Feb 27, 2024

Hi Seb. Yes sure. working on it

@SebaMutuku SebaMutuku changed the title Implement reading configuration resources Load resources like Questionnaire, StructureMap,PlanDefinition from resources folder when using appId with /debug Feb 28, 2024
@SebaMutuku SebaMutuku removed the DNM DO NOT MERGE label Feb 29, 2024
@ellykits
Copy link
Collaborator

@SebaMutuku Did you verify if the implementation follows the directory structure required by FHIRCore tools as proposed before?

@SebaMutuku
Copy link
Contributor

@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

@SebaMutuku
Copy link
Contributor

@Raynafs is there anything pending on this PR. Can we close?

@Raynafs
Copy link
Contributor Author

Raynafs commented Mar 27, 2024

Hey @SebaMutuku I believe I have completed the full implementation for this. Unless @ellykits would like me to add something.

@Raynafs
Copy link
Contributor Author

Raynafs commented Apr 3, 2024

@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

Screencast.from.03-04-2024.11.08.16.ASUBUHI.webm

@f-odhiambo f-odhiambo changed the title Load resources like Questionnaire, StructureMap,PlanDefinition from resources folder when using appId with /debug Load resources like Questionnaire, StructureMap,PlanDefinition from resources folder when using appId with '/debug' Apr 12, 2024
@f-odhiambo f-odhiambo changed the title Load resources like Questionnaire, StructureMap,PlanDefinition from resources folder when using appId with '/debug' Load resources like Questionnaire, StructureMap,PlanDefinition from resources folder when using appId with /debug Apr 12, 2024
@Raynafs Raynafs enabled auto-merge (squash) April 16, 2024 14:10
@ellykits ellykits assigned SebaMutuku and unassigned Raynafs May 14, 2024
@SebaMutuku SebaMutuku closed this May 15, 2024
auto-merge was automatically disabled May 15, 2024 10:13

Pull request was closed

@SebaMutuku SebaMutuku force-pushed the implement-reading-configuration-resources branch from 791a040 to 79b564e Compare May 15, 2024 10:13
@SebaMutuku SebaMutuku removed the DNM DO NOT MERGE label May 20, 2024
@SebaMutuku SebaMutuku enabled auto-merge (squash) May 24, 2024 10:33
@ellykits ellykits changed the title Load resources like Questionnaire, StructureMap,PlanDefinition from resources folder when using appId with /debug Load FHIR Resources from configs in assets directory May 30, 2024
@ellykits
Copy link
Collaborator

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.

f-odhiambo and others added 6 commits May 31, 2024 16:11
…m:opensrp/fhircore into implement-reading-configuration-resources
Signed-off-by: Elly Kitoto <[email protected]>
Configs should be added to the map and FHIR resources saved to SQLite
database.

Signed-off-by: Elly Kitoto <[email protected]>
Signed-off-by: Elly Kitoto <[email protected]>
@pld pld dismissed ellykits’s stale review May 31, 2024 15:52

out of date

@SebaMutuku SebaMutuku merged commit ee6d05e into main Jun 1, 2024
5 checks passed
@SebaMutuku SebaMutuku deleted the implement-reading-configuration-resources branch June 1, 2024 07:56
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
6 participants