RGVCCMR1 ;GAI/TMG-CMOR ACTIVITY SCORE GENERATOR (PART 1) ;01/15/98
 ;;1.0;CLINICAL INFO RESOURCE NETWORK;**2,19**;30 Apr 99
 ;Reference to ^DPT("ACMORS" and ^DPT(0 supported by IA #2070
 ;
EN ;  this routine contains entry points to start/restart the batch cmor
 ;  score initialization, flag a running
 ;  initialization to stop, calculate and file an activity score for an
 ;  individual patient, and display the status of the cmor initialization 
START ; entry point to start or restart the cmor activity score initialization
 N RGY
 S U="^"
 S NODE=$G(^RGSITE(991.8,1,"CMOR"))
 I '(+$P(NODE,U)) D  G QUIT
 .W !!,"This is the initial run of the CMOR patient activity score generator."
 .S RUNTYPE="I",RGDFN=0 D TASK
 S STATUS=$P(NODE,U,7)
 I STATUS="R" D  I RUN G QUIT
 .S RUN=0
 .S ZTSK=+$P(NODE,U,9)
 .I 'ZTSK D INT Q
 .D STAT^%ZTLOAD
 .I ZTSK(1)=0!(ZTSK(1)=3)!(ZTSK(1)=4) D INT Q
 .I ZTSK(1)=1 W !!,"CMOR Patient Activity Score queued task #",ZTSK,!,"is waiting to run.  Do not start another job at this time." S RUN=1 Q
 .I ZTSK(1)=2 W !!,"CMOR Patient Activity Score queued task #",ZTSK,!,"is currently running.  Do not start another job at this time." S RUN=1 Q
 .I ZTSK(1)=5 W !!,"CMOR Patient Activity Score queued task #",ZTSK,!,"was interrupted abnormally, possibly from a system error." D INT
 I STATUS="SN" D
 .S STOPDT=$P(NODE,U,3) I +STOPDT D
 ..S STOPDT=$$FMTE^XLFDT(STOPDT,"1P")
 ..W !!,"The CMOR patient activity score generator",!,"completed successfully on ",STOPDT,"."
 .W !
 .S DIR(0)="Y",DIR("A")="Would you like to reset all patient activity scores",DIR("B")="N" D ^DIR S RGY=Y
 .I RGY=1 S DIR(0)="Y",DIR("A")="This will take quite a while.  Are you sure",DIR("B")="N" D ^DIR S RGY=Y
 .I RGY=1 S RUNTYPE="R",RGDFN=0 D TASK
 I STATUS="SM"!(STATUS="INT") D 
 .S STOPDT=$P(NODE,U,3) D
 ..I +STOPDT S STOPDT=$$FMTE^XLFDT(STOPDT,"1P")
 ..W !!,"The CMOR patient activity score generator was "
 ..W:STATUS="SM" ! W $S(STATUS="SM":"STOPPED MANUALLY",1:"INTERRUPTED ABNORMALLY.") I STATUS="SM" W " on ",STOPDT,"."
 .I +$P(NODE,U) D
 ..S LASTDFN=$P(NODE,U),LASTPT=$P($G(^DPT(+LASTDFN,0)),U),LASTSSN=$P(^(0),U,9)
 ..W !,"The last patient processed was ",LASTPT,"   SSN: ",LASTSSN,!?31,"[RECORD# ",LASTDFN,"]"
 .W ! S DIR(0)="Y",DIR("A")="Would you like to start with this patient and continue",DIR("B")="N" D ^DIR S RGY=Y
 .W ! I RGY=1 D
 ..S DIR(0)="Y",DIR("A")="This will take quite a while.  Are you sure"
 ..S DIR("B")="N" D ^DIR I Y=1 S RUNTYPE="RS",RGDFN=LASTDFN D TASK
 .W ! I RGY=0 D
 ..S DIR(0)="Y",DIR("A")="Would you like to rerun the CMOR calculation for all patients"
 ..S DIR("B")="N" D ^DIR I Y=1 D
 ...W ! S DIR(0)="Y",DIR("A")="This will take quite a while.  Are you sure",DIR("B")="N" D ^DIR I Y=1 S RUNTYPE="RS",RGDFN=0 D TASK
 G QUIT
STOP ;  entry point to flag a running cmor score initialization to stop
 S U="^"
 S NODE=$G(^RGSITE(991.8,1,"CMOR"))
 I $P(NODE,U,7)'="R" W !,"The CMOR activity score generation is NOT running." G QUIT
 W !,"This option will stop the CMOR patient activity score generation"
 W !,"after it has completed calculating and filing the score for the current"
 W !,"patient."
 W ! S DIR("A")="Are you sure you want to do this",DIR("B")="N",DIR(0)="Y" D ^DIR K DIR S RGY=Y
 W ! S DIR("A")="Stop patient activity score generation after the current patient",DIR("B")="N",DIR(0)="Y" D ^DIR S RGY=Y
 ;I RGY=1 S DA=1,DIE="^RGSITE(991.8,",DR="21////Y;24////SM" D ^DIE
 I RGY=1 D
 .S $P(^RGSITE(991.8,1,"CMOR"),U,4)="Y"
 .W !!,"CMOR patient activity generation is flagged to stop after"
 .W !,"it has completed the current patient.  This may take a short time."
 .W !,"Please check the status later."
 G QUIT
INDIV ;  entry point to allow a cmor score for an individual patient to be
 ;  calculated and filed
 N MNODE
 S U="^"
 S DIC="^DPT(",DIC(0)="AEQMNZ" D ^DIC K DIC Q:+Y<0  S RGDFN=+Y
 S PTNAM=$P(Y(0),"^"),SSN=$P(Y(0),"^",9),FILE=1
 S MNODE=$$MPINODE^MPIFAPI(RGDFN)
 I $P($G(MNODE),U,7)'="" D
 .S FILE=0
 .S SCOREDT=$$FMTE^XLFDT($P(MNODE,U,7),"1P")
 .S CURSCORE=$P(MNODE,U,6) W !!,"This patient has an existing CMOR score of ",+CURSCORE," calculated on ",SCOREDT,".",!
 .S DIR(0)="Y",DIR("A")="Do you want to calculate and file a new score for this patient",DIR("B")="NO" D ^DIR I Y=1 S FILE=1
 I FILE=1 D
 .W !!,"Working.  Please standby..." S FILEFLG=0 D CALCI^RGVCCMR2
 .I 'FILEFLG W !!,"No Patient Activity in the Past Three Years - No Score Filed!" Q
 .W !!,"CMOR Activity Score: ",SCORE," filed for ",PTNAM,"  SSN: ",SSN,"."
 G QUIT
DISPLAY ;  displays the status of the background cmor score initialization
 W !,"The CMOR Activity Score Generator",!
 ;count number of CMOR scores"
 W !,"..one moment please...",!
 S (SCORE,CNT)=0
 F  S SCORE=$O(^DPT("ACMORS",SCORE)) Q:'SCORE  D
 .S RGDFN=0 F  S RGDFN=$O(^DPT("ACMORS",SCORE,RGDFN)) Q:'RGDFN  D
 ..S CNT=CNT+1
 W !,"There are ",$P(^DPT(0),U,4)," records in your PATIENT file."
 W !,"The last record number is ",$P(^DPT(0),U,3),"."
 I $P($G(^RGSITE(991.8,1,"CMOR")),U)'="" D CHKSTAT
 I $P($G(^RGSITE(991.8,1,"CMOR")),U)="" D
 . W !,"The CMOR Calculation has NEVER been run on your system."
 G QUIT
CHKSTAT S NODE=$G(^RGSITE(991.8,1,"CMOR"))
 S PTNAM="-Unknown-",SSN="---"
 S RGDFN=+NODE I RGDFN,$D(^DPT(RGDFN,0)) D
 .S PTNAM=$P(^(0),U),SSN=$P(^(0),U,9)
 S OSTARTED="UNSPECIFIED" I $P(NODE,U,2)'="" D
 .S OSTARTED=$$FMTE^XLFDT($P(NODE,U,2),"1P")
 S OSTOPPED="UNSPECIFIED" I $P(NODE,U,3)'="" D
 .S OSTOPPED=$$FMTE^XLFDT($P(NODE,U,3),"1P")
 S ORESTART=$G(^XTMP("RGVCCMR","@@@@","RESTARTED"))
 I +ORESTART S ORESTART=$$FMTE^XLFDT(ORESTART,"1P")
 S ODFNCT=""
 I $D(^XTMP("RGVCCMR","@@@@","DFNCOUNT")) S ODFNCT=^XTMP("RGVCCMR","@@@@","DFNCOUNT")
STATUS S ST=$P(NODE,U,7)
 ;if status is RUNNING, check to see if task errored out
 I ST="R" D
 .S ZTSK=$P(NODE,U,9) I $D(ZTSK) D
 ..D STAT^%ZTLOAD
 ..I ZTSK(1)=5 D INT S ST="INT"
 S STATUS=$S(ST="R":"RUNNING.",ST="SM":"STOPPED MANUALLY",ST="SN":"SUCCESSFULLY COMPLETED",ST="INT":"INTERRUPTED ABNORMALLY.",1:"- NO STATUS LISTED -")
 ;S PERCOMP=((ODFNCT/$P(^DPT(0),U,4))*100),PERCOMP=$P(PERCOMP,".")_"."_$E($P(PERCOMP,".",2),1,2)
 W !,"Last Patient Processed: ",PTNAM,"   SSN: ",SSN,"   [RECORD# ",RGDFN,"]"
 W !!,"The CMOR score initialization last started on ",OSTARTED,"."
 I ORESTART]"" W !,"Job was restarted on ",ORESTART,"."
 I +ODFNCT W !,ODFNCT," patient records have been processed."
 W !,"Status: ",STATUS I ST'="R"&(ST'="INT") W " on ",OSTOPPED,"."
 W !,"CMOR Score Count: ",CNT
 ;
 G QUIT
 ;
