Index: FOIAVistA/tag/r/IMAGING-MAG-ZMAG/MAGJLS2.m
===================================================================
--- FOIAVistA/trunk/r/IMAGING-MAG-ZMAG/MAGJLS2.m	(revision 631)
+++ FOIAVistA/tag/r/IMAGING-MAG-ZMAG/MAGJLS2.m	(revision 636)
@@ -1,5 +1,4 @@
 MAGJLS2 ;WIRMFO/JHC Rad. Workstation RPC calls ; 29 Jul 2003  9:58 AM
- ;;3.0;IMAGING;**22,18,76**;Jun 22, 2007;Build 19
- ;;Per VHA Directive 2004-038, this routine should not be modified.
+ ;;3.0;IMAGING;**22,18**;Mar 07, 2006
  ;; +---------------------------------------------------------------+
  ;; | Property of the US Government.                                |
@@ -19,5 +18,5 @@
  Q
  ;  ACTIVE -- list exams (Unread, Recent, &/or Pending) for input Imaging Type(s)
- ;    RPC Call: MAGJ RADACTIVEEXAMS
+ ;       RPC Call: MAGJ RADACTIVEEXAMS
  ;  BKGND -- EP for Bkgnd Compile of UNREAD list
  ;  BKGND2 -- EP for Bkgnd Compile of RECENT list
@@ -39,5 +38,4 @@
  S X=$P(DATA,U) D PARAMS^MAGJLS2B(X)
  I 'LSTID S MAGGRY=$NA(^TMP($J,"RET")),@MAGGRY@(0)="0^4~Problem with Exams List Compile--"_DATA_"." Q
- I MAGJOB("P32"),+$G(MAGJOB("P32STOP")) S MAGGRY=$NA(^TMP($J,"RET")),@MAGGRY@(0)="0^4~VistARad Patch 32 is no longer supported.  Contact Imaging support for the current version of the VistARad client software." Q  ; <*>
  I BKGND,LSTREQ="U" D BKREQU Q  ; UNREAD in bkgnd
  I BKGND,LSTREQ="R" D BKREQR Q  ; RECENT in bkgnd
@@ -89,5 +87,4 @@
  I +$G(COMPFAIL) S MAGGRY=$NA(^TMP($J,"RET")),@MAGGRY@(0)="0^4~Unable to Compile Unread Exams list"
  E  D LSTOUT^MAGJLS2B(.MAGGRY,LSTID,$NA(^XTMP("MAGJ2",LSTNAM,LSTNUM)),LSTAGE)
- K LSTAGE
  Q
  ;
@@ -100,5 +97,4 @@
  I 'LSTNUM S MAGGRY=$NA(^TMP($J,"RET")),@MAGGRY@(0)="0^4~Problem with "_LSTNM_" List Compile program (age="_LSTAGE_" for "_LSTNAM_")"_$S(LSTNAM["9992":"--May need to Schedule RECENT List Compile in TaskMan.",1:"")
  E  D LSTOUT^MAGJLS2B(.MAGGRY,LSTID,$NA(^XTMP("MAGJ2",LSTNAM,LSTNUM)),LSTAGE)
- K LSTAGE
  Q
  ;
@@ -117,5 +113,4 @@
  . D LSTOUT^MAGJLS2B(.MAGGRY,LSTID,$NA(^TMP($J,"MAGJ")))
  I 'ALLGO S MAGGRY=$NA(^TMP($J,"RET")),@MAGGRY@(0)="0^4~Problem with ALL Exams List Compile "_DATA_". "_REPLY
- K LSTAGE
  Q
  ;
@@ -151,25 +146,33 @@
  D LSTCOMP()
  I LSTREQ="R" D NEWINT
- I LSTREQ="U" D UPDR^MAGJLS2B G BKLOOP  ;UNREAD loops; RECENT uses TaskMan
+ I LSTREQ="U" D UPDR G BKLOOP  ;UNREAD loops; RECENT uses TaskMan
 BKGNDZ I LSTREQ="U" L -^XTMP("MAGJ2","BKGND2","RUN")
  N ZTREQ S ZTREQ="@"  ;  clean up task entry
- K BKLOOP,DELTA,LSTAGE
+ K BKLOOP,DELTA
  Q  ; Exit bkgnd
  ;
