source: WorldVistAEHR/trunk/r/IMAGING-MAG-ZMAG/MAGGNTI1.m@ 1421

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

revised back to 6/30/08 version

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