opensrp / fhircore

FHIR Core / OpenSRP 2 is a Kotlin application for delivering offline-capable, mobile-first healthcare project implementations from local community to national and international scale using FHIR and WHO Smart Guidelines on Android.
https://opensrp.io
Apache License 2.0
56 stars 59 forks source link

Allow reading of configuration resources e.g. Questionnaires, List etc from the local assets director only during development #3041

Closed ellykits closed 5 months ago

ellykits commented 9 months ago

Describe the feature request. Read and use content for configuration resources from the configs/app/resources directory in the assets directory. Ideally, any FHIR resource can be loaded into the application through the assets.

Additional context The current implementation loads the configuration resources declared in the Composition (including Questionnaires, StructureMaps, PlanDefs, Lists, etc) by retrieving them from the server, which requires the device to be online. This enhancement should allow the user to create config directories for the resources inside /configs/app/resources. The resources directory name should be in lowercase format e.g. configs/app/resources/binary, configs/app/resources/questionnaire, configs/app/resources/structuremap, configs/app/resources/plandefinition, etc.

Acceptance criteria

  1. Be able to introduce a resource directory in the configs/appId/resources directory.
  2. Create a new file, copy and paste Resource content
  3. Read the assets file ONLY when using debug configurations e.g. app/debug
  4. Override the database content with the content of the file

Area path A list of ordered steps in the app on usage of the feature to support anyone testing it e.g. Code reviewer, QA e.g.

  1. Create a new file config/app/resources/questionnaire/add_household.json
  2. Update the questionnaire content
  3. Login to the app using app/debug
  4. Click on Household register
  5. Click on add household from the side navigation or configured fab
  6. Observe the questionnaire updated

Implementation plan (For Engineers) The plan for implementing the solution e.g. via a description or a check list for the various ordered tasks that will need to be completed. _i.e. Describe how you intend to solve the problem

  1. Update the functionality for reading local asset configurations to include reading FHIR resources from the config/resources directory.
  2. Override the previously loaded resource in the DB
  3. This functionality should only work during development to improve developer productivity by allowing devs to update Questionnaires, StructureMaps, etc. without the need to post the configurations to the server first.
pld commented 9 months ago

Could you potential use this to hard-code the initial config into an APK for a specific project?

ellykits commented 9 months ago

Could you potentially use this to hard-code the initial config into an APK for a specific project?

Yes, we could if we enable this functionality for release apps.