Chat Feature Integration and Access Policy Issue
# support
a
I am working on integrating a chat feature for patients and have configured specific access policies for them. I created a subscription for communication using the useSubscription() hook and also tried implementing it via the reset API. However, messages are not being triggered when sent by the practitioner. During troubleshooting, I came across a related issue on GitHub and referred to the solution provided in Medplum Issue #4385(https://github.com/medplum/medplum/issues/4385). Here’s the current configuration for Access Policy { "resourceType": "Subscription", "criteria": "Subscription?type=websocket&author=%patient" }, { "resourceType": "Communication", "criteria": "Communication?_compartment=%patient" } Code Snippet on the Patient Side app: Using Hook: useSubscription(
Communication?recipient=${PATIENT_REFERENCE}
, () => { console.log('message received'); setNotifications(notifications + 1); }, [] ); Using REST API: Attached screenshot for the same Observation: Interestingly, when the access policy is removed, the messages are successfully triggered and received by the patient. Could you please help us resolve this issue and suggest if there is anything we might be missing?
c
@rahul1 Do you have any ideas on this?
p
@rahul1 any directions would be helpful.
r
Can you confirm that this search works correctly? Communication?recipient=${PATIENT_REFERENCE} - wrongly constructed reference for example may cause no matches
a
Yes this search works correctly. Even this criteria works for subscription when accessPolicy is removed
r
If you try Communication?recipient=${PATIENT_REFERENCE} in the access policy instead of Compartment, does that work?
a
I did try Communication?recipient=${PATIENT_REFERENCE} in the access policy instead of Compartment but still doesn't work. @reshma
p
@rahul1 any thoughts? Removing Access Policy not the right solution so looking for how we can resolve it.
a
Hi @reshma and @rahul1 , Could you please review the sample app source code available on GitHub (https://github.com/anujapisemb/MedplumDemoApp/tree/medplumCommunicationDemo) and assist us in resolving the issue? Issue Details: - Communication is not being triggered when an access policy is assigned to the patient. - If no access policy is assigned, communication is received, and the "Communication Received" count in the UI increases as expected.
184 Views