Batch Signing of Documents: Difference between revisions

From VistApedia
Jump to navigationJump to search
No edit summary
No edit summary
Line 3: Line 3:
<pre>
<pre>
FREECUR
FREECUR
;"Purpose: For current user, ask a date range, and change all
      ;"Purpose: For current user, cycle through all alerts regarding
;" TIU DOCUMENTS that have status of unsigned to completed
      ;" documents needing to be signed, and automatically sign
;"Input: none.  User will be asked for start and end dates
      ;" them, then print if user wants.
;"Output: Produces a report to choses output channel.
      ;"Input: none.  User will be asked for signature password,
      ;" and if they want documents printed.
      ;"Output: Produces a report to chosen output channel.
        new Options
      write @IOF
       
      write !,"-- RELEASE UNSIGNED DOCUMENTS -- ",!!
write @IOF
      write "Releasing transcription for: ",$piece($get(^VA(200,DUZ,0)),"^",1),!!
        write !,"-- RELEASE UNSIGNED DOCUMENTS -- ",!!
        write "Releasing transcription for: ",$piece($get(^VA(200,DUZ,0)),"^",1),!!


set Options("AUTHOR")=DUZ
do FreeDocs(DUZ)
do FreeAskDates(.Options)


quit
quit
Line 21: Line 20:


FREEASK
FREEASK
;"Purpose: To ask for a given user, and a date range, and change all
;"Purpose: Ask for chosen user, then cycle through all alerts
;" TIU DOCUMENTS that have status of unsigned to completed
      ;" regarding documents needing to be signed, and automatically
;"Input: none.  User will be asked for the user to report on, and also
      ;" sign them, then print if user wants.
;" start and end dates
;"Input: none.  User will be asked for signature password,
      ;" and if they want documents printed.
;"Output: Produces a report to choses output channel.
;"Output: Produces a report to choses output channel.


new Options,Y,DIC
new Y,DIC
          
          
write @IOF
write @IOF
        write !,"-- RELEASE UNSIGNED DOCUMENTS -- ",!!
      write !,"-- RELEASE UNSIGNED DOCUMENTS -- ",!!


set DIC=200  ;"NEW PERSON file
set DIC=200  ;"NEW PERSON file
Line 39: Line 39:
. write !,"No author selected.  Aborting report.",!
. write !,"No author selected.  Aborting report.",!
set Options("AUTHOR")=+Y
do FreeDocs(+Y)
 
do FreeAskDates(.Options)
FADone
FADone
quit
quit




FreeAskDates(Options)
FreeDocs(AuthorIEN,ShowDetails)
;"Purpose: to finish the interactive release documents process.
;"Purpose: to finish the interactive release documents process.
;" This separate entry point allows restriction of the author
;" This separate entry point allows restriction of the author
;" whose's documents are to be released.
;" whose's documents are to be released.
;"Input: An array that should contain Options("AUTHOR")=IEN
;"Input: AuthorIEN, the record number of the author in file 200
      ;" ShowDetails: optional.  Default is to show details (1)
      ;" 0=don't show, 1=show


new Signed
new Signed
new abort set abort=0
new abort set abort=0
      new Options
       
      set Options("AUTHOR")=+$get(AuthorIEN)
set Options("SIG")=0
set Options("SIG")=0
      set Options("DETAILS")=$get(ShowDetails,1)
       
do
do
. new DUZ
. new DUZ
. set DUZ=+$get(Options("AUTHOR"))
. set DUZ=+$get(AuthorIEN)
. if DUZ=0 quit
. if DUZ=0 quit
. do SIG^XUSESIG
. do SIG^XUSESIG
Line 64: Line 69:
. write "Signature code incorrect. Aborting.",!
. write "Signature code incorrect. Aborting.",!


        ;"new YN
        ;"read !,"Show Details? NO// ",YN:$get(DTIME,3600)
        ;"set Options("DETAILS")=($$UP^XLFSTR(YN)["Y")
        ;"if YN["^" write "Aborting.",! goto FADDone
       
        set Options("DETAILS")=1