INT ;Set status to INTERRUPTED for abnormally stopped jobs
 S $P(^RGSITE(991.8,1,"CMOR"),"^",7)="INT"
 S STATUS="INT"
 Q
TASK S ZTIO="",ZTRTN="^RGVCCMR2",ZTDESC="BACKGROUND CMOR SCORE CALCULATOR"
 S (ZTSAVE("RUNTYPE"),ZTSAVE("RGDFN"))=""
 ; change ztsave("*")="" to specific variables when done
 D ^%ZTLOAD
 I $D(ZTSK) W "   Task#, ",ZTSK," queued" S $P(^RGSITE(991.8,1,"CMOR"),U,9)=ZTSK
 D ^%ZISC
 Q
QUIT K RGDFN,DIC,DIR,FILE,LASTDFN,LASTPT,LASTSSN,ODFNCT,ORESTART,OSTARTED
 K OSTOPPED,PTNAM,RUNTYPE,SCORE,SSN,ST,STATUS,X,Y,%DT,ZTDESC,ZTIO,ZTRTN,ZTSAVE,ZTSK
 K CURSCORE,SCOREDT,NODE,STOPDT,FILEFLG,SCORE,CNT,RGDFN,RUN
 ;kill variables leftover from the CALI^RGVCCMR2 entry point
 K LRCODE,DA,DR,DIE,APSTDT,LRCODE,LRSCORE,NXPC,NXPTF,NXSCE,NXRX,NXXR,PCCODE,PSOVER,PTF0,RXDT,STDT,XRCODE,XRSTDT,YR
 Q
 
