source: WorldVistAEHR/trunk/r/IMAGING-MAG-ZMAG/MAGDTR03.m@ 724

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

initial load of WorldVistAEHR

File size: 8.7 KB
RevLine 
[613]1MAGDTR03 ;WOIFO/PMK - Read a DICOM image file ; 20 Nov 2006 2:46 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 ;
19ADD(OUT,GMRCIEN,EVENT,IMAGECNT) ; add an entry to the read/unread list
20 N ACQSITE ;-- the site where the images were acquired
21 N IFCIEN ;--- the IEN of the IFC consult at the reading site
22 N IFCSITE ;-- 0 if not IFC
23 N ISPECIDX ;- index to specialties - read/unread list sort key
24 N IPROCIDX ;- index to procedures - read/unread list sort key (may be null)
25 N STATUS ;--- status of unread list entry (Unread or Waiting)
26 N TIMESTMP ;- FM date/time
27 N TRIGGER ;-- create unread list trigger: Forward, Image, or Order
28 N UNREAD ;-- pointer to entry in unread list
29 N X
30 ; should this consult be added to the Unread List?
31 S OUT=0 ; return variable
32 Q:$G(EVENT)="" ; nope, an event F, I, or O must be specified
33 Q:$$FINDLIST^MAGDTR01(GMRCIEN,.ISPECIDX,.IPROCIDX,.ACQSITE,.TRIGGER)<1
34 S IMAGECNT=+$G(IMAGECNT) ; count of images
35 ;
36 S UNREAD=$$UNREAD^MAGDTR02(GMRCIEN)
37 I UNREAD="",EVENT'[TRIGGER Q ; nope, don't create it now
38 ;
39 ; get IFC information
40 S IFCSITE=$$GET1^DIQ(123,GMRCIEN,.07,"I") ; Routing Facility
41 S IFCIEN=$$GET1^DIQ(123,GMRCIEN,.06,"I") ; remote consult file entry
42 ;
43 I UNREAD="" D ; add record to the unread list
44 . N X
45 . L +^MAG(2006.5849,0):1E9 ; serial generation
46 . S UNREAD=$O(^MAG(2006.5849," "),-1)+1 ; get next IEN
47 . L +^MAG(2006.5849,UNREAD):1E9
48 . S X=$G(^MAG(2006.5849,0))
49 . S X="TELEREADER READ/UNREAD LIST^2006.5849^"_UNREAD_"^"_($P(X,"^",4)+1)
50 . S ^MAG(2006.5849,0)=X
51 . S ^MAG(2006.5849,UNREAD,0)=GMRCIEN_"^"_ACQSITE_"^"_ISPECIDX_"^"_IPROCIDX
52 . L -^MAG(2006.5849,0) ; end serial generation
53 . S TIMESTMP=$$TIMESTMP^MAGDTR02(UNREAD)
54 . S $P(^MAG(2006.5849,UNREAD,0),"^",7)=TIMESTMP ; acquisition start d/t
55 . S ^MAG(2006.5849,"B",GMRCIEN,UNREAD)=""
56 . ;
57 . ; set status -- if unpaired IFC, status="Waiting", otherwise "Unread"
58 . S STATUS=$S(IFCSITE&'IFCIEN:"W",1:"U")
59 . S $P(^MAG(2006.5849,UNREAD,0),"^",11)=STATUS
60 . S ^MAG(2006.5849,"D",ACQSITE,ISPECIDX,IPROCIDX,STATUS,UNREAD)=""
61 . L -^MAG(2006.5849,UNREAD)
62 . Q
63 E D
64 . S TIMESTMP=$$TIMESTMP^MAGDTR02(UNREAD) ; update d/t piece of last activity
65 . Q
66 ;
67 I IFCSITE D ; record the IFC remote site times, if they are not set
68 . ; save time the entry is added to the unread list, if not set
69 . I $P($G(^MAG(2006.5849,UNREAD,0)),"^",5)="" S $P(^(0),"^",5)=TIMESTMP
70 . I IFCIEN D
71 . . ; IFC remote consult already created - save same time, if not set
72 . . I $P($G(^MAG(2006.5849,UNREAD,0)),"^",6)="" S $P(^(0),"^",6)=TIMESTMP
73 . . Q
74 . Q
75 ;
76 I IMAGECNT D
77 . S $P(^MAG(2006.5849,UNREAD,0),"^",8)=TIMESTMP ; last acquisition d/t
78 . S $P(^(0),"^",10)=$P(^MAG(2006.5849,UNREAD,0),"^",10)+IMAGECNT
79 . Q
80 ;
81 S OUT=UNREAD
82 Q
83 ;
84COMPLETE ; entry point from ^MAGDTR01 & ^MAGDTRLU for COMPLETED consults
85 N LOCATION,MAGPTR,TIMESTMP,UNREAD
86 S UNREAD=$$UNREAD^MAGDTR02(GMRCIEN)
87 S TIMESTMP=$$STATUPDT^MAGDTR02(UNREAD,"R")
88 I TIMESTMP D ; changed status to Resulted
89 . D FINISH ; record who updated the consult
90 . ; check if there is an image
91 . S MAGPTR=$O(^MAG(2006.5839,"C",123,GMRCIEN,0))
92 . I MAGPTR,'$$TIULAST^MAGDGMRC(GMRCIEN) D
93 . . ; there is an image but no TIU note
94 . . D TIUNOTE ; create a TIU note for the image
95 . . Q
96 . Q
97 Q
98 ;
99CANCEL ; entry point from ^MAGDTR01 & ^MAGDTRLU for CANCELLED consults
100 N TIMESTMP,UNREAD
101 S UNREAD=$$UNREAD^MAGDTR02(GMRCIEN)
102 S TIMESTMP=$$STATUPDT^MAGDTR02(UNREAD,"C")
103 I TIMESTMP D ; changed status to Cancelled
104 . ; remove any old data about the reading activities
105 . S $P(^MAG(2006.5849,UNREAD,0),"^",12,16)="^^^^"
106 . D FINISH ; record who cancelled the consult
107 . Q
108 Q
109 ;
110FINISH ; finalize resulted or cancelled consult
111 N DUZACQ,FULLNAME,INITIALS,LOCKNAME,X
112 ; record who resulted or cancelled the consult
113 ;
114 I $G(MODE)="REPAIR" G REPAIR ; set in ^MAGDTRLU
115 ;
116 ; process the transaction
117 I $D(HLNEXT) D ; IFC - data comes from HL7 message
118 . D GETHL7B^MAGDTR01(.FULLNAME,.LOCATION)
119 . ; if resulter is not the person who locked the study, update name
120 . S LOCKNAME=$P(^MAG(2006.5849,UNREAD,0),"^",12)
121 . I LOCKNAME'=FULLNAME,FULLNAME'="" D ; not the same person, update
122 . . ; look up resulter in file 200 - check for >1 people with same name
123 . . S DUZACQ=$O(^VA(200,"B",FULLNAME,""))
124 . . I DUZACQ,$O(^VA(200,"B",FULLNAME,DUZACQ)) S DUZACQ="" ; same name
125 . . S INITIALS=$$GET1^DIQ(200,DUZACQ,1) ; initial
126 . . ; DUZread (piece 4) is not known - set to null
127 . . S X=FULLNAME_"^"_INITIALS_"^"_DUZACQ_"^^"_LOCATION
128 . . S $P(^MAG(2006.5849,UNREAD,0),"^",12,16)=X ; reader identification
129 . . Q
130 . Q
131 E D ; local consult - FULLNAME array is for IFCs only
132 . ; record the id of the resulter - DUZ comes from RPC session
133 . ; assumes that the results were entered directly, not via IFC/HL7
134 . S FULLNAME=$$GET1^DIQ(200,DUZ,.01)
135 . S INITIALS=$$GET1^DIQ(200,DUZ,1) ; initial
136 . S X=FULLNAME_"^"_INITIALS_"^"_DUZ_"^"_DUZ_"^"_DUZ(2) ; DUZacq=DUZread
137 . S $P(^MAG(2006.5849,UNREAD,0),"^",12,16)=X ; reader identification
138 . Q
139 ;
140 D EXREF(UNREAD,TIMESTMP) ; set "E" cross-reference
141 Q
142 ;
143EXREF(UNREAD,TIMESTMP) ; set cancellation or reading stop date/time and "E" cross-reference
144 N ACQSITE ;-- acquisition site
145 N LISTDATA ;- read/unread list data
146 Q:UNREAD="" Q:TIMESTMP=""
147 S LISTDATA=^MAG(2006.5849,UNREAD,0)
148 S ACQSITE=$P(LISTDATA,"^",2) Q:ACQSITE=""
149 S $P(^MAG(2006.5849,UNREAD,0),"^",18)=TIMESTMP
150 S ^MAG(2006.5849,"E",ACQSITE,TIMESTMP\1,UNREAD)=""
151 Q
152 ;
153REPAIR ; code to repair a defective unread list entry
154 N ACTIVITY,DUZACQ,FULLNAME,HIT,I,IFCSITE,INITIALS,LOCATION,SUBFILE,TIMESTMP
155 S IFCSITE=$$GET1^DIQ(123,GMRCIEN,.07,"I") ; routing facility
156 ;
157 ; first find the consult request tracking "completion" activity in cprs
158 S HIT=0 F I=1:1 D Q:HIT Q:ACTIVITY=""
159 . S SUBFILE=I_","_GMRCIEN ; format: <subfile ien>,<gmrc ien>
160 . S ACTIVITY=$$GET1^DIQ(123.02,SUBFILE,1) ; activity - from ^GMR(123.1)
161 . I ACTIVITY="COMPLETE/UPDATE" S HIT=1
162 . E I ACTIVITY="CANCELLED" S HIT=2
163 . E I ACTIVITY="DISCONTINUED" S HIT=3
164 . Q
165 I 'HIT S SUBFILE=(I-1)_","_GMRCIEN ; use the last entry
166 ;
167 ; now make the corrections
168 S TIMESTMP=$$GET1^DIQ(123.02,SUBFILE,2,"I") ; date/time of actual activity
169 S DUZACQ=$$GET1^DIQ(123.02,SUBFILE,3,"I") ; who's responsible for activity
170 I DUZACQ D ; action was perfomed locally
171 . S FULLNAME=$$GET1^DIQ(200,DUZACQ,.01) ; name
172 . S INITIALS=$$GET1^DIQ(200,DUZACQ,1) ; initials
173 . S LOCATION=ACQSITE
174 . S X=FULLNAME_"^"_INITIALS_"^"_DUZACQ_"^"_DUZACQ_"^"_ACQSITE ; DUZacq=DUZread
175 . Q
176 E I IFCSITE D ; remotely completed IFC
177 . S FULLNAME=$$GET1^DIQ(123.02,SUBFILE,.22) ; remote responsible person
178 . ; look up resulter in file 200 - check for >1 people with same name
179 . S DUZACQ=$O(^VA(200,"B",FULLNAME,""))
180 . I DUZACQ,$O(^VA(200,"B",FULLNAME,DUZACQ)) S DUZACQ="" ; same name
181 . S INITIALS=$$GET1^DIQ(200,DUZACQ,1) ; initials
182 . ; DUZread (piece 4) is not known - set to null
183 . S X=FULLNAME_"^"_INITIALS_"^"_DUZACQ_"^^"_IFCSITE
184 . Q
185 E S X="^^^^" ; problem with cprs consult
186 S $P(^MAG(2006.5849,UNREAD,0),"^",12,16)=X ; reader identification
187 N % D NOW^%DTC S $P(^MAG(2006.5849,UNREAD,0),"^",19)=% ; Record Repair TimeStamp in piece 19 Field #18
188 D EXREF(UNREAD,TIMESTMP) ; set "E" cross-reference
189 Q
190 ;
191TIUNOTE ; create a TIU result note, if one is not present
192 N DUZ ; this is called by the HL7 - DUZ and DUZ(2) are not set
193 N MAGDFN,MAGTEXT,MAGTITLE,UNREAD,XECUTE,ZZ
194 Q:'$D(HLNEXT) ; only create TIU result note for IFCs
195 Q:'$$FINDLIST^MAGDTR01(GMRCIEN,,,,,.MAGTITLE)
196 S UNREAD=$$UNREAD^MAGDTR02(GMRCIEN) Q:'UNREAD
197 S MAGTEXT(1)="Please refer to Inter-facility Consult for results."
198 S MAGTEXT(2)=""
199 S MAGTEXT(3)="Automatically generated note - signature not required."
200 S DUZ=$P(^MAG(2006.5849,UNREAD,0),"^",14) Q:'DUZ ; get DUZacq
201 S DUZ(0)="@",DUZ(2)=LOCATION ; get reading site ien
202 S MAGDFN=$$GET1^DIQ(123,GMRCIEN,.02,"I")
203 D NEW^MAGGNTI1(.ZZ,MAGDFN,MAGTITLE,1,"E",,DUZ,,,GMRCIEN,.MAGTEXT)
204 Q
205 ;
Note: See TracBrowser for help on using the repository browser.