source: FOIAVistA/tag/r/TEXT_INTEGRATION_UTILITIES-GMRP-TIU/TIUFHA8.m@ 636

Last change on this file since 636 was 628, checked in by George Lilly, 14 years ago

initial load of FOIAVistA 6/30/08 version

File size: 8.0 KB
Line 
1TIUFHA8 ; SLC/MAM - MOVEDOC, MDRPOINT(OLDTLDA,NEWTLDA,POLDTLDA,PNEWTLDA,NOLOCK), NEWTITLE(FILEDA,PFILEDA), MTRPOINT(TITLEDA,OLDCLASS) ;1/29/06
2 ;;1.0;TEXT INTEGRATION UTILITIES;**11,27,64,184**;Jun 20, 1997
3 ;
4CANT(FILEDA,NODE0) ; Check if docmts can be moved; return 1 if cant
5 N CANTMSG,CANT S CANT=0
6 I $P(NODE0,U,4)'="DOC" S CANTMSG=" ?? Entry must be a TITLE (not a Document Class, etc.)" G:$D(CANTMSG) CANTX
7 I $$HASITEMS^TIUFLF1(FILEDA) S CANTMSG=" ?? Documents cannot be moved for Titles with Components" G:$D(CANTMSG) CANTX
8 I '$O(^TIU(8925,"B",FILEDA,0)) S CANTMSG=" ?? Title has no documents to move" G:$D(CANTMSG) CANTX
9 I FILEDA=81 S CANTMSG=" ?? Can't Move Addenda" G:$D(CANTMSG) CANTX
10 I $$ISPFTTL^TIUPRFL(FILEDA) S CANTMSG=" ?? Documents cannot be moved for PRF Flag Titles" G:$D(CANTMSG) CANTX
11CANTX I $D(CANTMSG) W !,CANTMSG,! D PAUSE^TIUFXHLX S CANT=1
12 Q CANT
13 ;
14MOVEDOC ; Move documents from old Title to new Title. Template H ONLY. Titles must have same grandparent. Titles cannot have components.
15 N INFO,FILEDA,NODE0,PFILEDA,TENDA,NEWTLY,LINENO,PLINENO
16 N DA,DIK,NPLINENO,DIR,NPFILEDA,NOLOCK,CWAD1,CWAD2
17 ; N DIR for EN^VALM2 default
18 S VALM("ENTITY")="Title whose documents you want to Move"
19AGAINDOC D EN^VALM2(TIUFXNOD,"SO") G:'$O(VALMY(0)) MDOCX 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 MDOCX
20 S FILEDA=$P(INFO,U,2),NODE0=^TIU(8925.1,FILEDA,0),LINENO=+INFO
21 N DIRUT
22 ; - Check selected title. Need TIUFXNOD phrase to prevent loop:
23 I $$CANT(FILEDA,NODE0) G MDOCX:$D(DIRUT)!(TIUFXNOD["="),AGAINDOC
24 S PFILEDA=+$O(^TIU(8925.1,"AD",FILEDA,0)),PLINENO=$P(INFO,U,5)
25 S TENDA=$P(INFO,U,6)
26 S VALMBCK="R" K DIRUT
27 S NEWTLY=$$NEWTITLE(FILEDA,PFILEDA)
28 I 'NEWTLY G MDOCX
29 D I 'NEWTLY G MDOCX ;P64 add Are you sure; add CWAD/nonCWAD warning
30 . S DIR(0)="Y",DIR("B")="YES",DIR("?")=" Action not reversible if target title already has its own documents."
31 . S DIR("A",1)="Moving documents from title",DIR("A",2)=" "_$P(NODE0,U),DIR("A",3)=" to title "_$P(NEWTLY,U,2)_"."
32 . S DIR("A")=" Are you sure"
33 . S NPFILEDA=+$O(^TIU(8925.1,"AD",+NEWTLY,0)),CWAD1=$P($G(^TIU(8925.1,NPFILEDA,0)),U,14),CWAD2=$P($G(^TIU(8925.1,PFILEDA,0)),U,14)
34 . I (CWAD1="")&(CWAD2'="")!((CWAD1'="")&(CWAD2="")) S DIR("A")="CWADs behave differently from nonCWAD documents. Sure you want to move",DIR("B")="NO",DIR("?")=" CWADs generate alerts; nonCWADs don't."
35 . W ! D ^DIR I 'Y S NEWTLY=0
36 I $P(NODE0,U,7)'=+^TMP("TIUF",$J,"STATI") D AUTOSTAT^TIUFLF6(FILEDA,NODE0,"INACTIVE")
37 S NOLOCK=0 D MDRPOINT(FILEDA,+NEWTLY,PFILEDA,NPFILEDA,.NOLOCK)
38 W ! W:NOLOCK "...done. Please move remaining documents later."
39 W:'NOLOCK "...done. All documents Moved to Title ",$P(NEWTLY,U,2),".",!,"Parent Document Type updated as necessary for all documents."
40 W !!,"If you want users to be able to enter more documents on the OLD TITLE,",!,"please reactivate it."
41 D PAUSE^TIUFXHLX
42 S NPLINENO=+$O(^TMP("TIUF1IDX",$J,"DAF",NPFILEDA,0))
43 I NPFILEDA'=PFILEDA D REEXPAND^TIUFHA7(PFILEDA,PLINENO,1)
44 D REEXPAND^TIUFHA7(NPFILEDA,NPLINENO,1),VALMBG^TIUFHA7(+NEWTLY,FILEDA,LINENO)
45MDOCX I '$G(NEWTLY) W !,"...Nothing moved" H 2 ;P64 add Nothing moved
46 S VALM("ENTITY")="Entry"
47 Q
48 ;
49MDRPOINT(OLDTLDA,NEWTLDA,POLDTLDA,PNEWTLDA,NOLOCK) ; Repoint for Move Documents from one title to another: Repoints TITLE and PARENT DOCUMENT TYPE for documents that use old title.
50 ; If old and new titles are in same DC, skips repointing PARENT DOCUMENT TYPE.
51 N DIE,DR,DA,FILEDA
52 W !!,"OLD Title inactivated. Moving documents..."
53 S DR=".01////"_NEWTLDA,DIE=8925
54 S:POLDTLDA'=PNEWTLDA DR=DR_";.04////"_PNEWTLDA
55 S FILEDA=0 F S FILEDA=$O(^TIU(8925,"B",OLDTLDA,FILEDA)) Q:'FILEDA D
56 . L +^TIU(8925,FILEDA,0):1 I '$T W !,"...Document can't be locked. Please move it later. Continuing to move others...",! H 2 S NOLOCK=1 Q
57 . S DA=FILEDA D ^DIE
58 . W "." L -^TIU(8925,FILEDA,0)
59 Q
60 ;
61NEWTITLE(FILEDA,PFILEDA) ; Function returns DIC's Y=N^S of New Title to move documents to, or 0 if none chosen.
62 ;Requires FILEDA = IFN of old Title
63 ;Requires PFILEDA = parent of old Title
64 N X,Y,DIC,DIR,NEWTLY,TIUFCK,NPFILEDA,GPFILEDA,OVERRIDE
65 N SCRN1,SCRN2,SCRN3
66 S GPFILEDA=+$O(^TIU(8925.1,"AD",PFILEDA,0)) ; G'parent of old Title
67AGAINNEW S DIC=8925.1,DIC(0)="AEMNQZ" K NEWTLY
68 W !!," Selecting target Title."
69 W " Enter '??' for a list of selectable ones.",!
70 W " You may not select PRF Flag Titles or Titles outside"
71 W " the original Class."
72 S DIC("A")="Select TIU TITLE NAME to Move documents to: "
73 ; - Type=TL, not=old title, not addm title, not PRF title,
74 ; same g'parent (i.e. class):
75 S SCRN1="I $P(^(0),U,4)=""DOC""&(Y'=FILEDA)&(Y'=81)"
76 S SCRN2="&'$$ISPFTTL^TIUPRFL(Y)&(GPFILEDA="
77 S SCRN3="+$O(^TIU(8925.1,""AD"",+$O(^TIU(8925.1,""AD"",Y,0)),0)))"
78 S DIC("S")=SCRN1_SCRN2_SCRN3
79 D ^DIC I Y=-1 G NEWTLX
80 S NEWTLY=Y,NEWTLY(0)=Y(0),NPFILEDA=+$O(^TIU(8925.1,"AD",+NEWTLY,0))
81 ;P64 removed "can't move docmts to natl titles"
82 I $$HASITEMS^TIUFLF1(+NEWTLY) W !," ?? Documents cannot be moved to Titles with Components",! G AGAINNEW
83 D CHECK^TIUFLF3(+NEWTLY,NPFILEDA,0,.TIUFCK)
84 I 'TIUFCK D
85 . W !!,"Faulty Title. Please TRY Title and correct problems",!,"before moving documents to it."
86 . S OVERRIDE=$$OVERRIDE^TIUFHA2("select title even though it is FAULTY")
87 . I 'OVERRIDE W " Documents NOT Moved.",! D PAUSE^TIUFXHLX K NEWTLY
88NEWTLX I $D(DTOUT) S VALMQUIT=1
89 Q $S($G(NEWTLY):NEWTLY,1:0)
90 ;
91MTRPOINT(TITLEDA,OLDCLASS) ; Repoint for Move Title from one DC to another:
92 ; Repoints PARENT DOCUMENT TYPE to parent of TITLEDA for documents using
93 ;title TITLEDA.
94 ; If by special arrangement with TIU developers, Title is moved from one
95 ;CLASS to another, ALSO resets class xrefs for documents using TITLEDA.
96 ;Requires OLDCLASS = IFN of class title was moved FROM. Gets OLDCLASS
97 ;from MOVETL, or from UPDATE using ^XTMP("TIUFMOVEN",TITLEDA) = OLDCLASS
98 ; Requires TIUFMOVE,^XTMP("TIUFMOVE"[_N]_TLDA,0)
99 N DIE,DR,DA,FILEDA,NOLOCK,XDCDA
100 I '$O(^TIU(8925,"B",TITLEDA,0)) W !!,"Title has no documents to update.",! Q
101 S NOLOCK=0,XDCDA=+$O(^TIU(8925.1,"AD",TITLEDA,0)) I 'XDCDA W !!,"Title has no parent.",! Q
102 W !!,"Processing documents that use this Title...",!
103 S FILEDA=0 F S FILEDA=$O(^TIU(8925,"B",TITLEDA,FILEDA)) Q:'FILEDA D MTRPT1(TITLEDA,FILEDA,XDCDA,+$G(OLDCLASS),.NOLOCK)
104 W !,"Done."
105 I NOLOCK D D PAUSE^TIUFXHLX Q
106 . W !!," Since some documents needing update were (still) not available, please update",!,"them using action 'Update Documents' (again) for this title.",!
107 . S ^XTMP("TIUFMOVE"_TIUFMOVE_TITLEDA,"ONCETHRU")=""
108 W " All documents updated for selected Title.",!
109 K ^XTMP("TIUFMOVE"_TIUFMOVE_TITLEDA) D PAUSE^TIUFXHLX
110 Q
111 ;
112MTRPT1(TITLEDA,DA,XDCDA,OLDCLASS,NOLOCK) ; Repoint 1 docmt for Move TL.
113 ; Requires TITLEDA,DA,XDCDA,TIUFMOVE. Requires OLDCLASS>or=0.
114 ; Kills DA node of ^XTMP("TIUFMOVE[N]"_TLDA if successfully updated.
115 I $D(^XTMP("TIUFMOVE"_TIUFMOVE_TITLEDA,"ONCETHRU")),'$D(^XTMP("TIUFMOVE"_TIUFMOVE_TITLEDA,DA)) Q ;DA already updated
116 I TIUFMOVE'="N",XDCDA=$P(^TIU(8925,DA,0),U,4) Q ; move NOT between CLASSES, Parent Docmt Type already ok.
117 L +^TIU(8925,DA,0):1 I '$T W !,"...Document ",DA," can't be locked, not updated.",! S NOLOCK=1 S ^XTMP("TIUFMOVE"_TIUFMOVE_TITLEDA,DA)="" Q
118 S DR=".04////"_XDCDA,DIE=8925 D ^DIE
119 I OLDCLASS D CLXREF^TIUFHA9(DA,OLDCLASS)
120 L -^TIU(8925,DA,0)
121 I $G(ACTION)="U" W !,"Document ",DA," updated"
122 E W "."
123 K ^XTMP("TIUFMOVE"_TIUFMOVE_TITLEDA,DA)
124 Q
125 ;
126DCDOCMTS(XDCLASS,OLDCLASS) ; Updates CLASS xrefs for documents using DC XDCLASS
127 N TENDA,TITLEDA
128 S TENDA=0
129 F S TENDA=$O(^TIU(8925.1,XDCLASS,10,TENDA)) Q:'TENDA D
130 . S TITLEDA=+^TIU(8925.1,XDCLASS,10,TENDA,0) Q:'TITLEDA
131 . D TLDOCMTS(TITLEDA,OLDCLASS)
132 Q
133 ;
134TLDOCMTS(TITLEDA,OLDCLASS) ; Updates CLASS xrefs for documents using title TITLEDA.
135 N DIE,DR,DA,FILEDA,NOLOCK,XDCDA
136 I '$O(^TIU(8925,"B",TITLEDA,0)) Q
137 ;I '$O(^TIU(8925,"B",TITLEDA,0)) W !!,"Title has no documents to update.",! Q
138 ;W !!,"Updating CLASS cross-references for documents that use this Title...",!
139 S FILEDA=0 F S FILEDA=$O(^TIU(8925,"B",TITLEDA,FILEDA)) Q:'FILEDA D CLXREF^TIUFHA9(FILEDA,OLDCLASS)
140 ;W !,"Done."
141 W "."
142 Q
143 ;
Note: See TracBrowser for help on using the repository browser.