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

TIUFHA7.m

Go to the documentation of this file.
  1. TIUFHA7 ; SLC/MAM - VALMBG(FILEDA,EFILEDA,EOLDLNO), UPDATE, MOVETL, REEXPAND(FILEDA,LINENO,UPDATE), WHICHDC(FILEDA,PFILEDA,ACTION) ;1/27/06
  1. ;;1.0;TEXT INTEGRATION UTILITIES;**11,27,184**;Jun 20, 1997
  1. ;
  1. WHICHDC(FILEDA,PFILEDA,ACTION) ; Function returns IFN of DC to copy/move Title to, or 0 if none chosen
  1. ;Requires FILEDA = IFN of Title to copy/move
  1. ;Requires PFILEDA = parent of Title
  1. ;Requires ACTION = MT or C
  1. N X,Y,GPFILEDA,DIC,DIR,NEWDCY,CWAD1,CWAD2
  1. S GPFILEDA=+$O(^TIU(8925.1,"AD",PFILEDA,0)) ;orig g'parent of title
  1. AGAINDC S DIC=8925.1,DIC(0)="AEMNQZ"
  1. I ACTION="MT" D
  1. . W !!," Selecting target Document Class. Enter '??' for a list of selectable ones.",!
  1. . W " You may not select PRF Flag Document Classes"
  1. . I TIUFWHO'="N" W " or Document Classes",!," outside the original Class."
  1. . E W "."
  1. . S DIC("A")="Select TIU DOCUMENT CLASS NAME to Move Title to: "
  1. . ; - Selected DC must: be DC, in hierarchy, not=current DC,
  1. . ; not addm, not PRF DC, & unless user is natl,
  1. . ; must be in same class as orig DC:
  1. . ; - Careful! last global ref could change during screen:
  1. . S DIC("S")="I $P(^(0),U,4)=""DC""&($$ORPHAN^TIUFLF4(Y,^(0))=""NO"")"
  1. . S DIC("S")=DIC("S")_"&(Y'=PFILEDA)&(Y'=512)&'$$ISPFDC^TIUPRFL(Y)"
  1. . I TIUFWHO'="N" S DIC("S")=DIC("S")_"&(GPFILEDA=+$O(^TIU(8925.1,""AD"",Y,0)))"
  1. I ACTION="C" S DIC("A")="Select TIU DOCUMENT CLASS NAME to Add Copy to: ",DIC("S")="I $P(^(0),U,4)=""DC""&($$ORPHAN^TIUFLF4(Y,^(0))=""NO"")&(Y'=512)"
  1. D ^DIC I Y=-1 G WDCX
  1. S NEWDCY=Y,NEWDCY(0)=Y(0)
  1. N TIUFCK D CHECK^TIUFLF3(+NEWDCY,+$O(^TIU(8925.1,"AD",+NEWDCY,0)),0,.TIUFCK)
  1. I 'TIUFCK D I '$$OVERRIDE^TIUFHA2("select entry even though it is FAULTY") W $S(ACTION="MT":" Title NOT moved.",1:" Copy NOT added.") D PAUSE^TIUFXHLX K NEWDCY G WDCX
  1. . W !!,"Faulty Document Class. Please TRY it and correct problems before ",$S(ACTION="MT":"Moving Title",1:"Adding Copy"),!,"to it. "
  1. I PFILEDA S CWAD1=$P(NEWDCY(0),U,14),CWAD2=$P(^TIU(8925.1,PFILEDA,0),U,14) I (CWAD1="")&(CWAD2'="")!((CWAD1'="")&(CWAD2="")) D G AGAINDC:Y=0,WDCX:'Y
  1. . S DIR(0)="Y",DIR("B")="NO"
  1. . S DIR("A",1)="CWAD's behave differently from nonCWAD documents.",DIR("A")="Are you sure you want this Document Class" D ^DIR
  1. . I 'Y K NEWDCY
  1. WDCX I $D(DTOUT) S VALMQUIT=1
  1. Q $S($G(NEWDCY):NEWDCY,1:0)
  1. ;
  1. VALMBG(FILEDA,EFILEDA,EOLDLNO) ; Set VALMBG to show FILEDA if FILEDA is in LM Array.
  1. ; requires FILEDA.
  1. ; Requires EFILEDA = DA of LM entry of interest, EOLDLNO = old lineno of EFILEDA. EFILEDA and/or EOLDLNO may be 0.
  1. ; Entry of interest is entry to be copied, or Parent of Title to me moved, or Title whose documents are being moved.
  1. N LINENO,ENEWLNO
  1. S LINENO=+$O(^TMP("TIUF1IDX",$J,"DAF",FILEDA,0)),ENEWLNO=+$O(^TMP("TIUF1IDX",$J,"DAF",EFILEDA,0))
  1. I 'LINENO,"AJ"[TIUFTMPL W !,"... Not in Current View" H 2
  1. I 'LINENO Q
  1. ; If FILEDA shows on the screen, and entry of interest is still in same place on screen then don't change screen position:
  1. I LINENO'<VALMBG,LINENO'>(VALMBG+VALM("LINES")-1),EOLDLNO=ENEWLNO Q
  1. S VALMBG=LINENO
  1. Q
  1. ;
  1. UPDATE ; Update Parent Document Type for documents of a certain title
  1. ; ALSO updates CLASS xrefs if valid OLDCLASS can be gotten from ^XTMP("TIUFMOVEN",FILEDA)=OLDCLASS
  1. N FILEDA,NODE0,INFO,DIR,OLDCLASS
  1. ; N DIR for EN^VALM2 default
  1. I '$D(TIUFMOVE) S TIUFMOVE="" ;Set to N in opt ZZTIUFH EDIT DDEFS NATL
  1. S VALM("ENTITY")="Title whose documents you want to Update"
  1. AGAINUP D EN^VALM2(TIUFXNOD,"SO") G:'$O(VALMY(0)) UPDAX S INFO=$G(^TMP("TIUF1IDX",$J,$O(VALMY(0)))) I 'INFO W !!," Missing List Manager Data; See IRM",! D PAUSE^TIUFXHLX S VALMBCK="Q" G UPDAX
  1. S FILEDA=$P(INFO,U,2),NODE0=^TIU(8925.1,FILEDA,0)
  1. ; Need TIUFXNOD phrase to prevent loop:
  1. N DIRUT I $P(NODE0,U,4)'="DOC" W !," ?? Entry must be a TITLE (not a Document Class, etc.).",! D PAUSE^TIUFXHLX G UPDAX:$D(DIRUT)!(TIUFXNOD["="),AGAINUP
  1. I '$O(^TIU(8925,"B",FILEDA,0)) W !," ?? Title has no documents to Update",! D PAUSE^TIUFXHLX G UPDAX:$D(DIRUT)!(TIUFXNOD["="),AGAINUP
  1. I TIUFMOVE="N" S OLDCLASS=$G(^XTMP("TIUFMOVEN"_FILEDA))
  1. S OLDCLASS=+$G(OLDCLASS) ;may be 0
  1. S ^XTMP("TIUFMOVE"_TIUFMOVE_FILEDA,0)=+$$FMADD^XLFDT(DT,30)_U_DT
  1. D MTRPOINT^TIUFHA8(FILEDA,OLDCLASS)
  1. UPDAX K:TIUFMOVE="" TIUFMOVE S VALM("ENTITY")="Entry" Q
  1. ;
  1. MOVETL ; Move Title to different DC. Template H ONLY. National titles cannot be moved. Unless special arrangements are made w/ TIU developers, new DC must be in same CLASS as original DC.
  1. N INFO,FILEDA,NODE0,LINENO,PFILEDA,TENDA,NEWDCY,NDCLNO,PLINENO
  1. N GPFILEDA,OLDCLASS,DIR ; DIR for EN^VALM2 default
  1. N EXPAND,DA,DIK,TIUFI,LACKTECH,OVERRIDE
  1. S VALM("ENTITY")="Title to Move"
  1. S TIUFMOVE=$G(TIUFMOVE) ; Set to N in opt ZZTIUFH EDIT DDEFS NATL
  1. AGAINTL D EN^VALM2(TIUFXNOD,"SO") G:'$O(VALMY(0)) MTLX S INFO=$G(^TMP("TIUF1IDX",$J,$O(VALMY(0)))) I 'INFO W !!," Missing List Manager Data; See IRM",! D PAUSE^TIUFXHLX S VALMBCK="Q" G MTLX
  1. S FILEDA=$P(INFO,U,2),NODE0=^TIU(8925.1,FILEDA,0),LINENO=+INFO
  1. ; Need TIUFXNOD phrase to prevent loop:
  1. N DIRUT I $P(NODE0,U,4)'="DOC" W !," ?? Entry must be a TITLE (not a Document Class, etc.).",! D PAUSE^TIUFXHLX G MTLX:$D(DIRUT)!(TIUFXNOD["="),AGAINTL
  1. I $P(NODE0,U,13) W !," ?? Can't Move National Titles",! D PAUSE^TIUFXHLX G MTLX:$D(DIRUT)!(TIUFXNOD["="),AGAINTL
  1. I $$ISPFTTL^TIUPRFL(FILEDA) W !," ?? Can't Move PRF Flag Titles",! D PAUSE^TIUFXHLX G MTLX:$D(DIRUT)!(TIUFXNOD["="),AGAINTL
  1. S PFILEDA=+$O(^TIU(8925.1,"AD",FILEDA,0))
  1. S TENDA=$P(INFO,U,6),PLINENO=$P(INFO,U,5)
  1. ; -----Check Title under PRESENT parent:
  1. N TIUFCK D CHECK^TIUFLF3(FILEDA,PFILEDA,1,.TIUFCK) G:$D(DTOUT) MTLX
  1. K TIUFCK("E"),TIUFCK("R"),TIUFCK("V"),TIUFCK("D"),TIUFCK("H"),TIUFCK("N"),TIUFCK("G")
  1. I $D(TIUFCK)>9 D G:'OVERRIDE MTLX
  1. . W !!,"Faulty Title. Please TRY it and correct problems before moving it.",!
  1. . S OVERRIDE=$$OVERRIDE^TIUFHA2("select title even though it is FAULTY")
  1. . I 'OVERRIDE W " NOT Moved",! D PAUSE^TIUFXHLX
  1. S VALMBCK="R" K DIRUT
  1. L +^TIU(8925.1,FILEDA):1 I '$T W !!,"Another user is editing this Title.",! H 4 G MTLX
  1. S NEWDCY=$$WHICHDC(FILEDA,PFILEDA,"MT")
  1. I 'NEWDCY G MTLX ;NEWDCY=New Document Class Y
  1. S GPFILEDA=+$O(^TIU(8925.1,"AD",PFILEDA,0))
  1. I GPFILEDA'=+$O(^TIU(8925.1,"AD",+NEWDCY,0)) S OLDCLASS=GPFILEDA
  1. S OLDCLASS=+$G(OLDCLASS)
  1. ; -----Check Title under PROPOSED parent:
  1. N TIUFCK D CHECK^TIUFLF3(FILEDA,NEWDCY,1,.TIUFCK) G:$D(DTOUT) MTLX
  1. ; -----If Title faulty under proposed parent, don't move:
  1. S LACKTECH=0
  1. F TIUFI="E^Edit Template","R^Print Method","V^Visit Linkage Method","D^Validation Method","H^Print Form Header","N^Print Form Number","G^Print Group" S:$D(TIUFCK($E(TIUFI))) LACKTECH=1
  1. I LACKTECH D
  1. . W !!,"Documents would not function properly under this move",!,"since Title lacks Technical Fields. Please edit Title's:",!
  1. . F TIUFI="E^Edit Template","R^Print Method","V^Visit Linkage Method","D^Validation Method","H^Print Form Header","N^Print Form Number","G^Print Group" W:$D(TIUFCK($E(TIUFI))) ?16,$P(TIUFI,U,2),!
  1. . W !,"Use values Title inherits from its ancestors. (To see inherited values, select",!,"Detailed Display for the CURRENT PARENT."
  1. . I $D(TIUFCK("H"))!$D(TIUFCK("N"))!$D(TIUFCK("G")) W " In some cases you may have to look",!,"higher up the hierarchy than current parent."
  1. . W ") Then come back and try again",!,"to move the Title.",!
  1. I LACKTECH,'$$OVERRIDE^TIUFHA2("ignore missing fields") W " Title NOT moved",! D PAUSE^TIUFXHLX G MTLX
  1. ; -----Delete Title from old parent, Add to new parent:
  1. I $P(NODE0,U,7)'=+^TMP("TIUF",$J,"STATI") D AUTOSTAT^TIUFLF6(FILEDA,NODE0,"INACTIVE")
  1. S DA=TENDA,DA(1)=PFILEDA,DIK="^TIU(8925.1,DA(1),10," D ^DIK
  1. D REEXPAND(PFILEDA,PLINENO,1)
  1. D ADDTEN^TIUFLF4(+NEWDCY,FILEDA,NODE0,"")
  1. S NDCLNO=+$O(^TMP("TIUF1IDX",$J,"DAF",+NEWDCY,0))
  1. I NDCLNO D REEXPAND(+NEWDCY,NDCLNO,1),VALMBG(FILEDA,PFILEDA,PLINENO)
  1. W !,"...Title Inactivated, Moved to ",$P(NEWDCY,U,2),"."
  1. K ^XTMP("TIUFMOVE"_TIUFMOVE_FILEDA) ; Cleanup before resetting
  1. S ^XTMP("TIUFMOVE"_TIUFMOVE_FILEDA,0)=+$$FMADD^XLFDT(DT,30)_U_DT
  1. D MTRPOINT^TIUFHA8(FILEDA,OLDCLASS)
  1. D D:'$D(DIRUT) PAUSE^TIUFXHLX
  1. . W !!,"Since the Title is in a new Document Class, it now inherits from a new parent",!,"wherever it lacks its own values, and its behavior may differ from before. It",!
  1. . W "may also differ from its new siblings wherever it HAS its own values and",!,"siblings INHERIT them.",!
  1. . W !,"Please check Title thoroughly before reactivating. Check Business Rules,",!,"TIU Document Parameters, and Document Definition attributes including Basic,",!,"Technical, and Upload fields.",!
  1. . I TIUFWHO="N" D
  1. . . W !,"Note that the IN USE display is not updated for CLASSES if old and new Document",!
  1. . . W "Classes were in different Classes. This is intentional, to speed up the move",!
  1. . . W "process. Display can be updated at any time by collapsing and reexpanding",!
  1. . . W "the hierarchy.",!
  1. MTLX I $D(DTOUT) S VALMBCK="Q"
  1. L -^TIU(8925.1,+$G(FILEDA)) S VALM("ENTITY")="Entry" K:TIUFMOVE="" TIUFMOVE
  1. Q
  1. ;
  1. REEXPAND(FILEDA,LINENO,UPDATE) ; Collapse, reexpand FILEDA; FILEDA is LINENO in LM array. Sets VALMCNT. Updates LINENO if UPDATE.
  1. ; Requires FILEDA, LINENO.
  1. ;DON'T CALL THIS except from template H or C since it resets VALMCNT.
  1. N INFO,EXPAND
  1. S INFO=^TMP("TIUF1IDX",$J,LINENO),EXPAND=$P(INFO,U,3) D PARSE^TIUFLLM(.INFO),COLLAPSE^TIUFH1(.INFO) S VALMCNT=VALMCNT-EXPAND D EXPAND1^TIUFH1(.INFO) S VALMCNT=VALMCNT+$P(INFO,U,3)
  1. I $G(UPDATE) D LINEUP^TIUFLLM1(.INFO,"H")
  1. Q
  1. ;