PSSORUTL ;BIR/RSB/RTR-CPRS Dosage call ;03/24/00 ;;1.0;PHARMACY DATA MANAGEMENT;**34,38,49,53,69,83**;9/30/97 ;Reference ^PS(50.607 - DBIA 2221 ;Reference ^YSCL(603.01 - DBIA 2697 ;Reference to ^PSNAPIS - DBIA 2531 ; DOSE(PSSX,PD,TYPE,PSSDFN) ; K PSSX ; PSSX - Target array ; PD - Orderable Item ; TYPE - O:Outpt,U:Unit Dose,I:IV,X:Non-VA Med ; PSSDFN - Patient ; N DLOOP,DCNT1,DLOOP1,LOW,FORM,PSSOIU,PSSLOW,PSSLOW1,PSSLOW2,PSOLC,PL,PSSHOLD,PSSA,PSSZ,PSSC,PSIEN,PSSTRN,PSSDSE,PSSVERB,PSSPREP,PSSCLO,PSSDEA,PSSMAX,PSSDLP,PSNN,PSNNN,PSSREQS,PSSLOW4,PL2,PSSA1,PL3,PSSUNITX,PSSLD,PSSLD1 N PSSDOSE,PSSUNTS,PSSUDOS,PSSQT,PSSBCM,PSSHLF S PSSOIU=$S(TYPE="I":1,TYPE="U":1,1:0) F DLOOP=0:0 S DLOOP=$O(^PSDRUG("ASP",PD,DLOOP)) Q:'DLOOP D .Q:'$O(^PSDRUG(DLOOP,"DOS1",0)) .S PSSTRN=$P($G(^PSDRUG(DLOOP,"DOS")),"^"),PSSUNITX=$P($G(^("DOS")),"^",2) Q:PSSTRN="" .S PSSUNITX=$S($P($G(^PS(50.607,+$G(PSSUNITX),0)),"^")'=""&($P($G(^(0)),"^")'["/"):$P($G(^(0)),"^"),1:"") .I $P($G(^PSDRUG(DLOOP,"I")),"^"),+$P($G(^("I")),"^")
1 S PSSX(PSSLOW4,(PSOLC-1))=PSSX(PSSLOW2) K PSSX(PSSLOW2) K PSSHOLD S PL="" F S PL=$O(PSSX(PL)) Q:PL="" S PSSHOLD($P(PSSX(PL),"^"),PL)=PSSX(PL) I $O(PSSX(PL,0)) D .S PL2="" F S PL2=$O(PSSX(PL,PL2)) Q:PL2="" S PSSHOLD($P(PSSX(PL,PL2),"^"),PL,PL2)=PSSX(PL,PL2) K PSSX S PSSA=1,PSSZ="" F S PSSZ=$O(PSSHOLD(PSSZ)) Q:PSSZ="" F PSSC=0:0 S PSSC=$O(PSSHOLD(PSSZ,PSSC)) Q:'PSSC S PSSX(PSSA)=PSSHOLD(PSSZ,PSSC) D SLS D:'$D(PSSX("DD",+$P(PSSX(PSSA),"^",6))) D:$O(PSSHOLD(PSSZ,PSSC,0)) MULTI S PSSA=PSSA+1 .S (PSIEN,DLOOP)=+$P(PSSX(PSSA),"^",6) K PSSMAX D:$G(TYPE)["O" MAX .D SETU^PSSORUTE .S PSSX("DD",PSIEN)=$P($G(^PSDRUG(PSIEN,0)),"^")_"^"_$P($G(^(660)),"^",6)_"^"_$P($G(^(0)),"^",9)_"^"_$P($G(^(660)),"^",8)_"^"_$P($G(^("DOS")),"^") .S PSSX("DD",PSIEN)=PSSX("DD",PSIEN)_"^"_$G(PSSUNITX)_"^"_$P($G(^PS(50.606,+$G(PSSDSE),0)),"^")_"^"_$G(PSSMAX) .D REQS S PSSX("DD",PSIEN)=PSSX("DD",PSIEN)_"^"_$G(PSSREQS) D DEA^PSSUTLA1(PSIEN) .S PSSX("MISC")=$G(PSSVERB)_"^"_$G(PSSPREP)_"^"_$P($G(^PS(50.606,+$G(PSSDSE),"MISC")),"^",4) K PSSHOLD,PSSDZUNT D LEAD^PSSUTLA1 D:$G(TYPE)["O" EN3^PSSUTLA1(PD,245) S PSSX("DEA")=$$OIDEA^PSSUTLA1(PD,TYPE) Q DOSE2 ;Local doses N PSOCT,PSONDS,PSOND,PSOND1,PSONDX,PSONDU,PSODOS,PSLOC,PSLOCV,PSODUPD,PSOXDOSE S PSOCT=1 S PSOXDOSE=+$P($G(^PS(50.7,PD,0)),"^",2) K PSNNN F DLOOP=0:0 S DLOOP=$O(^PSDRUG("ASP",PD,DLOOP)) Q:'DLOOP D .I $P($G(^PSDRUG(DLOOP,"I")),"^"),+$P($G(^("I")),"^")
3 S PSSNPL=$E(PSNNN,($L(PSNNN)-2),$L(PSNNN)) I $G(PSSNPL)="(S)"!($G(PSSNPL)="(s)") D .I $G(PSSUDOS)'>1 S PSSNP=$E(PSNNN,1,($L(PSNNN)-3)) .I $G(PSSUDOS)>1 S PSSNP=$E(PSNNN,1,($L(PSNNN)-3))_$E(PSSNPL,2) Q LEAD F PSSLD=0:0 S PSSLD=$O(PSSX(PSSLD)) Q:'PSSLD D .I $E($P(PSSX(PSSLD),"^"),1)="." S $P(PSSX(PSSLD),"^")="0"_$P(PSSX(PSSLD),"^") .I $E($P(PSSX(PSSLD),"^",5),1)="." S $P(PSSX(PSSLD),"^",5)="0"_$P(PSSX(PSSLD),"^",5) .I $O(PSSX(PSSLD,0)) D ..F PSSLD1=0:0 S PSSLD1=$O(PSSX(PSSLD,PSSLD1)) Q:'PSSLD1 D ...I $E($P(PSSX(PSSLD,PSSLD1),"^"),1)="." S $P(PSSX(PSSLD,PSSLD1),"^")="0"_$P(PSSX(PSSLD,PSSLD1),"^") ...I $E($P(PSSX(PSSLD,PSSLD1),"^",5),1)="." S $P(PSSX(PSSLD,PSSLD1),"^",5)="0"_$P(PSSX(PSSLD,PSSLD1),"^",5) S PSSLD="" F S PSSLD=$O(PSSX("DD",PSSLD)) Q:PSSLD="" D .I $E($P(PSSX("DD",PSSLD),"^",5),1)="." S $P(PSSX("DD",PSSLD),"^",5)="0"_$P(PSSX("DD",PSSLD),"^",5) Q ; APP N APPUSE S PSSQT=0,APPUSE=$P($G(^PSDRUG(DLOOP,2)),"^",3) I $G(TYPE)="O" S:APPUSE'["O" PSSQT=1 Q I $G(TYPE)="X" S:APPUSE'["X" PSSQT=1 Q I APPUSE'["U",APPUSE'["I" S PSSQT=1 Q NS I PSONDS'?.N&(PSONDS'?.N1".".N) K PSONDS Q NU D NU^PSSORUTE Q