source: FOIAVistA/trunk/r/CLINICAL_REMINDERS-PXRM/PXRMCOPY.m@ 1354

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

initial load of FOIAVistA 6/30/08 version

File size: 4.9 KB
Line 
1PXRMCOPY ; SLC/PKR,PJH - Copy various reminder files. ;09/13/2007
2 ;;2.0;CLINICAL REMINDERS;**6**;Feb 04, 2005;Build 123
3 ;
4 ;=====================================================
5COPY(PROMPT,ROOT,WHAT) ;Copy an entry of ROOT into a new entry.
6 N DIROUT,DTOUT,DUOUT
7 F D GETORGR Q:$D(DIROUT) Q:$D(DTOUT)
8 Q
9 ;
10 ;=====================================================
11GETORGR ;Look-up logic to get and copy source entry to destination.
12 N DA,DIE,DIC,DIK,DIR,DIRUT,FDA,FIELDLEN,FILE
13 N IENN,IENO,IENS,MSG,NAME,ORGNAME,X,Y
14 S DIC=ROOT,DIC(0)="AEMQ",DIC("A")=PROMPT
15 W !
16 D ^DIC
17 I $D(DUOUT)!$D(DTOUT) S DIROUT="" Q
18 S IENO=$P(Y,U,1)
19 I IENO=-1 S DIROUT="" Q
20 ;
21 ;Set the starting place for additions.
22 D SETSTART^PXRMCOPY(DIC)
23 S IENN=$$GETFOIEN(ROOT)
24 D MERGE(IENN,IENO,ROOT)
25 ;
26 ;Get the new name.
27 S ORGNAME=$P(@(ROOT_IENO_",0)"),U,1)
28 S FILE=$$FNFR^PXRMUTIL(ROOT)
29 S FIELDLEN=$$GET1^DID(FILE,.01,"","FIELD LENGTH")
30 S DIR(0)="F"_U_"3:"_FIELDLEN_U_"K:(X?.N)!'(X'?1P.E) X"
31 S DIR("A")="PLEASE ENTER A UNIQUE NAME"
32GETNAM D ^DIR
33 I $D(DIRUT) D DELETE(ROOT,IENN) Q
34 S NAME=Y
35 ;
36 ;Make sure the new name is valid.
37 I '$$VNAME^PXRMINTR(NAME,FILE) G GETNAM
38 ;
39 ;Change to the new name.
40 S IENS=IENN_","
41 S FDA(FILE,IENS,.01)=NAME
42 K MSG
43 D FILE^DIE("","FDA","MSG")
44 ;Check to make sure the name was not a duplicate.
45 I $G(MSG("DIERR",1))=740 D G GETNAM
46 . W !,NAME," is not a unique name!"
47 ;Change the class to local and delete the sponsor.
48 D SCAS(FILE,IENN,"L","")
49 ;Initialize the edit history.
50 D INIEH(FILE,ROOT,IENN,IENO)
51 ;
52 ;Reindex the cross-references.
53 S DIK=ROOT,DA=IENN
54 D IX^DIK
55 W !
56 ;
57 ;Tell the user what has happened and allow for editing of the new item.
58 S DIR(0)="Y"
59 S DIR("A")="Do you want to edit it now"
60 S DIR("A",1)="The original "_WHAT_" "_ORGNAME_" has been copied into "_NAME_"."
61 D ^DIR Q:$D(DIRUT)
62 I Y D EDIT^PXRMEDIT(ROOT,IENN)
63 Q
64 ;
65 ;=====================================================
66COPYLL ;Copy a location list.
67 N PROMPT,ROOT,WHAT
68 S WHAT="location list"
69 S ROOT="^PXRMD(810.9,"
70 S PROMPT="Select the reminder location list to copy: "
71 D COPY(PROMPT,ROOT,WHAT)
72 Q
73 ;
74 ;=====================================================
75COPYREM ;Copy a reminder definition.
76 N PROMPT,ROOT,WHAT
77 S WHAT="reminder"
78 S ROOT="^PXD(811.9,"
79 S PROMPT="Select the reminder definition to copy: "
80 D COPY(PROMPT,ROOT,WHAT)
81 Q
82 ;
83 ;=====================================================
84COPYTAX ;Copy a taxonomy.
85 N PROMPT,ROOT,WHAT
86 S WHAT="taxonomy"
87 S ROOT="^PXD(811.2,"
88 S PROMPT="Select the reminder taxonomy to copy: "
89 D COPY(PROMPT,ROOT,WHAT)
90 Q
91 ;
92 ;=====================================================
93COPYTERM ;Copy a reminder term.
94 N PROMPT,ROOT,WHAT
95 S WHAT="reminder term"
96 S ROOT="^PXRMD(811.5,"
97 S PROMPT="Select the reminder term to copy: "
98 D COPY(PROMPT,ROOT,WHAT)
99 Q
100 ;
101 ;=====================================================
102DELETE(DIK,DA) ;Delete the entry just added.
103 D ^DIK
104 W !!,"New entry not created due to invalid name!",!
105 Q
106 ;
107 ;=====================================================
108GETFOIEN(ROOT) ;Return the first open IEN in ROOT. This should be called
109 ;after a call to SETSTART.
110 N ENTRY,NIEN,OIEN
111 S ENTRY=ROOT_0_")"
112 S OIEN=$P(@ENTRY,U,3)
113 S ENTRY=ROOT_OIEN_")"
114 F S NIEN=$O(@ENTRY) Q:+(NIEN-OIEN)>1 Q:+NIEN'>0 S OIEN=NIEN,ENTRY=ROOT_NIEN_")"
115 Q OIEN+1
116 ;
117 ;=====================================================
118INIEH(FILENUM,ROOT,IENN,IENO) ;Initialize the edit history after a copy.
119 ;First delete any existing history entries.
120 N ENTRY,IND,IENS,FDA,FDAIEN,MSG,SFN,TARGET,WP
121 D FIELD^DID(FILENUM,"EDIT HISTORY","","SPECIFIER","TARGET")
122 S SFN=+$G(TARGET("SPECIFIER"))
123 I SFN=0 Q
124 S ENTRY=ROOT_IENN_",110)"
125 S IND=0
126 F S IND=$O(@ENTRY@(IND)) Q:+IND=0 D
127 . S IENS=IND_","_IENN_","
128 . S FDA(SFN,IENS,.01)="@"
129 I $D(FDA(SFN)) D FILE^DIE("K","FDA","MSG")
130 I $D(MSG) D AWRITE^PXRMUTIL("MSG")
131 ;Establish an initial entry in the edit history.
132 K FDA,MSG
133 S IENS="+1,"_IENN_","
134 S FDAIEN(IENN)=IENN
135 S FDA(SFN,IENS,.01)=$$FMTE^XLFDT($$NOW^XLFDT,"5Z")
136 S FDA(SFN,IENS,1)=$$GET1^DIQ(200,DUZ,.01)
137 S FDA(SFN,IENS,2)="WP(1,1)"
138 S WP(1,1,1)="Copied from "_$$GET1^DIQ(FILENUM,IENO,.01)
139 D UPDATE^DIE("E","FDA","FDAIEN","MSG")
140 I $D(MSG) D AWRITE^PXRMUTIL("MSG")
141 Q
142 ;
143 ;=====================================================
144MERGE(IENN,IENO,ROOT) ;Use MERGE to copy ROOT(IENO into ROOT(IENN.
145 N DEST,SOURCE
146 S DEST=ROOT_IENN_")"
147 ;Lock the file before merging.
148 L +@DEST:10
149 S SOURCE=ROOT_IENO_")"
150 M @DEST=@SOURCE
151 ;Unlock the file
152 L -@DEST
153 Q
154 ;
155 ;=====================================================
156SCAS(FILENUM,IEN,CLASS,SPONSOR) ;Set the class field to CLASS and the sponsor
157 ;field to SPONSOR.
158 N IENS,FDA,MSG
159 S IENS=IEN_","
160 S FDA(FILENUM,IENS,100)=CLASS
161 S FDA(FILENUM,IENS,101)=SPONSOR
162 D FILE^DIE("K","FDA","MSG")
163 I $D(MSG) D AWRITE^PXRMUTIL("MSG")
164 Q
165 ;
166 ;=====================================================
167SETSTART(ROOT) ;Set the starting value to add new entries. Start
168 ;at the begining so empty spaces are filled in.
169 N CUR,ENTRY
170 S ENTRY=ROOT_"0)"
171 S $P(@ENTRY,U,3)=1
172 Q
173 ;
Note: See TracBrowser for help on using the repository browser.