Provider seeing only assigned patients

Hi,

I am trying to implement Bahmni on a polyclinic setting. One of the user requirement is that providers can only see patients they were assigned to or referred to. How can I configure OpenMrs to meet that requirement ?

Best,

Right now the application doesn’t have a specific ability to configure query of patient list queue based on the logged in user.

However using a few of other features, one solution to achieve your use case right now could be, to configure multiple patient lists as mentioned in the wiki below. Each query would have hardcoded provider name in the query and then you can control the visibility of the patient queue based on privileges.

Refer the documentation to configure the patient queue. https://bahmni.atlassian.net/wiki/display/BAH/Configure+Patient+Lists

For assigning patients to providers you can use one of the two

  1. Obs form having coded answers as provider names to a question, which you can later use in the query mentioned above.

  2. Relationship https://bahmni.atlassian.net/wiki/display/BAH/Configure+Patient+Registration#ConfigurePatientRegistration4.ConfigurePatientRelationships

I like the suggestion on using some Obs form. Would it be better if we use a Visit Attribute instead and the registration person can set that while starting visit. That way, the registration clerk won’t need access to Clinical App.

I don’t think we should be using Patient Relationships for this. These are for linking family members of patients like Mother and Child etc. Also these are at the Patient level and not expected to change per visit.

Also can you please share how “you can control the visibility of the patient queue based on privileges.”?

Relationship can also be used to relate a Doctor and a patient which is termed as Provider relationship.

In “extension.json” under the key “requiredPrivilege” you can specify the privilege required to view the queue. Please refer this https://bahmni.atlassian.net/wiki/display/BAH/Configure+Patient+Lists

1 Like

Thank you all.

Making sure some of the things said here are correct.

>> Right now the application doesn’t have flexibility to configure query of patient list queue based on the logged in user. One solution would be hardcode the patient list query with provider name and then control the visibility of the patient queue based on privileges This is not correct. You can do this. Patient listing can be defined based on current logged in provider. To do that you can define query like the following: https://github.com/Bahmni/jss-config/blob/master/openmrs/migrations/liquibase.xml#L1263 Notice “pr.uuid=${provider_uuid}” in the query this is passed dyanmically. And you define the patient listing like this: https://github.com/Bahmni/jss-config/blob/master/openmrs/apps/clinical/extension.json#L83 So, you don’t need to create query per provider. I have updated the documentation https://bahmni.atlassian.net/wiki/display/BAH/Configure+Patient+Lists for this.

>> Relationship can also be used to relate a Doctor and a patient which is termed as Provider relationship. One can do this. Except that you will have to change this every time the provider changes.

1 Like

Hi Vivek, Can you help me with instructions on how to perform this step: To do that you can define query like the following: https://github.com/Bahmni/jss-config/blob/master/openmrs/migrations/liquibase.xml#L1263 ? The other 2 steps are clear to me where to make the changes, but for the first one I don’t have any idea (I’m a biochemist, not a programmer, sorry) Thanks in advance for your help.

Hi German Acevedo,

Step 1 : Go to https://{{your-ip}}/openmrs -> click on Administration -> Advanced Settings Step 2 : Click on “Add Property” which is at the bottom of the page. Step 3 : Under Name, please add “emrapi.sqlSearch.todaysPatientsByProvider” and also add the below query under value then click on save

select distinct concat(pn.given_name," “, pn.family_name) as name, pi.identifier as identifier, concat(”",p.uuid) as uuid, concat("",v.uuid) as activeVisitUuid from visit v join person_name pn on v.patient_id = pn.person_id and pn.voided = 0 and v.voided=0 join patient_identifier pi on v.patient_id = pi.patient_id and pi.voided=0 join person p on p.person_id = v.patient_id and p.voided=0 join encounter en on en.visit_id = v.visit_id and en.voided=0 join encounter_provider ep on ep.encounter_id = en.encounter_id and ep.voided=0 join provider pr on ep.provider_id=pr.provider_id and pr.retired=0 join person per on pr.person_id=per.person_id and per.voided=0 where date(en.encounter_datetime)=curdate() and pr.uuid=${provider_uuid} order by en.encounter_datetime desc;

Step 4: Add the below section in /var/www/bahmni_config/openmrs/apps/clinical/extension.json