;"do ScanSign(.Options,.Signed)
do AlertSign(.Options,.Signed)
do AlertSign(.Options,.Signed)
do PRINT(.Signed)  
do PRINT(.Signed)  
Line 77: Line 74:
FADDone
FADDone
quit
quit
ScanSign(OPTIONS,SIGNED)
;"Purpose: To scan through all TIU DOCUMENTS, and release those
        ;"   that have a status of unsigned to completed
;"Input: The following elements in OPTIONS should be defined
;" 0PTIONS("AUTHOR")  ;"the IEN of the user (IEN from file 200)
;" OPTIONS("START")  ;"Earliest date of documents, in Fileman internal format
;" OPTIONS("END")    ;"Latest date of documents, in Fileman internal format
        ;" OPTIONS("DETAILS") ;"if 1, then each document is shown as signed (not quiet)
;" OPTIONS("SIG")    ;"1 if signature has been verified.
;" SIGNED: OPTIONAL. This is an OUT PARAMETER -- must be passed by reference
;" This will contain list of documents freed/signed, in this format:
;" SIGNED(1234)=1234  with 1234 being IEN of document signed.
;" SIGNED(1235)=1235  with 1235 being IEN of document signed.
;" SIGNED(1236)=1236  with 1235 being IEN of document signed.
new index
new DocAuth,Status
new User,initials
new NeedsCR set NeedsCR=1
        new StartDT,EndDT
        new ShowDetails set ShowDetails=+$get(OPTIONS("DETAILS"))
       
new %DT
set %DT="AEP"
set %DT("A")="Enter starting date (^ to abort): "
do ^%DT
if Y=-1 do  goto FADDone
. write "Invalid date.  Aborting report.",!
set Options("START")=Y
set %DT("A")="Enter ending date (^ to abort): "
do ^%DT
if Y=-1 do  goto FADDone
. write "Invalid date.  Aborting report.",!
set Options("END")=Y
     
set User=+$get(OPTIONS("AUTHOR"))
if User=0 do  goto RQDone
. if $get(OPTIONS("DETAILS")) write "No author IEN supplied. Aborting.",!
        set StartDT=+$get(OPTIONS("START"))
        set EndDT=+$get(OPTIONS("END"))
if $get(OPTIONS("DETAILS")) do
. write !,"----------------------------------------------",!
. write "Starting scan of documents. [ESC] will abort.",!
. write "----------------------------------------------",!
set initials=$piece($get(^VA(200,User,0)),"^",2)  ;"field 1 = initials
new sUnsigned set sUnsigned=$order(^TIU(8925.6,"B","UNSIGNED",""))
set index=$order(^TIU(8925,0))
for  do  quit:(index="")
. if index="" quit
. new k read *k:0
. if k=27 do  quit
. . set index=""
. . if $get(OPTIONS("DETAILS")) write "Release aborted by ESC from user.",!
. set DocAuth=$piece($get(^TIU(8925,index,12)),"^",2)  ;"field 1202 = Author
. if (DocAuth=$get(OPTIONS("AUTHOR"))) do
. . set Status=$piece($get(^TIU(8925,index,0)),"^",5)  ;"field .05 = Status
. . if (Status=sUnsigned) do
        . . . new tDate
        . . . set tDate=$piece($get(^TIU(8925,index,12)),"^",1)
        . . . set tDate=tDate\1  ;"integer round down (removes time decimal amount)
        . . . if (tDate'<StartDT)&(tDate'>EndDT) do
        . . . . if $$SIGNDOC(index,.OPTIONS) do
. . . . . set SIGNED(index)=index
. set index=+$order(^TIU(8925,index))
        . if index=0 set index=""
