MAGXCVP ;WOIFO/SEB,MLH - Image Index Conversion Generate & Commit ; 05/18/2007 11:23
;;3.0;IMAGING;**17,25,31,54**;03-July-2009;;Build 1424
;; Per VHA Directive 2004-038, this routine should not be modified.
;; +---------------------------------------------------------------+
;; | Property of the US Government. |
;; | No permission to copy or redistribute this software is given. |
;; | Use of unreleased versions of this software requires the user |
;; | to execute a written test agreement with the VistA Imaging |
;; | Development Office of the Department of Veterans Affairs, |
;; | telephone (301) 734-0100. |
;; | The Food and Drug Administration classifies this software as |
;; | a medical device. As such, it may not be changed in any way. |
;; | Modifications to this software may result in an adulterated |
;; | medical device under 21CFR820, the use of which is considered |
;; | to be a violation of US Federal Statutes. |
;; +---------------------------------------------------------------+
;;
Q
;
; Input starting and ending IENs. Return in variables START and END.
BOUNDS(START,END) N TEMP
START R !,"From ID: 1 // ",START:DTIME
I $E(START)="?" D G START
. W !!,"Please enter the ID of an entry in the image file. This will be the first image"
. W !,"in the range of images processed by this menu option.",!
. Q
I START="" S START=1
I START="^" Q
I +START'=START W !!,"Please enter a starting image ID - numbers only." G START
END R !,"To ID: LAST // ",END:DTIME
I $E(END)="?" D G END
. W !!,"Please enter the ID of an entry in the image file. This will be the last image"
. W !,"in the range of images processed by this menu option.",!
. Q
I "^LAST"[("^"_$$UCASE(END)) D ; includes null response default
. W " LAST"
. S END=+$P($G(^MAG(2005,0)),U,3)
. Q
I END="^" S START="^" Q
I +END'=END W !!,"Please enter an ending image ID - numbers only." G END
I START>END D G END ;S TEMP=END,END=START,START=TEMP
. W !!,"'To ID' value must not be less than 'From ID' value."
. Q
Q
;
; Prompt whether the user wishes to recreate previously-calculated indices. Return in FLAG.
RECREATE(FLAG) S FLAG=""
RECR R !,"Recreate previously calculated indices? Y // ",FLAG:DTIME
S FLAG=$$UCASE($E(FLAG)) I FLAG="" S FLAG="Y"
I FLAG="?" D G RECR
. W !!,"Entering YES will cause index fields that have been calculated by a previous"
. W !,"execution of this option to be recalculated. Entering NO will cause the option"
. W !,"to skip images that already have index fields.",!
. Q
I "YN^"'[FLAG W !!,"Please enter YES or NO." G RECR
Q
;
; Ask if user wishes to job a task into the background with TaskMan. Returns NULL if
; the user wishes to run it in the foreground, and a schedule date/time if the user
; wishes to use TaskMan.
TASKMAN(RETURN) N ASK,X,%DT
I '$$TM^%ZTLOAD() S RETURN="" Q
TMA R !,"Would you like to schedule this with TaskMan? Y // ",ASK:DTIME
S ASK=$$UCASE($E(ASK))
I ASK="?" D G TMA
. W !!,"Entering YES will run this task with TaskMan. Entering NO will cause it to"
. W !,"run in the foreground.",!
I "YN^"'[ASK W !!,"Please enter YES or NO." G TMA
I ASK="^" S RETURN="^" Q
I ASK="N" S RETURN="" Q
SCHED R !!,"Please enter the date/time for scheduling the task: NOW // ",X:DTIME I X="" S X="NOW"
I X="^" S RETURN="^" Q
S %DT="R" D ^%DT I Y=-1 G SCHED
S RETURN=Y Q
Q
;
DONE W !!,"Done!"
Q
;
; Generate a notification message and send it to group MAG SERVER
NOTIFY(RESULT,SUBJECT,STARTDT,ENDDT,STARTIEN,ENDIEN,RECR) N Y,LOC,XMSUB,DIS,CAP,CNT,I,VR,DM,SUMMARY
K ^TMP($J,"MAGQ")
S Y=$$HTE^XLFDT($H,1) ; EdM: is Y used anywhere?
S U="^",LOC=$$KSP^XUPARAM("WHERE")
S SUBJECT=$G(SUBJECT)
I +SUBJECT=SUBJECT S SUBJECT=$P("Generate^Commit",U,SUBJECT)
S XMSUB=SUBJECT_" Image Index Conversion Values: "_$G(ENDDT)
S ^TMP($J,"MAGQ",1)="Status: "_$$ST^MAGXCVR
S ^TMP($J,"MAGQ",2)="Started on: "_$G(STARTDT)
S ^TMP($J,"MAGQ",3)="Finished on: "_$G(ENDDT)
S ^TMP($J,"MAGQ",4)="Starting IEN: "_$G(STARTIEN)
S ^TMP($J,"MAGQ",5)="Ending IEN: "_$G(ENDIEN)
S ^TMP($J,"MAGQ",6)="Recreate Indices: "_$G(RECR)
S SUMMARY=""
F I=7:1 S SUMMARY=$O(^XTMP("MAG30P25","SUMMARY",SUMMARY)) Q:SUMMARY="" D
. S ^TMP($J,"MAGQ",I)=SUMMARY_U_^XTMP("MAG30P25","SUMMARY",SUMMARY)
. Q
N XMY,XMTEXT
S XMTEXT="^TMP($J,""MAGQ"","
S:$G(DUZ) XMY(DUZ)=""
S XMY("G.MAG SERVER")=""
S:$G(MAGDUZ) XMY(MAGDUZ)=""
D ^XMD
S RESULT="1"
K ^TMP($J,"MAGQ")
Q
;
; Convert a string to all uppercase.
UCASE(STRING) N OUTPUT
S OUTPUT=$TR(STRING,"abcdefghijklmnopqrstuvwxyz","ABCDEFGHIJKLMNOPQRSTUVWXYZ")
Q OUTPUT
;
; Convert a string to all lowercase.
LCASE(STRING) N OUTPUT
S OUTPUT=$TR(STRING,"ABCDEFGHIJKLMNOPQRSTUVWXYZ","abcdefghijklmnopqrstuvwxyz")
Q OUTPUT
;
; Strip leading and trailing spaces.
STRIP(STRING) N START,END
F START=1:1:$L(STRING) I $E(STRING,START)'=" " Q
F END=$L(STRING):-1:1 I $E(STRING,END)'=" " Q
Q $E(STRING,START,END)
;
SCRUBTKN(XSTRING) ; FUNCTION - Create standard token delimiters for parsing
; by changing all punctuation to spaces.
N STRING ; output string
S STRING=$TR(XSTRING,"+-/\.,~`!@#$%^&*()_-={}[]|:;""'<>?"," ")
; compress multiple spaces to single space
F Q:STRING'[" " S STRING=$P(STRING," ",1)_" "_$P(STRING," ",2,999)
Q STRING
;
--- Routine Detail --- with STRUCTURED ROUTINE LISTING ---[H[J[2J[HMAGXCVP 5521 printed Oct 16, 2024@18:11:22 Page 2
MAGXCVP ;WOIFO/SEB,MLH - Image Index Conversion Generate & Commit ; 05/18/2007 11:23
+1 ;;3.0;IMAGING;**17,25,31,54**;03-July-2009;;Build 1424
+2 ;; Per VHA Directive 2004-038, this routine should not be modified.
+3 ;; +---------------------------------------------------------------+
+4 ;; | Property of the US Government. |
+5 ;; | No permission to copy or redistribute this software is given. |
+6 ;; | Use of unreleased versions of this software requires the user |
+7 ;; | to execute a written test agreement with the VistA Imaging |
+8 ;; | Development Office of the Department of Veterans Affairs, |
+9 ;; | telephone (301) 734-0100. |
+10 ;; | The Food and Drug Administration classifies this software as |
+11 ;; | a medical device. As such, it may not be changed in any way. |
+12 ;; | Modifications to this software may result in an adulterated |
+13 ;; | medical device under 21CFR820, the use of which is considered |
+14 ;; | to be a violation of US Federal Statutes. |
+15 ;; +---------------------------------------------------------------+
+16 ;;
+17 QUIT
+18 ;
+19 ; Input starting and ending IENs. Return in variables START and END.
BOUNDS(START,END) NEW TEMP
START READ !,"From ID: 1 // ",START:DTIME
+1 IF $EXTRACT(START)="?"
Begin DoDot:1
+2 WRITE !!,"Please enter the ID of an entry in the image file. This will be the first image"
+3 WRITE !,"in the range of images processed by this menu option.",!
+4 QUIT
End DoDot:1
GOTO START
+5 IF START=""
SET START=1
+6 IF START="^"
QUIT
+7 IF +START'=START
WRITE !!,"Please enter a starting image ID - numbers only."
GOTO START
END READ !,"To ID: LAST // ",END:DTIME
+1 IF $EXTRACT(END)="?"
Begin DoDot:1
+2 WRITE !!,"Please enter the ID of an entry in the image file. This will be the last image"
+3 WRITE !,"in the range of images processed by this menu option.",!
+4 QUIT
End DoDot:1
GOTO END
+5 ; includes null response default
IF "^LAST"[("^"_$$UCASE(END))
Begin DoDot:1
+6 WRITE " LAST"
+7 SET END=+$PIECE($GET(^MAG(2005,0)),U,3)
+8 QUIT
End DoDot:1
+9 IF END="^"
SET START="^"
QUIT
+10 IF +END'=END
WRITE !!,"Please enter an ending image ID - numbers only."
GOTO END
+11 ;S TEMP=END,END=START,START=TEMP
IF START>END
Begin DoDot:1
+12 WRITE !!,"'To ID' value must not be less than 'From ID' value."
+13 QUIT
End DoDot:1
GOTO END
+14 QUIT
+15 ;
+16 ; Prompt whether the user wishes to recreate previously-calculated indices. Return in FLAG.
RECREATE(FLAG) SET FLAG=""
RECR READ !,"Recreate previously calculated indices? Y // ",FLAG:DTIME
+1 SET FLAG=$$UCASE($EXTRACT(FLAG))
IF FLAG=""
SET FLAG="Y"
+2 IF FLAG="?"
Begin DoDot:1
+3 WRITE !!,"Entering YES will cause index fields that have been calculated by a previous"
+4 WRITE !,"execution of this option to be recalculated. Entering NO will cause the option"
+5 WRITE !,"to skip images that already have index fields.",!
+6 QUIT
End DoDot:1
GOTO RECR
+7 IF "YN^"'[FLAG
WRITE !!,"Please enter YES or NO."
GOTO RECR
+8 QUIT
+9 ;
+10 ; Ask if user wishes to job a task into the background with TaskMan. Returns NULL if
+11 ; the user wishes to run it in the foreground, and a schedule date/time if the user
+12 ; wishes to use TaskMan.
TASKMAN(RETURN) NEW ASK,X,%DT
+1 IF '$$TM^%ZTLOAD()
SET RETURN=""
QUIT
TMA READ !,"Would you like to schedule this with TaskMan? Y // ",ASK:DTIME
+1 SET ASK=$$UCASE($EXTRACT(ASK))
+2 IF ASK="?"
Begin DoDot:1
+3 WRITE !!,"Entering YES will run this task with TaskMan. Entering NO will cause it to"
+4 WRITE !,"run in the foreground.",!
End DoDot:1
GOTO TMA
+5 IF "YN^"'[ASK
WRITE !!,"Please enter YES or NO."
GOTO TMA
+6 IF ASK="^"
SET RETURN="^"
QUIT
+7 IF ASK="N"
SET RETURN=""
QUIT
SCHED READ !!,"Please enter the date/time for scheduling the task: NOW // ",X:DTIME
IF X=""
SET X="NOW"
+1 IF X="^"
SET RETURN="^"
QUIT
+2 SET %DT="R"
DO ^%DT
IF Y=-1
GOTO SCHED
+3 SET RETURN=Y
QUIT
+4 QUIT
+5 ;
DONE WRITE !!,"Done!"
+1 QUIT
+2 ;
+3 ; Generate a notification message and send it to group MAG SERVER
NOTIFY(RESULT,SUBJECT,STARTDT,ENDDT,STARTIEN,ENDIEN,RECR) NEW Y,LOC,XMSUB,DIS,CAP,CNT,I,VR,DM,SUMMARY
+1 KILL ^TMP($JOB,"MAGQ")
+2 ; EdM: is Y used anywhere?
SET Y=$$HTE^XLFDT($HOROLOG,1)
+3 SET U="^"
SET LOC=$$KSP^XUPARAM("WHERE")
+4 SET SUBJECT=$GET(SUBJECT)
+5 IF +SUBJECT=SUBJECT
SET SUBJECT=$PIECE("Generate^Commit",U,SUBJECT)
+6 SET XMSUB=SUBJECT_" Image Index Conversion Values: "_$GET(ENDDT)
+7 SET ^TMP($JOB,"MAGQ",1)="Status: "_$$ST^MAGXCVR
+8 SET ^TMP($JOB,"MAGQ",2)="Started on: "_$GET(STARTDT)
+9 SET ^TMP($JOB,"MAGQ",3)="Finished on: "_$GET(ENDDT)
+10 SET ^TMP($JOB,"MAGQ",4)="Starting IEN: "_$GET(STARTIEN)
+11 SET ^TMP($JOB,"MAGQ",5)="Ending IEN: "_$GET(ENDIEN)
+12 SET ^TMP($JOB,"MAGQ",6)="Recreate Indices: "_$GET(RECR)
+13 SET SUMMARY=""
+14 FOR I=7:1
SET SUMMARY=$ORDER(^XTMP("MAG30P25","SUMMARY",SUMMARY))
if SUMMARY=""
QUIT
Begin DoDot:1
+15 SET ^TMP($JOB,"MAGQ",I)=SUMMARY_U_^XTMP("MAG30P25","SUMMARY",SUMMARY)
+16 QUIT
End DoDot:1
+17 NEW XMY,XMTEXT
+18 SET XMTEXT="^TMP($J,""MAGQ"","
+19 if $GET(DUZ)
SET XMY(DUZ)=""
+20 SET XMY("G.MAG SERVER")=""
+21 if $GET(MAGDUZ)
SET XMY(MAGDUZ)=""
+22 DO ^XMD
+23 SET RESULT="1"
+24 KILL ^TMP($JOB,"MAGQ")
+25 QUIT
+26 ;
+27 ; Convert a string to all uppercase.
UCASE(STRING) NEW OUTPUT
+1 SET OUTPUT=$TRANSLATE(STRING,"abcdefghijklmnopqrstuvwxyz","ABCDEFGHIJKLMNOPQRSTUVWXYZ")
+2 QUIT OUTPUT
+3 ;
+4 ; Convert a string to all lowercase.
LCASE(STRING) NEW OUTPUT
+1 SET OUTPUT=$TRANSLATE(STRING,"ABCDEFGHIJKLMNOPQRSTUVWXYZ","abcdefghijklmnopqrstuvwxyz")
+2 QUIT OUTPUT
+3 ;
+4 ; Strip leading and trailing spaces.
STRIP(STRING) NEW START,END
+1 FOR START=1:1:$LENGTH(STRING)
IF $EXTRACT(STRING,START)'=" "
QUIT
+2 FOR END=$LENGTH(STRING):-1:1
IF $EXTRACT(STRING,END)'=" "
QUIT
+3 QUIT $EXTRACT(STRING,START,END)
+4 ;
SCRUBTKN(XSTRING) ; FUNCTION - Create standard token delimiters for parsing
+1 ; by changing all punctuation to spaces.
+2 ; output string
NEW STRING
+3 SET STRING=$TRANSLATE(XSTRING,"+-/\.,~`!@#$%^&*()_-={}[]|:;""'<>?"," ")
+4 ; compress multiple spaces to single space
+5 FOR
if STRING'[" "
QUIT
SET STRING=$PIECE(STRING," ",1)_" "_$PIECE(STRING," ",2,999)
+6 QUIT STRING
+7 ;