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

ADEPSUB.m

Go to the documentation of this file.
ADEPSUB ; IHS/HQT/MJL  -SUBROUTINE & FUNCTION LIBRARY ;05:06 PM  [ 03/24/1999   9:04 AM ]
 ;;6.0;ADE;;APRIL 1999
 ;
 ;SUBROUTINES AND $$FUNCTIONS FOR ADEP REPORTS
 ;
MDATE ;EP - MONTHLY REPORTS
 ;Prompts for Beginning Month
 ;Returns date range in ADEDATE and ADEWK1, 2, & 3 variables
 N ADECNT,ADEX,ADEBEG,ADEJ
 S ADEDATE=$$MMONTH()
 S ADEBEG=$P(ADEDATE,U,2)
 S ADECNT=0
 F ADEJ="07","14","21" S ADECNT=ADECNT+1,ADEX="ADEWK"_ADECNT,@ADEX=$E(ADEBEG,1,5)_ADEJ
 Q
 ;
MMONTH() ;EP - Returns "1 or 0^Begin^End"
 N DIR,ADEBEG,X,Y,ADEND
 W ! S DIR("A")="Report will cover which month (MONTH-YR): "
 S DIR(0)="DA^2810101:"_DT_":E"
MDAT1 D ^DIR
 Q:$$HAT^ADEPQA() 0
 S ADEBEG=Y
 I $E(ADEBEG,6,7)'="00" W !?5,"Please enter only the month and year" G MDAT1
 S ADEND=$E(ADEBEG,4,5)+1,ADEND="00"_ADEND,ADEND=$E(ADEND,$L(ADEND)-1,$L(ADEND)),ADEND=$E(ADEBEG,1,3)_ADEND_"00"
 Q "1^"_ADEBEG_U_ADEND
 ;
 ;
QDATE ;EP - DATE PROCESSING FOR QUARTERLY REPORTS
 N ADECNT,ADEX,ADEBEG,ADEJ
 S ADEDATE=$$QMONTH()
 S ADEBEG=$P(ADEDATE,U,2)
 S ADECNT=0
 ;F ADEJ="07","14","21" S ADECNT=ADECNT+1,ADEX="ADEWK"_ADECNT,@ADEX=$E(ADEBEG,1,5)_ADEJ
 F ADEJ=1:1:2 S ADECNT=ADECNT+1,ADEX="ADEWK"_ADECNT D
 . N ADEWK,ADETMP
 . S ADEWK=ADEBEG
 . ;beginning Y2K fix
 . ;S ADETMP="00"_($E(ADEWK,4,5)+ADEJ)
 . ;S ADETMP=$E(ADETMP,$L(ADETMP)-1,$L(ADETMP))
 . ;S $E(ADEWK,4,5)=ADETMP
 . ;I $E(ADEWK,4,5)=13 S $E(ADEWK,2,3)=$E(ADEWK,2,3)+1,$E(ADEWK,4,5)="01"
 . ;I $E(ADEWK,4,5)=14 S $E(ADEWK,2,3)=$E(ADEWK,2,3)+1,$E(ADEWK,4,5)="02"
 .S ADETMP=$E(ADEWK,4,5)+ADEJ  ;Y2000
 .I ADETMP<13 S $E(ADEWK,4,5)=$S($L(ADETMP)=1:"0"_ADETMP,1:ADETMP)  ;Y2000
 .I ADETMP=13 S $E(ADEWK,1,3)=$E(ADEWK,1,3)+1,$E(ADEWK,4,5)="01"  ;Y2000
 .I ADETMP=14 S $E(ADEWK,1,3)=$E(ADEWK,1,3)+1,$E(ADEWK,4,5)="02"  ;Y2000
 . ;end Y2K fix block
 . S @ADEX=ADEWK
 Q
 ;
QMONTH() ;EP Returns "1 or 0^Begin^End"
 N DIR,ADEBEG,X,Y,ADEND,ADENDY
 W ! S DIR("A")="Report will cover 3 month period beginning (MONTH-YR): "
 S DIR(0)="DA^2810101:"_DT_":E"
QDAT1 D ^DIR
 Q:$$HAT^ADEPQA() 0
 S ADEBEG=Y
 I $E(ADEBEG,6,7)'="00" W !?5,"Please enter only the month and year" G QDAT1
 S ADEND=$E(ADEBEG,4,5)
 ;beginning Y2K fix
 ;I ADEND>9 S ADEND=ADEND-9
 ;E  S ADEND=ADEND+3
 ;S ADEND="00"_ADEND
 ;S ADEND=$E(ADEND,$L(ADEND)-1,$L(ADEND))
 ;S ADENDY=$E(ADEBEG,2,3)
 ;S:$E(ADEBEG,4,5)>9 ADENDY=ADENDY+1
 ;S ADEND=2_ADENDY_ADEND_"00"
 S ADENDM=$S(ADEND>9:ADEND-9,1:ADEND+3)  ;Y2000
 S ADENDY=$S(ADEND>9:$E(ADEBEG,1,3)+1,1:$E(ADEBEG,1,3))  ;Y2000
 S ADEND=ADENDY_$S($L(ADENDM)=1:"0"_ADENDM,1:ADENDM)_"00"  ;Y2000
 ;end Y2K fix block
 Q "1^"_ADEBEG_U_ADEND
 ;
 ;
