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

SCCVCST1.m

Go to the documentation of this file.
  1. SCCVCST1 ; ALB/TMP - SCHED VSTS CONV/ARCHIVE - REQUEST/EDIT ; 25-NOV-97
  1. ;;5.3;Scheduling;**211**;Aug 13, 1993
  1. ;
  1. REQ(SCFUNC,SCCVSCRN,ASKBULL) ; -- Schedule request to run/stop
  1. ; SCFUNC = 0 if from add new template, 1 if from edit or schedule
  1. ; SCCVSCRN = 1 if called from main menu, 2 if called from log menu
  1. ; ASKBULL = 1 if user should be asked to answer send bulletin question
  1. ; = 0 if user already answered the question during this action
  1. ; Assumes SCCVDA = template entry ien from List Manager selection
  1. ;
  1. N DA,DIC,DIE,DR,SCCV,SCCV0,SCCV1,SCCVACT,SCCVDA1,SCCVOK,SCCVNOW,SCCV7,SCCV8,SCCV5,SCRESULT,SCSTOP,SCABORT,X,Y
  1. D FULL^VALM1
  1. I $G(SCCVDA),$P($G(^SD(404.98,SCCVDA,0)),U,9) D G REQX
  1. . W *7,!,"You cannot run a canceled template!"
  1. . D PAUSE^SCCVU
  1. I $D(SCCVDONE) D DONE G REQX
  1. I '$G(SCCVDA) D SELX^SCCVDSP("CST",1)
  1. G:'$G(SCCVDA) REQX
  1. ;
  1. S SCCV0=$G(^SD(404.98,SCCVDA,0)),SCCV1=$G(^(1)),SCCV7=$P(SCCV0,U,7),SCCV5=$P(SCCV0,U,5),SCCV8=$P(SCCV0,U,8),SCCVACT="",SCABORT=0
  1. ;
  1. ; -- quit is convert or reconvert and conversion disabled
  1. IF SCCV5=1!(SCCV5=2),'$$OK^SCCVU(1) S SCABORT=1 G REQX
  1. ;
  1. I $P(SCCV1,U,3) D G:SCABORT REQX ; Check log's task
  1. . D TASKSTA^SCCVU1(.SCRESULT,SCCVDA)
  1. . Q:$S($G(SCRESULT):0,$P(SCRESULT,U,3)=0:1,"124"[SCCV7:1,1:$P(SCRESULT,U,3)>2)
  1. . W !!,$S($G(SCRESULT):"An error has occurred (",1:"This CST already has a valid task "_$P(SCCV1,U,3)_" (")_$P(SCRESULT,U,2)_")."
  1. . I $G(SCRESULT) D PAUSE^SCCVU K:$G(SCCVSCRN)'=2 SCCVDA S SCABORT=1 Q
  1. ;
  1. I SCCV7=5 D G:SCABORT REQX ;Last event completed
  1. .;
  1. . I $P(SCCV0,U,5)=1 D K:$G(SCCVSCRN)'=2 SCCVDA Q ;Convert complete
  1. .. W !!,"This CST has completed converting the data in its date range."
  1. .. W !,"The event must be 'RE-CONVERT' in order to run this CST again."
  1. .. D PAUSE^SCCVU
  1. .. S SCABORT=1
  1. .;
  1. . I $P(SCCV0,U,5)=2 D Q ;Re-convert complete
  1. .. S DIR(0)="YA",DIR("B")="NO",DIR("A",1)="You are about to request a RE-CONVERT event 'again' using this CST."
  1. .. S DIR("A")="Are you sure you want to do this?: "
  1. .. D ^DIR K DIR
  1. .. I Y'=1 K:$G(SCCVSCRN)'=2 SCCVDA S SCABORT=1
  1. .;
  1. . I '$P(SCCV0,U,5) D Q ;Estimate complete
  1. .. S DIR(0)="YA",DIR("B")="NO"
  1. .. S DIR("A",1)=" ",DIR("A",2)="This CST has already completed an ESTIMATE event.",DIR("A",3)="Re-running the ESTIMATE will delete the totals previously stored."
  1. .. S DIR("A")="Are you sure you want to do this?: "
  1. .. D ^DIR K DIR
  1. .. I Y'=1 K:$G(SCCVSCRN)'=2 SCCVDA S SCABORT=1
  1. ;
  1. W !!,"Requested Event : ",$$EXPAND^SCCVDSP2(404.98,.05,$P(SCCV0,U,5))
  1. W !,"Last Event Status : ",$$EXPAND^SCCVDSP2(404.98,.07,$P(SCCV0,U,7))
  1. W !,"Last Requested Action: ",$$NONE^SCCVDSP2(404.98,.08,$P(SCCV0,U,8),"<No action requested>"),!
  1. ;
  1. D G:SCCVACT'>0 REQX
  1. .I SCCV7<2 S SCCVACT=1 Q ;Never started
  1. .S DIR(0)="SABM^"
  1. .I SCCV5 S DIR(0)=DIR(0)_$S(SCCV7'=5&(SCCV5=1):"1:SCHEDULE;",SCCV7=5&(SCCV5=2):"1:SCHEDULE",1:"")_$S(SCCV7'=5:"2:STOP;3:RE-START",1:"")
  1. .I 'SCCV5 S DIR(0)=DIR(0)_$S(SCCV7'=4:"1:SCHEDULE"_$S(SCCV7'=5:";",1:""),1:"")_$S(SCCV7'=5:"2:STOP",1:"")
  1. .S DIR("A")="Request Action: "
  1. .I SCCV5 S DIR("B")=$S("23"[SCCV7:"RE-START",SCCV7=5:"SCHEDULE",1:"STOP")
  1. .I 'SCCV5 S DIR("B")=$S("35"[SCCV7:"SCHEDULE",1:"STOP")
  1. .W !
  1. .D ^DIR K DIR
  1. .S SCCVACT=+Y
  1. .IF SCCVACT'>0 S SCCVACT="" Q
  1. .I $S(SCCVACT=2:SCCV7=3,SCCVACT=1!(SCCVACT=3):SCCV7=2!(SCCV7=4)!(SCCV7=6),1:0) D
  1. ..S Z=1,DIR(0)="YA",DIR("B")="NO"
  1. ..S:SCCVACT=2 DIR("A",1)="You are requesting to STOP the running of this CST.",Z=Z+1
  1. ..S DIR("A",Z)="This ACTION is the same(or similar) as the previous action on this CST."
  1. ..S DIR("A")="Are you sure you want to do this?: "
  1. ..D ^DIR K DIR
  1. ..I Y'=1 S SCCVACT=""
  1. I SCCVACT=2 D G:SCCVACT'>0 REQX
  1. .S SCSTOP=1
  1. .I SCCV7'=3 S DIR(0)="YA",DIR("A",1)="You are requesting to STOP the running of this CST.",DIR("A")="Are you sure you want to do this?: ",DIR("B")="NO" D ^DIR K DIR I Y'=1 S SCCVACT=""
  1. S SCCVOK=0 K SCCVDA1
  1. S DIE="^SD(404.98,",DR="[SCCV SCHEDULE REQUEST]",DA=SCCVDA
  1. D ^DIE
  1. I 'SCCVOK D:$G(SCCVDA1) NOTDONE G REQX
  1. ;
  1. S SCCV("TEMPLNO")=SCCVDA,SCCV("REQNUM")=SCCVDA1
  1. D PROCREQ^SCCVU1(.SCRESULT,.SCCV)
  1. ;
  1. I $G(SCFUNC) D
  1. .I $G(SCCVSCRN)=2 D BLD^SCCVCDS1
  1. .I $G(SCCVSCRN)=1 D BLD^SCCVDSP("CST")
  1. REQX S VALMBCK="R"
  1. I $G(SCCVSCRN)'=2 K SCCVDA
  1. Q
  1. ;
  1. NOTDONE ; -- all needed fields not answered - delete entry
  1. N DIK,DA,X,Y
  1. S DA(1)=SCCVDA,DA=SCCVDA1,DIK="^SD(404.98,"_DA(1)_",""R""," D ^DIK
  1. W !,"All fields must be answered. Nothing has been scheduled."
  1. D PAUSE^SCCVU
  1. Q
  1. ;
  1. EDIT(SCCVSCRN) ; -- Edit the selected CST
  1. N DA,DIC,DIE,DIR,DR,SCCV,SCCVX,SCCV0,SCCV1,SCCVY,SCRERUN,X,Y
  1. ;
  1. D FULL^VALM1
  1. I $G(SCCVDA),$P($G(^SD(404.98,SCCVDA,0)),U,9) D G EDITX
  1. .W *7,!,"You cannot edit a canceled template!"
  1. .D PAUSE^SCCVU
  1. I $G(SCCVDONE) D DONE G EDITX
  1. I $G(SCCVSCRN)=1 N SCCVDA D SELX^SCCVDSP("CST",1)
  1. G:'$G(SCCVDA) EDITX
  1. ;
  1. S SCCV0=$G(^SD(404.98,SCCVDA,0)),SCCV1=$G(^(1))
  1. S SCCV("STARTDT")=$P(SCCV0,U,3),SCCV("ENDDT")=$P(SCCV0,U,4)
  1. S SCCVY=""
  1. ;
  1. IF $P(SCCV0,U,5),$P(SCCV0,U,7)=5 S SCRERUN=0 D G:'SCRERUN EDITX
  1. . W !!,"This template has completed its "_$P("^re-",U,$P(SCCV0,U,5))_"conversion."
  1. . ; -- site parameter must allow re-convert
  1. . IF '$P($G(^SD(404.91,1,"CNV")),U,6) D PAUSE^SCCVU Q
  1. . ;
  1. . S DIR("A")="Do you want to request a"_$P("^nother",U,$P(SCCV0,U,5))_" 'RE-CONVERT' to be run for this CST?: "
  1. . S DIR(0)="YA",DIR("B")="NO"
  1. . D ^DIR K DIR
  1. . IF Y S SCCVY="@12",SCRERUN=1
  1. ;
  1. S DIE("NO^")="",DIE="^SD(404.98,",DA=SCCVDA,DR="[SCCV EDIT TEMPLATE]",SCCVY=$S(SCCVY'="":SCCVY,$P(SCCV1,U,2):"@15",$$CNVTSCH^SCCVU1(SCCVDA):"@15",1:"@5") D ^DIE K DIE
  1. S SCCV0=$G(^SD(404.98,SCCVDA,0))
  1. W !
  1. S DIR(0)="YA",DIR("A")="Do you want to schedule this "_$$EXPAND^SCCVDSP2(404.98,.05,$P(SCCV0,U,5))_" event to run?: ",DIR("B")="YES" D ^DIR K DIR
  1. D
  1. .I Y D REQ(1,$G(SCCVSCRN),0) Q
  1. .I $G(SCCVSCRN)=2 D BLD^SCCVCDS1,HDR^SCCVDSP1(SCCVDA,"CST")
  1. .I $G(SCCVSCRN)=1 D BLD^SCCVDSP("CST")
  1. EDITX S VALMBCK="R"
  1. Q
  1. ;
  1. BULL ; Re-generate bulletin for estimate
  1. N SCCVSENT,SCEST,Z
  1. D FULL^VALM1
  1. ;
  1. I $D(SCCVDONE) D DONE G BULLX
  1. I $G(SCCVSCRN)=1 N SCCVDA D SELX^SCCVDSP("CST")
  1. G:'$G(SCCVDA) BULLX
  1. ;
  1. S SCEST=$$CHKACT^SCCVLOG(SCCVDA,0,5,"CST")
  1. ;
  1. I 'SCEST D G BULLX
  1. . W !,"The CST must have a completed ESTIMATE event to re-generate the bulletin."
  1. . D PAUSE^SCCVU
  1. ;
  1. D MAILSUM^SCCVEGD0(SCCVDA,.SCCVSENT)
  1. ;
  1. W !,"Estimate bulletin "_$S($G(SCCVSENT):"has been sent to "_SCCVSENT_" user"_$S(SCCVSENT>1:"s",1:""),1:"was not generated due to an error - try agin later")_"."
  1. D PAUSE^SCCVU
  1. ;
  1. BULLX S VALMBCK="R"
  1. Q
  1. ;
  1. CANCEL ; Cancel a selected CST that has not been completely converted
  1. N SCCVLST,SCCVEVT,SCCVACT,SCCVOK
  1. D FULL^VALM1
  1. I $D(SCCVDONE) D DONE G CANCQ
  1. I $G(SCCVSCRN)=1 N SCCVDA D SELX^SCCVDSP("CST",1)
  1. G:'$G(SCCVDA) CANCQ
  1. ;
  1. S SCCV0=$G(^SD(404.98,SCCVDA,0))
  1. S SCCVLST=+$$LSTACT^SCCVLOG(SCCVDA)
  1. S SCCVEVT=+$$LSTEVT^SCCVLOG(SCCVDA)
  1. S SCCVOK=0
  1. ;
  1. ; Check: If reconvert or convert, did it ever finish?
  1. I SCCVEVT=0 S SCCVOK=1
  1. I (SCCVEVT=1!(SCCVEVT=2)),'$$CHKACT^SCCVLOG(SCCVDA,SCCVEVT,5,"CST") S SCCVOK=1
  1. ;
  1. I 'SCCVOK D G CANCQ
  1. . W !,"This template has "_$S(SCCVEVT<3:"completed successfully and does not need to be canceled",1:"already been canceled")_"."
  1. . D PAUSE^SCCVU
  1. ;
  1. I SCCVEVT,SCCVOK S DIR("A",1)="This CST has started, but has not successfully completed running."
  1. W !
  1. S DIR(0)="YA",DIR("A")="Are you sure you want to cancel this CST? ",DIR("B")="NO" D ^DIR K DIR
  1. G:Y'=1 CANCQ
  1. W !
  1. S DIE="^SD(404.98,",DR="[SCCV CONV CANCEL]",DA=SCCVDA D ^DIE
  1. I $G(SCCVSCRN)=2 D BLD^SCCVCDS1,HDR^SCCVDSP1(SCCVDA,"CST")
  1. I $G(SCCVSCRN)=1 D BLD^SCCVDSP("CST")
  1. ;
  1. CANCQ S VALMBCK="R"
  1. Q
  1. ;
  1. DONE ; Message to say complete is over
  1. W *7,!!,"Conversion is complete - this function is invalid!"
  1. D PAUSE^SCCVU
  1. Q
  1. ;