if $get(OPTIONS("DETAILS")) write !,"Done signing  documents.",!       
        quit


          
          
AlertSign(OPTIONS,SIGNED)
AlertSign(OPTIONS,SIGNED)
;"Purpose: To cycle through all alerts for AUTHOR, and release TIU DOCUMENTS
;"Purpose: To cycle through all alerts for AUTHOR, and release TIU DOCUMENTS
        ;"   needing signature.
      ;"   needing signature.
;"Input: The following elements in OPTIONS should be defined
;"Input: The following elements in OPTIONS should be defined
;" 0PTIONS("AUTHOR")  ;"the IEN of the user (IEN from file 200)
;" 0PTIONS("AUTHOR")  ;"the IEN of the user (IEN from file 200)
        ;" OPTIONS("DETAILS") ;"if 1, then each document is shown as signed (not quiet)
      ;" OPTIONS("DETAILS") ;"if 1, then each document is shown as signed (not quiet)
;" OPTIONS("SIG")    ;"1 if signature has been verified.
;" OPTIONS("SIG")    ;"1 if signature has been verified.
;" SIGNED: OPTIONAL. This is an OUT PARAMETER -- must be passed by reference
;" SIGNED: OPTIONAL. This is an OUT PARAMETER -- must be passed by reference
Line 168: Line 90:


new index
new index
        new Abort set Abort=0
      new Abort set Abort=0
        new Alert
      new Alert
        new DocIEN
      new DocIEN
        new NumFound set NumFound=0
      new NumFound set NumFound=0


set User=+$get(OPTIONS("AUTHOR"))
set User=+$get(OPTIONS("AUTHOR"))
Line 177: Line 99:
. if $get(OPTIONS("DETAILS")) write "No author IEN supplied. Aborting.",!
. if $get(OPTIONS("DETAILS")) write "No author IEN supplied. Aborting.",!
          
          
        write !!,"-------- List of Documents to be Signed --------",!
      write !!,"-------- List of Documents to be Signed --------",!
set index=$order(^XTV(8992,User,"XQA",0))
set index=$order(^XTV(8992,User,"XQA",0))
for  do  quit:(index="")
for  do  quit:(index="")
Line 191: Line 113:
. set index=$order(^XTV(8992,User,"XQA",index))
. set index=$order(^XTV(8992,User,"XQA",index))
          
          
        write "-----------------------------------------------",!
      write "-----------------------------------------------",!
write !,NumFound," documents needing signature.",!!
      write !,NumFound," documents needing signature.",!!
if NumFound=0 do  goto ASgnDone
      if NumFound=0 do  goto ASgnDone
         . write "Good bye!",!
         . write "Good bye!",!
                  
                  
Line 223: Line 145:
SIGNDOC(DocIEN,OPTIONS)
SIGNDOC(DocIEN,OPTIONS)
;"Purpose: To sign one document
;"Purpose: To sign one document
        ;"Input: DocIEN -- the record number of the document to sign
      ;"Input: DocIEN -- the record number of the document to sign
        ;" OPTIONS -- An array with input values.  The following are used:
      ;" OPTIONS -- An array with input values.  The following are used:
;" 0PTIONS("AUTHOR")  ;"the IEN of the user (IEN from file 200)
;" 0PTIONS("AUTHOR")  ;"the IEN of the user (IEN from file 200)
        ;" OPTIONS("DETAILS") ;"if 1, then each document showed
      ;" OPTIONS("DETAILS") ;"if 1, then each document showed
;" OPTIONS("SIG")    ;"1 if signature has been verified.
;" OPTIONS("SIG")    ;"1 if signature has been verified.
;"Results: 1 = successful sign.  0 = failure
;"Results: 1 = successful sign.  0 = failure
Line 232: Line 154:
new result set result=1 ;"default to failure
new result set result=1 ;"default to failure


        if $get(OPTIONS("SIG"))'=1 goto SDCDone
      if $get(OPTIONS("SIG"))'=1 goto SDCDone
