AMHEXDI ; IHS/CMI/LAB - INIT FOR MHSS EXPORT ;
;;4.0;IHS BEHAVIORAL HEALTH;;MAY 14, 2010
;
START ;
D BASICS ; Set variables like U,DT,DUZ(2) etc.
D CHKSITE ; Make sure Site file has correct fields.
Q:AMH("QFLG")
;
D:AMHO("RUN")="NEW" ^AMHEXDI2 ; Do new run initialization.
Q:$D(ZTQUEUED)
Q:AMH("QFLG")
D:AMHO("RUN")="NEW" QUEUE
Q
;
BASICS ; BASIC INITS
D HOME^%ZIS S AMHBS=$S('$D(ZTQUEUED):IOBS,1:"")
K AMH,AMHS,AMHV,AMHT,AMHE
S AMH("RUN LOCATION")=$P(^AUTTLOC(DUZ(2),0),U,10),AMH("QFLG")=0
S (AMH("A"),AMH("M"),AMH("D"),AMH("ERROR COUNT"),AMH("COUNT"))=0
Q
;
CHKSITE ; CHECK SITE FILE
I '$D(^AMHSITE(DUZ(2),0)) W:'$D(ZTQUEUED) !!,"*** Site file has not been setup! ***" S AMH("QFLG")=1 Q
I '$D(^AMHSITE(DUZ(2))) W:'$D(ZTQUEUED) !!,"*** RUN LOCATION not in SITE file!" S AMH("QFLG")=2 Q
I $P(^AMHSITE(DUZ(2),0),U,7)="" W:'$D(ZTQUEUED) !!,"***No DEFAULT DEVICE value in Site file! ***" S AMH("QFLG")=4
Q
;
;
;
QUEUE ;EP
K ZTSK
S DIR(0)="Y",DIR("A")="Do you want to QUEUE this to run at a later time",DIR("B")="N" D ^DIR K DIR S:$D(DUOUT) DIRUT=1
I Y=1 D QUEUE1 Q
I AMHO("RUN")="NEW",$D(DIRUT) S AMH("QFLG")=99 S DA=AMH("RUN LOG"),DIK="^AMHXLOG(" W !,"Okay, you '^'ed out or timed out so I'm deleting the Log entry and quitting.",! D ^DIK K DIK,DA
I AMHO("RUN")="REDO",$D(DIRUT) S AMH("QFLG")=99 Q
Q
QUEUE1 ;
S ZTRTN=$S(AMHO("RUN")="NEW":"DRIVER^AMHEXD",1:"EN^AMHREDO")
S ZTIO="",ZTDTH="",ZTDESC="PCC DATA TRANSMISSION" S ZTSAVE("AMH*")="",ZTSAVE("APCD*")=""
D ^%ZTLOAD
W !!,$S($D(ZTSK):"Request Queued!!",1:"Request cancelled")
I '$D(ZTSK),AMHO("RUN")="NEW" S AMH("QFLG")=99 S DA=AMH("RUN LOG"),DIK="^AMHXLOG(" W !,"Okay, you '^'ed out or timed out so I'm deleting the Log entry and quitting.",! D ^DIK K DIK,DA Q
S AMHO("QUEUE")=""
S DIE="^AMHXLOG(",DA=AMH("RUN LOG"),DR=".15///Q" D CALLDIE^AMHLEIN
K ZTSK
Q
AMHEXDI ; IHS/CMI/LAB - INIT FOR MHSS EXPORT ;
+1 ;;4.0;IHS BEHAVIORAL HEALTH;;MAY 14, 2010
+2 ;
START ;
+1 ; Set variables like U,DT,DUZ(2) etc.
DO BASICS
+2 ; Make sure Site file has correct fields.
DO CHKSITE
+3 IF AMH("QFLG")
QUIT
+4 ;
+5 ; Do new run initialization.
IF AMHO("RUN")="NEW"
DO ^AMHEXDI2
+6 IF $DATA(ZTQUEUED)
QUIT
+7 IF AMH("QFLG")
QUIT
+8 IF AMHO("RUN")="NEW"
DO QUEUE
+9 QUIT
+10 ;
BASICS ; BASIC INITS
+1 DO HOME^%ZIS
SET AMHBS=$SELECT('$DATA(ZTQUEUED):IOBS,1:"")
+2 KILL AMH,AMHS,AMHV,AMHT,AMHE
+3 SET AMH("RUN LOCATION")=$PIECE(^AUTTLOC(DUZ(2),0),U,10)
SET AMH("QFLG")=0
+4 SET (AMH("A"),AMH("M"),AMH("D"),AMH("ERROR COUNT"),AMH("COUNT"))=0
+5 QUIT
+6 ;
CHKSITE ; CHECK SITE FILE
+1 IF '$DATA(^AMHSITE(DUZ(2),0))
IF '$DATA(ZTQUEUED)
WRITE !!,"*** Site file has not been setup! ***"
SET AMH("QFLG")=1
QUIT
+2 IF '$DATA(^AMHSITE(DUZ(2)))
IF '$DATA(ZTQUEUED)
WRITE !!,"*** RUN LOCATION not in SITE file!"
SET AMH("QFLG")=2
QUIT
+3 IF $PIECE(^AMHSITE(DUZ(2),0),U,7)=""
IF '$DATA(ZTQUEUED)
WRITE !!,"***No DEFAULT DEVICE value in Site file! ***"
SET AMH("QFLG")=4
+4 QUIT
+5 ;
+6 ;
+7 ;
QUEUE ;EP
+1 KILL ZTSK
+2 SET DIR(0)="Y"
SET DIR("A")="Do you want to QUEUE this to run at a later time"
SET DIR("B")="N"
DO ^DIR
KILL DIR
IF $DATA(DUOUT)
SET DIRUT=1
+3 IF Y=1
DO QUEUE1
QUIT
+4 IF AMHO("RUN")="NEW"
IF $DATA(DIRUT)
SET AMH("QFLG")=99
SET DA=AMH("RUN LOG")
SET DIK="^AMHXLOG("
WRITE !,"Okay, you '^'ed out or timed out so I'm deleting the Log entry and quitting.",!
DO ^DIK
KILL DIK,DA
+5 IF AMHO("RUN")="REDO"
IF $DATA(DIRUT)
SET AMH("QFLG")=99
QUIT
+6 QUIT
QUEUE1 ;
+1 SET ZTRTN=$SELECT(AMHO("RUN")="NEW":"DRIVER^AMHEXD",1:"EN^AMHREDO")
+2 SET ZTIO=""
SET ZTDTH=""
SET ZTDESC="PCC DATA TRANSMISSION"
SET ZTSAVE("AMH*")=""
SET ZTSAVE("APCD*")=""
+3 DO ^%ZTLOAD
+4 WRITE !!,$SELECT($DATA(ZTSK):"Request Queued!!",1:"Request cancelled")
+5 IF '$DATA(ZTSK)
IF AMHO("RUN")="NEW"
SET AMH("QFLG")=99
SET DA=AMH("RUN LOG")
SET DIK="^AMHXLOG("
WRITE !,"Okay, you '^'ed out or timed out so I'm deleting the Log entry and quitting.",!
DO ^DIK
KILL DIK,DA
QUIT
+6 SET AMHO("QUEUE")=""
+7 SET DIE="^AMHXLOG("
SET DA=AMH("RUN LOG")
SET DR=".15///Q"
DO CALLDIE^AMHLEIN
+8 KILL ZTSK
+9 QUIT