PDF Export of report data
Before closing a session the doctor should be able to export all the patient's answers into a pdf file by clicking on the Report item on the Open Sessions Screen and selecting 'Export as PDF' from the menu. The PDF should include the questions answered in the Report and a list of all answers with the days they were given for.
How to find the right place in the UI where this is relevant
In order to reach the relevant part in the UI the doctor's app needs to have an open session with patient data. Sadly this is rather tough to achieve.
-
Quick (needs two devices): Serve app with doc configuration; Open the patient's app on dev: https://dev.recoverycat.de/app/pat Start a new session in the doctor's app; Add a couple of Questions. Send them to the patients app. In the patient's app accept the new SymptomCheck; answer the questions (maybe even for previous days). Send your answers back to the doctor's. In the doctor's app accept the session. You should now see a report item in the upper half of the screen. Click it and you'll get a little menu with items like 'export data' or 'inspect data'. This is where 'Export to PDF' should be added. After you did this for the first time, you don not need to create another SymptomCheck, just directly resend your previous answers from the patient's app.
-
Thorough: Inject IncomingData (from @rcc/common) into your module/service (or better yet: a new module in /lib/examples) and post a mock session, like this:
constructor(incomingData: IncomingData){
const mockEntries : EntryConfig[] = [ // EntryConfig comes from '@rcc/core'
[
'rcc-curated-extended-0001-daily', // The question with this id is already present in the current doc version,
// see CuratedExtendedQuestionStore
1, // Answer
'2022-10-11T23:42:50.699Z', // When the answer was given
undefined, // A note
'2022-10-11' // For which day the answer was given
]
//...
]
const sessionConfig = {
symptomCheck: {meta: {}, questions: [] as unknown[]}, // empty symptomCheck config
report: ['my-mock-report', '2022-10-11T23:42:50.699Z', mockEntries], // label, creation date, entries
questions : [] as unknown
}
setTimeout( () => incomingData.next(sessionConfig), 500)
}
This should spawn a new session, as soon as you load the doctor's app. The Report of that session will include your mock report (mockEntries). The Session screen should now show the currently open session an a clickable Report item; Click it to see the export menu.
Requirements/Tasks
-
Create a new module in /lib/features/src -
Create a service that can turn a (report: Report) into PDF file -
Use DatasetsService.getDatasets() to turn a Report into DataSet[]. (The Report represents the raw data, whereas the resulting Dataset[] is already processed). See Docs for more details. -
Do not change any other files outside your module folder except /lib/features/src/sessions/home/session-home-page.component.ts; (resp. .../session-home.module.ts) if not possible -> new task :) -
In the end, clicking the report on the session home page should open a menu with a newly added third option 'Export as PDF' -
Clicking that option should prompt a file download for the PDF -
Provide translation data (see provideTranslationMap) in your module -
Take notes where better documentation would have been helpful in order to close this issue
Where to start
Add a reportAction in /features/src/sessions/home/session-home-page.component.ts (search for "this.reportActions" , l.155) At that point you'll find two already defined actions; use them as a temaplte and add a third one that makes use of the new Service.