source: FOIAVistA/trunk/r/IMAGING-MAG-ZMAG/MAGGNTI1.m@ 1071

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

initial load of FOIAVistA 6/30/08 version

File size: 8.5 KB
Line 
1MAGGNTI1 ;WOIFO/GEK - Imaging interface to TIU. RPC Calls etc. ; 04 Apr 2002 2:37 PM
2 ;;3.0;IMAGING;**46,59**;Nov 27, 2007;Build 20
3 ;; Per VHA Directive 2004-038, this routine should not be modified.
4 ;; +---------------------------------------------------------------+
5 ;; | Property of the US Government. |
6 ;; | No permission to copy or redistribute this software is given. |
7 ;; | Use of unreleased versions of this software requires the user |
8 ;; | to execute a written test agreement with the VistA Imaging |
9 ;; | Development Office of the Department of Veterans Affairs, |
10 ;; | telephone (301) 734-0100. |
11 ;; | |
12 ;; | The Food and Drug Administration classifies this software as |
13 ;; | a medical device. As such, it may not be changed in any way. |
14 ;; | Modifications to this software may result in an adulterated |
15 ;; | medical device under 21CFR820, the use of which is considered |
16 ;; | to be a violation of US Federal Statutes. |
17 ;; +---------------------------------------------------------------+
18 ;;
19 Q
20NEW(MAGRY,MAGDFN,MAGTITLE,MAGADCL,MAGMODE,MAGES,MAGESBY,MAGLOC,MAGDATE,MAGCNSLT,MAGTEXT) ;RPC [MAG3 TIU NEW]
21 ;
22 ; RPC call to create a New Note
23 ; and Optionally :
24 ; Electronically Sign,
25 ; Administratively Close
26 ; or Add Text to the Note.
27 ;
28 ; - - - Required - - -
29 ; MAGDFN - Patient DFN
30 ; MAGTITLE - IEN of TIU Document Title in file 8925.1
31 ; - - - Optional - - -
32 ; Use DUZ for TIUAUTH
33 ; Use NOW for TIURDT
34 ; MAGTEXT - Array of Text to add to the New Note.
35 ; MAGLOC - IEN in Hospital Location File 44
36 ; MAGES - The encrypted Electronic Signature
37 ; MAGESBY - The DUZ of the Signer (Defaults to DUZ)
38 ; MAGADCL - 1 = Mark this Note as Administratively Closed
39 ; MAGMODE - Mode of Admin Closure: "S" = Scanned Document
40 ; "M" = Manual closure, "E" = Electronically Filed
41 ; MAGDATE - Date of the Note. For New Notes.
42 ; MAGCNSLT - DA of Consult to Link to.
43 ;
44 N $ETRAP,$ESTACK S $ETRAP="D ERR^"_$T(+0)
45 S MAGDFN=$G(MAGDFN),MAGTITLE=$G(MAGTITLE),MAGLOC=$G(MAGLOC)
46 S MAGES=$G(MAGES),MAGADCL=$G(MAGADCL)
47 S MAGESBY=$S($G(MAGESBY):MAGESBY,1:DUZ)
48 S MAGMODE=$S($L($G(MAGMODE)):MAGMODE,1:"S")
49 S MAGDATE=$G(MAGDATE),MAGCNSLT=$G(MAGCNSLT)
50 N MAGTIUDA,I,NODE,MAGTY,ISVAL,MAGISC,MTXT,MUPD,MAGX,MAGVSTR,MAGTIUX
51 ;
52 ; MAGMODE is only sent if Admin Closure is wanted.
53 I (MAGMODE="S") S MAGTEXT(.1)=" VistA Imaging - Scanned Document"
54 I (MAGMODE="M") S MAGTEXT(.1)=" VistA Imaging - Manual Closure"
55 I "MSE"'[MAGMODE S MAGRY="0^Invalid Mode of Closure: """_MAGMODE_"""" Q
56 ;
57 ; Here if we have no Text, we'll add at least a line.
58 I $O(MAGTEXT(""))="" S MAGTEXT(.1)=" VistA Imaging - - Scanned Document"
59 ; Reformat Text - "TEXT",i,0)" for TIU Call.
60 S I="",NODE=0
61 F S I=$O(MAGTEXT(I)) Q:I="" D
62 . S NODE=NODE+1 S MAGTIUX("TEXT",NODE,0)=MAGTEXT(I)
63 . Q
64 ; validate the DFN
65 I '$D(^DPT(+MAGDFN,0)) S MAGRY="0^Invalid data: Patient DFN is invalid" Q
66 ; validate the User
67 I '$D(^VA(200,MAGESBY,0)) S MAGRY="0^Invalid data: Author DUZ is invalid" Q
68 ; validate the TIU TITLE
69 I '$D(^TIU(8925.1,MAGTITLE,0)) S MAGRY="0^Invalid data: Note TITLE is invalid" Q
70 ; validate Esig first, if caller wants to also mark this Note as Signed
71 I +$G(MAGES) I '$$VALES^MAGGNTI2(MAGES) S MAGRY="0^Invalid data: E-sign is invalid" Q
72 ; validate the Date MAGDATE is changed to INternal if it is valid.
73 I +$L(MAGDATE) I '$$VALID^MAGGSIV1(8925,1301,.MAGDATE,.MAGX) S MAGRY="0^"_MAGX Q
74 I '$L(MAGDATE) S MAGDATE=$$NOW^XLFDT
75 ; LINK TO CONSULT
76 ; can user create Notes with This Title
77 I '$$CANENTR^TIULP(MAGTITLE) S MAGRY="0^You need privileges to enter notes of that Title" Q
78 ;
79 D ISCNSLT^TIUCNSLT(.MAGISC,MAGTITLE)
80 I MAGISC D I 'MAGISC S MAGRY=MAGISC Q
81 . ; See if a Consult DA was sent.
82 . IF 'MAGCNSLT S MAGISC="0^A Consult is needed to link to this note title"
83 . Q
84 I ('MAGISC)&(MAGCNSLT) S MAGRY="0^Cannot Link Consult with a Non Consult Title" Q
85 ;
86 ; make a VSTR for TIU Call.
87 S MAGVSTR=MAGLOC_";"_MAGDATE_";E"
88 ;
89 ; Call to NEW^TIUPNAPI wasn't doing what we needed. Now call TIU CREATE RECORD
90 ; MAKE(SUCCESS,DFN,TITLE,VDT,VLOC,VSIT,TIUX,VSTR,SUPPRESS,NOASF)
91 D MAKE^TIUSRVP(.MAGTIUDA,MAGDFN,MAGTITLE,"",MAGLOC,"",.MAGTIUX,MAGVSTR)
92 I 'MAGTIUDA!(MAGTIUDA=-1) S MAGRY="0^Error creating Note"_$G(MAGTIUDA) Q
93 S MAGRY=MAGTIUDA_"^Note was created."
94 S MAGTY=MAGRY
95 ;
96 ; ;Put in the Date that was sent.
97 I '$$VALID^MAGGSIV1(8925,1301,.MAGDATE,.MAGRES) S MAGRY=MAGRY_" "_MAGRES
98 E S MTXT(1301)=MAGDATE
99 ; - Fix in T30, if DUZ isn't MAGESBY, we have Author different than User.
100 I MAGESBY'=DUZ S MTXT("1202")=MAGESBY
101 ; Update and LINK TO CONSULT if needed.
102 I MAGISC S MTXT("1405")=MAGCNSLT_";GMR(123,"
103 I $D(MTXT) D I 'MUPD S MAGRY=MUPD Q
104 . D UPDATE^TIUSRVP(.MUPD,MAGTIUDA,.MTXT)
105 . Q
106 ;
107 ; If Admin Close, then We quit.
108 I MAGADCL="1" D Q
109 . D ADMNCLOS^MAGGNTI2(.MAGTY,MAGDFN,MAGTIUDA,MAGMODE)
110 . S MAGRY=$S('MAGTY:MAGTY,1:MAGRY_" Administrative Closure.")
111 . Q
112 ;
113 ; if caller sent esignature to Sign this Note.
114 I $L(MAGES) D
115 . D SIGN^MAGGNTI3(.MAGTY,MAGDFN,MAGTIUDA,MAGES,MAGESBY)
116 . S MAGRY=$S('MAGTY:MAGTY,1:MAGRY_" Signed.")
117 . Q
118 Q
119 ;
120 ;(MAGRY,MAGDFN,MAGTITLE,MAGADCL,MAGMODE,MAGES,MAGESBY,MAGLOC,MAGTEXT)
121NEWADD(MAGRY,MAGDFN,MAGTIUDA,MAGADCL,MAGMODE,MAGES,MAGESBY,MAGDATE,MAGTEXT) ; RPC [MAG3 TIU CREATE ADDENDUM]
122 ; RPC call to create an Addendum to a Note
123 ; and Optionally :
124 ; Electronically Sign,
125 ; Administratively Close,
126 ; or Add Text to the Addendum
127 ;
128 ; - - - Required - - -
129 ; MAGDFN - Patient DFN
130 ; MAGTIUDA - IEN of TIU NOTE in file 8925
131 ; - - - Optional - - -
132 ; MAGTEXT - Array of Text to add to the New Note.
133 ; MAGES - The encrypted Electronic Signature
134 ; MAGESBY - The DUZ of the Signer (Defaults to DUZ)
135 ; MAGADCL - 1 = Mark this Note as Administratively Closed
136 ; MAGMODE - Mode of Admin Closure: "S" = Scanned Document "M" = Manual closure "E" = Electronically Filed
137 ; MAGDATE - Date of the Addendum.
138 ;
139 N $ETRAP,$ESTACK S $ETRAP="D ERR^"_$T(+0)
140 S MAGDFN=$G(MAGDFN),MAGTIUDA=$G(MAGTIUDA),MAGES=$G(MAGES),MAGADCL=$G(MAGADCL)
141 S MAGESBY=$S($G(MAGESBY):MAGESBY,1:DUZ),MAGMODE=$S($L($G(MAGMODE)):MAGMODE,1:"S")
142 S MAGDATE=$G(MAGDATE)
143 ;
144 I '$$VALDATA^MAGGNTI2(.MAGRY,MAGDFN,MAGTIUDA) Q
145 N MAGXT,I,CT,NEWTIUDA,MAGY,MAGRES,MAGUPD
146 S CT=1,I=""
147 S MAGXT("TEXT",1,0)="VistA Imaging Scanned Document - Addendum."
148 I $D(MAGTEXT) F S I=$O(MAGTEXT(I)) Q:I="" D
149 . S CT=CT+1,MAGXT("TEXT",CT,0)=MAGTEXT(I)
150 . Q
151 ;
152 ; Calling TIU CREATE ADDENDUM RECORD
153 D MAKEADD^TIUSRVP(.MAGRY,MAGTIUDA,.MAGXT)
154 ; MAGRY could be 0^error message
155 ; -1^message
156 ; TIUDA
157 I $P(MAGRY,"^")<0 S $P(MAGRY,"^")=0 Q
158 S NEWTIUDA=+MAGRY
159 S MAGRY=MAGRY_"^Addendum was created."
160 ;
161 ;Put in the Date that was sent.
162 K MAGUPD
163 I '$$VALID^MAGGSIV1(8925,1301,.MAGDATE,.MAGRES) S MAGRY=MAGRY_" "_MAGRES
164 E D
165 . S MAGUPD(1301)=MAGDATE
166 . S MAGUPD(1211)=$$GET1^DIQ(8925,1211,MAGTIUDA,"I")
167 ; - Fix in T30, if DUZ isn't MAGESBY, we have Author different than User.
168 I MAGESBY'=DUZ S MAGUPD("1202")=MAGESBY
169 I $D(MAGUPD) D
170 . D UPDATE^TIUSRVP(.MAGY,NEWTIUDA,.MAGUPD)
171 . I 'MAGY S MAGRY=MAGRY_" TIU Data was Not Correctly Filed."
172 . Q
173 ;
174 ; if caller sent esignature to Sign this Addendum.
175 I $L(MAGES) D Q
176 . D SIGN^MAGGNTI3(.MAGTY,MAGDFN,NEWTIUDA,MAGES,MAGESBY)
177 . S MAGRY=$S('MAGTY:MAGTY,1:MAGRY_" Signed.")
178 . Q
179 ;
180 ; if caller wants to Admin Close this Addendum.
181 I MAGADCL="1" D Q
182 . D ADMNCLOS^MAGGNTI2(.MAGTY,MAGDFN,NEWTIUDA,MAGMODE)
183 . S MAGRY=$S('MAGTY:MAGTY,1:MAGRY_" Administrative Closure.")
184 . Q
185 Q
186MOD(MAGRY,MAGDFN,MAGTIUDA,MAGADCL,MAGMODE,MAGES,MAGESBY,MAGTEXT) ; RPC [MAG3 TIU MODIFY NOTE]
187 ; After a Note is filed, we call this to Modify the Note. We do this to sign it.
188 ; That way the Signed Date is After the Image Association Date/Time.
189 N $ETRAP,$ESTACK S $ETRAP="D ERR^"_$T(+0)
190 S MAGDFN=$G(MAGDFN),MAGTIUDA=$G(MAGTIUDA)
191 S MAGADCL=$G(MAGADCL)
192 S MAGMODE=$S($L($G(MAGMODE)):MAGMODE,1:"S")
193 S MAGES=$G(MAGES)
194 S MAGESBY=$S($G(MAGESBY):MAGESBY,1:DUZ)
195 D MOD^MAGGNTI3(.MAGRY,MAGDFN,MAGTIUDA,MAGADCL,MAGMODE,MAGES,MAGESBY)
196 Q
197ERR ; ERROR TRAP
198 N ERR S ERR=$$EC^%ZOSV
199 S MAGRY="0^ETRAP: "_ERR
200 D @^%ZOSF("ERRTN")
201 Q
202SIGN(MAGRY,MAGDFN,MAGTIUDA,MAGES,MAGESBY) ;RPC [MAG3 TIU SIGN RECORD]
203 ; RPC Call to 'Sign' a Note.
204 D SIGN^MAGGNTI3(.MAGRY,$G(MAGDFN),$G(MAGTIUDA),$G(MAGES),$G(MAGESBY))
205 Q
Note: See TracBrowser for help on using the repository browser.