You need to know the PVID of the provider that you want to do a query for and add to the CDA.
Do a query on the usr table to find the firstname and lastname of the provider you want to add.
var queryResult = qie.doQuery(
channelCache.getValue('dbName'),
"SELECT firstname, lastname\n" +
"FROM usr\n" +
"WHERE pvid = {mc:PVID}");
messageCache.setValue("firstName", queryResult.getNode("firstname"));
messageCache.setValue("lastName", queryResult.getNode("lastname"));
Create a template of the assignedPerson xml.
var value = qie.evaluateTemplate("<assignedPerson>\n" +
"<name>\n" +
"<given>{mc:firstName}</given>\n" +
"<family>{mc:lastName}</family>\n" +
"</name>\n" +
"</assignedPerson>");
Now you can add this xml to your existing xml message.
message.addChildAfter('/ClinicalDocument/author/assignedAuthor/telecom', 'assignedPerson', value);