Sidebar

How can I replace the PVID for each provider in a CDA with an NPI?

0 votes
415 views
asked Oct 26, 2016 by michael-h-5027 (14,350 points)
The CDA contains the Centricity internal PVID for providers instead of the NPI. I would like to replace that number with the NPI from our Centricity database.

1 Answer

0 votes

It seems that Centricity is using the OID like 1.2.840.113619.21.1.8899560752578716278.2.2 to represent PVID from the EMR. We can use that to get all of the PVIDs from the CDA document and then loop through the document and replace each one with the NPI of the provider as long as each provider has an NPI in the USR table of Centricity. 

If no NPI is found you can default the nullFlavor attribute with UNK or NA depending on what the receiving system requests.

 

// get pvid oid
var clientOID = StringUtils.substring(message.getNode('/ClinicalDocument/id/@root'), 0, -3) + '2.2';
qie.debug(clientOID);
 
var pvids = source.getAllNodes('//id[@root="'+clientOID+'"]/@extension');
 
// First remove all of the blank NPI CDA ids
message.removeAllNodes('//id[@root="2.16.840.1.113883.4.6"]');
 
for (var i=0 ; i < pvids.length ; i++) {
   var queryResult = qie.doQuery("CPS DB",
   "select npi, lastname, firstname \n" +
      "from usr \n" +
      "where pvid = " + pvids[i]);
   
   var npi = queryResult.getNode("npi");
   
   // Replace the pvid with the npi
   if (StringUtils.isBlank(npi)) {
      npi = 'No NPI on File';
      if (message.checkNodeExists('//id[@extension="'+pvids[i]+'" and @root="'+clientOID+'"]/@extension')) {
         message.removeAllNodes('//id[@extension="'+pvids[i]+'" and @root="'+clientOID+'"]/@extension');
      }
   } else {
      if (message.checkNodeExists('//id[@extension="'+pvids[i]+'" and @root="'+clientOID+'"]/@extension')) {
         message.setAllNodes('//id[@extension="'+pvids[i]+'" and @root="'+clientOID+'"]/@extension', npi);
      }
   }
   qie.debug('npi['+i+'] ' + npi);
}
 
// Replace the pvid root with the npi root
message.setAllNodes('//id[@root="'+clientOID+'"]/@root', '2.16.840.1.113883.4.6');
 
// Do this format so that the replace below works
message.formatXML(3);
 
// Must replace because we can't add an attribute via setNode
var messageString = message.getNode('/');
messageString = StringUtils.replace(messageString, '<id root="2.16.840.1.113883.4.6"/>', '<id root="2.16.840.1.113883.4.6" nullFlavor="UNK"/>'); // UNK is unknown or NA for not applicable
message.setNode('/', messageString);
answered Oct 26, 2016 by michael-h-5027 (14,350 points)
edited Oct 31, 2016 by michael-h-5027
...