“bahmniClinicalPatientsSearchTodaysPatientsByProvider”: { “id”: “bahmni.clinical.patients.search.allPatients”, “extensionPointId”: “org.bahmni.patient.search”, “type”: “config”, “extensionParams”: { “searchHandler”: “emrapi.sqlSearch.todaysPatientsByProvider”, “display”: “My Patients”, “forwardUrl”: “#/default/patient/{{patientUuid}}/dashboard?encounterUuid=active”, “label”:“My Patients” }, “label”: “My Patients”, “order”: 2, “requiredPrivilege”: “app:clinical” }

Please refer the documentation link https://bahmni.atlassian.net/wiki/display/BAH/Configure+Patient+Lists

1 Like

Thanks, I have now it working, but something strange is happening:

I have created a new user with Bahmni Doctor and Registration Clerk roles (in our organization the doctor makes the registration of the patient also). First there were only 1 patient showing: Test CloseVisit (GAN200061). Then I created a new patient, and it showed in My Patients tab as expected. I created a 2nd. patient, but now there are 4 patients in my patients tab, but more strange is that I have 2 My Patients tabs inside Clinical, as you can see in this screenshot:

Now also appears another patient (that is not associated with my new doctor) with ID Test DrugDataOne (GAN200000) and my new doctor can add consultations tho this patient and see all his medical history. Is there any way to filter also the registered patients to the provider? Regards, German

In the screenshot you shared, i could see 3 patients under “My patients” tab. If your requirement is to show only “My Patients” tab to the Doctors, you can remove the other tabs from the configuration (extension.json). Can you please share the extension.json content ?

Thanks for your help, sure I want to show only My Patients tab for Bahmni Doctors.

This is the content of /opt/bahmni-web/etc/bahmni_config/openmrs/apps/clinical/extension.json:

{ “observations”: { “id”: “bahmni.clinical.consultation.observations”, “extensionPointId”: “org.bahmni.clinical.consultation.board”, “type”: “link”, “label”: “Observations”, “translationKey”:“OBSERVATIONS_BOARD_LABEL_KEY”, “url”: “concept-set-group/observations”, “default”: true, “icon”: “fa-user-md”, “order”: 1, “requiredPrivilege”: “app:clinical:observationTab” }, “diagnosis”: { “id”: “bahmni.clinical.consultation.diagnosis”, “extensionPointId”: “org.bahmni.clinical.consultation.board”, “type”: “link”, “label”: “Diagnosis”, “translationKey”:“DIAGNOSIS_BOARD_LABEL_KEY”, “url”: “diagnosis”, “icon”: “fa-user-md”, “order”: 2, “requiredPrivilege”: “app:clinical:diagnosisTab” }, “disposition”: { “id”: “bahmni.clinical.consultation.disposition”, “extensionPointId”: “org.bahmni.clinical.consultation.board”, “type”: “link”, “label”: “Disposition”, “translationKey”:“DISPOSITION_BOARD_LABEL_KEY”, “url”: “disposition”, “icon”: “fa-user-md”, “order”: 3, “requiredPrivilege”: “app:clinical:dispositionTab” }, “consultationSummary”: { “id”: “bahmni.clinical.consultation.summary”, “extensionPointId”: “org.bahmni.clinical.consultation.board”, “type”: “link”, “label”: “Consultation”, “translationKey”:“CONSULTATION_BOARD_LABEL_KEY”, “url”: “consultation”, “icon”: “fa-user-md”, “order”: 5, “requiredPrivilege”: “app:clinical:consultationTab” }, “bahmniClinicalOrdersPending”: { “id”: “bahmni.clinical.orders.pending”, “extensionPointId”: “org.bahmni.clinical.orders”, “type”: “link”, “label”: “Pending Orders”, “url”: “pendingOrders”, “icon”: “fa-user-md”, “order”: 5, “requiredPrivilege”: “app:radiologyOrders” }, “bahmniClinicalPatientsSearchAllActivePatients”: { “id”: “bahmni.clinical.patients.search.allActivePatients”, “extensionPointId”: “org.bahmni.patient.search”, “type”: “config”, “extensionParams”: { “searchHandler”: “emrapi.sqlSearch.activePatients”, “translationKey”: “MODULE_LABEL_ACTIVE_KEY”, “forwardUrl”: “#/default/patient/{{patientUuid}}/dashboard” }, “label”: “Active”, “order”: 1, “requiredPrivilege”: “app:clinical” }, “bahmniClinicalPatientsSearchActivePatientsForPrograms”: { “id”: “bahmni.clinical.patients.search.activePatients”, “extensionPointId”: “org.bahmni.patient.search”, “type”: “config”, “extensionParams”: { “searchHandler”: “emrapi.sqlSearch.activePatients”, “translationKey”: “MODULE_LABEL_PROGRAMS_KEY”, “forwardUrl”: “#/default/patient/{{patientUuid}}/consultationContext” }, “label”: “Active”, “order”: 1, “requiredPrivilege”: “app:clinical” }, “bahmniClinicalPatientsASearchActivePatientsByProvider”: { “id”: “bahmni.clinical.patients.search.activePatientsByProvider”, “extensionPointId”: “org.bahmni.patient.search”, “type”: “config”, “extensionParams”: { “searchHandler”: “emrapi.sqlSearch.activePatientsByProvider”, “translationKey”: “MODULE_LABEL_MY_PATIENTS_KEY”, “forwardUrl”: “#/default/patient/{{patientUuid}}/dashboard” }, “label”: “Active”, “order”: 2, “requiredPrivilege”: “app:clinical” }, “bahmniClinicalPatientsSearchOPDActivePatientsByProvider”: { “id”: “bahmni.clinical.patients.search.OPDActivePatientsByProvider”, “extensionPointId”: “org.bahmni.patient.search”, “type”: “config”, “extensionParams”: { “searchHandler”: “emrapi.sqlSearch.activePatientsByProvider”, “translationKey”: “MODULE_LABEL_OPD_1_KEY”, “forwardUrl”: “#/default/patient/{{patientUuid}}/consultationContext” }, “label”: “OPD-1”, “order”: 3, “requiredPrivilege”: “app:clinical” }, “activePatientsByLocation”: { “id”: “bahmni.clinical.patients.search.activePatientsByLocation”, “extensionPointId”: “org.bahmni.patient.search”, “type”: “config”, “extensionParams”: { “searchHandler”: “emrapi.sqlSearch.activePatientsByLocation”, “translationKey”: “MODULE_LABEL_ACTIVE_PATIENTS_BY_LOCATION”, “forwardUrl”: “#/default/patient/{{patientUuid}}/dashboard” }, “label”: “Active”, “order”: 4, “requiredPrivilege”: “app:clinical” }, “bahmniClinicalPatientsSearchAllPatients”: { “id”: “bahmni.clinical.patients.search.allPatients”, “extensionPointId”: “org.bahmni.patient.search”, “type”: “config”, “extensionParams”: { “translationKey”: “MODULE_LABEL_ALL_KEY”, “forwardUrl”: “#/default/patient/{{patientUuid}}/dashboard” }, “label”: “All”, “order”: 5, “requiredPrivilege”: “app:clinical” }, “bahmniClinicalConceptSetGroupObservationsHistory”: { “id”: “bahmni.clinical.conceptSetGroup.observations.history”, “extensionPointId”: “org.bahmni.clinical.conceptSetGroup.observations”, “type”: “config”, “extensionParams”: { “conceptName”: “History and Examination”, “default”: true }, “order”: 1, “requiredPrivilege”: “app:clinical:history” }, “bahmniClinicalConceptSetGroupObservationsVitals”: { “id”: “bahmni.clinical.conceptSetGroup.observations.vitals”, “extensionPointId”: “org.bahmni.clinical.conceptSetGroup.observations”, “type”: “config”, “extensionParams”: { “default”: true, “conceptName”: “Vitals” }, “order”: 2, “requiredPrivilege”: “app:clinical” }, “bahmniClinicalConceptSetGroupObservationsSecondVitals”: { “id”: “bahmni.clinical.conceptSetGroup.observations.secondVitals”, “extensionPointId”: “org.bahmni.clinical.conceptSetGroup.observations”, “type”: “config”, “extensionParams”: { “conceptName”: “Second Vitals”, “showIf”: [ “var visitTypes = [];”, “if(visitTypes.length === 0) return true;”, “var visitTypeName = context.visitType ? context.visitType.name : null;”, “return visitTypes.indexOf(visitTypeName) !== -1;” ] }, “order”: 3, “requiredPrivilege”: “app:clinical” }, “bahmniClinicalConceptSetGroupObservationsObstetrics”: { “id”: “bahmni.clinical.conceptSetGroup.observations.obstetrics”, “extensionPointId”: “org.bahmni.clinical.conceptSetGroup.observations”, “type”: “config”, “extensionParams”: { “conceptName”: “Obstetrics” }, “order”: 4, “requiredPrivilege”: “app:clinical” }, “bahmniClinicalConceptSetGroupObservationsGynaecology”: { “id”: “bahmni.clinical.conceptSetGroup.observations.gynaecology”, “extensionPointId”: “org.bahmni.clinical.conceptSetGroup.observations”, “type”: “config”, “extensionParams”: { “conceptName”: “Gynaecology” }, “order”: 5, “requiredPrivilege”: “app:clinical” }, “bahmniClinicalConceptSetGroupObservationsDischargeSummary”: { “id”: “bahmni.clinical.conceptSetGroup.observations.dischargeSummary”, “extensionPointId”: “org.bahmni.clinical.conceptSetGroup.observations”, “type”: “config”, “extensionParams”: { “conceptName”: “Discharge Summary” }, “order”: 6, “requiredPrivilege”: “Discharge Summary” }, “bahmniClinicalBillingTreatment”: { “id”: “bahmni.clinical.billing.treatment”, “extensionPointId”: “org.bahmni.clinical.consultation.board”, “type”: “link”, “label”: “Medications”, “translationKey”:“MEDICATIONS_BOARD_LABEL_KEY”, “extensionParams”:{ “tabConfigName”: “allMedicationTabConfig” }, “url”: “treatment”, “icon”: “fa-user-md”, “order”: 7, “requiredPrivilege”: “app:clinical:consultationTab” }, “bahmniClinicalConsultationOrders”: { “id”: “bahmni.clinical.consultation.orders”, “extensionPointId”: “org.bahmni.clinical.consultation.board”, “type”: “link”, “label”: “Orders”, “translationKey”:“ORDERS_BOARD_LABEL_KEY”, “url”: “orders”, “icon”: “icon-user-md”, “order”: 6, “requiredPrivilege”: “app:clinical:diagnosisTab” }, “bahmniClinicalConsultationBacteriology”: { “id”: “bahmni.clinical.consultation.bacteriology”, “extensionPointId”: “org.bahmni.clinical.consultation.board”, “type”: “link”, “label”: “Bacteriology”, “translationKey”:“BACTERIOLOGY_BOARD_LABEL_KEY”, “url”: “bacteriology”, “icon”: “icon-user-md”, “order”: 7, “requiredPrivilege”: “app:clinical:diagnosisTab” }, “bahmniClinicalPatientsSearchTodaysPatientsByProvider”: { “id”: “bahmni.clinical.patients.search.allPatients”, “extensionPointId”: “org.bahmni.patient.search”, “type”: “config”, “extensionParams”: { “searchHandler”: “emrapi.sqlSearch.todaysPatientsByProvider”, “display”: “My Patients”, “forwardUrl”: “#/default/patient/{{patientUuid}}/dashboard?encounterUuid=active”, “label”:“My Patients” }, “label”: “My Patients”, “order”: 2, “requiredPrivilege”: “app:clinical” } }

According to your requirement, if you want only one tab i.e
, tab that shows the active patients per Doctor, then you can remove the below quoted sections from your extension.json.

@sravanthi17 I believe we can utilize the Appointment module to see a patient’s list under certain provider/clinic through filtering appointments by providers/clinics.

When a patient walks in to a clinic, she can be checked-in as a “walk-in appointment”, then provider/clinic will have access to the appointment page and can filter patients under her name.

Just a thought.

Regards,

@arak2002:

You can configure it that way.

But the use case here is in different modules
 not the appointment module. For example: Doctor accessing clinical module, wants to see the active patients for that Doctor in the patient search page.

I came across this as I haven’t still managed to get the appointment module working with 0.88. The sql query supplied with the demo database wasn’t working for the provider, so I replaced it with the one suggested here. However that still didn’t work as expected. To make it clear, I have regone as receptionist who assigns a provider(doctorone) to a patient while starting the visit. When the doctorone logs in, he doesn’t see any patients in ‘MyPatients’ list. Trying to troubleshoot this, I ran the query without the provider uuid criteria mysql> select distinct concat(pn.given_name," “, pn.family_name) as name, pi.identifier as identifier, concat(”",p.uuid) as uuid, concat("",v.uuid) as activeVisitUuid, pr.provider_id as provider from visit v join person_name pn on v.patient_id = pn.person_id and pn.voided = 0 and v.voided=0 join patient_identifier pi on v.patient_id = pi.patient_id and pi.voided=0 join person p on p.person_id = v.patient_id and p.voided=0 join encounter en on en.visit_id = v.visit_id and en.voided=0 join encounter_provider ep on ep.encounter_id = en.encounter_id and ep.voided=0 join provider pr on ep.provider_id=pr.provider_id and pr.retired=0 join person per on pr.person_id=per.person_id and per.voided=0 where date(en.encounter_datetime)=curdate() order by en.encounter_datetime desc; ±------------±--------------±-------------------------------------±-------------------------------------±---------+ | name | identifier | uuid | activeVisitUuid | provider | ±------------±--------------±-------------------------------------±-------------------------------------±---------+ | Vijay Kumar | PNV-KKL203003 | b04b88b2-e5fc-4134-8871-f29552059fe0 | a7778368-8eba-4a20-836a-be5ca558d78f | 12 | | Vijay Kumar | 2804 | b04b88b2-e5fc-4134-8871-f29552059fe0 | a7778368-8eba-4a20-836a-be5ca558d78f | 12 | | Vijay Kumar | PNV-KKL203003 | b04b88b2-e5fc-4134-8871-f29552059fe0 | 8e1ec7d2-be9f-4ba4-81c2-cdd9ddba3920 | 12 | | Vijay Kumar | 2804 | b04b88b2-e5fc-4134-8871-f29552059fe0 | 8e1ec7d2-be9f-4ba4-81c2-cdd9ddba3920 | 12 | ±------------±--------------±-------------------------------------±-------------------------------------±---------+

That is listing the visits(It is odd to see two visits created, one for patient identifier and one for national id).

However it didn’t look like provider id was right. Looking at it further mysql> select distinct concat(pn.given_name," ", pn.family_name) as name from person p join person_name pn on p.person_id = pn.person_id join provider pr on pr.person_id=p.person_id where provider_id=12; ±-----------+ | name | ±-----------+ | RegOne Rao | ±-----------+ 1 row in set (0.00 sec)

That is the user who started the visit rather than the assigned doctor. Normally, I wouldn’t treat registration user as provider, however I had to create provider account for registration user due to some login issue. Wondering whether I have done something wrong or it is defect.

this doesn’t mean there are two visits
 The query returns multiple results for same visit because there are 2 patient identifiers for a patient. Instead if you modify the query to filter based on primary identifier as shown below (type 3 is primary identifier), you could see only one result.

patient_identifier pi on v.patient_id = pi.patient_id and pi.voided=0 and pi.identifier_type=3

In the system, the provider is the one who created the visit. In this case registration user is the one who created the visit. this is what the query also defines
 As of now the system doesn’t support assigning a patient to a doctor during registration.

Thanks, Its been ages since I last used sql!

hmm, that is disappointing as it won’t work for patient queues unless the doctor also takes the role of a registration user. It looks more of a defect rather than system limitation. Wondering where else Provider relationship is used if not for patient queues


Can still be used in the case of patient queues. For instance, as a provider I would like to see all the patient list for whom I have given consultation. In this case the encounter provider is the doctor and not the registration person.

Thanks @sravanthi17,

I am recording the patient<->provider(encounter provider?) relationship as a registration user. I would like to get that info when logged in as encounter provider, so that the doctor can see the list of patients who are going to get consulted. He isn’t really interested in the registration user that created the encounter. I tried some variation of the query by using encounter_provider_id instead of provider_id. However that didn’t make any difference. Could you please help in getting this working? I looked at the encounter_provider and provider tables, but couldn’t really find good links to get this done myself :frowning:

If the information is captured as relationships, then the query should pull out data from relationship table which is were the data is recorded into