Based on the information you've provided there seems to be three different user types for your product
Unless appropriate exploratory research has been made already, there seems to be a few assumptions made:
- All three user types will be tech-savvy enough to be willing to adopt new digital products
- Doctors' and pharmacists' existing software will be able to support communication with yours to send/receive prescription orders
- Patients will want to receive SMS to notify them they have a new prescription
- Patients will want to receive SMS to notify them to download your product to view their prescriptions
- Patients own a smartphone
Exploratory research (such as interviews with your potential users to understand their needs, their relationship with technology, current behaviours, pain points, etc) would be beneficial to save you time and other resources building something that might need a lot more re-work further down the line - if any of the above assumptions/hypotheses are validated after going live. Also have you checked to see if there are any other competitors in your market and how they do things? Be careful in case they are trying to meet different needs for different user base than yours, but definitely worth to get an idea of what's happening out there.
In case the above are not simply assumptions but information spawned from research insights - my thoughts would be:
If you've got a strong case study why SMS is the way to go ahead, can the doctor email or communicate with the patient on your behalf (considering they already have permission and hold their patient's contact details)? Not 100% sure about security on this but could the doctor create a placeholder-account on behalf of their patients (with their permission of course) using only the patient's email (or a QR code like you've already mentioned)? Then it's up to the patient to accept the invitation link and setup a password as a way of validating their account, else after 48hrs the placeholder-account will get removed. That way it might be less hassle for the patient and they'll be able to immediately view their prescription - giving them the option in-app to opt-in for SMS alerts.
In the UK to get access to the PatientAccess app (web and mobile - for doctor appointments and prescriptions online) the GP Practice needs to send you a registration letter with an account ID to sign up with.
Moreover, PatientAccess exists both as a web app and as a mobile app to meet the needs and situation/circumstances of a broader patient base - just a thought to consider. Doesn't mean because someone has a phone they'll prefer to use it to book appointments or view prescriptions, take into consideration the patient demographics and any accessibility needs they might have.
As a final note, when it comes to user onboarding this is a cool site to follow https://www.useronboard.com/ - lots of different onboarding methods researched that are used by varied companies.
I hope this helps.