Home   Package List   Routine Alphabetical List   Global Alphabetical List   FileMan Files List   FileMan Sub-Files List   Package Component Lists   Package-Namespace Mapping  
Routine: PSN441P

PSN441P.m

Go to the documentation of this file.
PSN441P ;BIR/HW-Post install routine to update Trade Name allergies - Class; 29 June 2015  3:18 PM
 ;;4.0;NATIONAL DRUG FILE;**441**; 30 Oct 98;Build 15
 ;Reference to UPDATE^GMRAUTL2 supported by DBIA #4667
 ;This routine will update patient allergies with a Trade Name in the Reactant field 
 ;based on the VA Generic and VA Drug Class(es) provided 
 Q
EN ;Call at entry point
 N PSNPRIEN,PSNTNCNT,PSNGIEN,PSNCLASS,PSNX,PSNDONTK,PSNVAPRD,MSG,PSNTRNAM,PSNDCIEN,XPDIDTOT
 S XPDIDTOT=63
 K ^TMP("PSNMSG",$J),^TMP("PSN441P",$J)
 S ^TMP("PSNMSG",$J,1,0)="Number of Patient Allergy entries by VA DRUG CLASS:"
 S ^TMP("PSNMSG",$J,2,0)=" "
 S ^TMP("PSNMSG",$J,3,0)="Before update:"
 S ^TMP("PSNMSG",$J,4,0)="CN103 - NON-OPIOID ANALGESICS:                         "_$$CNT("CN103")
 S ^TMP("PSNMSG",$J,5,0)="CN101 - OPIOID ANALGESICS:                             "_$$CNT("CN101")
 S ^TMP("PSNMSG",$J,6,0)=" "
 S ^TMP("PSNMSG",$J,7,0)="CN400 - ANTICONVULSANTS:                               "_$$CNT("CN400")
 S ^TMP("PSNMSG",$J,8,0)="CN302 - BENZODIAZEPINE DERIVATIVE SEDATIVES/HYPNOTICS: "_$$CNT("CN302")
 S PSNTNCNT=0
 S PSNVAGEN=3283,PSNOCL=72,PSNNCL=73 D UPDATE(PSNVAGEN,PSNOCL,PSNNCL,.PSNTNCNT) ;TRAMADOL (72 is CN103, 73 is CN101)
 S PSNVAGEN=4924,PSNOCL=72,PSNNCL=73 D UPDATE(PSNVAGEN,PSNOCL,PSNNCL,.PSNTNCNT) ;TRAMADOL/ACETAMINOPHEN (72 is CN103, 73 is CN101)
 S PSNVAGEN=3743,PSNOCL=72,PSNNCL=73 D UPDATE(PSNVAGEN,PSNOCL,PSNNCL,.PSNTNCNT) ;ACETAMINOPHEN/TRAMADOL (72 is CN103, 73 is CN101)
 S PSNVAGEN=161,PSNOCL=84,PSNNCL=83 D UPDATE(PSNVAGEN,PSNOCL,PSNNCL,.PSNTNCNT) ;CLONAZEPAM (84 is CN400, 83 is CN302)
 S PSNVAGEN=167,PSNOCL=84,PSNNCL=83 D UPDATE(PSNVAGEN,PSNOCL,PSNNCL,.PSNTNCNT) ;DIAZEPAM (84 is CN400, 83 is CN302)
 ;
 K ^TMP("PSN441P",$J)
 ;
 S ^TMP("PSNMSG",$J,9,0)=" "
 S ^TMP("PSNMSG",$J,10,0)=" "
 S ^TMP("PSNMSG",$J,11,0)="After update:"
 S ^TMP("PSNMSG",$J,12,0)="CN103 - NON-OPIOID ANALGESICS:                         "_$$CNT("CN103")
 S ^TMP("PSNMSG",$J,13,0)="CN101 - OPIOID ANALGESICS:                             "_$$CNT("CN101")
 S ^TMP("PSNMSG",$J,14,0)=" "
 S ^TMP("PSNMSG",$J,15,0)="CN400 - ANTICONVULSANTS:                               "_$$CNT("CN400")
 S ^TMP("PSNMSG",$J,16,0)="CN302 - BENZODIAZEPINE DERIVATIVE SEDATIVES/HYPNOTICS: "_$$CNT("CN302")
 ; 
 K PSNVAGEN,PSNOCL,PSNNCL
 Q
 ;
CNT(PSNCLASS) ;Count the number of Patient Allergy entries for a specific class
 N PSNA,PSNB,PSNC,PSNCNT
 S (PSNA,PSNB,PSNC,PSNCNT)=0
 F  S PSNA=$O(^GMR(120.8,"APC",PSNA)) Q:'PSNA  D
 .F  S PSNB=$O(^GMR(120.8,"APC",PSNA,PSNCLASS,PSNB)) Q:'PSNB  D
 ..F  S PSNC=$O(^GMR(120.8,"APC",PSNA,PSNCLASS,PSNB,PSNC)) Q:'PSNC  D
 ...S PSNCNT=PSNCNT+1
 Q PSNCNT
UPDATE(PSNVAGEN,PSNOCL,PSNNCL,PSNTNCNT) ;Find Trade Names and update Allergies 
 N CLASS
 S CLASS("D",PSNOCL)="" ;IEN of class to be deleted
 S CLASS("A",PSNNCL)="" ;IEN of class to be added
 S PSNPRIEN=0
 F  S PSNPRIEN=$O(^PSNDF(50.68,PSNPRIEN)) Q:'PSNPRIEN  D
 .I +$P($G(^PSNDF(50.68,PSNPRIEN,0)),"^",2)'=PSNVAGEN Q 
 .I +$G(^PSNDF(50.68,PSNPRIEN,3))'=PSNNCL Q 
 .S PSNGIEN=$P(^PSNDF(50.68,PSNPRIEN,0),"^",2)
 .S PSNDCIEN=0
 .F  S PSNDCIEN=$O(^PSNDF(50.68,"ANDC",PSNPRIEN,PSNDCIEN)) Q:'PSNDCIEN  D 
 ..S PSNTRNAM=$P($G(^PSNDF(50.67,PSNDCIEN,0)),"^",5)
 ..I $D(^TMP("PSN441P",$J,PSNGIEN,PSNTRNAM)) Q 
 ..S PSNX=PSNGIEN_";PSNDF(50.6,^"_PSNTRNAM
 ..S PSNDONTK=0,PSNVAPRD=0
 ..F  S PSNVAPRD=$O(^PSNDF(50.6,"APRO",PSNGIEN,PSNVAPRD)) Q:'PSNVAPRD  D 
 ...I $P(^PSNDF(50.68,PSNVAPRD,3),"^")=PSNOCL S PSNDONTK=1
 ..I PSNDONTK K CLASS("D")
 ..S PSNTNCNT=PSNTNCNT+1
 ..D BMES^XPDUTL("Updating Patient Allergies for "_PSNTRNAM)
 ..I $T(UPDATE^GMRAUTL2)]"" D UPDATE^GMRAUTL2(PSNX,,.CLASS)
 ..S ^TMP("PSN441P",$J,PSNGIEN,PSNTRNAM)=""
 ..D UPDATE^XPDID(PSNTNCNT)
 Q