source: WorldVistAEHR/trunk/r/IMAGING-MAG-ZMAG/MAGGSIU3.m@ 1604

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

initial load of WorldVistAEHR

File size: 5.1 KB
Line 
1MAGGSIU3 ;WOIFO/GEK - Utilities
2 ;;3.0;IMAGING;**7,8,48**;Jan 11, 2005
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
19LOG(MAGRY,MAGIX,IMAGES,PAT,WRKS,TRKID) ;Utilities for Import API, logging data for tracking and debugging
20 ; into Imaging Windows Session and Imaging Windows Workstation files.
21 N WRKSIEN,WRKSN0,USERSRV,MAGSTART,I,SESSIEN,X,Z,DIERR
22 I '$L($G(WRKS)) S WRKS="NULL WORKSTATION NAME"
23 S WRKSIEN=0
24 S SESSIEN=0
25 S WRKSIEN=$O(^MAG(2006.81,"B",WRKS,""))
26 I 'WRKSIEN D NEWWRKS^MAGGTAU(WRKS,"",.WRKSIEN) I WRKSIEN<1 S MAGRY="0^Error Creating Workstation Entry." Q 0
27 ;
28 S WRKSN0=^MAG(2006.81,WRKSIEN,0) ; '0' node for use later.
29 S WRKSIEN=+WRKSIEN_","
30 S MAGGFDA(2006.81,WRKSIEN,.01)=WRKS ; Computer Name
31 S MAGGFDA(2006.81,WRKSIEN,8)=0 ; Active or not.
32 S MAGGFDA(2006.81,WRKSIEN,3)="@" ; delete logoff time for this job.
33 S MAGGFDA(2006.81,WRKSIEN,10)="@" ; delete session pointer
34 S MAGGFDA(2006.81,WRKSIEN,11)="@" ; reset the session error count.
35 ;
36 ;
37 S MAGGFDA(2006.81,WRKSIEN,12.5)=$P(WRKSN0,U,14)+1 ; total Import Sessions for workstation
38 ;
39 S X=$$NOW^XLFDT
40 S MAGSTART=$E(X,1,12)
41 I $G(DUZ) D
42 . S MAGGFDA(2006.81,WRKSIEN,1)=DUZ
43 . S MAGGFDA(2006.81,WRKSIEN,2)=MAGSTART
44 ;
45 D UPDATE^DIE("S","MAGGFDA","MAGXIEN","MAGXERR")
46 I $D(DIERR) D RTRNERR^MAGGTAU(.MAGRY) Q 0
47 ;
48 S MAGRY="1^"
49 ;
50 ; SESSION : Now here we have to create a new session entry;
51 ; //TODO, make a generic call to create a Session entry, this is
52 ; a duplicate of code in MAGGTAU
53 D GETS^DIQ(200,DUZ_",","29","I","Z","") ; service/section
54 S USERSRV=$G(Z(200,DUZ_",",29,"I"))
55 ;
56 K MAGGFDA,MAGXERR,MAGXIEN
57 S MAGGFDA(2006.82,"+1,",.01)=$P(^VA(200,DUZ,0),U,1) ; User
58 S MAGGFDA(2006.82,"+1,",1)=DUZ ; USER
59 S MAGGFDA(2006.82,"+1,",2)=MAGSTART ; Session Start Time
60 S MAGGFDA(2006.82,"+1,",4)=+WRKSIEN ; Workstation
61 I $D(^DPT(+PAT,0)) S MAGGFDA(2006.82,"+1,",5)=+PAT ; Patient
62 S MAGGFDA(2006.82,"+1,",7)=+USERSRV ; User's Service/Section pointer
63 S MAGGFDA(2006.82,"+1,",13)=3 ; 1=normal 2= started by CPRS 3= Import API session.
64 S MAGGFDA(2006.82,"+1,",8)=$G(TRKID) ; Tracking ID
65 ;
66 D UPDATE^DIE("","MAGGFDA","MAGXIEN","MAGXERR")
67 I $D(DIERR) D RTRNERR^MAGGTAU(.MAGRY) Q 0
68 S MAGRY="1^"
69 I '+MAGXIEN(1) S MAGRY="0^" Q 0
70 S SESSIEN=+MAGXIEN(1)
71 S MAGRY=SESSIEN_"^Session # "_SESSIEN_" Started."
72 S MAGGFDA(2006.81,+WRKSIEN_",",10)=SESSIEN
73 D UPDATE^DIE("","MAGGFDA","MAGXIEN","MAGXERR")
74 D ACTION^MAGGTAU("IMPORT^",0,SESSIEN) ;
75 S I="" F S I=$O(MAGIX(I)) Q:I="" D ACTION^MAGGTAU("Data:|"_"("_I_"): "_$TR(MAGIX(I),"^","~"),0,SESSIEN)
76 S I="" F S I=$O(IMAGES(I)) Q:I="" D ACTION^MAGGTAU("Image:|"_"("_I_"): "_$TR(IMAGES(I),"^","~"),0,SESSIEN)
77 Q SESSIEN
78LOGRES(RES,LOGTM,MAGSESS) ;
79 N I
80 S LOGTM=+$G(LOGTM)
81 I '$G(MAGSESS) Q
82 D ACTION^MAGGTAU("RESULTS^",1,MAGSESS) ;
83 S I="" F S I=$O(RES(I)) Q:I="" D ACTION^MAGGTAU("Result:|"_"("_I_"): "_$TR(RES(I),"^","~"),LOGTM,MAGSESS)
84 Q
85INPRC(RET,ARR) ; gek/Duplicate Import check
86 ; gek/stop duplicates. Import now has a status in the Session File.
87 ; ^MAG(2006.82,"STATUS",TRKID,SESSION IEN)= status
88 ; INPRC tells if the Session (by Tracking ID) is in process or not.
89 ; if In Process, we won't return the data.
90 ; INPRC will set the status to In Process if not currently in process.
91 ; P48T1 This function is not called in P48.
92 ; Possible use in future.
93 N I,SESS,STAT,TRKID
94 S TRKID=0
95 S I="" F S I=$O(ARR(I)) Q:I="" D
96 . S FLD=$P(ARR(I),"^",1) I (FLD=108)!(FLD="TRKID") D
97 . . S TRKID=$P(ARR(I),"^",2)
98 . . Q
99 . Q
100 I TRKID="" S RET="0^Null value for Tracking ID." Q 0
101 S RET="0^This tracking ID: "_TRKID_" isn't being processed"
102 I '$D(^MAG(2006.82,"E",TRKID)) Q 0
103 S SESS=$$SES4TRK(TRKID) Q:'SESS 0 ; This tracking ID isn't being processed yet.
104 S STAT=$$GETSTAT(TRKID,SESS)
105 I 'STAT D SETSTAT(TRKID,SESS,"-5") Q 0 ; -5 means In Process
106 ; If in process we return 1
107 I (+STAT=-5) D Q 1
108 . S RET="0^Import for Tracking ID: "_TRKID_" has been processed."
109 Q 0
110SES4TRK(TRKID) ; Returns the Session ID for a Tracking ID
111 Q +$O(^MAG(2006.82,"E",TRKID,""),-1)
112 ;
113GETSTAT(TRKID,SESS) ; Get Status for given Tracking ID and Session ID
114 Q $G(^MAG(2006.82,"STATUS",TRKID,SESS))
115 ;
116SETSTAT(TRKID,SESS,STAT) ; Set Status for given Tracking ID and Session ID
117 S ^MAG(2006.82,"STATUS",TRKID,SESS)=STAT
118 Q
Note: See TracBrowser for help on using the repository browser.