if +$get(OPTIONS("AUTHOR"))'>0 goto SDCDone
if +$get(OPTIONS("AUTHOR"))'>0 goto SDCDone
if $get(DocIEN)="" goto SDCDone
if $get(DocIEN)="" goto SDCDone


new SignerS
new SignerS
        set SignerS=1_"^"_$piece($get(^VA(200,+OPTIONS("AUTHOR"),20)),"^",2,3)
      set SignerS=1_"^"_$piece($get(^VA(200,+OPTIONS("AUTHOR"),20)),"^",2,3)
        do ES^TIURS(DocIEN,SignerS)
      do ES^TIURS(DocIEN,SignerS)
;"Note: alert r.e. "Note available for signature" are automatically removed
;"Note: alert r.e. "Note available for signature" are automatically removed


        if OPTIONS("DETAILS")=1 do
      if OPTIONS("DETAILS")=1 do
. new Date,DateS,Pt
. new Date,DateS,Pt
. set Date=$piece($get(^TIU(8925,DocIEN,12)),"^",1)        ;"field 1201 = Entry Date
. set Date=$piece($get(^TIU(8925,DocIEN,12)),"^",1)        ;"field 1201 = Entry Date
Line 247: Line 169:
. set Pt=+$piece($get(^TIU(8925,DocIEN,0)),"^",2)          ;"field .02 = patient  
. set Pt=+$piece($get(^TIU(8925,DocIEN,0)),"^",2)          ;"field .02 = patient  
. if Pt'=0 set Patient=$piece($get(^DPT(Pt,0)),"^",1)    ;"field .01 = name
. if Pt'=0 set Patient=$piece($get(^DPT(Pt,0)),"^",1)    ;"field .01 = name
        . write DateS," -- ",Patient," Released (auto-'signed')",!
      . write DateS," -- ",Patient," Released (auto-'signed')",!


set result=1  ;"success
set result=1  ;"success
Line 256: Line 178:
PRINT(DocArray) ; Prompt and print, or array
PRINT(DocArray) ; Prompt and print, or array
;"This function was copied from PRINT^TIUEPRNT, to allow modification
;"This function was copied from PRINT^TIUEPRNT, to allow modification
        ;"Function modification: changed to allow array input.
      ;"Function modification: changed to allow array input.
