source: WorldVistAEHR/trunk/r/IMAGING-MAG-ZMAG/MAGQE3.m@ 1150

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

initial load of WorldVistAEHR

File size: 9.5 KB
Line 
1MAGQE3 ;WOIFO/RMP - Support for MAG Enterprise ; 05/06/2004 06:32
2 ;;3.0;IMAGING;**27,29,30,20,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
19 ;
20COUNT(SDATE,EDATE,INST,AI,IQ,DUP,TIOP,TGPP,TIEDP,GRPPRNT,IMAGE,DELETED) ;
21 N CLIN,CONSENTS,CPTR,D0,DAT,DICOM,DOC,DOCGRP,DOCUMENT,ED0,I,IMPORT
22 N NAME,OTHER,PCE,PROC,SD0,TRK,ZNODE,CNODE
23 S SD0=$$SDATE^MAGQE1(SDATE,"F")
24 S ED0=$$SDATE^MAGQE1(EDATE,"R")
25 S D0="" F S D0=$O(^MAG(2005.02,"B","DOCUMENT",D0)) Q:D0="" D
26 . S:$G(^MAG(2005.02,D0,4))["TIF" DOC(D0)=""
27 . Q
28 S (CONSENTS,GRPPRNT,IMAGE,DELETED,DOCGRP,DOCUMENT,DUP,TIOP,TGPP,TIEDP)=0
29 S IQ="0^0^0"
30 S CPTR=$O(^MAG(2005.83,"B","CONSENT",""))
31 S D0=SD0 F S D0=$O(^MAG(2005,D0)) Q:'D0 Q:D0'<ED0 D
32 . S CNODE=$G(^MAG(2005,D0,100))
33 . S PCE=$P(CNODE,"^",3) Q:((PCE'=INST)&(AI'[("^"_PCE_"^")))
34 . S ZNODE=$G(^MAG(2005,D0,0))
35 . I $P(ZNODE,"^",2)="" S TGPP=TGPP+1 ;TOTAL FILE WIDE by Place
36 . E S TIOP=TIOP+1
37 . S X=$P($G(^MAG(2005,D0,2)),"^",1)\1 Q:'X Q:X<SDATE Q:X>EDATE
38 . S:$P(ZNODE,U,12) DUP=DUP+1
39 . S:($P(ZNODE,U,11)="") $P(IQ,U,1)=$P(IQ,U,1)+1
40 . S:($P(ZNODE,U,11)="0") $P(IQ,U,2)=$P(IQ,U,2)+1
41 . S:($P(ZNODE,U,11)="1") $P(IQ,U,3)=$P(IQ,U,3)+1
42 . S PCE=$P(CNODE,"^",5),TRK="" I PCE'="" D
43 . . S TRK=$P($G(^MAG(2006.04,$P(CNODE,U,4),0)),U)
44 . . S TRK=$S(TRK'="":TRK,1:"?") Q
45 . I $P(ZNODE,"^",2)="" D Q
46 . . S GRPPRNT=GRPPRNT+1
47 . . S PCE=$P(ZNODE,"^",8) S:PCE="" PCE="NIL"
48 . . S:$D(^MAG(2005,D0,"PACS")) DICOM(PCE,0)=$G(DICOM(PCE,0))+1
49 . . S PCE=$P(ZNODE,"^",6) I PCE,$D(DOC(PCE)) S DOCGRP=DOCGRP+1
50 . . S:TRK'="" IMPORT(TRK,0)=$G(IMPORT(TRK,0))+1
51 . . Q
52 . S:TRK'="" IMPORT(TRK)=$G(IMPORT(TRK))+1
53 . I CPTR,$P($G(^MAG(2005,D0,40)),"^",3)=CPTR S CONSENTS=CONSENTS+1
54 . E S PCE=$$UPPER^MAGQE4($P($G(^MAG(2005,D0,2)),"^",4)) S:PCE["CONSENT" OTHER(PCE)=$G(OTHER(PCE))+1
55 . S IMAGE=IMAGE+1
56 . S PCE=$P(ZNODE,"^",6) I PCE,$D(DOC(PCE)) S DOCUMENT=DOCUMENT+1
57 . S PCE=$P(ZNODE,"^",7) S:PCE="" PCE="NIL"
58 . S ^TMP($J,"MAGQ","ACQPAT",PCE)=""
59 . S ^TMP($J,"MAGQ","ALLPAT",PCE)=""
60 . S PCE=$P(ZNODE,"^",8) S:PCE="" PCE="NIL"
61 . I $D(^MAG(2005,D0,"PACS")) S DICOM(PCE)=$G(DICOM(PCE))+1
62 . E S CLIN(PCE)=$G(CLIN(PCE))+1
63 . Q
64 S NAME="" F S NAME=$O(DICOM(NAME)) Q:NAME="" D
65 . D:$E(NAME,1,4)="RAD "
66 . . Q:'$D(DICOM(NAME,0))
67 . . S I=$E(NAME,5,$L(NAME)) Q:I=""
68 . . Q:$D(DICOM(I,0))
69 . . S DICOM(I,0)=DICOM(NAME,0) K DICOM(NAME,0) Q
70 . S PROC=$O(^RAMIS(73.1,"B",NAME,"")) Q:'PROC
71 . S $P(DICOM(NAME),"^",2)=$P($G(^RAMIS(73.1,PROC,0)),"^",2) Q
72 S D0=SD0 F S D0=$O(^MAG(2005.1,D0)) Q:'D0 Q:D0'<ED0 D
73 . S PCE=$P($G(^MAG(2005.1,D0,100)),"^",3) Q:((PCE'=INST)&(AI'[("^"_PCE_"^")))
74 . S TIEDP=TIEDP+1
75 . S X=$P($G(^MAG(2005.1,D0,2)),"^",1)\1 Q:'X Q:X<SDATE Q:X>EDATE
76 . S DELETED=DELETED+1 Q
77 S I="" F S I=$O(DICOM(I)) Q:I="" D
78 . S X=" DICOM CAPTURE: "_I_"^"_$G(DICOM(I))
79 . S:$G(DICOM(I,0)) $P(X,"^",4)=DICOM(I,0)
80 . D MSG^MAGQE2(X) Q
81 S I="" F S I=$O(IMPORT(I)) Q:I="" D
82 . S X=" IMPORT API: "_I_"^"_IMPORT(I)
83 . S:$G(IMPORT(I,0)) X=X_"^"_IMPORT(I,0)
84 . D MSG^MAGQE2(X) Q
85 D LLOAD^MAGQE5(.CLIN,"CLIN CAPTURE:")
86 D MSG^MAGQE2("CONSENT FORMS: "_CONSENTS)
87 D LLOAD^MAGQE5(.OTHER,"OTHER CONSENTS:")
88 D MSG^MAGQE2("Document Images (TIF): "_DOCUMENT)
89 D MSG^MAGQE2("Document Groups (TIF): "_DOCGRP)
90 Q
91 ;
92ACT(D0,DIS,CAP,VD,VI,RES) ;
93 N ACT,AN,AN2,D1,IMG
94 S D1=0 F S D1=$O(^MAG(2006.82,D0,"ACT",D1)) Q:'D1 D
95 . S AN=^MAG(2006.82,D0,"ACT",D1,0)
96 . S ACT="^"_$P(AN,"^",1)_"^",AN2=+$P(AN,"^",2)
97 . Q:"^LOGON^LOGOFF^PAT^"[ACT
98 . I "^SC_BAD^SCR_OK^"[ACT D Q
99 . . S AN=$P(AN,"^",10,14) Q:AN=""
100 . . S RES(ACT,AN)=$G(RES(ACT,AN))+1 Q
101 . I "^CAP^IMG^"[ACT D Q
102 . . S IMG=+$P(AN,"^",3) Q:'IMG Q:$P($G(^MAG(2005,IMG,0)),"^",2)=""
103 . . I ACT="^CAP^" S CAP=CAP+1 Q
104 . . S DIS=DIS+1,^TMP($J,"MAGQ","DISPAT",AN2)="",^TMP($J,"MAGQ","ALLPAT",AN2)=""
105 . . Q
106 . I "^VR-VW^"[ACT D VRAD(.VD,AN) S ^TMP($J,"MAGQ","DISPAT",AN2)="",^TMP($J,"MAGQ","ALLPAT",AN2)="" Q
107 . I "^VR-INT^"[ACT D VRAD(.VI,AN) S ^TMP($J,"MAGQ","DISPAT",AN2)="",^TMP($J,"MAGQ","ALLPAT",AN2)="" Q
108 . Q
109 Q
110 ;
111VRAD(ARR,AN) ;
112 ;ARR=STUDIES^IMAGES^PATIENTS^User Type(Rad/Non-Rad)^Remotes(Remote/Local)^Modalities
113 N P,X
114 S $P(ARR,"^",1)=$P($G(ARR),"^",1)+1 ; Studies
115 S $P(ARR,"^",2)=$P($G(ARR),"^",2)+$P(AN,"^",6) ; Images
116 S $P(ARR,"^",3)=$P($G(ARR),"^",3)+$P(AN,"^",7) ; Patients
117 S P=$P(ARR,"^",4)
118 I +$P(AN,"^",8)=1 S $P(P,"/",1)=$P(P,"/",1)+1
119 E S $P(P,"/",2)=$P(P,"/",2)+1
120 S $P(ARR,"^",4)=P ; User Type
121 S P=$P(ARR,"^",5)
122 I +$P(AN,"^",9)=1 S $P(P,"/",1)=$P(P,"/",1)+1
123 E S $P(P,"/",2)=$P(P,"/",2)+1
124 S $P(ARR,"^",5)=P ; Remotes
125 S P=$P(AN,"^",4) S:P="" P="unknown"
126 S ARR(P)=$G(ARR(P))+1
127 S (P,X)="" F S P=$O(ARR(P)) Q:P="" S X=X_"/"_P_"="_ARR(P)
128 S $P(ARR,"^",6)=X ; Modalities
129 Q
130 ;
131GPACHX() ; Get Package File Install History of Imaging
132 N I,LCNT,MSG,PKG,PKT,PV
133 S LCNT=0
134 F PKG="IMAGING","MAGJ RADIOLOGY" D
135 . N J,K,L,PKNAM,VERS
136 . S J=$$FIND1^DIC(9.4,",","MX",PKG) Q:'J
137 . I PKG="MAGJ RADIOLOGY" D Q
138 . . N TAR
139 . . D LIST^DIC(9.49,","_J_",","@;.01;2;3","","","","","","","","TAR","MSG")
140 . . Q:$D(MSG("DIERR"))
141 . . S L=0 F S L=$O(TAR("DILIST","ID",L)) Q:'L D
142 . . . S LCNT=LCNT+1
143 . . . S PV(LCNT)=PKG_"^P"_$P(TAR("DILIST","ID",L,".01"),"^",1)
144 . . . S PV(LCNT)=PV(LCNT)_"^"_$P(TAR("DILIST","ID",L,"2"),"^",1)
145 . . . S PV(LCNT)=PV(LCNT)_"^"_$P(TAR("DILIST","ID",L,"3"),"^",1) Q
146 . . Q
147 . K PKT D LIST^DIC(9.49,","_J_",",.01,"","*","","","B","","","PKT","MSG")
148 . S VERS="" F S VERS=$O(PKT("DILIST",2,VERS)) Q:VERS="" S K=PKT("DILIST",2,VERS) D
149 . . K MSG
150 . . D LIST^DIC(9.4901,","_K_","_J_",","@;.01;.02;.03","","","","","","","","TAR","MSG")
151 . . Q:$D(MSG("DIERR"))
152 . . S L=0 F S L=$O(TAR("DILIST","ID",L)) Q:'L D
153 . . . S LCNT=LCNT+1
154 . . . S PV(LCNT)=PKG_"^"_VERS_"P"_$P(TAR("DILIST","ID",L,".01"),"^",1)
155 . . . S PV(LCNT)=PV(LCNT)_"^"_$P(TAR("DILIST","ID",L,".02"),"^",1)
156 . . . S PV(LCNT)=PV(LCNT)_"^"_$P(TAR("DILIST","ID",L,".03"),"^",1) Q
157 . . Q
158 . Q
159 S I="" F S I=$O(PV(I)) Q:I="" D
160 . D MSG^MAGQE2("IMAGING PACKAGE INSTALLATION HX: "_I_"^"_PV(I)) Q
161 Q
162 ;
163ADCNT(SDATE,EDATE,INST,AI) ;
164 ; SAC = Scanned, Administrative Closure SMC = Scanned, Manual Closure UMC = Unscanned, Manual Closure
165 N ARRY,D0,D1,DATE,DATES,DOC,HLOC,SAC,SCR,SMC,STAT,STATA,STATC,TITLE,TIUDA,UMC
166 S STATA="^",D0=0 F S D0=$O(^TIU(8925.6,"B","AMENDED",D0)) Q:'D0 D
167 . S STATA=STATA_D0_"^" Q
168 S STATC="^",D0=0 F S D0=$O(^TIU(8925.6,"B","COMPLETED",D0)) Q:'D0 D
169 . S STATC=STATC_D0_"^" Q
170 S DOC="ADVANCE DIRECTIVE"
171 S D0=0 F S D0=$O(^TIU(8925.1,"B",DOC,D0)) Q:'D0 D
172 . Q:$P($G(^TIU(8925.1,D0,0)),"^",4)'="DC"
173 . S D1=0 F S D1=$O(^TIU(8925.1,D0,10,"B",D1)) Q:'D1 D
174 . . S TITLE=$P($G(^TIU(8925.1,+D1,0)),"^",1) S:TITLE="" TITLE=" "
175 . . S ARRY(TITLE,D1)="" Q
176 . Q
177 S SCR="",(SAC,SMC,UMC)=0
178 S TITLE="" F S TITLE=$O(ARRY(TITLE)) Q:TITLE="" D
179 . S D1="" F S D1=$O(ARRY(TITLE,D1)) Q:D1="" D
180 . . S TIUDA=0 F S TIUDA=$O(^TIU(8925,"B",D1,TIUDA)) Q:'TIUDA D
181 . . . N MSG,TARGET
182 . . . S SCR="" ; INSTITUTION screen for consolidation sites only.
183 . . . D GETS^DIQ(8925,TIUDA,".05;1205;1501;1507;1603;1606;1613","IE","TARGET","MSG")
184 . . . Q:$D(MSG("DIERR"))
185 . . . I $$CONSOLID^MAGQE5() D Q:SCR
186 . . . . S HLOC=TARGET(8925,TIUDA_",",1205,"I") ; INSTITUTION screen - dependent upon TIU*1*113
187 . . . . I HLOC="" S SCR=1
188 . . . . E I (($P($G(^SC(HLOC,0)),"^",4)'=INST)&(AI'[("^"_$P($G(^SC(HLOC,0)),"^",4)_"^"))) S SCR=1
189 . . . . Q
190 . . . S STAT="^"_TARGET(8925,TIUDA_",",.05,"I")_"^"
191 . . . Q:STATA_STATC'[STAT
192 . . . I TARGET(8925,TIUDA_",",1613,"I")="S" D Q
193 . . . . Q:TARGET(8925,TIUDA_",",1606,"I")<SDATE
194 . . . . Q:$P(TARGET(8925,TIUDA_",",1606,"I"),".")>EDATE
195 . . . . S SAC=SAC+1,SAC(TITLE)=$G(SAC(TITLE))+1 Q
196 . . . I STATC[STAT D Q
197 . . . . S DATE=TARGET(8925,TIUDA_",",1507,"I")
198 . . . . S DATE=$S(DATE?1.N:DATE,1:+TARGET(8925,TIUDA_",",1501,"I"))
199 . . . . Q:DATE<SDATE
200 . . . . Q:$P(DATE,".")>EDATE
201 . . . . I $$SCAN(TIUDA) S SMC=SMC+1,SMC(TITLE)=$G(SMC(TITLE))+1 Q
202 . . . . S UMC=UMC+1,UMC(TITLE)=$G(UMC(TITLE))+1 Q
203 . . . I STATA[STAT D Q
204 . . . . Q:TARGET(8925,TIUDA_",",1603,"I")<SDATE
205 . . . . Q:$P(TARGET(8925,TIUDA_",",1603,"I"),".")>EDATE
206 . . . . I $$SCAN(TIUDA) S SMC=SMC+1,SMC(TITLE)=$G(SMC(TITLE))+1 Q
207 . . . . S UMC=UMC+1,UMC(TITLE)=$G(UMC(TITLE))+1 Q
208 . . . Q
209 . . Q
210 . Q
211 D MSG^MAGQE2(DOC_" SCANNED ADMINISTRATIVE CLOSURE: "_SAC)
212 S TITLE="" F S TITLE=$O(SAC(TITLE)) Q:TITLE="" D
213 . D MSG^MAGQE2(DOC_" - SAC - "_TITLE_": "_SAC(TITLE)) Q
214 D MSG^MAGQE2(DOC_" UNSCANNED MANUAL CLOSURE: "_UMC)
215 S TITLE="" F S TITLE=$O(UMC(TITLE)) Q:TITLE="" D
216 . D MSG^MAGQE2(DOC_" - UMC - "_TITLE_": "_UMC(TITLE)) Q
217 D MSG^MAGQE2(DOC_" SCANNED MANUAL CLOSURE: "_SMC)
218 S TITLE="" F S TITLE=$O(SMC(TITLE)) Q:TITLE="" D
219 . D MSG^MAGQE2(DOC_" - SMC - "_TITLE_": "_SMC(TITLE)) Q
220 Q
221 ;
222SCAN(IEN) ;
223 N LINK
224 S LINK=$O(^TIU(8925.91,"B",IEN,"")) Q:'LINK 0
225 Q $S($P($G(^TIU(8925.1,LINK,0)),"^",2)?1.N:0,1:1)
226 ;
Note: See TracBrowser for help on using the repository browser.