-NEWINT ; Add exams newly Interp since Recent Compile started to Recent List
- ; 1st, get list of candidates:
+UPDR ; Add Newly Interp exams to Recent
+ D PARAMS^MAGJLS2B(9995)
+ I 'LSTID G UPDRZ
+ S X=$$CURLIST(LSTNAM),LSTAGE=$P(X,U,2),LSTNUM=+X
+ D LSTCOMP()
+UPDRZ Q  ;
+ ;
+NEWINT ; Exams newly Interp since Recent Compile started
+ ; are added to Recent List (add to "RECENT" index)
+ ; 1st, get list of all potential candidates:
  N INDX L +^XTMP("MAGJ2","RECENT"):15
  E  Q
  S INDX=+$G(^TMP($J,"NEWINT")) ; counter when Recent Compile started
  I INDX S INDX=INDX-1 F  S INDX=$O(^XTMP("MAGJ2","RECENT",INDX)) Q:'INDX  S X=^(INDX) I X S ^TMP($J,"NEWINT",0,INDX)=X
- K ^XTMP("MAGJ2","RECENT") S ^("RECENT",0)=0
+ K ^XTMP("MAGJ2","RECENT") S ^("RECENT",0)=0 ; init this index
  L -^XTMP("MAGJ2","RECENT")
- ;if not in Recent Compile, add to index
+ ;find those not included in Recent Compile, and add to index
  S INDX=""
  F  S INDX=$O(^TMP($J,"NEWINT",0,INDX)) Q:'INDX  S X=^(INDX) D
- . I $D(^TMP($J,"NEWINT",$P(X,U,1,3))) Q  ; already there
+ . I $D(^TMP($J,"NEWINT",$P(X,U,1,3))) Q  ; already in the compile
  . L +^XTMP("MAGJ2","RECENT"):15
  . E  Q
- . S I=+$G(^XTMP("MAGJ2","RECENT",0))+1,$P(^(0),U)=I,^(I)=X ;add 
+ . S I=+$G(^XTMP("MAGJ2","RECENT",0))+1,$P(^(0),U)=I,^(I)=X ; add to indx
  . L -^XTMP("MAGJ2","RECENT")
  K ^TMP($J,"NEWINT")
@@ -178,9 +181,9 @@
 LSTCOMP(COMPFAIL) ; Compile new list; subrtn used by Active and Bkgnd tags
  S COMPFAIL=0 ; Return T/F for "Executed a List Compile?"
- L +^XTMP("MAGJ2","BKGND",LSTNAM,"COMPILE"):60
+ L +^XTMP("MAGJ2","BKGND",LSTNAM,"COMPILE"):60 ; shouldn't need any time
  E  S COMPFAIL=1 G LSTCOMZ
- S NEWLIST=$S(LSTNUM=1:2,1:1) ; toggle node to use
+ S NEWLIST=$S(LSTNUM=1:2,1:1) ; toggle node to use for new compile
  N TS,COMTIM
- S TS="" F I=2,0 S TS=TS_$S(TS="":"",1:U)_$$HTFM^XLFDT($H+I,0)
+ S TS="" F I=2,0 S %H=$H+I D YMD^%DTC S TS=TS_$S(TS="":"",1:U)_X
  S ^XTMP("MAGJ2",0)=TS_U_"VistaRad List Compile"
  S ^XTMP("MAGJ2",0,LSTNAM,NEWLIST)=$H
@@ -194,5 +197,7 @@
 LSTCOMZ L -^XTMP("MAGJ2","BKGND",LSTNAM,"COMPILE")
  Q  ;
-CURLIST(LSTNAM,WAIT) ; return cur. list & age in secs
+ ;
+CURLIST(LSTNAM,WAIT) ; return current list & its age in seconds
+ ;
  S WAIT=+$G(WAIT)
  N X,RET,AGE,TRY,START,EXTRATIM
@@ -204,11 +209,11 @@
 CURLISZ Q RET
  ;
-DELTA(X,Y) ; calc # secs bet 2 $h values; dflt 2nd value = now
+DELTA(X,Y) ; calc # seconds between 2 $h values; default 2nd value = now
  ; useful limit is one day
  I $G(Y)="" S Y=$H
  I +Y=+X
  E  D
- . I Y-X=1 S $P(Y,",",2)=86400+$P(Y,",",2)  ; midnight boundary
- . E  S $P(X,",",2)=0,$P(Y,",",2)=86400  ; > one day
+ . I Y-X=1 S $P(Y,",",2)=86400+$P(Y,",",2)  ; cross midnight boundary
+ . E  S $P(X,",",2)=0,$P(Y,",",2)=86400  ; more than one day
  Q ($P(Y,",",2)-$P(X,",",2))
  ;
