PSOORRDI ;BHAM-ISC/EJW - Remote Data Interoperability Order Checks ;04/25/05 ;;7.0;OUTPATIENT PHARMACY;**207,243**;DEC 1997;Build 22 ; ;External references to ^ORRDI1 supported by DBIA 4659 ;External references to ^XTMP("ORRDI" supported by DBIA 4660 ;External reference to ^PS(50.605 supported by DBIA 696 ;External reference to ^PSDRUG supported by DBIA 221 ;External reference to ^PS(56 supported by DBIA 2229 ;External reference to ^PS(50.416 supported by DBIA 692 ;External reference to DDIEX^PSNAPIS supported by DBIA 2574 REMOTE(PSODFN,DREN) ; ; Input: DFN: PATIENT file (#2) IEN ; : DREN: DRUG file (#50) IEN of order being checked I $T(HAVEHDR^ORRDI1)']"" Q I '$$HAVEHDR^ORRDI1 Q I $D(^XTMP("ORRDI","OUTAGE INFO","DOWN")) Q N PSORDI,RDIINST,RDIVUID,RDIRX,RDIDNAM,RDISTA,RDISIG,RDIDAYS,RDIQTY,RDIFILL,RDIEXP,RDIISS,RDIFILL,RDIREF,RDIPHYS,PSOPROD,PSOCLASS,DRNM,RDITMP,PSODC,IT,PSOICT,NDF,RDIDI,PSOPRODA,PSOFILE,PSOSIG I '$G(DT) S DT=$$DT^XLFDT S PSORDI=0 I $T(GET^ORRDI1)]"" S PSORDI=$$GET^ORRDI1(PSODFN,"PSOO") I PSORDI<1 Q I '$D(^XTMP("ORRDI","PSOO",PSODFN)) Q K ^TMP($J,"PSORDI") D PARSE,FILTER I '$D(^TMP($J,"PSORDI")) Q D DRGNAME ; GET VA PRODUCT FILE NAME FOR FILE 50 DRUG BEING CHECKED S PSORDI="" F S PSORDI=$O(^TMP($J,"PSORDI",PSORDI)) Q:'PSORDI S RDITMP=^(PSORDI) D .S RDIINST=$P(RDITMP,"^") .S RDIVUID=$P(RDITMP,"^",2) .I RDIVUID="" Q .S RDIDNAM=$P(RDITMP,"^",3) .S RDISTA=$P(RDITMP,"^",4) .S RDIRX=$P(RDITMP,"^",5) .S RDIFILL=$P(RDITMP,"^",6) .S RDIDAYS=$P(RDITMP,"^",7) I $E(RDIDAYS)="D" S RDIDAYS=$P(RDIDAYS,"D",2) .S RDIQTY=$P(RDITMP,"^",8) .S RDIREF=$P(RDITMP,"^",9) .S RDIEXP=$P(RDITMP,"^",10) .S RDIPHYS=$P(RDITMP,"^",11) .S RDIISS=$P(RDITMP,"^",12) .S DRNM=$G(PSODRUG("NAME")) .D GETPROD .I DRNM'="" I PSODRUG("NAME")=DRNM S DD=$G(DD)+1,^TMP($J,"DD",DD,0)=PSODRUG("IEN")_"^"_PSODRUG("NAME")_"^"_"^"_RDIRX_"R;O"_"^"_RDIINST D Q:'$G(PSOPHI) ..S ^TMP($J,"DD",DD,1)=RDIDNAM_"^"_RDISTA_"^"_RDIFILL_"^"_RDIDAYS_"^"_RDIQTY_"^"_RDIREF_"^"_RDIEXP_"^"_RDIPHYS_"^"_RDIISS ..M ^TMP($J,"DD",DD,1)=^TMP($J,"PSORDI",PSORDI,"SIG") .I PSODRUG("NAME")'=DRNM I PSODRUG("VA CLASS")]"",$E(PSODRUG("VA CLASS"),1,4)=$E(PSOCLASS,1,4) D ..I $E(PSODRUG("VA CLASS"),1,2)="HA",$E(PSOCLASS,1,2)="HA" Q ..S PSODC=$O(^PS(50.605,"B",PSODRUG("VA CLASS"),0)) Q:'PSODC ..S DC=$G(DC)+1,^TMP($J,"DC",DC,0)=PSODRUG("VA CLASS") ..S PSODC=$P(^PS(50.605,PSODC,0),"^",2),^TMP($J,"DC",DC,0)=^TMP($J,"DC",DC,0)_"^"_PSODC_"^"_RDIVUID_"^"_DRNM_"^"_"^"_RDIRX_"R;O"_"^"_RDIINST D ...S ^TMP($J,"DC",DC,1)=RDIDNAM_"^"_RDISTA_"^"_RDIFILL_"^"_RDIDAYS_"^"_RDIQTY_"^"_RDIREF_"^"_RDIEXP_"^"_RDIPHYS_"^"_RDIISS ...M ^TMP($J,"DC",DC,1)=^TMP($J,"PSORDI",PSORDI,"SIG") .;drug interaction check .K ^TMP($J,"PSOPROD") .D DATA^PSN50P68(PSOPROD,,"PSOPROD") .S NDF=+$G(^TMP($J,"PSOPROD",PSOPROD,.05)) .I NDF=0 Q .S NDF=NDF_"A"_PSOPROD .K ^TMP($J,"PSOPROD") .S IT=0,PSOICT="" .F S IT=$O(^PS(56,"APD",NDF,PSODRUG("NDF"),IT)) Q:'IT D ..Q:$$DDIEX^PSNAPIS($P(NDF,"A"),$P(NDF,"A",2)) ..Q:$$DDIEX^PSNAPIS($P(PSODRUG("NDF"),"A"),$P(PSODRUG("NDF"),"A",2)) ..Q:$P(^PS(56,IT,0),"^",7)&($P(^PS(56,IT,0),"^",7)($E(DT,2,3)+1) S PSOPRE=PSOPRE-1 ..S NEWISS=PSOPRE_$P(RDIISS,"/",3)_$P(RDIISS,"/")_$P(RDIISS,"/",2) I NEWISS>(DT-10000) S RDIEXP=RDIISS,BADEXP=0 .I RDISTA["EXPIRE" S PSO30=0 D I PSO30 Q ..S PSOPRE=$E(DT) I $P(RDIEXP,"/",3)>($E(DT,2,3)+1) S PSO30=1 Q ..S NEWEXP=PSOPRE_$P(RDIEXP,"/",3)_$P(RDIEXP,"/")_$P(RDIEXP,"/",2) ..S X1=NEWEXP,X2=30 D C^%DTC I X
($E(DT,2,3)+1) S PSO30=1 Q ..S NEWDC=PSOPRE_$P(RDIFILL,"/",3)_$P(RDIFILL,"/")_$P(RDIFILL,"/",2) ..S X1=NEWDC,X2=30+RDIDAYS D C^%DTC I X
RDIEXP2 K ^TMP($J,"PSORDI",PSORDI) Q .S PSOPRE=$E(DT) I $P(RDIEXP,"/",3)>($E(DT,2,3)+1) S PSOPRE=PSOPRE-1 .S RDIEXP2=PSOPRE_$P(RDIEXP,"/",3)_$P(RDIEXP,"/")_$P(RDIEXP,"/",2) .S PSOPRE=$E(DT) I $P(OLDEXP,"/",3)>($E(DT,2,3)+1) S PSOPRE=PSOPRE-1 .S OLDEXP2=PSOPRE_$P(OLDEXP,"/",3)_$P(OLDEXP,"/")_$P(OLDEXP,"/",2) S OLDRDI=$P(ZZ,"^") K ^TMP($J,"PSORDI",OLDRDI) D SETRDI Q ; SETRDI ; S RDI(RDIINST,RDIVUID)=PSORDI_"^"_RDISTA_"^"_RDIEXP Q ; GETPROD ; S PSOFILE=50.68 S DRNM="",PSOCLASS="",PSOPROD=0 N PSOPR K PSOPRODA N DIC D GETIREF^XTID(PSOFILE,.01,RDIVUID,"PSOPRODA",1) I 'PSOPRODA Q S PSOPR="" F S PSOPR=$O(PSOPRODA(PSOFILE,.01,PSOPR)) Q:PSOPR="" D Q:DRNM'="" Q:PSOCLASS'="" .I +(PSOPRODA(PSOFILE,.01,PSOPR)) S PSOPROD=+PSOPR D VAPROD(PSOPROD) Q .I +(PSOPRODA(PSOFILE,.01,PSOPR))=0 I '$O(PSOPRODA(PSOFILE,.01,PSOPR)) S PSOPROD=+PSOPR D VAPROD(PSOPROD) ; USE LAST ENTRY IF ALL ARE INACTIVE Q ;