onaio / fhir-web

A web based interface for administering FHIR based digital health solutions
https://ona.io/home/introducing-quest-fhir-native-case-management/
Other
18 stars 20 forks source link

[New Feature Request]: Addition of a District Report Download Link on the Web Portal #919

Closed qiarie closed 2 years ago

qiarie commented 2 years ago

Feature Use Case

WP has a report that aggregates monthly reports per district. The monthly report is generated as an excel sheet at the end of every month based on submissions made from the android client. The excel sheet is routinely scheduled and saved on the server. The Excel sheet is accessible via a link that downloads the raw .xlsx file.

The download link has the format GET: {host}/opensrp/rest/report/generate/{districtId:.+}/{period:.+} where:

Below is an example of a complete URL: {host}/opensrp/rest/report/generate/5cf8fa0e-2dc6-47de-9b0d-b14b890adf25/2021-12

A user must have the role DISTRICT_REPORT assigned to their assigned user group to download the excel sheet.

Acceptance criteria

  1. A user should be able to see the Download District Report (or equivalent) menu option when they have the role DISTRICT_REPORT assigned to them.
  2. On clicking on the Download District Report button, they should have a download dialog window prompting them to save the report file.
  3. A user is only able to download reports for the district they are assigned.

Project Contact

Simon Njoroge

Relevant Information

  1. This report is specific to WP at the moment, but may be relevant to other deployments as well. For example, the report template is specific to Mauritania.
  2. The URL might change with evolving requirements. The original specs did not have a UI available hence the need to specify the district when fetching the report.
dubdabasoduba commented 2 years ago

@samkanga What is the server URL for this?

dubdabasoduba commented 2 years ago

Web Scoping pieces

samkanga commented 2 years ago

@dubdabasoduba its https://web.wellnesspass-preview.smartregister.org/

dubdabasoduba commented 2 years ago

@samkanga This is blocked. The endpoint is yet to be deployed to the instance shared above.

qiarie commented 2 years ago

@samkanga @dubdabasoduba The branch with the endpoint is deployed

machariamuguku commented 2 years ago

@qiarie please talk more about the endpoint. Is the method POST or GET, are the keywords districtId, and period included in the url? Could you provide an example of a complete endpoint and if possible a link to the swagger documentation?

qiarie commented 2 years ago

@machariamuguku Use GET method to access the endpoint. 400 is returned

Please have a look at this example: {host}/opensrp/rest/report/generate/5cf8fa0e-2dc6-47de-9b0d-b14b890adf25/2021-12

If there is a report available for the district & period, a file is returned for download. If no report is found, an error is thrown.

machariamuguku commented 2 years ago

@qiarie what are the response headers? specifically the content-type

qiarie commented 2 years ago

@machariamuguku

Content-Type: application/vnd.openxmlformats-officedocument.spreadsheetml.sheet Content-Disposition: attachment; filename="XXXXXX"

dubdabasoduba commented 2 years ago

@machariamuguku The agreement here was if we can build something that downloads the pdf doc (I assume) the web work is done. Making sure the doc has data is the OpenSRP server team's responsibility.

machariamuguku commented 2 years ago

@dubdabasoduba we need to know the nature of the download request(s) in order to build something generic yet usable. Also to test if the functionality works.

dubdabasoduba commented 2 years ago

I think the download is a PDF but I will let @qiarie comment about that

machariamuguku commented 2 years ago

@dubdabasoduba he says it's an .xlsx from the first comment above and also from the Content-Type

dubdabasoduba commented 2 years ago

@dubdabasoduba he says it's an .xlsx from the first comment above and also from the Content-Type

Ooh, yah. Seen that. Thanks

dubdabasoduba commented 2 years ago

@machariamuguku Please hit this endpoint to get a sample of the report to be downloaded https://wellnesspass-stage.smartregister.org/opensrp/rest/report/download/60f07b23-682d-4fdf-8eaf-4db0957ceaea/2022-02

The endpoint is still under construction but I think this will help you get the sample you require

cc: @qiarie @samkanga

qiarie commented 2 years ago

@machariamuguku

Instead of calling the download URL provided earlier, please use {host}/opensrp/rest/report/download/{districtId:.+}/{period:.+}

The rest of the conditions remain the same.

machariamuguku commented 2 years ago

@qiarie I can't get the filename from the Content-Disposition header because it's blocked by default for scripts. I've made a suggestion here based on this

qiarie commented 2 years ago

@machariamuguku The change has been approved and merged