Home   Package List   Routine Alphabetical List   Global Alphabetical List   FileMan Files List   FileMan Sub-Files List   Package Component Lists   Package-Namespace Mapping  
Routine: TIUSRVT4

TIUSRVT4.m

Go to the documentation of this file.
  1. TIUSRVT4 ; SLC/PKS Remove all terminated user Templates. ; [3/15/01 12:15pm]
  1. ;;1.0;TEXT INTEGRATION UTILITIES;**110**;Jun 20, 1997
  1. ;
  1. ; Variables used herein:
  1. ;
  1. ; TIUANS = Result of call to $$VERIF.
  1. ; TIUARY = Array holder.
  1. ; TIUCNT = Counter Variable.
  1. ; TIUERR = Error array for call return.
  1. ; TIUIDX = X-ref holder.
  1. ; TIUIEN = Template IEN holder.
  1. ; TIUNOW = Current date.
  1. ; TIUNUM = Loop counter.
  1. ; TIUSR = Terminated user (DUZ).
  1. ; TIUSTAT = Status of user.
  1. ; TIUTMP = Call return array value holder.
  1. ; TIUTPLT = Template IEN.
  1. ;
  1. Q
  1. ;
  1. CTRL ; Main control section.
  1. ;
  1. N TIUANS,TIUCNT,TIUERR,TIUIDX,TIUNOW,TIUSR,TIUSTAT,TIUTPLT
  1. ;
  1. S TIUANS=$$VERIF ; Confirm before deleting.
  1. I 'TIUANS Q ; User failed to confirm - quit.
  1. ;
  1. D EACH ; Call to process template cleanup.
  1. ;
  1. Q
  1. ;
  1. EACH ; Process template deletion for each user found who has any.
  1. ;
  1. ; Get current date information:
  1. D NOW^%DTC
  1. S TIUNOW=X
  1. K X
  1. ;
  1. ; Retrieve each user in ^TIU(8927 file:
  1. S TIUSR=0
  1. F D Q:'TIUSR
  1. .S TIUSR=$O(^TIU(8927,"AROOT",TIUSR))
  1. .I 'TIUSR Q
  1. .;
  1. .; Check user's status - look for terminated users:
  1. .I '$D(^VA(200,TIUSR,0)) Q ; No user record.
  1. .I '$L($P($G(^VA(200,TIUSR,0)),"^",1)) Q ; Invalid user data.
  1. .S TIUSTAT=$$GET1^DIQ(200,TIUSR,9.2,"I",,.TIUERR) ; Termination date?
  1. .I 'TIUSTAT Q ; Active user.
  1. .I TIUSTAT>TIUNOW Q ; User terminated on a future date.
  1. .;
  1. .; User terminated, effective today or earlier, so proceed:
  1. .; Find AROOT x-ref record, if any:
  1. .S TIUTPLT=0
  1. .F D Q:'TIUTPLT
  1. ..S TIUTPLT=$O(^TIU(8927,"AROOT",TIUSR,TIUTPLT))
  1. ..I 'TIUTPLT Q
  1. ..;
  1. ..; Get any existing templates, delete them:
  1. ..D DEL(TIUTPLT)
  1. ;
  1. Q
  1. ;
  1. DEL(TIUIEN) ; Pass root node of AROOT x-ref.
  1. ;
  1. N TIUARY,TIUNUM,TIUTMP
  1. ;
  1. D BLD(TIUIEN,.TIUARY) ; Recursive call.
  1. ;
  1. D DELETE^TIUSRVT(.TIUTMP,.TIUARY) ; Kill record(s).
  1. ;
  1. Q
  1. ;
  1. BLD(TIUIEN,TIUARY) ; Build array of templates for user.
  1. ;
  1. N TIUIDX
  1. ;
  1. S TIUIDX=$O(TIUARY(" "),-1)+1
  1. S TIUARY(TIUIDX)=TIUIEN
  1. S TIUIDX=0
  1. F S TIUIDX=$O(^TIU(8927,TIUIEN,10,TIUIDX)) Q:'TIUIDX D
  1. .D BLD($P(^TIU(8927,TIUIEN,10,TIUIDX,0),U,2),.TIUARY)
  1. ;
  1. Q
  1. ;
  1. PARSET ; Edit parameter for auto-cleanup of templates upon termination.
  1. ;
  1. D EDITPAR^XPAREDIT("TIU TEMPLATE USER AUTO DELETE")
  1. ;
  1. Q
  1. ;
  1. VERIF() ; Verify that user really wants to execute this option:
  1. ;
  1. N DIR,X,Y ; DIR variables.
  1. S DIR("T")=120 ; Two minute maximum timeout for response.
  1. S DIR("A")=" Delete all non-shared templates for all terminated users (Y/N)"
  1. S DIR("?")=" Templates for terminated users will be permanently lost..."
  1. S DIR("B")="NO" ; Default.
  1. ;
  1. ; Define DIR input requirements:
  1. S DIR(0)="YO^1:2:0"
  1. ;
  1. ; Call DIR for user choice:
  1. W !! ; Spacing for screen display.
  1. D ^DIR
  1. ;
  1. ; Check user response:
  1. I '$L($G(Y)) Q 0 ; Skip if Y isn't assigned.
  1. I Y="" Q 0 ; Skip if Y is null.
  1. I Y="^" Q 0 ; Skip if Y is "^" character.
  1. I Y<1 Q 0 ; Skip if Y is less than one.
  1. I Y>2 Q 0 ; "No" choice.
  1. I Y=1 Q 1 ; "Yes" choice.
  1. ;
  1. Q 0 ; Default return of "No."
  1. ;