;" DocArray:  This will contain list of documents to print, in this format:
;" DocArray:  This will contain list of documents to print, in this format:
;" DocArray(1234)=1234  with 1234 being IEN of document to be printed.
;" DocArray(1234)=1234  with 1234 being IEN of document to be printed.
Line 262: Line 184:
;" DocArray(1236)=1236  with 1235 being IEN of document to be printed.
;" DocArray(1236)=1236  with 1235 being IEN of document to be printed.


        New TIUDEV,TIUTYP,DFN,TIUPMTHD,TIUD0,TIUMSG,TIUPR,TIUDARR,TIUFLAG,TIUDPRM
      New TIUDEV,TIUTYP,DFN,TIUPMTHD,TIUD0,TIUMSG,TIUPR,TIUDARR,TIUFLAG,TIUDPRM
        New TIUPGRP,TIUPFHDR,TIUPFNBR
      New TIUPGRP,TIUPFHDR,TIUPFNBR


        new index set index=$order(DocArray(""))
      new index set index=$order(DocArray(""))
        if index="" goto PRINT1X
      if index="" goto PRINT1X
        for  do  quit:(index="")
      for  do  quit:(index="")
        . set DocIEN=index
      . set DocIEN=index
        . ;
      . ;
        . If +$$ISADDNDM^TIULC1(DocIEN) Set DocIEN=$Piece($Get(^TIU(8925,+DocIEN,0)),U,6)
      . If +$$ISADDNDM^TIULC1(DocIEN) Set DocIEN=$Piece($Get(^TIU(8925,+DocIEN,0)),U,6)
        . If $Get(^TIU(8925,DocIEN,21)) Set DocIEN=^TIU(8925,DocIEN,21)
      . If $Get(^TIU(8925,DocIEN,21)) Set DocIEN=^TIU(8925,DocIEN,21)
        . Set TIUD0=$Get(^TIU(8925,DocIEN,0))
      . Set TIUD0=$Get(^TIU(8925,DocIEN,0))
        . Set TIUTYP=$Piece(TIUD0,U)
      . Set TIUTYP=$Piece(TIUD0,U)
        . Set DFN=$Piece(TIUD0,U,2)
      . Set DFN=$Piece(TIUD0,U,2)
        . If +TIUTYP'>0 Quit
      . If +TIUTYP'>0 Quit
        . ;
      . ;
        . Set TIUPMTHD=$$PRNTMTHD^TIULG(+TIUTYP)
      . Set TIUPMTHD=$$PRNTMTHD^TIULG(+TIUTYP)
        . Set TIUPGRP=$$PRNTGRP^TIULG(+TIUTYP)
      . Set TIUPGRP=$$PRNTGRP^TIULG(+TIUTYP)
        . Set TIUPFHDR=$$PRNTHDR^TIULG(+TIUTYP)
      . Set TIUPFHDR=$$PRNTHDR^TIULG(+TIUTYP)
        . Set TIUPFNBR=$$PRNTNBR^TIULG(+TIUTYP)
      . Set TIUPFNBR=$$PRNTNBR^TIULG(+TIUTYP)
        . ;
      . ;
        . Do DOCPRM^TIULC1(+TIUTYP,.TIUDPRM,DocIEN)
      . Do DOCPRM^TIULC1(+TIUTYP,.TIUDPRM,DocIEN)
        . ;
      . ;
        . If +$Piece($Get(TIUDPRM(0)),U,9) Set TIUFLAG=$$FLAG^TIUPRPN3
      . If +$Piece($Get(TIUDPRM(0)),U,9) Set TIUFLAG=$$FLAG^TIUPRPN3
        . If ($Get(TIUPMTHD)]"")&(+$Get(TIUPGRP))&($Get(TIUPFHDR)]"")&($Get(TIUPFNBR)]"") do
      . If ($Get(TIUPMTHD)]"")&(+$Get(TIUPGRP))&($Get(TIUPFHDR)]"")&($Get(TIUPFNBR)]"") do
. . Set TIUDARR(TIUPMTHD,$Get(TIUPGRP)_"$"_TIUPFHDR_";"_DFN,1,DocIEN)=TIUPFNBR
. . Set TIUDARR(TIUPMTHD,$Get(TIUPGRP)_"$"_TIUPFHDR_";"_DFN,1,DocIEN)=TIUPFNBR
        . Else  Set TIUDARR(TIUPMTHD,DFN,1,DocIEN)=""
      . Else  Set TIUDARR(TIUPMTHD,DFN,1,DocIEN)=""
. ;
. ;
        . If $Get(TIUPMTHD)']"" do  ;"Goto PRINT1X
      . If $Get(TIUPMTHD)']"" do  ;"Goto PRINT1X
        . . if OPTIONS("DETAILS")=1 do
      . . if OPTIONS("DETAILS")=1 do
. . . Write !,$Char(7),"No Print Method Defined for "
. . . Write !,$Char(7),"No Print Method Defined for "
        . . . write $Piece($Get(^TIU(8925.1,+TIUTYP,0)),U)  
      . . . write $Piece($Get(^TIU(8925.1,+TIUTYP,0)),U)  
