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

APCMVAEM.m

Go to the documentation of this file.
APCMVAEM ; IHS/CMI/LAB - V2 MED BY PROV SUB RTN KFOX ;
 ;;1.0;IHS MU PERFORMANCE REPORTS;**5,6**;MAR 26, 2012;Build 65
START ;Set beginning/ending sort dates for ORDERS
 S %DT="AE",%DT("A")="Enter Start Date range:  " D ^%DT
 I (Y'>0)!(X["^")!(X="") D EXIT Q
 S CPSTART=Y
 K %DT,%DT("A"),X,Y
 S Y=CPSTART D DD^%DT S CPSTART(0)=Y
 ;
 S %DT="AE",%DT("A")="Enter Ending Date range:  " D ^%DT
 I (Y'>0)!(X["^")!(X="") D EXIT Q
 S CPSEND=Y
 K %DT,%DT("A"),X,Y
 S Y=CPSEND D DD^%DT S OEND(0)=Y
 S (CNT("UNIT DOSE","TR"),CNT("UNIT DOSE"))=0
 K ^TMP($J)
P55 ; LOOP 55 UNIT DOSE
 S CPSDATE=CPSTART F  S CPSDATE=$O(^PS(55,"AUDS",CPSDATE)) Q:CPSDATE>CPSEND!('+CPSDATE)  D
 .S CPSDFN=0 F  S CPSDFN=$O(^PS(55,"AUDS",CPSDATE,CPSDFN)) Q:'+CPSDFN  D
 ..S CPS55=0 F  S CPS55=$O(^PS(55,"AUDS",CPSDATE,CPSDFN,CPS55)) Q:'+CPS55  D
 ...;COUNT POSSIBLE DOSES DUE FOR ORDER.
 ...S CPSPOS=0
 ...S CPSFRE=$P($G(^PS(55,CPSDFN,5,+CPS55,2)),U,6),CPSTOP=$P($G(^PS(55,CPSDFN,5,+CPS55,2)),U,4),CPSSCH=$P($G(^PS(55,CPSDFN,5,+CPS55,0)),U,7)
 ...Q:CPSTOP<CPSDATE
 ...I CPSFRE="D"&(CPSSCH="C") S CPSN=$L($P($G(^PS(55,CPSDFN,5,+CPS55,2)),U,1),"-") S X2=CPSDATE,X1=$S(CPSTOP<DT:DT,1:CPSTOP) D ^%DTC S CPSPOS=CPSN*X
 ...I +CPSFRE&(CPSSCH="C") D
 ....S CPSS1=0,CPSS1=(24-$E($P(CPSDATE,".",2),1,2))*60 ;MINS FOR FIRST DATE
 ....IF CPSTOP>DT D NOW^%DTC S CPSS1=CPSS1+($E($P(%,".",2),1,2)*60) ; MINS FOR MIDNIGHT LAST DATE
 ....IF CPSTOP<DT S CPSS1=CPSS1+($E($P(CPSTOP,".",2),1,2)*60) ;MINS FOR MIDNIGHT LAST DATE
 ....S X1=CPSDATE,X2=+1 D C^%DTC S X2=X,X1=$S(CPSTOP>DT:DT,1:CPSTOP) D ^%DTC S CPSPOS=((X*1440)+CPSS1)/CPSFRE
 ....;S X1=DT,X2=+1 D C^%DTC S CPSNDT=X S X2=CPSDATE,X1=$S(CPSTOP>DT:CPSNDT,1:CPSTOP) D ^%DTC S CPSPOS=((X*1440)+CPSS1)/CPSFRE
 ...I CPSSCH="C"!(CPSSCH="P") S CNT("UNIT DOSE")=CNT("UNIT DOSE")+1
 ...;LOOK 53.79 FOR DOSE TRACKED.
 ...I CPSSCH="P" S CPSPOS=1 ;PRNS TO ONE
 ...Q:+CPSPOS<0!(CPSPOS=0)
 ...S CPSQ=$S(CPSSCH="P":1,CPSSCH="C":1,1:0)
 ...Q:CPSQ=0
 ...;W !,CPSSCH
 ...S (CPSPSB,CPSN1)=0 F  S CPSN1=$O(^PSB(53.79,"AORDX",CPSDFN,CPS55_"U",CPSN1)) Q:'+CPSN1  S CPSPSB=CPSPSB+1
 ...Q:CPSPSB<CPSPOS
 ...S CNT("UNIT DOSE","TR")=CNT("UNIT DOSE","TR")+1 S ^TMP($J,"BCMA","TRUD",CPSDFN,CPS55)=CPSPOS_U_CPSPSB
 ...;W !,CPS55,U,CPSPOS,U,CPSPSB,U,CPSSCH
IV ;LOOP IVS
 S (CNT("IV","TR"),CNT("IV"))=0
 S CPSDATE=CPSTART F  S CPSDATE=$O(^PS(55,"AIVS",CPSDATE)) Q:CPSDATE>CPSEND!('+CPSDATE)  D
 .S CPSDFN=0 F  S CPSDFN=$O(^PS(55,"AIVS",CPSDATE,CPSDFN)) Q:'+CPSDFN  D
 ..S CPS55=0 F  S CPS55=$O(^PS(55,"AIVS",CPSDATE,CPSDFN,CPS55)) Q:'+CPS55  D
 ...S CNT("IV")=CNT("IV")+1,(CPSPSB,CPSPOS)=0
 ...S CPSTYPE=$P($G(^PS(55,CPSDFN,"IV",CPS55,0)),U,4)
 ...I CPSTYPE="P"!(CPSTYPE="S") D
 ....S CPSFRE=$P($G(^PS(55,CPSDFN,"IV",CPS55,0)),U,15) I +CPSFRE S CPSTOP=$P($G(^PS(55,CPSDFN,"IV",CPS55,0)),U,3) S X2=CPSDATE,X1=$S(CPSTOP<DT:DT,1:CPSTOP) D ^%DTC S CPSPOS=(X*1440)/CPSFRE
 ....I CPSFRE="O" S CPSPOS=1 ;ONCE 
 ...;COUND TOTAL NUMBER OF IV BAGS FOR ORDER
 ...I $D(^PS(55,CPSDFN,"IV",+CPS55,"BCMA"))&(CPSTYPE'="P")&(CPSTYPE'="S") S (CPSPOS,CPSNUM)=0 F  S CPSNUM=$O(^PS(55,CPSDFN,"IV",+CPS55,"BCMA",CPSNUM)) Q:'+CPSNUM  S CPSPOS=CPSPOS+1
 ...;NO LABELS
 ...I '$D(^PS(55,CPSDFN,"IV",+CPS55,"BCMA"))&(CPSTYPE'="P")&(CPSTYPE'="S") D
 ....S CPSVOL=$P($G(^PS(55,CPSDFN,"IV",CPS55,"SOL",1,0)),U,2),CPSRAT=$P($G(^PS(55,CPSDFN,"IV",CPS55,0)),U,8)
 ....S CPSTOP=$P($G(^PS(55,CPSDFN,"IV",CPS55,0)),U,3)
 ....S CPSS1=0,CPSS1=(24-$E($P(CPSDATE,".",2),1,2))*60 ;MINS FOR FIRST DATE
 ....IF CPSTOP>DT D NOW^%DTC S CPSS1=CPSS1+($E($P(%,".",2),1,2)*60) ; MINS FOR MIDNIGHT LAST DATE
 ....IF CPSTOP<DT S CPSS1=CPSS1+($E($P(CPSTOP,".",2),1,2)*60) ;MINS FOR MIDNIGHT LAST DATE
 ....S X1=CPSDATE,X2=+1 D C^%DTC S X2=X,X1=$S(CPSTOP>DT:DT,1:CPSTOP) D ^%DTC S CPSPOS=(((((+CPSRAT*24)*X)+CPSS1)+CPSS1)\+CPSVOL)
 ...Q:'+CPSPOS&('+$G(CPSRAT))  ;NO POSSIBLE FOUND AND NO INFUSTION RATE BAIL THIS ONE.
 ...;LOOK IN BCMA FOR IVS
 ...S (CPSNUM,CPSPSB)=0 F  S CPSNUM=$O(^PSB(53.79,"AUID",CPSDFN,CPS55_"V",CPSNUM)) Q:'+CPSNUM  S CPSPSB=CPSPSB+1 D
 ....;W !,CPS55,U,CPSPOS,U,CPSPSB
 ....Q:CPSPSB<CPSPOS
 ....S CNT("IV","TR")=CNT("IV","TR")+1 S ^TMP($J,"BCMA","IV",CPSDFN,CPS55,CPSNUM)=CPSPOS_U_CPSPSB
 ..;NEXT FIND BCMA TOTAL MEDS GIVE ON UD AND MATCH IV ORDERS. 
PRT ;
 S (CNTT,CNTTR)=0
 W !,?5,"Meaningfull Use Stage II Report From " S Y=CPSTART D DD^%DT W Y_" TO " S Y=CPSEND D DD^%DT  W Y
 D NOW^%DTC S Y=% D DD^%DT W !,?45,"Run Date/Time:"_Y
 W !,"Order Type",?15,"Total Orders",?30," %100 Tracked"
 W ! F J=1:1:IOM W "-"
 W ! F I="UNIT DOSE","IV" W I,?17,$G(CNT(I)),?35,$G(CNT(I,"TR")),! S CNTT=CNTT+$G(CNT(I)),CNTTR=CNTTR+$G(CNT(I,"TR"))
 W ! F J=1:1:IOM W "-"
 W !,?17,CNTT,?35,CNTTR
EXIT ;
 Q