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

PSONEWOC.m

Go to the documentation of this file.
PSONEWOC ;BIR/SAB-STORES BACKDOOR ORDER CHECKS IN FILE #100.05 ;11/08/2012
 ;;7.0;OUTPATIENT PHARMACY;**411**;DEC 1997;Build 95
 ;External reference to SAVEOC^OROCAPI1 supported by DBIA 5729
 ;External reference to ^ORD(100.05, supported by DBIA 5731
 ; 
ACT ;store order checks
 N PSOZH,PSOKIND,DA,DR,DIC,DIE S RXN=$O(^TMP("PSORXN",$J,0))
 I $G(PSONV) S ZRXN=PSONV
 ;I $G(^TMP("PSODAOC",$J,"NORDI",1,0))]"" D NORDI^PSONEWO1
 ;I $D(^TMP("PSODAOC",$J,"DD")) S PSOKIND="DD",PSOZH="Duplicate Drug" D SET ;dup drug
 I $D(^TMP("PSODAOC",$J,"ALLERGY")) S PSOZH="Order Allergy" D DAOC^PSONEWOA ;drug allergies
 ;I $G(^TMP("PSODAOC",$J,"CLOZ",0))]"" S PSOZH="Clozapine" D CLOZ^PSONEWO1
 ;I $D(^TMP("PSODAOC",$J,"DI",0))]"" S PSOKIND="DI",PSOZH="Drug Interaction" D SET ;drug interaction
 ;I $D(^TMP("PSODAOC",$J,"CROC")) D CROCLOG^PSOCROC
 ;I $D(^TMP("PSODAOC",$J,"DT")) S PSOKIND="DT",PSOZH="Duplicate Therapy" D SET ;dup drug therapy
 ;I $O(^TMP("PSODAOC",$J,"CPRS",0)) S PSOZH="Order Check" D CPRS^PSONEWO1 ;cprs order checks
 ;I $G(^TMP("PSODAOC",$J,"NOSYS",1,0))]"" D NOSYS^PSONEWO1 ;fdb down
 ;I $O(^TMP("PSODAOC",$J,"EXEC",0)) D EXEC^PSONEWO1 ;order chk execeptions
 ;I $O(^TMP("PSODAOC",$J,"DRG","ERROR",0))!($O(^TMP("PSODAOC",$J,"THP","ERROR",0))) D ERROR^PSONEWO1 ;order chk errors
 ;I $D(^TMP("PSODAOC",$J,"DOSE","ERROR")) D DERROR^PSONEWO1 ;dosing order chk errors
 ;I $O(^TMP("PSODAOC",$J,"DOSE","EXEC",0)) D DEXEC^PSONEWO1 ;dosing order chk exceptions
 ;I $O(^TMP("PSODAOC",$J,"DOSE","MSG",0)) D DMSG^PSONEWO1 ;dosing order chk messages
 ;I $G(^TMP("PSODAOC",$J,"DOSE NOSYS",1,0))]"" D NODSYS^PSONEWO1 ;dosing fdb down
 K CT,IT,PSODAOC,I,PI,XZX,ZZCOPY,PSOZH
 Q
 ;
