Index: ccr/trunk/p/C0CBAT.m
===================================================================
--- ccr/trunk/p/C0CBAT.m	(revision 439)
+++ ccr/trunk/p/C0CBAT.m	(revision 440)
@@ -19,4 +19,29 @@
  ;
  W "This is the CCR Batch Utility Library ",!
+ Q
+ ;
+STOP ; STOP A CURRENTLY RUNNING BATCH JOB
+ I '$D(^TMP("C0CBAT","RUNNING")) Q  ;
+ W !,!,"HALTING CCR BATCH",!
+ S ^TMP("C0CBAT","STOP")="" ; SIGNAL JOB TO TERMINATE
+ H 10 ; WAIT TEN SECONDS FOR SIGNAL TO BE RECEIVED
+ I '$D(^TMP("C0CBAT","STOP")) D  ; SIGNAL RECEIVED
+ . W "CCR BATCH JOB TERMINATING",!
+ E  K ^TMP("C0CBAT","STOP") ; STOP SIGNALING
+ Q
+ ;
+START ; STARTS A TAKSMAN CCR BATCH JOB - FOR USE IN A MENU OPTION
+ ;
+ I $D(^TMP("C0CBAT","RUNNING")) D  Q  ; ONLY ONE ALLOWED AT A TIME
+ . W !,"CCR BATCH ALREADY RUNNING",!
+ . W !,"STOP FIRST WITH STOP^C0CBAT",!
+ N ZTRTN,ZTDESC,ZTDTH,ZTSAVE,ZTSK,ZTIO
+ S ZTRTN="EN^C0CBAT",ZTDESC="CCR Batch"
+ S ZTDTH=$H ; 
+ ;S ZTDTH=$S(($P(ZTDTH,",",2)+10)\86400:(1+ZTDTH)_","_((($P(ZTDTH,",",2)+10)#86400)/100000),1:(+ZTDTH)_","_($P(ZTDTH,",",2)+10))
+ S ZTSAVE("C0C")="",ZTSAVE("C0C*")=""
+ S ZTIO="NULL" ;
+ W !,!,"CCR BATCH JOB STARTED",!
+ D ^%ZTLOAD
  Q
  ;
@@ -28,11 +53,14 @@
  ;
  S C0CQT=1 ; QUIET MODE
+ I $D(^TMP("C0CBAT","RUNNING")) Q  ; ONLY ONE AT A TIME
+ S ^TMP("C0CBAT","RUNNING")="" ; RUNNING SIGNAL
  S C0CBDT=$$NOW^XLFDT ; DATE OF THIS RUN
  S C0CBF=177.301 ; FILE NUMBER OF C0C BATCH CONTROL FILE
+ S C0CBFR=177.3013 ; FILE NUMBER OF UPDATE SUBFILE
  S C0CBB=$NA(^TMP("C0CBATCH",C0CBDT)) ; BATCH WORK AREA
  I $D(@C0CBB@(0)) D  ; ERROR SHOULDN'T EXIST
  . W "WORK AREA ERROR",!
  . B
- S @C0CBB@(0)="V21" ; VERSION USED TO CREATE THIS WORK AREA
+ S @C0CBB@(0)="V22" ; VERSION USED TO CREATE THIS WORK AREA
  S C0CBH=$NA(@C0CBB@("HOTLIST")) ; BASE FOR HOT LIST
  S C0CBS=$NA(^C0CS("B")) ; SUBSCRIPTION LIST BASE
@@ -52,9 +80,16 @@
  S (C0CN,C0CNH)=0 ; COUNTERS FOR TOTAL AND HOT LIST
  S C0CBCUR="" ; CURRENT PATIENT
+ S C0CSTOP=0 ; STOP FLAG FOR HALTING BATCH SET ^TMP("C0CBAT","STOP")=""
  ;F  S C0CBCUR=$O(@C0CBH@(C0CBCUR),-1) Q:C0CBCUR=""  D  ; HOT LIST LATEST FIRST
- F  S C0CBCUR=$O(@C0CBH@(C0CBCUR)) Q:C0CBCUR=""  D  ; HOT LIST FIRST FIRST
+ F  S C0CBCUR=$O(@C0CBH@(C0CBCUR)) Q:(C0CSTOP)!(C0CBCUR="")  D  ; HOT LIST FIRST
  . D ANALYZE^C0CRIMA(C0CBCUR,1,"LABLIMIT:T-760^VITLIMIT:T-760")
- . D PUTRIM^C0CFM2(C0CBCUR)
- . I $G(C0CCHK) D XPAT^C0CCCR(C0CBCUR) ; IF VARIABLES HAVE CHANGED GENERATE CCR
+ . I $G(C0CCHK) D  ;
+ . . D PUTRIM^C0CFM2(C0CBCUR)
+ . . D XPAT^C0CCCR(C0CBCUR) ; IF VARIABLES HAVE CHANGED GENERATE CCR
+ . . K C0CFDA
+ . . S C0CFDA(C0CBFR,"+1,"_C0CIEN_",",.01)=C0CBCUR
+ . . S C0CFDA(C0CBFR,"+1,"_C0CIEN_",",1)="Y"
+ . . S C0CFDA(C0CBFR,"+1,"_C0CIEN_",",2)=$G(^TMP("C0CCCR","FNAME",C0CBCUR))
+ . . D UPDIE ; CREATE UPDATE SUBFILE 
  . S C0CN=C0CN+1 ; INCREMENT NUMBER IN TOTAL
  . S C0CNH=C0CNH+1 ; INCREMENT HOT LIST TOTAL
@@ -70,10 +105,19 @@
  . S C0CFDA(C0CBF,C0CIEN_",",4.2)=C0CEST ;ESTIMATED COMPLETION TIME
  . D UPDIE ;
+ . I $D(^TMP("C0CBAT","STOP")) D  ; IF STOP SIGNAL DETECTED
+ . . S C0CSTOP=1
+ . . K ^TMP("C0CBAT","STOP") ; SIGNAL RECEIVED 
  . H 1 ; GIVE OTHERS A CHANCE 
- F  S C0CBCUR=$O(@C0CBS@(C0CBCUR)) Q:C0CBCUR=""  D  ; REMAINING SUBSCRIPTION LIST
+ F  S C0CBCUR=$O(@C0CBS@(C0CBCUR)) Q:(C0CSTOP)!(C0CBCUR="")  D  ; SUBS LIST
  . I $D(@C0CBH@(C0CBCUR)) Q  ; SKIP IF IN HOT LIST - ALREADY DONE
  . D ANALYZE^C0CRIMA(C0CBCUR,1,"LABLIMIT:T-760^VITLIMIT:T-760")
- . D PUTRIM^C0CFM2(C0CBCUR)
- . I $G(C0CCHK) D XPAT^C0CCCR(C0CBCUR) ; IF VARIABLES HAVE CHANGED GENERATE CCR
+ . I $G(C0CCHK) D  ;
+ . . D PUTRIM^C0CFM2(C0CBCUR)
+ . . D XPAT^C0CCCR(C0CBCUR) ; IF VARIABLES HAVE CHANGED GENERATE CCR
+ . . K C0CFDA
+ . . S C0CFDA(C0CBFR,"+1,"_C0CIEN_",",.01)=C0CBCUR
+ . . S C0CFDA(C0CBFR,"+1,"_C0CIEN_",",1)="Y"
+ . . S C0CFDA(C0CBFR,"+1,"_C0CIEN_",",2)=$G(^TMP("C0CCCR","FNAME",C0CBCUR))
+ . . D UPDIE ; CREATE UPDATE SUBFILE 
  . S C0CN=C0CN+1 ; INCREMENT NUMBER IN TOTAL
  . S C0CFDA(C0CBF,C0CIEN_",",1.1)=C0CN ;UPDATE TOTAL PROGRESS
@@ -87,5 +131,9 @@
  . S C0CFDA(C0CBF,C0CIEN_",",4.2)=C0CEST ;ESTIMATED COMPLETION TIME
  . D UPDIE ; 
+ . I $D(^TMP("C0CBAT","STOP")) D  ; IF STOP SIGNAL DETECTED
+ . . S C0CSTOP=1
+ . . K ^TMP("C0CBAT","STOP") ; SIGNAL RECEIVED 
  . H 1 ; GIVE IT A BREAK
+ K ^TMP("C0CBAT","RUNNING")
  Q
  ;
