Initial SymptomChecks
This issue is about adding initial / pre-made symptom checks, that get imported when scanning static QR codes. This issue is not supposed to actually update the runtime config (That will be a task for another time).
What is do be done?
-
Check if !974 (merged) was already merged (this issue depends on that MR) -
Import a symptom check from the runtime config after a static QR-Code has been scanned -
Post a link in the MR that upon loading triggers the import of the SymptomCheck. -
Add docs on how to add further initial SymptomChecks -
Add Unit tests -
Do NOT use the id of the symptom check!!
Import a symptom check from the runtime config after a static QR-Code has been scanned
I suggest doing this by the following steps:
1) Try out the static QR-Code functionality
(take a look at @rcc/features/static-qr-code/static-qr-page.component.spec.ts to get a better understanding of how this is supposed to work):
- Listen to
IncomingDataService
and log to the console everything that is emitted - Create an arbitrary json object, that you would recognize (e.g. `{ "my": {"json" : "object" } })
- Turn that object into url friendly base64 string using
objectToBase64URIComponent
from our utils - open
/data?d=$base64
(replace '$base64' with your string from above) - The logs from
IncomingDataService
should show something like this:{ "source": "link", data: { "my": {"json" : "object" } }
This step is done, if you see the appropriate logs.
2) Listen to incoming data from links
Use the IncomingDataService
to wait for data from Links (See StaticQrCodeComponent) It should look something like this:
{
data: {
preConfiguredSymptomCheck: 'name_of_a_preconfigured_symptom_check'
},
source: 'link'
}
Wait for emissions on IncomingDataService
that have the above structure and use the 'preConfiguredSymptomCheck' value to later pull a respective SymptomCheck from the RuntimeCongfig.
This should work just like 1) above. To test it turn { "preConfiguredSymptomCheck": "name_of_a_preconfigured_symptom_check"}
into base64 just like above and try the link with the new string.
You should be able to extract the name of the of the pre-configured symptomcheck (in this case "name_of_a_preconfigured_symptom_check"); this is not the ID of the SymptomCheck!!
Log the name of the pre-configured SymptomCheck.
Use this name later to pull the respective symptomcheck config from the runtime config.
This step is done if you see the "name_of_a_preconfigured_symptom_check" in the logs when opening the data/?d=... link (or any other name you might have used).
3) Add a section for a dictionary of SymptomChecks to the runtime config setup
When starting the app the logs will print a clickable "RuntimeConfiguration" entry. Click it to check the current runtime config setup.
Check the documentation at RccPublicRuntimeConfigService
. Request a new optional value from the runtime config. It should look something like this:
providers: [ // <-- it says 'imports' in the docs, which is wrong, please correct :D
...,
requestPublicRuntimeConfigValue({
path: 'preConfiguresSymptomChecks',
description: 'A dictionary of symptom checks, that can be used by the app right from the start.',
type: 'SymptomCheckDictionary',
required: 'false'
})
]
A SymptomCheckDictionary should look similar to this:
export interface SymptomCheckDictionary{
[index:string]: SymptomCheckConfig
}
This step is done, when you see 'RuntimeConfiguration' in the logs when starting the app, and upon clicking it you see (among other things) the new section you just requested.
4) Add MockData to examples
Check the RuntimeConfig examples (in the example folder) and add the preConfiguresSymptomChecks entry with an example entry:
{
...,
"preConfiguresSymptomChecks":{
"name_of_a_preconfigured_symptom_check": { ... } // some dummy symptom check config
}
Remember to add the respective examples module to features.ts the when working and remove it later (for the MR please post the module, the reviewer should include).
This step is done, when you're able to load a SymptomCheckDictionary
by `await RccPublicRuntimeConfigService.get('preConfiguresSymptomChecks'). (see the docs at RccPublicRuntimeConfigService)
preConfiguresSymptomChecks.name_of_a_preconfigured_symptom_check
). Log the resulting symptomcheck config.
5) Go back to 2) and instead of logging the name, load 'preConfiguresSymptomChecks' from the runtime config (see the docs at RccPublicRuntimeConfigService) use the name to read the specific symptom check from that dictionary (e.g. This step is done, when you see the the dummy symptom check config from step 4) being logged after opening the link ('data/d=...')
IncomingDataService
(calling `.next()). This should trigger a modal asking to import the symptom check.
6) Instead of logging the symptom check config announce it on This step is done, if opening the link, triggers the modal.