SET ;DEFINED 100.05
 N DA,DIC,DIE,OCCDT,ORN,ORL,RET,SEV,ZOC,ZZX,ZTOT,ZDRG,ZORT,ZCHK,ZCLZ,ZX,PSODAOCN,PSOSTYP,CLASS,CLASSIEN,STATUS,ODA,ZVA,PSORDRG,SEVERITY
 S RXN=ZRXN
 S PSODAOC=$$LBL(RXN)
 S OCCDT=$$NOW^XLFDT,ORN=$P(^PSRX(RXN,"OR1"),"^",2),ZCLZ=""
 ;
 S (ZCLZ,SEV,ZVA)="",ZX=0
 F  S SEV=$O(^TMP("PSODAOC",$J,PSOKIND,SEV)) Q:SEV=""!(SEV="Z")  F  S ZVA=$O(^TMP("PSODAOC",$J,PSOKIND,SEV,ZVA)) Q:ZVA=""  D
 .S (PSOSTYP,SEVERITY,IT,ODA)=""
 .K DA,DIC,DIE
 .I PSOKIND="DD" D  S SEVERITY=16
 ..S PI=0,PSOSTYP=50 F  S PSOSTYP=$O(^TMP("PSODAOC",$J,PSOKIND,SEV,ZVA,PSOSTYP)) Q:PSOSTYP=""  F  S PI=$O(^TMP("PSODAOC",$J,PSOKIND,SEV,ZVA,PSOSTYP,"CLASS",PI)) Q:'PI  D
 ...S (CLASSIEN,CLASS)="",CLASS=^TMP("PSODAOC",$J,PSOKIND,SEV,ZVA,PSOSTYP,"CLASS",PI,0) ;,CLASSIEN=$O(^PS(50.605,"B",CLASS,CLASSIEN))  
 ...S:CLASS'="" ZCLZ=ZCLZ_", "_CLASS
 ..S ZCLZ=$E(ZCLZ,3,999)
 .I PSOKIND="DI" D
 ..S IT=$G(^TMP("PSODAOC",$J,"DI","Z","INT")),SEVERITY=$S(SEV="C":18,1:31)
 .K DA,RET,ORL
 .I PSOKIND="DT" S SEVERITY=17
 .S ORL(1,1)=ORN_"^"_$S($D(PSJDAOC):PSJDAOC,1:PSODAOC)_"^"_DUZ_"^"_OCCDT_"^"_SEVERITY
 .S ORL(1,2,1)=PSOZH_" exists for this medication." S:PSOKIND="DD" ORL(1,2,1)=ORL(1,2,1)_$S(ZCLZ'="":"["_ZCLZ_"]",1:"") K ZCLZ
 .D SAVEOC^OROCAPI1(.ORL,.RET)
 .S DA=$O(RET(1,0)) Q:'DA
 .S:ODA'=DA ODA=DA
 .;S STATUS="",STATUS=$$GET1^DIQ(52,RXN,100,"I")
 .S DR="1///6"
 .S:$G(IT) DR=DR_";81///"_IT
 .S DIE="^ORD(100.05,",DR=DR_$S(PSOKIND="DI":";83///"_SEV_";84///C",PSOKIND="DD":";84///V",1:";84///C")
 .I $E(DR,1)=";" S DR=$E(DR,2,999)
 .D ^DIE
 .D SET2
 K DR
 Q
 ;
SET2 ;
 ; #50 - DISPENSE DRUGS^100.06PA^^5;0
 I $D(^TMP("PSODAOC",$J,PSOKIND,ZVA,50)) S X="",X=$O(^TMP("PSODAOC",$J,PSOKIND,ZVA,50,X)) D
 .K DIC,DIE
 .S DA(1)=DA,DIC="^ORD(100.05,"_DA(1)_",5,",DIC(0)="Z"
 .D FILE^DICN K X
 ;
GRP1 ;
 ; #60 - GROUP ONE PHARMACY ORDERS^100.07VA^^6;0
 ; OP PENDING ORDERS - IEN;PS(52.41,
 ; IP RX - IEN;PS(53.1,
 ; OP RX - IEN;PSRX(
 S ZX=0
 F  S ZX=$O(^TMP("PSODAOC",$J,PSOKIND,SEV,ZVA,60,ZX)) Q:'ZX!(ZX="CL")  D
 .S ZORT="",ZORT=^TMP("PSODAOC",$J,PSOKIND,SEV,ZVA,60,ZX,0)
 .S DA(1)=DA,X=ZORT,DIC="^ORD(100.05,"_DA(1)_",6,",DIC(0)="Z"
 .D FILE^DICN
 .K DIC
 .S ODA(1)=DA(1)
 .;I $D(^TMP("PSODAOC",$J,PSOKIND,SEV,ZVA,60,"CL")) S PSODAOCN=60 D CLINEFF S DA=ODA,DA(1)=ODA(1)
 ;
GRP2 ;
 ;GROUP TWO PHARMACY ORDER FIELD (#70)
 ;Data is formatted as follows:
 ;"N;ien" => Non-VA Medications  ^PS(55,DFN,"NVA",ien)
 ;"R;rx#" => Remote Outpatient   ^PSRX(ien  Prescription Number
 S ZX=0 F  S ZX=$O(^TMP("PSODAOC",$J,PSOKIND,SEV,ZVA,70,ZX)) Q:'ZX!(ZX="CL")  D
 .S ZORT="",ZORT=^TMP("PSODAOC",$J,PSOKIND,SEV,ZVA,70,ZX,0)
 .N PSORIEN,PSORSITI,PSORSITE
 .I $P(ZORT,";")="R" D
 ..S PSORIEN=$P($P(ZORT,"^",1),";",2),PSORSITE=$P(ZORT,"^",2),PSORDRG=$P(ZORT,"^",5)
 ..S:PSORSITE'="" PSORSITI=$O(^DIC(4,"B",PSORSITE,PSORSITI))
 ..S ZORT="R;"_PSORIEN_"^"_PSORSITI
 .K DIC
 .S DA(1)=DA,X=ZORT,DIC="^ORD(100.05,"_DA(1)_",7,",DIC(0)="Z"
 .D FILE^DICN
 .K DIC
 .;I $D(^TMP("PSODAOC",$J,PSOKIND,SEV,ZVA,70,"CL")) S PSODAOCN=70 D CLINEFF S DA=ODA,DA(1)=ODA(1)
 ;Q
 ;
CLINEFF ;clinical effects
 N PSOFILE,PSOIENS,PSOCLEFF,DIWL,DIWR,DIWF,DINUM,DR,OLDX,OLD
 Q:'$D(^TMP("PSODAOC",$J,PSOKIND,SEV,ZVA,"CL"))
 K DIC,^UTILITY($J,"W")
 S DIWL=1,DIWR=78,DIWF="",(DINUM,PSOCLEFF,OLDX)=""
 I SEV="S" S X="*** Refer to MONOGRAPH for SIGNIFICANT INTERACTION CLINICAL EFFECTS" D ^DIWP G CLINEFF1
 F  S PSOCLEFF=$O(^TMP("PSODAOC",$J,PSOKIND,SEV,ZVA,"CL",PSOCLEFF)) Q:PSOCLEFF=""  D  S OLDX=X
 .S X="",X=^TMP("PSODAOC",$J,PSOKIND,SEV,ZVA,"CL",PSOCLEFF,0) I X'=OLDX D ^DIWP
CLINEFF1 ;
 S X="",DIC="^ORD(100.05,"_DA(1)_",10,",DIC(0)="Z"
 S (DA,DINUM)=$O(^ORD(100.05,DA(1),10,9999),-1)+1
 D FILE^DICN
 K DIC,DIE,DR
 S PSOFILE=100.05,PSOCLEFF="",PSOCLEFF=$NA(^UTILITY($J,"W",1))
 D WP^DIE(PSOFILE,DA(1),100,"A",PSOCLEFF,"PSOER")
 K ^UTILITY($J,"W")
 ;
 ;for some strange reason if you put the following code before CLINEFF the clinical effects aren't stored.
 K DIC,DIE,DIR,DA
 S DA=ODA
 I $P(ZORT,";")="R" D
 .S DIE="^ORD(100.05,"_DA_",7,",DA(2)=DA,DA(1)=7,DR="2///"_PSORSITI
 .S DA=99999,DA=$O(^ORD(100.05,DA(2),7,DA),-1)
 .D ^DIE
 Q
 ;
LBL(RXN) ;
 ;Q "OP "_$S($G(ZZVER):"Verification ",$G(ZFRENEW):"CPRS RENEWAL ",$G(ZZEDIT):"EDIT ",$G(ZZCOPY):"COPY ",$G(PSOREINS):"REINSTATE ",$P(^PSRX(RXN,"STA"),"^")=1:"NON-VERIFIED ",$G(PSOARENW)=1:"RENEWAL ",1:"NEW ")_$G(PSOZH)
LBL2 ;
 N TEXT
 S TEXT="",TEXT="OP "_$S('$D(^XUSEC("PSORPH",DUZ))&($P(^PSRX(RXN,"STA"),"^")):"Non-Verified ",$D(^XUSEC("PSORPH",DUZ))&($G(ZZVER)):"RPh Verification ",1:"")
 S TEXT=TEXT_$S($G(ZFRENEW):"CPRS RENEWAL ",$G(ZZEDIT):"EDIT ",$G(ZZCOPY):"COPY ",$G(PSOREINS):"REINSTATE ",$G(PSOARENW)=1:"RENEWAL ",1:"NEW ")
 Q TEXT