source: WorldVistAEHR/trunk/r/IMAGING-MAG-ZMAG/MAGDRTIM.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: 4.2 KB
Line 
1MAGDRTIM ;WOIFO/EdM - Routing Statistics ; 02/05/2004 08:45
2 ;;3.0;IMAGING;**11**;14-April-2004
3 ;; +---------------------------------------------------------------+
4 ;; | Property of the US Government. |
5 ;; | No permission to copy or redistribute this software is given. |
6 ;; | Use of unreleased versions of this software requires the user |
7 ;; | to execute a written test agreement with the VistA Imaging |
8 ;; | Development Office of the Department of Veterans Affairs, |
9 ;; | telephone (301) 734-0100. |
10 ;; | |
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 ;
20AVERAGE ;
21 N D0,D1
22 N DEST ;--- Destination where file is sent to
23 N PARENT ;- Parent Image
24 N PROC ;--- Procedure (closest to "Modality")
25 N SEC ;---- Stop time converted to seconds
26 N START ;-- Timestamp when transmission started
27 N STOP ;--- Timestamp when transmission completed
28 N TIME ;--- Duration of transmission
29 N TYP ;---- Type of tile (TXT, FULL, ABS, ...)
30 N X ;------ Scratch
31 ;
32 K ^TMP("MAG",$J,"RTTIM")
33 S DEST="" F S DEST=$O(^MAG(2005,"ROUTE",DEST)) Q:DEST="" D
34 . S STOP="" F S STOP=$O(^MAG(2005,"ROUTE",DEST,STOP)) Q:STOP="" D
35 . . Q:'STOP
36 . . S SEC=$$SEC(STOP)
37 . . S D0="" F S D0=$O(^MAG(2005,"ROUTE",DEST,STOP,D0)) Q:D0="" D
38 . . . S X=$G(^MAG(2005,D0,0))
39 . . . S PROC=$P(X,"^",8) S:PROC="" PROC="?"
40 . . . S PARENT=$P(X,"^",10) S:'PARENT PARENT=D0
41 . . . S ^TMP("MAG",$J,"RTTIM",PROC,DEST,PARENT,2)=$G(^TMP("MAG",$J,"RTTIM",PROC,DEST,PARENT,2))+1
42 . . . S D1="" F S D1=$O(^MAG(2005,"ROUTE",DEST,STOP,D0,D1)) Q:D1="" D
43 . . . . S X=$G(^MAG(2005,D0,4,D1,0)) Q:X=""
44 . . . . S START=$P(X,"^",5) Q:'START
45 . . . . S TIME=SEC-$$SEC(START) S:TIME<0 TIME=TIME+86400
46 . . . . S ^TMP("MAG",$J,"RTTIM",PROC,DEST,PARENT,1)=$G(^TMP("MAG",$J,"RTTIM",PROC,DEST,PARENT,1))+TIME
47 . . . . Q
48 . . . Q
49 . . Q
50 . Q
51 S PROC="" F S PROC=$O(^TMP("MAG",$J,"RTTIM",PROC)) Q:PROC="" D
52 . S DEST="" F S DEST=$O(^TMP("MAG",$J,"RTTIM",PROC,DEST)) Q:DEST="" D
53 . . N IMAGE
54 . . S (TIME,IMAGE)=0
55 . . S D0="" F S D0=$O(^TMP("MAG",$J,"RTTIM",PROC,DEST,D0)) Q:D0="" D
56 . . . S X=$G(^TMP("MAG",$J,"RTTIM",PROC,DEST,D0,1)) Q:'X
57 . . . S TIME=TIME+X,IMAGE=IMAGE+^TMP("MAG",$J,"RTTIM",PROC,DEST,D0,2)
58 . . . Q
59 . . Q:'IMAGE
60 . . W !,"Sending ",IMAGE," ",PROC," image" W:IMAGE'=1 "s"
61 . . W " to ",$P($G(^MAG(2005.2,DEST,0),"#"_DEST),"^",1)," took "
62 . . S X=$$HMS(TIME)
63 . . W X,"."
64 . . W !?5,$$HMS(TIME*100\IMAGE)," per 100 images."
65 . . Q
66 . Q
67 K ^TMP("MAG",$J,"RTTIM")
68 Q
69 ;
70HMS(T) N H,M,S,X
71 S H=T\3600,M=T\60#60,S=T#60,X=""
72 I H S X=H_" hour" S:H'=1 X=X_"s"
73 I M S:X'="" X=X_"; |" S X=X_M_" minute" S:M'=1 X=X_"s"
74 I S S:X'="" X=$TR(X,";|",",")_" |" S X=X_S_" second" S:S'=1 X=X_"s"
75 S:X["|" X=$P($TR(X,";"),"|",1)_"and "_$P(X,"|",2)
76 Q X
77 ;
78SEC(DT) N R,X
79 S X=DT-(DT\1)*1000000,R=X\10000,R=R*60+(X\100#100),R=R*60+(X#100)
80 Q R
81 ;
82TRANSID(OUT,LOC) ; RPC = MAG DICOM ROUTE GET TRANS ID
83 N PLACE,SITE,X
84 S PLACE=$S($G(LOC):$O(^MAG(2006.1,"B",LOC,"")),1:0)
85 S:'PLACE PLACE=$O(^MAG(2006.1,0))
86 S X=$G(^MAG(2006.1,PLACE,0)),SITE=$P(X,"^",9)
87 S:SITE="" SITE=$P(X,"^",2)
88 S:SITE="" SITE="!"
89 ;
90 L +^MAG(2006.1,PLACE,"TRANSACTION")
91 S OUT=$G(^MAG(2006.1,PLACE,"TRANSACTION"))+1
92 S ^MAG(2006.1,PLACE,"TRANSACTION")=OUT
93 L -^MAG(2006.1,PLACE,"TRANSACTION")
94 S OUT=SITE_$TR($J(OUT,12)," ",0)
95 Q
96 ;
97TRANSTS(OUT,TRANSID) ; RPC = MAG DICOM ROUTE TRANSACT STS
98 N CNT,D0,STS
99 I $G(TRANSID)="" S OUT="-1,No Transaction ID Specified" Q
100 I '$D(^MAGQUEUE(2006.035,"ID",TRANSID)) S OUT="-2,Invalid Transaction ID" Q
101 S D0="" F S D0=$O(^MAGQUEUE(2006.035,"ID",TRANSID,D0)) Q:D0="" D
102 . S STS=$P($G(^MAGQUEUE(2006.035,D0,1)),"^",1) S:STS="" STS="?"
103 . S CNT(STS)=$G(CNT(STS))+1
104 . Q
105 S OUT="" F STS="WAITING","SENDING","SENT","FAILED","?" D
106 . S OUT=OUT_$G(CNT(STS))_"="_STS_"^"
107 . Q
108 Q
109 ;
Note: See TracBrowser for help on using the repository browser.