--- Routine Detail   --- with STRUCTURED ROUTINE LISTING ---[H[J[2J[HRGVCCMR1   7400     printed  Sep 23, 2025@19:19:05                                                                                                                                                                                                    Page 2
RGVCCMR1  ;GAI/TMG-CMOR ACTIVITY SCORE GENERATOR (PART 1) ;01/15/98
 +1       ;;1.0;CLINICAL INFO RESOURCE NETWORK;**2,19**;30 Apr 99
 +2       ;Reference to ^DPT("ACMORS" and ^DPT(0 supported by IA #2070
 +3       ;
EN        ;  this routine contains entry points to start/restart the batch cmor
 +1       ;  score initialization, flag a running
 +2       ;  initialization to stop, calculate and file an activity score for an
 +3       ;  individual patient, and display the status of the cmor initialization 
START     ; entry point to start or restart the cmor activity score initialization
 +1        NEW RGY
 +2        SET U="^"
 +3        SET NODE=$GET(^RGSITE(991.8,1,"CMOR"))
 +4        IF '(+$PIECE(NODE,U))
               Begin DoDot:1
 +5                WRITE !!,"This is the initial run of the CMOR patient activity score generator."
 +6                SET RUNTYPE="I"
                   SET RGDFN=0
                   DO TASK
               End DoDot:1
               GOTO QUIT
 +7        SET STATUS=$PIECE(NODE,U,7)
 +8        IF STATUS="R"
               Begin DoDot:1
 +9                SET RUN=0
 +10               SET ZTSK=+$PIECE(NODE,U,9)
 +11               IF 'ZTSK
                       DO INT
                       QUIT 
 +12               DO STAT^%ZTLOAD
 +13               IF ZTSK(1)=0!(ZTSK(1)=3)!(ZTSK(1)=4)
                       DO INT
                       QUIT 
 +14               IF ZTSK(1)=1
                       WRITE !!,"CMOR Patient Activity Score queued task #",ZTSK,!,"is waiting to run.  Do not start another job at this time."
                       SET RUN=1
                       QUIT 
 +15               IF ZTSK(1)=2
                       WRITE !!,"CMOR Patient Activity Score queued task #",ZTSK,!,"is currently running.  Do not start another job at this time."
                       SET RUN=1
                       QUIT 
 +16               IF ZTSK(1)=5
                       WRITE !!,"CMOR Patient Activity Score queued task #",ZTSK,!,"was interrupted abnormally, possibly from a system error."
                       DO INT
               End DoDot:1
               IF RUN
                   GOTO QUIT
 +17       IF STATUS="SN"
               Begin DoDot:1
 +18               SET STOPDT=$PIECE(NODE,U,3)
                   IF +STOPDT
                       Begin DoDot:2
 +19                       SET STOPDT=$$FMTE^XLFDT(STOPDT,"1P")
 +20                       WRITE !!,"The CMOR patient activity score generator",!,"completed successfully on ",STOPDT,"."
                       End DoDot:2
 +21               WRITE !
 +22               SET DIR(0)="Y"
                   SET DIR("A")="Would you like to reset all patient activity scores"
                   SET DIR("B")="N"
                   DO ^DIR
                   SET RGY=Y
 +23               IF RGY=1
                       SET DIR(0)="Y"
                       SET DIR("A")="This will take quite a while.  Are you sure"
                       SET DIR("B")="N"
                       DO ^DIR
                       SET RGY=Y
 +24               IF RGY=1
                       SET RUNTYPE="R"
                       SET RGDFN=0
                       DO TASK
               End DoDot:1
 +25       IF STATUS="SM"!(STATUS="INT")
               Begin DoDot:1
 +26               SET STOPDT=$PIECE(NODE,U,3)
                   Begin DoDot:2
 +27                   IF +STOPDT
                           SET STOPDT=$$FMTE^XLFDT(STOPDT,"1P")
 +28                   WRITE !!,"The CMOR patient activity score generator was "
 +29                   if STATUS="SM"
                           WRITE !
                       WRITE $SELECT(STATUS="SM":"STOPPED MANUALLY",1:"INTERRUPTED ABNORMALLY.")
                       IF STATUS="SM"
                           WRITE " on ",STOPDT,"."
                   End DoDot:2
 +30               IF +$PIECE(NODE,U)
                       Begin DoDot:2
 +31                       SET LASTDFN=$PIECE(NODE,U)
                           SET LASTPT=$PIECE($GET(^DPT(+LASTDFN,0)),U)
                           SET LASTSSN=$PIECE(^(0),U,9)
 +32                       WRITE !,"The last patient processed was ",LASTPT,"   SSN: ",LASTSSN,!?31,"[RECORD# ",LASTDFN,"]"
                       End DoDot:2
 +33               WRITE !
                   SET DIR(0)="Y"
                   SET DIR("A")="Would you like to start with this patient and continue"
                   SET DIR("B")="N"
                   DO ^DIR
                   SET RGY=Y
 +34               WRITE !
                   IF RGY=1
                       Begin DoDot:2
 +35                       SET DIR(0)="Y"
                           SET DIR("A")="This will take quite a while.  Are you sure"
 +36                       SET DIR("B")="N"
                           DO ^DIR
                           IF Y=1
                               SET RUNTYPE="RS"
                               SET RGDFN=LASTDFN
                               DO TASK
                       End DoDot:2
 +37               WRITE !
                   IF RGY=0
                       Begin DoDot:2
 +38                       SET DIR(0)="Y"
                           SET DIR("A")="Would you like to rerun the CMOR calculation for all patients"
 +39                       SET DIR("B")="N"
                           DO ^DIR
                           IF Y=1
                               Begin DoDot:3
 +40                               WRITE !
                                   SET DIR(0)="Y"
                                   SET DIR("A")="This will take quite a while.  Are you sure"
                                   SET DIR("B")="N"
                                   DO ^DIR
                                   IF Y=1
                                       SET RUNTYPE="RS"
                                       SET RGDFN=0
                                       DO TASK
                               End DoDot:3
                       End DoDot:2
               End DoDot:1
 +41       GOTO QUIT
STOP      ;  entry point to flag a running cmor score initialization to stop
 +1        SET U="^"
 +2        SET NODE=$GET(^RGSITE(991.8,1,"CMOR"))
 +3        IF $PIECE(NODE,U,7)'="R"
               WRITE !,"The CMOR activity score generation is NOT running."
               GOTO QUIT
 +4        WRITE !,"This option will stop the CMOR patient activity score generation"
 +5        WRITE !,"after it has completed calculating and filing the score for the current"
 +6        WRITE !,"patient."
 +7        WRITE !
           SET DIR("A")="Are you sure you want to do this"
           SET DIR("B")="N"
           SET DIR(0)="Y"
           DO ^DIR
           KILL DIR
           SET RGY=Y
 +8        WRITE !
           SET DIR("A")="Stop patient activity score generation after the current patient"
           SET DIR("B")="N"
           SET DIR(0)="Y"
           DO ^DIR
           SET RGY=Y
 +9       ;I RGY=1 S DA=1,DIE="^RGSITE(991.8,",DR="21////Y;24////SM" D ^DIE
 +10       IF RGY=1
               Begin DoDot:1
 +11               SET $PIECE(^RGSITE(991.8,1,"CMOR"),U,4)="Y"
 +12               WRITE !!,"CMOR patient activity generation is flagged to stop after"
 +13               WRITE !,"it has completed the current patient.  This may take a short time."
 +14               WRITE !,"Please check the status later."
               End DoDot:1
 +15       GOTO QUIT
INDIV     ;  entry point to allow a cmor score for an individual patient to be
 +1       ;  calculated and filed
 +2        NEW MNODE
 +3        SET U="^"
 +4        SET DIC="^DPT("
           SET DIC(0)="AEQMNZ"
           DO ^DIC
           KILL DIC
           if +Y<0
               QUIT 
           SET RGDFN=+Y
 +5        SET PTNAM=$PIECE(Y(0),"^")
           SET SSN=$PIECE(Y(0),"^",9)
           SET FILE=1
 +6        SET MNODE=$$MPINODE^MPIFAPI(RGDFN)
 +7        IF $PIECE($GET(MNODE),U,7)'=""
               Begin DoDot:1
 +8                SET FILE=0
 +9                SET SCOREDT=$$FMTE^XLFDT($PIECE(MNODE,U,7),"1P")
 +10               SET CURSCORE=$PIECE(MNODE,U,6)
                   WRITE !!,"This patient has an existing CMOR score of ",+CURSCORE," calculated on ",SCOREDT,".",!
 +11               SET DIR(0)="Y"
                   SET DIR("A")="Do you want to calculate and file a new score for this patient"
                   SET DIR("B")="NO"
                   DO ^DIR
                   IF Y=1
                       SET FILE=1
               End DoDot:1
 +12       IF FILE=1
               Begin DoDot:1
 +13               WRITE !!,"Working.  Please standby..."
                   SET FILEFLG=0
                   DO CALCI^RGVCCMR2
 +14               IF 'FILEFLG
                       WRITE !!,"No Patient Activity in the Past Three Years - No Score Filed!"
                       QUIT 
 +15               WRITE !!,"CMOR Activity Score: ",SCORE," filed for ",PTNAM,"  SSN: ",SSN,"."
               End DoDot:1
 +16       GOTO QUIT
DISPLAY   ;  displays the status of the background cmor score initialization
 +1        WRITE !,"The CMOR Activity Score Generator",!
 +2       ;count number of CMOR scores"
 +3        WRITE !,"..one moment please...",!
 +4        SET (SCORE,CNT)=0
 +5        FOR 
               SET SCORE=$ORDER(^DPT("ACMORS",SCORE))
               if 'SCORE
                   QUIT 
               Begin DoDot:1
 +6                SET RGDFN=0
                   FOR 
                       SET RGDFN=$ORDER(^DPT("ACMORS",SCORE,RGDFN))
                       if 'RGDFN
                           QUIT 
                       Begin DoDot:2
 +7                        SET CNT=CNT+1
                       End DoDot:2
               End DoDot:1
 +8        WRITE !,"There are ",$PIECE(^DPT(0),U,4)," records in your PATIENT file."
 +9        WRITE !,"The last record number is ",$PIECE(^DPT(0),U,3),"."
 +10       IF $PIECE($GET(^RGSITE(991.8,1,"CMOR")),U)'=""
               DO CHKSTAT
 +11       IF $PIECE($GET(^RGSITE(991.8,1,"CMOR")),U)=""
               Begin DoDot:1
 +12               WRITE !,"The CMOR Calculation has NEVER been run on your system."
               End DoDot:1
 +13       GOTO QUIT
CHKSTAT    SET NODE=$GET(^RGSITE(991.8,1,"CMOR"))
 +1        SET PTNAM="-Unknown-"
           SET SSN="---"
 +2        SET RGDFN=+NODE
           IF RGDFN
               IF $DATA(^DPT(RGDFN,0))
                   Begin DoDot:1
 +3                    SET PTNAM=$PIECE(^(0),U)
                       SET SSN=$PIECE(^(0),U,9)
                   End DoDot:1
 +4        SET OSTARTED="UNSPECIFIED"
           IF $PIECE(NODE,U,2)'=""
               Begin DoDot:1
 +5                SET OSTARTED=$$FMTE^XLFDT($PIECE(NODE,U,2),"1P")
               End DoDot:1
 +6        SET OSTOPPED="UNSPECIFIED"
           IF $PIECE(NODE,U,3)'=""
               Begin DoDot:1
 +7                SET OSTOPPED=$$FMTE^XLFDT($PIECE(NODE,U,3),"1P")
               End DoDot:1
 +8        SET ORESTART=$GET(^XTMP("RGVCCMR","@@@@","RESTARTED"))
 +9        IF +ORESTART
               SET ORESTART=$$FMTE^XLFDT(ORESTART,"1P")
 +10       SET ODFNCT=""
 +11       IF $DATA(^XTMP("RGVCCMR","@@@@","DFNCOUNT"))
               SET ODFNCT=^XTMP("RGVCCMR","@@@@","DFNCOUNT")
STATUS     SET ST=$PIECE(NODE,U,7)
 +1       ;if status is RUNNING, check to see if task errored out
 +2        IF ST="R"
               Begin DoDot:1
 +3                SET ZTSK=$PIECE(NODE,U,9)
                   IF $DATA(ZTSK)
                       Begin DoDot:2
 +4                        DO STAT^%ZTLOAD
 +5                        IF ZTSK(1)=5
                               DO INT
                               SET ST="INT"
                       End DoDot:2
               End DoDot:1
 +6        SET STATUS=$SELECT(ST="R":"RUNNING.",ST="SM":"STOPPED MANUALLY",ST="SN":"SUCCESSFULLY COMPLETED",ST="INT":"INTERRUPTED ABNORMALLY.",1:"- NO STATUS LISTED -")
 +7       ;S PERCOMP=((ODFNCT/$P(^DPT(0),U,4))*100),PERCOMP=$P(PERCOMP,".")_"."_$E($P(PERCOMP,".",2),1,2)
 +8        WRITE !,"Last Patient Processed: ",PTNAM,"   SSN: ",SSN,"   [RECORD# ",RGDFN,"]"
 +9        WRITE !!,"The CMOR score initialization last started on ",OSTARTED,"."
 +10       IF ORESTART]""
               WRITE !,"Job was restarted on ",ORESTART,"."
 +11       IF +ODFNCT
               WRITE !,ODFNCT," patient records have been processed."
 +12       WRITE !,"Status: ",STATUS
           IF ST'="R"&(ST'="INT")
               WRITE " on ",OSTOPPED,"."
 +13       WRITE !,"CMOR Score Count: ",CNT
 +14      ;
 +15       GOTO QUIT
 +16      ;
INT       ;Set status to INTERRUPTED for abnormally stopped jobs
 +1        SET $PIECE(^RGSITE(991.8,1,"CMOR"),"^",7)="INT"
 +2        SET STATUS="INT"
 +3        QUIT 
TASK       SET ZTIO=""
           SET ZTRTN="^RGVCCMR2"
           SET ZTDESC="BACKGROUND CMOR SCORE CALCULATOR"
 +1        SET (ZTSAVE("RUNTYPE"),ZTSAVE("RGDFN"))=""
 +2       ; change ztsave("*")="" to specific variables when done
 +3        DO ^%ZTLOAD
 +4        IF $DATA(ZTSK)
               WRITE "   Task#, ",ZTSK," queued"
               SET $PIECE(^RGSITE(991.8,1,"CMOR"),U,9)=ZTSK
 +5        DO ^%ZISC
 +6        QUIT 
QUIT       KILL RGDFN,DIC,DIR,FILE,LASTDFN,LASTPT,LASTSSN,ODFNCT,ORESTART,OSTARTED
 +1        KILL OSTOPPED,PTNAM,RUNTYPE,SCORE,SSN,ST,STATUS,X,Y,%DT,ZTDESC,ZTIO,ZTRTN,ZTSAVE,ZTSK
 +2        KILL CURSCORE,SCOREDT,NODE,STOPDT,FILEFLG,SCORE,CNT,RGDFN,RUN
 +3       ;kill variables leftover from the CALI^RGVCCMR2 entry point
 +4        KILL LRCODE,DA,DR,DIE,APSTDT,LRCODE,LRSCORE,NXPC,NXPTF,NXSCE,NXRX,NXXR,PCCODE,PSOVER,PTF0,RXDT,STDT,XRCODE,XRSTDT,YR
 +5        QUIT