serenity-health / roadmap

Public roadmap for development of Serenity's apps reported by our community of users
0 stars 1 forks source link

feature/print prescription #40

Closed chris-dare closed 2 years ago

chris-dare commented 2 years ago

Tell us about your request! Should be able to print a patient's prescription

Which app does this concern? Provider portal

What will be benefit of this feature? What's the value of this feature

Describe the solution you'd like Looks similar to outsourced prescription. (Title will be different of course). See below: image

Describe alternatives you've considered Prescriptions are currently written on paper but this is not sustainable or aesthetically pleasing

Additional context N/A

pkdadson commented 2 years ago

@dexios1 please I will be waiting for the api.

chris-dare commented 2 years ago

Got it.

chris-dare commented 2 years ago

@pkdadson Richmond has created a design for the prescription. I need you to implement it so it can be integrated from the frontend.

@agbavorrichmond please share the UI design with Dadson. This should be A5 and A5 compatible please

pkdadson commented 2 years ago

@agbavorrichmond please share the UI for this task here. Merci.

pkdadson commented 2 years ago

Hello @agbavorrichmond

agbavorrichmond commented 2 years ago

Sure thing, doing that now

chris-dare commented 2 years ago

Sure thing, doing that now

@agbavorrichmond ...... :-)

chris-dare commented 2 years ago

Hi @TuyizereBapt, here is some context on this feature:

We have a version of this feature that generates the PDF on the server and sends to the frontend. We'll start with this and then switch to sharing the JSON instead for the PDF to be generated on the frontend later.

Here is a copy of the API specification: https://serenity-health.readme.io/reference/pharmacy-workflow#print-a-prescription

The task is to update the implementation so that the following are present in the printed prescription:

  1. Provider address details
  2. Patient bio info: name, MR number, Age and Gender, Mobile number
  3. Prescriptions. For each prescription, display: a. Medication name, dose, frequency, period duration, name of doctor who prescriped the medication, date prescribed You may find the encounter prescription form helpful as well as its corresponding API to see where this information gets stored: https://demo.provider.serenity.health/patients/14496/encounters/8d429f1a-8edb-468d-9a0c-00dcdc496d96/medications
  4. Name of practitioner who printed the prescription, date of prescription printing

Implementation recommendations: Note: An API view was set up for this at medication.views.MedicationRequestPrintListView. This has been done but requires an update to fulfil the use case. An endpoint has been set up for this view in medication.urls: {{base_url}}/providers/<provider_id>/medicationrequests/print/<slug:encounter_id>

You will find the pattern and implementation of diagnostics.views.DiagnosticReportPrintView as a better way to implement the printing of a prescription than seen in MedicationRequestPrintListView. I recommend this pattern because it's easier to follow and a better OOP approach. The concept of this approach is simple:

  1. Get the instance that has the core details required in the PDF
  2. Get the information as JSON and use it build the HTML file from a template
  3. Convert the HTML to a PDF
  4. Return the PDF to the client It allows for easier customizations if need be because of the abstraction and encapsulated implementations

Please review DiagnosticReportPrintView before reviewing the notes below

Now the notes below should be a helpful guide in modifying MedicationRequestPrintListView to become like DiagnosticReportPrintView

Please replace the existing template: medication/templates/prescriptions.html with a modified version of diagnostics/templates/diagnostic_report.html because that file is newer and has a better style which is consistent with all other printed documents. This updated file should have the prescription details listed above.

encounter.models.Encounter needs to have a method called prescriptions_as_pdf with the args of:

  1. self
  2. The request.user so you can retrieve and include their practitioner details in the PDF This method will be the equivalent of DiagnosticReport.as_pdf Why are we putting this method on encounter.models.Encounter and not medication.models.MedicationRequest? Because a prescription is a collection of medication requests created in an encounter. So when we know the encounter, we can get all related medication requests created in that encounter

Similarly, encounter.models.Encounter needs to have a method called build_prescription_template_context. This method will be the equivalent of DiagnosticReport.build_template_context

