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

Request "Invoice" PDF URL #321

Open
juanjgarcia opened this issue Oct 1, 2020 · 9 comments
Open

Request "Invoice" PDF URL #321

juanjgarcia opened this issue Oct 1, 2020 · 9 comments

Comments

@juanjgarcia
Copy link

Hi team, it would be really helpful if you could add a URL to the Invoice response which when GET would offer up the PDF render of that invoice.

This has multiple applications, from archival, to automated bill submissions to insurance providers.

If there's a workaround for now, let me know, as given a recent change in the UK insurance environment it would now be very useful.

@juanjgarcia juanjgarcia changed the title Request invoice PDF url Request "Invoice" PDF URL Oct 1, 2020
@bpinto
Copy link
Member

bpinto commented Oct 3, 2020

I think this should be doable! I will confirm early next week and reply here.

@bpinto
Copy link
Member

bpinto commented Oct 8, 2020

Well well, it's proven to be harder than I anticipated. There are some things we need to discuss before we can introduce a PDF end point:

  1. Would it work via GET or POST? I'm thinking POST could be nice for supporting custom parameters (e.g. margin, page size).

  2. We need to update our API to support extra accept headers application/pdf as of right now we only support application/json.

@juanjsebgarcia
Copy link

For the time being I've just engineered a solution which interfaces with the front end.

At a guess the request flow on your side is:

  1. Invoice Object render to HTML
  2. HTML render to PDF

So there's no pre-generated invoice PDFs sat anywhere, they're lazily created on fetch? Hence why we can push params to the generator func?

At any rate, I think an endpoint to get the exact PDF currently being created by the frontend without any modifications would be a great v1. Though I understand that might then compromise the ease of being able to add modifications later whilst maintaining backwards compat.

Long story short, I've worked around it for now, so take your time and do it your way :D

@DenisBogatirov
Copy link

Is there any way to use API token to "auth user"? What I whant to do is just open https://trainm3.au1.cliniko.com/patients/001/treatment_notes/111.pdf in new tab but currently will receive 401 error

@bpinto
Copy link
Member

bpinto commented Oct 20, 2020

@DenisBogatirov that's not supported, you are authenticated to the API and not to the web app.

@DenisBogatirov
Copy link

@bpinto Is there any way to get link to the file through API? I'm making mobile app and it's crucial to have ability to download files.

@bpinto
Copy link
Member

bpinto commented Oct 20, 2020

@DenisBogatirov you could link to the URL cliniko uses and open the link in a browser, the user will download it if they are logged into the cliniko app. If not, they will be asked to login first.

@DenisBogatirov
Copy link

@DenisBogatirov you could link to the URL cliniko uses and open the link in a browser, the user will download it if they are logged into the cliniko app. If not, they will be asked to login first.

It will not prompt login, and this app are for patients, so they don't have cliniko credentials

@juanjsebgarcia
Copy link

You will need to front the request for the patient by either downloading the file, serving it and deleting it, or it might be possible to use a HTTP streaming response.

However not sure if either is permitted or advisable (security/GDPR). 😅

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

4 participants