. . ;"Hang 2
. . ;"Hang 2
        . ;
      . ;
        . set index=$order(DocArray(index))
      . set index=$order(DocArray(index))


        Set TIUDEV=$$DEVICE^TIUDEV(.IO) ; Get Device/allow queueing
      Set TIUDEV=$$DEVICE^TIUDEV(.IO) ; Get Device/allow queueing
        If ($Get(IO)']"")!(TIUDEV']"") Do ^%ZISC Quit
      If ($Get(IO)']"")!(TIUDEV']"") Do ^%ZISC Quit
        If $Data(IO("Q")) Do QUE^TIUDEV("PRINTQ^TIUEPRNT",TIUDEV) Goto PRINT1X
      If $Data(IO("Q")) Do QUE^TIUDEV("PRINTQ^TIUEPRNT",TIUDEV) Goto PRINT1X
        Do PRINTQ^TIUEPRNT
      Do PRINTQ^TIUEPRNT
        Do ^%ZISC
      Do ^%ZISC


PRINT1X ; Exit single document print
PRINT1X ; Exit single document print
        Quit
      Quit


</pre>
</pre>

Revision as of 13:08, 17 March 2005

This will allow batch signing and printing of documents.

FREECUR
      ;"Purpose: For current user, cycle through all alerts regarding
      ;"	documents needing to be signed, and automatically sign
      ;"	them, then print if user wants.
      ;"Input: none.  User will be asked for signature password,
      ;"	and if they want documents printed.
      ;"Output: Produces a report to chosen output channel.
	
      write @IOF
      write !,"-- RELEASE UNSIGNED DOCUMENTS -- ",!!
      write "Releasing transcription for: ",$piece($get(^VA(200,DUZ,0)),"^",1),!!

	do FreeDocs(DUZ)

	quit


FREEASK
	;"Purpose: Ask for chosen user, then cycle through all alerts 
      ;"	regarding documents needing to be signed, and automatically 
      ;"	sign them, then print if user wants.
	;"Input: none.  User will be asked for signature password,
      ;"	and if they want documents printed.
	;"Output: Produces a report to choses output channel.

	new Y,DIC
        
	write @IOF
      write !,"-- RELEASE UNSIGNED DOCUMENTS -- ",!!

	set DIC=200  ;"NEW PERSON file
	set DIC(0)="MAQE"
	set DIC("A")="Enter name of author (^ to abort): "
	do ^DIC
	if +Y'>0 do  goto RADone
	. write !,"No author selected.  Aborting report.",!
	
	do FreeDocs(+Y)
FADone
	quit


FreeDocs(AuthorIEN,ShowDetails)
	;"Purpose: to finish the interactive release documents process.
	;"	This separate entry point allows restriction of the author
	;"	whose's documents are to be released.
	;"Input: AuthorIEN, the record number of the author in file 200
      ;"	ShowDetails: optional.  Default is to show details (1)
      ;"		0=don't show, 1=show

	new Signed
	new abort set abort=0
      new Options
        
      set Options("AUTHOR")=+$get(AuthorIEN)
	set Options("SIG")=0
      set Options("DETAILS")=$get(ShowDetails,1)
        
	do
	. new DUZ
	. set DUZ=+$get(AuthorIEN)
	. if DUZ=0 quit
	. do SIG^XUSESIG
	. if X1'="" set Options("SIG")=1
	if Options("SIG")'=1 do  goto FADDone
	. write "Signature code incorrect. Aborting.",!

	do AlertSign(.Options,.Signed)
	do PRINT(.Signed) 

FADDone
	quit

        