YDATE ;EP - DATE PROCESSING FOR ANNUAL REPORTS
 N ADECNT,ADEX,ADEBEG,ADEJ
 S ADEDATE=$$YMONTH()
 S ADEBEG=$P(ADEDATE,U,2)
 S ADECNT=0
 F ADEJ=3:3:9 S ADECNT=ADECNT+1,ADEX="ADEWK"_ADECNT D
 . N ADEWK,ADETMP
 . S ADEWK=ADEBEG
 . S ADETMP="00"_($E(ADEWK,4,5)+ADEJ)
 . S ADETMP=$E(ADETMP,$L(ADETMP)-1,$L(ADETMP))
 . S $E(ADEWK,4,5)=ADETMP
 . I $E(ADEWK,4,5)>12 D
 . . N ADEMO
 . . S $E(ADEWK,1,3)=$E(ADEWK,1,3)+1
 . . S ADEMO=$E(ADEWK,4,5)
 . . S ADEMO=ADEMO#12
 . . S ADEMO="00"_ADEMO
 . . S ADEMO=$E(ADEMO,$L(ADEMO)-1,$L(ADEMO))
 . . S $E(ADEWK,4,5)=ADEMO
 . . K ADEMO
 . S @ADEX=ADEWK
 Q
 ;
YMONTH() ;EP Returns "1 or 0^Begin^End"
 N DIR,ADEBEG,X,Y,ADEND,ADENDY
 W ! S DIR("A")="Report will cover 12 month period beginning (MONTH-YR): "
 S DIR(0)="DA^2810101:"_DT_":E"
YDAT1 D ^DIR
 Q:$$HAT^ADEPQA() 0
 S ADEBEG=Y
 I $E(ADEBEG,6,7)'="00" W !?5,"Please enter only the month and year" G YDAT1
 S ADEND=ADEBEG
 S $E(ADEND,1,3)=$E(ADEBEG,1,3)+1
 Q "1^"_ADEBEG_U_ADEND
 ;
ADEU() ;GET UNIQUE SUBSCRIPT NUMBER AND LOCK REPORT NODE
 ;RETURNS SUBSCRIPT NUMBER
 S ADEU=$J
ADEU1 F  L +^TMP("ADEP",ADEU):.1 Q:$T  S ADEU=ADEU+1
 I $G(^TMP("ADEP",ADEU))="RUNNING" L -^TMP("ADEP",ADEU) S ADEU=ADEU+1 G ADEU1
 Q ADEU
 ;
ASKDEV(ADERTN,ADEDESC) ;EP - DEVICE SELECTION
 ;ADERTN=PROCESSING ROUTINE ENTRY POINT
 ;ADEDESC=DESCRIPTION
 K ADEIOP,IOP,ZTSK,ADEIOPAR
 W !!,"Enter 'Q' at the DEVICE prompt to queue this report to run in the background."
 S %ZIS="NQ"
 D ^%ZIS
 Q:POP
 S ADEIOP=ION_";"_IOM_";"_IOSL
 S ADEIOPAR=IOPAR
 Q:'$D(IO("Q"))
 D QUE
 ;FHL 9/9/98 I '$D(ZTSK) K IOP,ADEIOP G ASKDEV
 I '$D(ZTQUEUED) K IOP,ADEIOP G ASKDEV
 D HOME^%ZIS
 W !,"REPORT IS QUEUED!"
 Q
 ;
QUE ;
 N ADEJ
 S ZTRTN=ADERTN
 S ZTDESC=ADEDESC
 F ADEJ="ADEIOP","ADEIOPAR","ADEDATE","ADEWK1","ADEWK2","ADEU" S ZTSAVE(ADEJ)=""
 I $D(ADEWK3) S ZTSAVE("ADEWK3")=""
 S ZTSAVE("ADEHYG")=""
 S ZTSAVE("ADEHNAM(")=""
 I $D(ADEDDS) D
 . S ZTSAVE("ADEDDS")=""
 . S ZTSAVE("ADEDNAM(")=""
 S ZTIO=""
 I $D(IO("HFSIO")) D
 . S ZTIO=ADEIOP
 D ^%ZTLOAD
 Q
 ;
PRINT(FLDS,ADEDHD) ;EP
 I $D(ZTQUEUED) L +^TMP("ADEP",ADEU):1 I '$T S ADENOLOK=1 G PRNEND
 N DIC,BY,ADED0,ADED1,ADED2,ADED3,Y,DHD
 S IOP=ADEIOP
 S %ZIS("IOPAR")=ADEIOPAR
 D ^%ZIS
 S IOP=ADEIOP
 S %ZIS("IOPAR")=ADEIOPAR
 S DIC="^ADEDUM(",BY="@NUMBER",(FR,TO)=""
 S DHD=$O(^ADEPARAM(0)),DHD=$P(^ADEPARAM(DHD,0),U),DHD=$P(^DIC(4,DHD,0),U)
 S DHD=DHD_ADEDHD
 S Y=$P(ADEDATE,U,2) X ^DD("DD")
 S DHD=DHD_" BEGINNING "_Y
 S (ADED0,ADED1,ADED2)=0
 ;FHL 9/9/98 I $D(ZTSK) S ADEZTSK=ZTSK K ZTSK
 I $D(ZTQUEUED) S ADEZTSK=ZTSK K ZTSK
 D EN1^DIP
 I $D(ADEZTSK) S ZTSK=ADEZTSK
PRNEND I $D(ZTQUEUED) S ZTREQ="@"
 I '$D(ADENOLOK) K ^TMP("ADEP",ADEU)
 K ADENOLOK
 Q