Invalid draftOrders in CDS-Hook Launch

25 views
Skip to first unread message

Rob Dingwell

unread,
Aug 31, 2023, 11:40:13 AM8/31/23
to Logica FHIR Developer Discussion Forum
I setup up a CDS-Hook Launch Scenario and noticed that the draftOrders included in the invocation is invalid.   The entry section of the bundle is just an array of the orders instead of being formatted as an entry with a "resource" attribute.  For example, this is what I am seeing in the draftOrders bundle. 

  "entry": [
    {
      "resourceType": "MedicationRequest",
      "id": "2a7879ba-161c-7a09-f499-94295ae9102c",
 .... }
        ]


While it should be: 

"entry": [
   { "resource" : {
      "resourceType": "MedicationRequest",
      "id": "2a7879ba-161c-7a09-f499-94295ae9102c",
 .... }
     }
        ]


I have not used a CDS-Hooks Launch Scenario before, has this been malformed for a while or could it be related to the recent changes that have been made?  

Rob Dingwell

unread,
Aug 31, 2023, 2:05:44 PM8/31/23
to Logica FHIR Developer Discussion Forum, Rob Dingwell
I would put an issue in for this on bitbucket but it looks like Jira is no longer configured for the snadbox-manager-v3 repository.  Here is the section that needs updating. 


That points to this section: 
let promises = [];
resources.forEach(res => {
promises.push(API.get(`${window.fhirClient.server.serviceUrl}/${encodeURI(res)}`));
});
let data = await Promise.all(promises);
val = {
resourceType : "Bundle",
total: data.length,
entry: data


The entry field in the generated Bundle is just an array of resources.  This should be more along the lines of something like this, where the resources are mapped to the correct format. 
let promises = [];
resources.forEach(res => {
promises.push(API.get(`${window.fhirClient.server.serviceUrl}/${encodeURI(res)}`));
});
let data = await Promise.all(promises);
val = {
resourceType : "Bundle",
total: data.length,
entry: data.map(x => { return {resource: x}})
Reply all
Reply to author
Forward
0 new messages