AlertSign(OPTIONS,SIGNED)
	;"Purpose: To cycle through all alerts for AUTHOR, and release TIU DOCUMENTS
      ;"	  needing signature.
	;"Input: The following elements in OPTIONS should be defined
	;"	0PTIONS("AUTHOR")  ;"the IEN of the user (IEN from file 200)
      ;"	OPTIONS("DETAILS") ;"if 1, then each document is shown as signed (not quiet)
	;"	OPTIONS("SIG")     ;"1 if signature has been verified.
	;"	SIGNED: OPTIONAL. This is an OUT PARAMETER -- must be passed by reference
	;"		This will contain list of documents freed/signed, in this format:
	;"		SIGNED(1234)=1234  with 1234 being IEN of document signed.
	;"		SIGNED(1235)=1235  with 1235 being IEN of document signed.
	;"		SIGNED(1236)=1236  with 1235 being IEN of document signed.

	new index
      new Abort set Abort=0
      new Alert
      new DocIEN
      new NumFound set NumFound=0

	set User=+$get(OPTIONS("AUTHOR"))
	if User=0 do  goto RQDone
	. if $get(OPTIONS("DETAILS")) write "No author IEN supplied. Aborting.",!
        
      write !!,"-------- List of Documents to be Signed --------",!
	set index=$order(^XTV(8992,User,"XQA",0))
	for  do  quit:(index="")
	. if index="" quit
	. new k read *k:0
	. if k=27 do  quit
	. . set index=""
	. . if $get(OPTIONS("DETAILS")) write "List aborted by ESC from user.",!
        . set Alert=$get(^XTV(8992,User,"XQA",index,0))
        . if $piece(Alert,"^",3)["available for SIGNATURE" do
        . . write $piece(Alert,"^",3),!
        . . set NumFound=NumFound+1
	. set index=$order(^XTV(8992,User,"XQA",index))
        
      write "-----------------------------------------------",!
      write !,NumFound," documents needing signature.",!!
      if NumFound=0 do  goto ASgnDone
        . write "Good bye!",!
                
	set index=$order(^XTV(8992,User,"XQA",0))
	for  do  quit:(index="")!(Abort=1)
        . new Title,YN
	. if index="" quit
        . set Alert=$get(^XTV(8992,User,"XQA",index,0))
        . set Title=$piece(Alert,"^",3)
        . if Title["available for SIGNATURE" do
        . . write "Sign: ",$piece(Title," ",1),"? YES// "
        . . read YN:$get(DTIME,3600)
        . . if YN="" set YN="Y" write "YES",!
        . . if YN["^" write "Aborting.",! set Abort=1 quit
        . . if ($$UP^XLFSTR(YN)["Y") do
        . . . set DocIEN=+$get(^XTV(8992,User,"XQA",index,1))
        . . . if DocIEN'=0 do
        . . . . ;"write "Would call SIGNDOC(",DocIEN,",.OPTIONS)",!
        . . . . if $$SIGNDOC(DocIEN,.OPTIONS) do
	. . . . . set SIGNED(DocIEN)=DocIEN
	. set index=$order(^XTV(8992,User,"XQA",index))

	if $get(OPTIONS("DETAILS")) write !!,"Done signing documents.",!        
	
ASgnDone        
        quit

        
SIGNDOC(DocIEN,OPTIONS)
	;"Purpose: To sign one document
      ;"Input: DocIEN -- the record number of the document to sign
      ;"	OPTIONS -- An array with input values.  The following are used:
	;"	0PTIONS("AUTHOR")  ;"the IEN of the user (IEN from file 200)
      ;"	OPTIONS("DETAILS") ;"if 1, then each document showed
	;"	OPTIONS("SIG")     ;"1 if signature has been verified.
	;"Results: 1 = successful sign.  0 = failure

	new result set result=1 ;"default to failure

      if $get(OPTIONS("SIG"))'=1 goto SDCDone
	if +$get(OPTIONS("AUTHOR"))'>0 goto SDCDone
	if $get(DocIEN)="" goto SDCDone

	new SignerS
      set SignerS=1_"^"_$piece($get(^VA(200,+OPTIONS("AUTHOR"),20)),"^",2,3)
      do ES^TIURS(DocIEN,SignerS)
	;"Note: alert r.e. "Note available for signature" are automatically removed

      if OPTIONS("DETAILS")=1 do
	. new Date,DateS,Pt
	. set Date=$piece($get(^TIU(8925,DocIEN,12)),"^",1)        ;"field 1201 = Entry Date
	. set DateS=$$FMTE^XLFDT(Date,"D")
	. set Pt=+$piece($get(^TIU(8925,DocIEN,0)),"^",2)          ;"field .02 = patient 
	. if Pt'=0 set Patient=$piece($get(^DPT(Pt,0)),"^",1)     ;"field .01 = name
      . write DateS," -- ",Patient," Released (auto-'signed')",!

	set result=1  ;"success

SDCDone quit result


PRINT(DocArray) ; Prompt and print, or array
	;"This function was copied from PRINT^TIUEPRNT, to allow modification
      ;"Function modification: changed to allow array input.
	;"	DocArray:  This will contain list of documents to print, in this format:
	;"		DocArray(1234)=1234  with 1234 being IEN of document to be printed.
	;"		DocArray(1235)=1235  with 1235 being IEN of document to be printed.
	;"		DocArray(1236)=1236  with 1235 being IEN of document to be printed.

      New TIUDEV,TIUTYP,DFN,TIUPMTHD,TIUD0,TIUMSG,TIUPR,TIUDARR,TIUFLAG,TIUDPRM
      New TIUPGRP,TIUPFHDR,TIUPFNBR

      new index set index=$order(DocArray(""))
      if index="" goto PRINT1X
      for  do  quit:(index="")
      . set DocIEN=index
      . ;
      . If +$$ISADDNDM^TIULC1(DocIEN) Set DocIEN=$Piece($Get(^TIU(8925,+DocIEN,0)),U,6)
      . If $Get(^TIU(8925,DocIEN,21)) Set DocIEN=^TIU(8925,DocIEN,21)
      . Set TIUD0=$Get(^TIU(8925,DocIEN,0))
      . Set TIUTYP=$Piece(TIUD0,U)
      . Set DFN=$Piece(TIUD0,U,2)
      . If +TIUTYP'>0 Quit
      . ;
      . Set TIUPMTHD=$$PRNTMTHD^TIULG(+TIUTYP)
      . Set TIUPGRP=$$PRNTGRP^TIULG(+TIUTYP)
      . Set TIUPFHDR=$$PRNTHDR^TIULG(+TIUTYP)
      . Set TIUPFNBR=$$PRNTNBR^TIULG(+TIUTYP)
      . ;
      . Do DOCPRM^TIULC1(+TIUTYP,.TIUDPRM,DocIEN)
      . ;
      . If +$Piece($Get(TIUDPRM(0)),U,9) Set TIUFLAG=$$FLAG^TIUPRPN3
      . If ($Get(TIUPMTHD)]"")&(+$Get(TIUPGRP))&($Get(TIUPFHDR)]"")&($Get(TIUPFNBR)]"") do
	. . Set TIUDARR(TIUPMTHD,$Get(TIUPGRP)_"$"_TIUPFHDR_";"_DFN,1,DocIEN)=TIUPFNBR
      . Else  Set TIUDARR(TIUPMTHD,DFN,1,DocIEN)=""
	. ;
      . If $Get(TIUPMTHD)']"" do  ;"Goto PRINT1X
      . . if OPTIONS("DETAILS")=1 do
	. . . Write !,$Char(7),"No Print Method Defined for "
      . . . write $Piece($Get(^TIU(8925.1,+TIUTYP,0)),U) 
	. . ;"Hang 2
      . ;
      . set index=$order(DocArray(index))

      Set TIUDEV=$$DEVICE^TIUDEV(.IO) ; Get Device/allow queueing
      If ($Get(IO)']"")!(TIUDEV']"") Do ^%ZISC Quit
      If $Data(IO("Q")) Do QUE^TIUDEV("PRINTQ^TIUEPRNT",TIUDEV) Goto PRINT1X
      Do PRINTQ^TIUEPRNT
      Do ^%ZISC

PRINT1X ; Exit single document print
      Quit