source: FOIAVistA/tag/r/REGISTRATION-DGQE-DG-DPT-GRPX-VAD-VAF-VAS-VAT-VAU--VA-VIC--DGBT--DGJ--DGYA--VALM/DGPFLMA3.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: 7.5 KB
Line 
1DGPFLMA3 ;ALB/KCL - PRF ASSIGNMENT LM PROTOCOL ACTIONS CONT. ; 6/2/05 3:24pm
2 ;;5.3;Registration;**425,623,554,650**;Aug 13, 1993;Build 3
3 ;
4 ;no direct entry
5 QUIT
6 ;
7EF ;Entry point for DGPF EDIT FLAG ASSIGNMENT action protocol.
8 ;
9 ; Input: None
10 ;
11 ; Output:
12 ; VALMBCK - 'R' = refresh screen
13 ;
14 ;input vars for EN^DIWE call
15 N DIC,DGWPROOT,DIWETXT,DIWESUB,DWLW,DWPK
16 N DGAROOT ;assignment narrative word processing root
17 N DGCROOT ;assignment history comment word processing root
18 N DGABORT ;abort flag for entering assignment narrative
19 N DGASK ;return value from $$ANSWER^DGPFUT call
20 N DGOK ;ok flag for entering assignment narrative
21 N DGCODE ;action code
22 N DGDFN ;pointer to patient in PATIENT (#2) file
23 N DGIEN ;assignment ien
24 N DGPFA ;assignment array
25 N DGPFAH ;assignment history array
26 N DGPFERR ;if error returned from STOALL api call
27 N DGQ ;quit var for narrative edit
28 N DGRDAT ;review date
29 N DGRESULT ;result of STOALL api call
30 N DGERR ;error if unable to edit assignment
31 N DGETEXT ;error text
32 N DGSUB ;for loop var
33 N SEL ;user selection (list item)
34 N VALMY ;output of EN^VALM2 call, array of user selected entries
35 ;
36 ;set screen to full scroll region
37 D FULL^VALM1
38 ;
39 ;quit if selected action is not appropriate
40 I '$D(@VALMAR@("IDX")) D Q
41 . I '$G(DGDFN) S DGETEXT(1)="Patient has not been selected."
42 . E S DGETEXT(1)="Patient has no record flag assignments."
43 . D BLD^DIALOG(261129,.DGETEXT,"","DGERR","F")
44 . D MSG^DIALOG("WE","","","","DGERR") W *7
45 . D PAUSE^VALM1
46 . S VALMBCK="R"
47 ;
48 ;allow user to select a SINGLE flag assignment for editing
49 S (DGIEN,VALMBCK)=""
50 D EN^VALM2($G(XQORNOD(0)),"S")
51 ;
52 ;process user selection
53 S SEL=$O(VALMY(""))
54 I SEL,$D(@VALMAR@("IDX",SEL,SEL)) D
55 . S DGIEN=$P($G(@VALMAR@("IDX",SEL,SEL)),U)
56 . S DGDFN=$P($G(@VALMAR@("IDX",SEL,SEL)),U,2)
57 . ;
58 . ;attempt to obtain lock on assignment record
59 . I '$$LOCK^DGPFAA3(DGIEN) D Q
60 . . W !!,"Record flag assignment currently in use, can not be edited!"
61 . . D PAUSE^VALM1
62 . ;
63 . ;init word processing arrays
64 . S DGAROOT=$NA(^TMP($J,"DGPFNARR"))
65 . S DGCROOT=$NA(^TMP($J,"DGPFCMNT"))
66 . K @DGAROOT,@DGCROOT
67 . ;
68 . ;get assignment into DGPFA array
69 . I '$$GETASGN^DGPFAA(DGIEN,.DGPFA) D Q
70 . . W !!,"Unable to retrieve the record flag assignment selected."
71 . . D PAUSE^VALM1
72 . ;
73 . ;is assignment edit allowed?
74 . I '$$EDTOK^DGPFAA2(.DGPFA,DUZ(2),"DGERR") D Q
75 . . W !!,"Assignment can not be edited..."
76 . . D MSG^DIALOG("WE","","",5,"DGERR")
77 . . D PAUSE^VALM1
78 . ;
79 . ;-if assigment is active, set available action codes to Continue
80 . ; and Inactivate; else set code to Reactivate
81 . ;-if Local Flag or PRF Phase 2 active, add Entered in Error code
82 . I +DGPFA("STATUS")=1 D
83 . . S DGCODE="S^C:Continue Assignment;I:Inactivate Assignment"
84 . . I $$P2ON^DGPFPARM()!(DGPFA("FLAG")[26.11) S DGCODE=DGCODE_";E:Entered in Error"
85 . E S DGCODE="S^R:Reactivate Assignment"
86 . ;
87 . ;prompt user for assignment action, quit if no action selected
88 . S DGPFAH("ACTION")=$$ANSWER^DGPFUT("Select an assignment action","",DGCODE)
89 . Q:(DGPFAH("ACTION")=-1)
90 . S DGPFAH("ACTION")=$S(DGPFAH("ACTION")="C":2,DGPFAH("ACTION")="I":3,DGPFAH("ACTION")="R":4,DGPFAH("ACTION")="E":5)
91 . ;
92 . ;if assignment action is 'Inactivate' or 'Entered in Error',
93 . ;set status to 'Inactive'. default='Active'.
94 . S DGPFA("STATUS")=$S(DGPFAH("ACTION")=3:0,DGPFAH("ACTION")=5:0,1:1)
95 . ;
96 . ;if action is not 'Inactivate', then prompt user to edit the narr
97 . S (DGABORT,DGOK,DGQ)=0
98 . I (DGPFAH("ACTION")'=3) D
99 . . F D Q:(DGOK!DGABORT!DGQ)
100 . . . ; if action code not 'Entered in Error', can't force edit
101 . . . I DGPFAH("ACTION")'=5 D Q:(DGQ!DGABORT)
102 . . . . S DGASK=$$ANSWER^DGPFUT("Would you like to edit the assignment narrative","YES","Y")
103 . . . . I DGASK<0 S DGABORT=1 Q ;abort edit action
104 . . . . I DGASK'=1 S DGQ=1 Q
105 . . . ;
106 . . . ;--edit narrative - only '5;Entered in Error' Required
107 . . . ;--edit the assignment narrative
108 . . . S DGAROOT=$$GET1^DIQ(26.13,DGIEN,"1","Z",DGAROOT)
109 . . . S DIC=$$OREF^DILF(DGAROOT)
110 . . . S DIWETXT="Patient Record Flag - Assignment Narrative Text"
111 . . . S DIWESUB="Assignment Narrative Text"
112 . . . S DWLW=75 ;max # of chars allowed to be stored on WP global node
113 . . . S DWPK=1 ;if line editor, don't join lines
114 . . . D EN^DIWE
115 . . . I '$$CKWP^DGPFUT(DGAROOT) D Q
116 . . . . W !,"Assignment Narrative Text is required!",*7
117 . . . . I '$$CONTINUE^DGPFUT() S DGABORT=1
118 . . . ;if number of text lines not the same, a change was made
119 . . . I $O(DGPFA("NARR",""),-1)'=$O(@DGAROOT@(""),-1) S DGOK=1 Q
120 . . . ;now check for a difference in text line content
121 . . . S DGSUB=0
122 . . . F S DGSUB=$O(DGPFA("NARR",DGSUB)) Q:DGSUB="" D Q:DGOK
123 . . . . I DGPFA("NARR",DGSUB,0)'=@DGAROOT@(DGSUB,0) S DGOK=1
124 . . . Q:DGOK
125 . . . I 'DGOK,(DGPFAH("ACTION")=5) D Q ;required edit
126 . . . . W !!,"No editing was found to the Narrative text."
127 . . . . W !,"For 'Entered in Error' Action, you must edit the Assignment Narrative Text.",*7,!
128 . . . . I '$$CONTINUE^DGPFUT() S DGABORT=1
129 . . . S DGOK=1
130 . ;
131 . Q:$G(DGABORT)
132 . ;
133 . ;if narrative edited, place new narrative into DGPFA array
134 . I $G(DGOK) D
135 . . K DGPFA("NARR") ;remove old narrative text
136 . . M DGPFA("NARR")=@DGAROOT K @DGAROOT
137 . ;
138 . ;prompt user for 'Approved By' person, quit if not selected
139 . S DGPFAH("APPRVBY")=$$ANSWER^DGPFUT("Approved By","","P^200:EMZ")
140 . Q:(DGPFAH("APPRVBY")'>0)
141 . ;
142 . ;have user enter the edit reason/history comments (required)
143 . S (DGABORT,DGOK)=0
144 . F D Q:(DGOK!DGABORT)
145 . . W !!,"Enter the reason for editing this assignment:" ;needed for line editor
146 . . S DIC=$$OREF^DILF(DGCROOT)
147 . . S DIWETXT="Patient Record Flag - Edit Reason Text"
148 . . S DIWESUB="Edit Reason Text"
149 . . S DWLW=75 ;max # of chars allowed to be stored on WP global node
150 . . S DWPK=1 ;if line editor, don't join lines
151 . . D EN^DIWE
152 . . I $$CKWP^DGPFUT(DGCROOT) S DGOK=1 Q
153 . . W !,"Edit Reason is required!",*7
154 . . I '$$CONTINUE^DGPFUT() S DGABORT=1
155 . ;
156 . ;quit if required edit reason/history comments not entered
157 . Q:$G(DGABORT)
158 . ;
159 . ;place comments into history array
160 . M DGPFAH("COMMENT")=@DGCROOT K @DGCROOT
161 . ;
162 . ;setup remaining assignment history nodes for filing
163 . S DGPFAH("ASSIGNDT")=$$NOW^XLFDT() ;current date/time
164 . S DGPFAH("ENTERBY")=DUZ ;current user
165 . ;
166 . ;calculate the default review date
167 . S DGRDAT=$$GETRDT^DGPFAA3($P(DGPFA("FLAG"),U),DGPFAH("ASSIGNDT"))
168 . ;
169 . ;prompt for review date when valid default review date and ACTIVE
170 . ;status, otherwise null
171 . I DGRDAT>0,DGPFA("STATUS")=1 D
172 . . S DGPFA("REVIEWDT")=$$ANSWER^DGPFUT("Enter Review Date",$$FMTE^XLFDT(DGRDAT,"5D"),"D^"_DT_":"_DGRDAT_":EX")
173 . E S DGPFA("REVIEWDT")=""
174 . Q:DGPFA("REVIEWDT")<0
175 . ;
176 . ;display flag assignment review screen to user
177 . D REVIEW^DGPFUT3(.DGPFA,.DGPFAH,DGIEN,XQY0,XQORNOD(0))
178 . ;
179 . Q:$$ANSWER^DGPFUT("Would you like to file the assignment changes","YES","Y")'>0
180 . ;
181 . ;file the assignment and history using STOALL api
182 . W !,"Updating the patient's record flag assignment..."
183 . S DGRESULT=$$STOALL^DGPFAA(.DGPFA,.DGPFAH,.DGPFERR)
184 . W !?5,"Assignment was "_$S(+$G(DGRESULT):"filed successfully.",1:"not filed successfully.")
185 . ;
186 . ;send HL7 message if editing assignment to a CAT I flag
187 . I $G(DGRESULT),DGPFA("FLAG")["26.15",$$SNDORU^DGPFHLS(+DGRESULT) D
188 . . W !?5,"Message sent...updating patient's sites of record."
189 . ;
190 . D PAUSE^VALM1
191 . ;
192 . ;re-build list of flag assignments for patient
193 . D BLDLIST^DGPFLMU(DGDFN)
194 ;
195 ;release lock after edit
196 D UNLOCK^DGPFAA3(DGIEN)
197 ;
198 ;return to LM (refresh screen)
199 S VALMBCK="R"
200 ;
201 Q
Note: See TracBrowser for help on using the repository browser.