source: FOIAVistA/trunk/r/IMAGING-MAG-ZMAG/MAGDIR83.m@ 1757

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

initial load of FOIAVistA 6/30/08 version

File size: 5.1 KB
Line 
1MAGDIR83 ;WOIFO/PMK - Read a DICOM image file ; 06/06/2005 09:20
2 ;;3.0;IMAGING;**11,30,51**;26-August-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 ;
19 ; M2MB server
20 ;
21 ; This routine is invoked by the ^MAGDIR8 to update handle DICOM
22 ; CORRECT functions, that is, the "CORRECT" REQUEST item.
23 ;
24 ; This is a four-step process:
25 ;
26 ; 1) The "QUERY" record is sent, to obtain a list of corrected
27 ; images. The list is sent back to the gateway in a list of
28 ; "CORRECT" RESULT items, each with new patient/study values.
29 ; If the images are to be deleted, the list will contain "DELETE"
30 ; instead of "FIXED" RESULT items.
31 ; 2) The gateway processes each corrected/deleted image, one at a
32 ; time.
33 ; 3) The gateway sends a "PROCESSED | IMAGE" record is sent back to
34 ; the server for each corrected image, so that each can be
35 ; deleted from the list. (This is called an RPC Callback.)
36 ; 4) Finally, the gateway sends a "PROCESSED | STUDY" record back to
37 ; the server to delete the remainder of the study from the list.
38 ;
39ENTRY ; update image acquisition statistics
40 N LOCATION,MACHID,STATUS
41 S STATUS=$P(ARGS,"|",1)
42 I STATUS="QUERY" D
43 . D QUERY
44 . Q
45 E I STATUS="PROCESSED" D
46 . D PROCESS
47 . Q
48 Q
49 ;
50QUERY ; get the list of DICOM CORRECTED files
51 N DELFLAG,ICOUNT,IMAGEIEN,INSTNAME,LOCATION,MACHID
52 N NEW,NEWNAME,NEWPID,NEWACN,NIMAGES,STUDYIEN,STUDYUID
53 ;
54 S LOCATION=$P(ARGS,"|",2),MACHID=$P(ARGS,"|",3)
55 S NIMAGES=0,STUDYIEN=""
56 F S STUDYIEN=$O(^MAGD(2006.575,"AFX",LOCATION,MACHID,STUDYIEN)) Q:'STUDYIEN Q:NIMAGES>24 D
57 . S DELFLAG=^MAGD(2006.575,"AFX",LOCATION,MACHID,STUDYIEN)
58 . S INSTNAME=$P(^MAGD(2006.575,STUDYIEN,"AMFG"),"^",1)
59 . S STUDYUID=^MAGD(2006.575,STUDYIEN,"ASUID")
60 . S NEW=^MAGD(2006.575,STUDYIEN,"FIXD")
61 . S NEWNAME=$P(NEW,"^",3),NEWPID=$P(NEW,"^",4),NEWACN=$P(NEW,"^",5)
62 . S IMAGEIEN=STUDYIEN ; need to process the first image
63 . D QUERY1("NONE") ; first time - defer deleting this node
64 . S ICOUNT=0
65 . F S ICOUNT=$O(^MAGD(2006.575,STUDYIEN,"RLATE",ICOUNT)) Q:'ICOUNT Q:NIMAGES>24 D
66 . . S IMAGEIEN=^MAGD(2006.575,STUDYIEN,"RLATE",ICOUNT,0)
67 . . D QUERY1("IMAGE") ; regular image - delete it
68 . . S NIMAGES=NIMAGES+1
69 . . Q
70 . I 'ICOUNT D ; end of study reached - delete first image & study
71 . . S IMAGEIEN=STUDYIEN ; need to delete first image and the study
72 . . D QUERY1("STUDY") ; second time, now delete the study entry
73 . . Q
74 . Q
75 Q
76 ;
77QUERY1(DELTYPE) ; build one CORRECT Result PROCESS array node
78 N FROMPATH,X
79 S FROMPATH=$P($G(^MAGD(2006.575,IMAGEIEN,0)),"^",1) Q:FROMPATH=""
80 S X=$S(DELFLAG="D":"DELETE",1:"FIXED")
81 S X=X_"|"_IMAGEIEN_"|"_STUDYIEN_"|"_DELTYPE_"|"_INSTNAME
82 S X=X_"|"_FROMPATH_"|"_STUDYUID_"|"_NEWNAME_"|"_NEWPID_"|"_NEWACN
83 D RESULT^MAGDIR8("CORRECT",X)
84 Q
85 ;
86 ; ----------------------- RPC CALLBACK ------------------------------
87 ;
88PROCESS ; delete the processed corrected entry from the ^MAGD(2006.575) file
89 N DELTYPE,EXIST,FILEPATH,IMAGEIEN,LOCATION,RLATEIEN,STUDYIEN
90 S IMAGEIEN=$P(ARGS,"|",2),STUDYIEN=$P(ARGS,"|",3)
91 S DELTYPE=$P(ARGS,"|",4),FILEPATH=$P(ARGS,"|",6) ; ignore piece #5
92 I DELTYPE'="NONE" D ; don't delete the first image/study in the list
93 . L +^MAGD(2006.575,0):1E9 ; Background process MUST wait
94 . I DELTYPE="IMAGE" D ; delete this image
95 . . ; remove the related image cross-references
96 . . S RLATEIEN=$O(^MAGD(2006.575,STUDYIEN,"RLATE","B",IMAGEIEN,""))
97 . . I RLATEIEN D
98 . . . K ^MAGD(2006.575,STUDYIEN,"RLATE",RLATEIEN)
99 . . . K ^MAGD(2006.575,STUDYIEN,"RLATE","B",IMAGEIEN,RLATEIEN)
100 . . . S $P(^(0),"^",4)=$P(^MAGD(2006.575,STUDYIEN,"RLATE",0),"^",4)-1
101 . . . Q
102 . . Q
103 . E I DELTYPE="STUDY" D ; delete the first image and study information
104 . . ; remove the "AFX" and "F" cross-references
105 . . S STUDYUID=$P(ARGS,"|",7),MACHID=$P(ARGS,"|",8)
106 . . S LOCATION=$P(ARGS,"|",9)
107 . . K ^MAGD(2006.575,"AFX",LOCATION,MACHID,STUDYIEN)
108 . . K ^MAGD(2006.575,"F",LOCATION,STUDYUID,STUDYIEN)
109 . . Q
110 . ; Only subtract 1 from #entries, if we're actually deleting one:
111 . S EXIST=$D(^MAGD(2006.575,IMAGEIEN))
112 . K ^MAGD(2006.575,IMAGEIEN)
113 . K ^MAGD(2006.575,"B",FILEPATH,IMAGEIEN)
114 . S:EXIST $P(^(0),"^",4)=$P(^MAGD(2006.575,0),"^",4)-1
115 . L -^MAGD(2006.575,0)
116 . Q
117 D RESULT^MAGDIR8("CORRECT","COMPLETE|"_IMAGEIEN_"|"_STUDYIEN_"|"_DELTYPE)
118 Q
Note: See TracBrowser for help on using the repository browser.