EncounterId is not passed into the cds-hooks request's context

19 views
Skip to first unread message

Supresh Bhujbal

unread,
Dec 14, 2022, 3:33:15 PM12/14/22
to Logica FHIR Developer Discussion Forum
Hi,

We are launching cds-hooks workflow via Launch scenarios in logica sandbox where we selected practitionerId, and added patientId and encounterId (of the patient) to the launch context while creating this launch scenario. 

However, when we launch the cds-hooks app via the same launch scenario, we do not see encounterId passed onto the cds-hooks services via context. We only see patientId and practitionerId. Can someone please look into this?

Please see attached screenshot for more details.

Screen Shot 2022-12-14 at 3.21.09 PM.pngScreen Shot 2022-12-14 at 3.21.56 PM.png

Thanks,
Supresh 

Benjamín Celis

unread,
Mar 23, 2023, 2:21:28 PM3/23/23
to Logica FHIR Developer Discussion Forum, Supresh Bhujbal
 Were you able to solve this issue or get additional infromation?

Benjamín Celis

unread,
Mar 23, 2023, 8:27:17 PM3/23/23
to Logica FHIR Developer Discussion Forum, Benjamín Celis, Supresh Bhujbal
The issue is not on the Logica Sandbox but  in the CDS Sandbox. In my case we have a local CDS Sandbox so i had to modify it to include the Encounter.
The retrieveLaunch function on launch context retrieval needs to be updated to pass the encounter parameter.
function retrieveLaunchContext(originalLink, accessToken, patientId, fhirBaseUrl, encounterId) {
const link = { ...originalLink, remappedUrl: originalLink.url };

return new Promise((resolve, reject) => {
const headers = {
Accept: 'application/json',
...(accessToken ? {
Authorization: `Bearer ${accessToken.access_token}`,
} : {}),
};

const launchParameters = {
patient: patientId,
smart_messaging_origin: window.origin,
encounter: encounterId,
};
And in Service Exchange you also need to modify the remapSmartLinks function to include Encounter ID.  
const remapSmartLinks = ({
dispatch,
cardResponse,
fhirAccessToken,
patientId,
fhirServerUrl,
encounterId,
}) => {
((cardResponse && cardResponse.cards) || [])
.flatMap((card) => card.links || [])
.filter(({ type }) => type === 'smart')
.forEach((link) => retrieveLaunchContext(
link,
fhirAccessToken,
patientId,
fhirServerUrl,
encounterId,
).catch((e) => e).then((newLink) => dispatch(storeLaunchContext(newLink))));
};
And in dispatch results where remapIsCalled add encounter ID
remapSmartLinks({
dispatch,
cardResponse: result.data,
fhirAccessToken: state.fhirServerState.accessToken,
patientId: state.patientState.currentPatient.id,
fhirServerUrl: state.fhirServerState.currentFhirServer,
encounterId: state.fhirServerState.accessToken.encounter,
});
Reply all
Reply to author
Forward
0 new messages