source: WorldVistAEHR/trunk/r/IMAGING-MAG-ZMAG/MAGBRTUT.m@ 1800

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

initial load of WorldVistAEHR

File size: 6.8 KB
RevLine 
[613]1MAGBRTUT ;WOIFO/EdM - Routing Utilities ; 12/15/2006 13:50
2 ;;3.0;IMAGING;**9,11,30,51,50,85**;16-March-2007;;Build 1039
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
19 ;
20SEND(IMAGE,LOC,PRI,MECH,FROM,ID) ; Enter image into Routing Queue
21 ; IMAGE ;---- Internal Entry Number in Image FIle
22 ; LOC ;------ Internal Entry Number in either Network Location file
23 ; or SCU_List file
24 ; PRI ;------ Priority
25 ; MECHanism = 1: Send using MS-DOS-Copy
26 ; = 2: Send using DICOM_Send
27 ; FROM ;----- Location from which request originates
28 ; ID ;------- Transaction ID
29 N D0 ;------- Internal Entry number
30 N FLAG ;----- List of file-types to transmit
31 N I ;-------- Scratch and loop counter
32 N ORIGIN ;--- Location from which image is being sent (IEN in Institution file)
33 N QQ ;------- List of queue-entries created
34 ;
35 S QQ="",MECH=$G(MECH) S:'MECH MECH=1
36 I '$D(^MAG(2005,+$G(IMAGE))) Q:$Q QQ Q
37 I MECH=1,'$D(^MAG(2005.2,+$G(LOC))) Q:$Q QQ Q
38 I MECH=2,'$D(^MAG(2006.587,+$G(LOC))) Q:$Q QQ Q
39 I MECH'=1,MECH'=2 Q:$Q QQ Q
40 S:MECH=1 LOC=(+LOC)_";MAG(2005.2,"
41 S:MECH=2 LOC=(+LOC)_";MAG(2006.587,"
42 ;
43 S ORIGIN=$G(FROM) D:'ORIGIN
44 . S ORIGIN=$P($G(^MAG(2005,IMAGE,100)),"^",3)
45 . S:'ORIGIN ORIGIN=$G(DUZ(2))
46 . S:'ORIGIN ORIGIN=$$KSP^XUPARAM("INST")
47 . Q
48 ;
49 S PRI=$G(PRI,500),ID=$G(ID)
50 S FLAG=$G(^MAG(2005.2,+LOC,1)) S:MECH=2 FLAG="^^^^5"
51 ;
52 I MECH=2 D Q:$Q QQ Q
53 . ; Stopgap until "native DICOM" storage is supported
54 . N APPNAM
55 . S APPNAM=$P($G(^MAG(2006.587,+LOC,0)),"^",1)
56 . D QUEUE^MAGDRPC3(.QQ,IMAGE,APPNAM,ORIGIN,"","6: Copy to HIPAA Compliant Storage",,PRI)
57 . Q
58 ;
59 F I=1:1:5 D:$P(FLAG,"^",I)
60 . N D0,T,X
61 . S T=$P("ABSTRACT FULL BIG TEXT DICOM"," ",I)
62 . ;
63 . S D0=$O(^MAGQUEUE(2006.035,"DEST",LOC,"WAITING",IMAGE,T,"")) I D0 D Q
64 . . N O,P,T,X0,X1
65 . . S X0=$G(^MAGQUEUE(2006.035,D0,0)),O=$P(X0,"^",5),T=$P(X0,"^",6)
66 . . S X1=$G(^MAGQUEUE(2006.035,D0,1)),P=$P(X1,"^",2)
67 . . ; Don't send multiple copies, but do increase priority if needed
68 . . Q:PRI'>P
69 . . S $P(X0,"^",5)=ORIGIN,^MAGQUEUE(2006.035,D0,0)=X0
70 . . I T'=ID,ID'="" D
71 . . . S $P(X0,"^",6)=ID
72 . . . S ^MAGQUEUE(2006.035,D0,0)=X0
73 . . . K:O'="" ^MAGQUEUE(2006.035,"ID",T,D0)
74 . . . S ^MAGQUEUE(2006.035,"ID",ID,D0)=""
75 . . . Q
76 . . S $P(X1,"^",2)=PRI,^MAGQUEUE(2006.035,D0,1)=X1
77 . . K:O ^MAGQUEUE(2006.035,"STS",O,"WAITING",P,LOC,D0)
78 . . S ^MAGQUEUE(2006.035,"STS",ORIGIN,"WAITING",PRI,LOC,D0)=""
79 . . Q
80 . ;
81 . L +^MAGQUEUE(2006.035,0)
82 . S D0=$O(^MAGQUEUE(2006.035," "),-1)+1
83 . S X=$G(^MAGQUEUE(2006.035,0))
84 . S $P(X,"^",1,2)="SEND QUEUE^2006.035"
85 . S $P(X,"^",3)=D0
86 . S $P(X,"^",4)=$P(X,"^",4)+1
87 . S ^MAGQUEUE(2006.035,0)=X
88 . S X=IMAGE_"^"_LOC_"^"_T_"^"_MECH_"^"_ORIGIN_"^"_ID
89 . S:ID'="" ^MAGQUEUE(2006.035,"ID",ID,D0)=""
90 . S ^MAGQUEUE(2006.035,D0,0)=X
91 . D NOW^%DTC
92 . S ^MAGQUEUE(2006.035,D0,1)="WAITING^"_PRI_"^"_%
93 . S ^MAGQUEUE(2006.035,"STS",ORIGIN,"WAITING",PRI,LOC,D0)=""
94 . S ^MAGQUEUE(2006.035,"DEST",LOC,"WAITING",IMAGE,T,D0)=""
95 . L -^MAGQUEUE(2006.035,0)
96 . S QQ=QQ_D0_"^"
97 . Q
98 Q:$Q QQ Q
99 ;
100DCMLIST(OUT,LOCATION) N D0,LO,LST,N,NM,X
101 S LOCATION=+$G(LOCATION)
102 S D0=0 F S D0=$O(^MAG(2006.587,D0)) Q:'D0 D
103 . S X=$G(^MAG(2006.587,D0,0))
104 . S NM=$P(X,"^",1),LO=$P(X,"^",7) Q:NM=""
105 . I LOCATION,LO,LO'=LOCATION Q
106 . S LST(NM,LO)=D0
107 . Q
108 S N=1,NM="" F S NM=$O(LST(NM)) Q:NM="" D
109 . S LO="",X=0 F S LO=$O(LST(NM,LO)) Q:LO="" S X=X+1,D0=LST(NM,LO)
110 . I X=1 S N=N+1,OUT(N)=NM_"^"_D0 Q
111 . S LO="" F S LO=$O(LST(NM,LO)) Q:LO="" S N=N+1,OUT(N)=NM_" ("_LO_")^"_LST(NM,LO)
112 . Q
113 S OUT(1)=N-1
114 Q
115 ;
116EVALPU(OUT,UNTIL) ; RPC = MAG DICOM ROUTE EVAL PURGE
117 N D0,MORE,N,P1,P4,P5,P6,P7,P8,TIME
118 S TIME=$$STAMP($H)+55,N=0,MORE=0
119 L +^MAGQUEUE(2006.03,0):19 ; Background process must wait
120 S D0="" F S D0=$O(^MAGQUEUE(2006.03,"B","EVAL",D0)) Q:D0="" D Q:MORE
121 . S X=$G(^MAGQUEUE(2006.03,D0,0))
122 . S P4=$P(X,"^",4),P6=$P(X,"^",6)
123 . S:P6 P4=-1
124 . Q:P4>UNTIL
125 . I $$STAMP($H)>TIME S MORE=1 Q
126 . S N=N+1,P1=$P(X,"^",1),P5=$P(X,"^",5),P7=$P(X,"^",7),P8=$P(X,"^",8)
127 . I P1'="" K ^MAGQUEUE(2006.03,"B",P1,D0)
128 . I P5'="" K ^MAGQUEUE(2006.03,"C",P5,D0)
129 . I P7'="",P8'="" K ^MAGQUEUE(2006.03,"JD",P7,P8,D0)
130 . I P7'="" K ^MAGQUEUE(2006.03,"JX",P7,D0)
131 . K ^MAGQUEUE(2006.03,D0)
132 . Q
133 S X=$G(^MAGQUEUE(2006.03,0))
134 S P1=$P(X,"^",4)-N S:P1<1 P1=0 S $P(X,"^",4)=P1
135 S $P(X,"^",1,2)="IMAGE BACKGROUND QUEUE^2006.03"
136 S ^MAGQUEUE(2006.03,0)=X
137 L -^MAGQUEUE(2006.03,0)
138 S OUT=N_"^"_MORE
139 Q
140 ;
141STAMP(H) Q H*86400+$P(H,",",2)
142 ;
143RENAME(OUT,OLD,NEW,KEY) ; RPC = MAG DICOM XMIT RENAME GATEWAY
144 N D0,ID,LOC,SVC,N,X
145 I $G(OLD)="" S OUT="-1,No previous Gateway name specified" Q
146 I $G(NEW)="" S OUT="-2,No new Gateway name specified" Q
147 S:'$G(KEY) KEY=5
148 I KEY'=5,KEY'=6 S OUT="-3,Invalid key specified ("_KEY_")" Q
149 ;
150 S (N,D0)=0 F S D0=$O(^MAG(2006.587,D0)) Q:'D0 D
151 . S X=$G(^MAG(2006.587,D0,0)),ID=$P(X,"^",KEY) Q:ID'=OLD
152 . S N=N+1
153 . S $P(X,"^",KEY)=NEW
154 . Q:KEY'=5
155 . S LOC=$P(X,"^",7),SVC=$P(X,"^",1)
156 . I LOC'="",SVC'="" K ^MAG(2006.587,"C",SVC,OLD,LOC,D0)
157 . I LOC'="" K ^MAG(2006.587,"D",OLD,LOC,D0)
158 . I LOC'="",SVC'="" S ^MAG(2006.587,"C",SVC,NEW,LOC,D0)=""
159 . I LOC'="" S ^MAG(2006.587,"D",NEW,LOC,D0)=""
160 . Q
161 S OUT=N_" entr"_$S(N=1:"y",1:"ies")_" renamed"
162 Q
163 ;
164REMOVE(OUT,OLD,KEY) ; RPC = MAG DICOM XMIT REMOVE GATEWAY
165 N D0,ID,LOC,SVC,N,T,X
166 I $G(OLD)="" S OUT="-1,No Gateway name specified" Q
167 S:'$G(KEY) KEY=5
168 I KEY'=5,KEY'=6 S OUT="-3,Invalid key specified ("_KEY_")" Q
169 ;
170 L +^MAG(2006.587,0):19 ; Background process MUST wait
171 S (N,D0)=0 F S D0=$O(^MAG(2006.587,D0)) Q:'D0 D
172 . S X=$G(^MAG(2006.587,D0,0)),ID=$P(X,"^",KEY) Q:ID'=OLD
173 . S N=N+1
174 . S LOC=$P(X,"^",7),SVC=$P(X,"^",1)
175 . I LOC'="",SVC'="" K ^MAG(2006.587,"C",SVC,OLD,LOC,D0)
176 . I LOC'="" K ^MAG(2006.587,"D",OLD,LOC,D0)
177 . I SVC'="" K ^MAG(2006.586,"B",SVC,D0)
178 . K ^MAG(2005.676,D0)
179 . Q
180 S X=$G(^MAG(2006.587,0))
181 S $P(X,"^",1,2)="DICOM TRANSMIT DESTINATION^2006.587"
182 S $P(X,"^",3)=$O(^MAG(2006.587," "),-1)
183 S T=$P(X,"^",4)-N S:T<1 T="" S $P(X,"^",4)=T
184 S ^MAG(2006.587,0)=X
185 L -^MAG(2006.587,0)
186 S OUT=N_" entr"_$S(N=1:"y",1:"ies")_" removed"
187 Q
188 ;
Note: See TracBrowser for help on using the repository browser.