So in conclusion, the API implementation will do this:

  1. Get the encounter for which we want to print prescriptions
  2. Build the PDF of the encounter prescriptions by doing the following: a. Get all medication requests made in that encounter b. Build a JSON template context with those medication request details, as well as the details of the provider, patient and practitionerrole of request.user c. Generate the HTML file and convert that to PDF. (This HTML file will be an updated version of diagnostics/templates/diagnostic_report.html)
  3. Return the PDF to the client
chris-dare commented 2 years ago

Hi @TuyizereBapt,

Here's a sample payload to create a medication request:

[
    {
        "id": "ef7112bf-d735-4da8-9663-a567423aa698",
        "name": "Paracetamol for adults",
        "priority": "routine",
        "form": null,
        "category": null,
        "code": null,
        "date": null,
        "encounter": "8d429f1a-8edb-468d-9a0c-00dcdc496d96",
        "visit": null,
        "intended_dispenser": "Nyaho Medical Center",
        "patient": 14496,
        "patient_detail": {
            "first_name": "Jean baptiste",
            "lastname": "Tuyizere",
            "gender": "MALE",
            "birth_date": "2003-01-01",
            "mobile": "+250781633004",
            "age": 19
        },
        "medication_detail": [
            {
                "id": "6bcc3926-d875-4e0b-a151-17285492263f",
                "uuid": "dc94c972-f690-425f-b383-cc8b3a71a0a2",
                "created_at": "2022-03-08T08:24:58.896398Z",
                "is_deleted": false,
                "modified_at": "2022-03-08T08:24:58.896407Z",
                "display": "Paracetamol for adults"
            }
        ],
        "careplan": null,
        "status_reason": null,
        "status": "active",
        "intent": "order",
        "do_not_perform": false,
        "performer_practitioner": null,
        "performer_practitioner_role": null,
        "requester_practitioner": null,
        "requester_patient": null,
        "requester_practitioner_role": "195f155e-60bd-4ed6-b6fb-f062fe750a9d",
        "practitioner_detail": {
            "name": "Mr Chris Dare"
        },
        "recorder_practitioner": null,
        "recorder_practitioner_role": null,
        "course_of_therapy_type": "continuous",
        "prior_prescription": null,
        "medication_request_notes": [
            {
                "id": "d73a47bb-fccb-49a7-a72e-492c3b24512f",
                "uuid": "3e94c59a-d462-4756-9262-52131efdb181",
                "created_at": "2022-03-08T08:24:58.900286Z",
                "modified_at": "2022-03-08T08:24:58.900296Z",
                "display": "Note",
                "medication_request": "ef7112bf-d735-4da8-9663-a567423aa698"
            }
        ],
        "medication_request_dosage_instruction": [
            {
                "frequency": "BID (twice a day)",
                "period": "5",
                "period_unit": "Days",
                "frequency_unit": null,
                "strength": "500mg",
                "route": "ORAL_USE"
            }
        ],
        "created_at": "2022-03-08T08:24:58.890279Z",
        "modified_at": "2022-03-08T08:24:58.890290Z",
        "medication_request_insurance": [],
        "medication_request_reason_reference": [],
        "medication_request_reason_code": [],
        "medication_request_category": [
            {
                "id": "3c961879-0cc8-4394-a0f9-d9c47ce2355f",
                "uuid": "be2d04ed-70b2-42a7-b865-9d8833d16936",
                "created_at": "2022-03-08T08:24:58.908029Z",
                "is_deleted": false,
                "modified_at": "2022-03-08T08:24:58.908038Z",
                "display": "outpatient"
            }
        ],
        "quantity": null,
        "past_refills": null,
        "next_refill": null,
        "dispense_interval_in_days": null,
        "number_of_repeats_allowed": null,
        "dosage_form": "CAPSULE"
    }
]
chris-dare commented 2 years ago

Hi @pkdadson, please reactivate the feature to print prescriptions.

chris-dare commented 2 years ago

@agbavorrichmond we need the link to the UI for printing prescriptions