source: FOIAVistA/trunk/r/IMAGING-MAG-ZMAG/MAGGSIV.m@ 1742

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

initial load of FOIAVistA 6/30/08 version

File size: 9.0 KB
Line 
1MAGGSIV ;WOIFO/GEK - Imaging RPC Broker calls. Validate Image data array ; [ 12/27/2000 10:49 ]
2 ;;3.0;IMAGING;**7,8,20,59**;Nov 27, 2007;Build 20
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 ;; | |
12 ;; | The Food and Drug Administration classifies this software as |
13 ;; | a medical device. As such, it may not be changed in any way. |
14 ;; | Modifications to this software may result in an adulterated |
15 ;; | medical device under 21CFR820, the use of which is considered |
16 ;; | to be a violation of US Federal Statutes. |
17 ;; +---------------------------------------------------------------+
18 ;;
19 Q
20VAL(MAGRY,MAGARRAY,ALL) ;RPC [MAG4 VALIDATE DATA]
21 ;Call to Validate the Image Data Array before a new image/modified entry is attempted.
22 ; Called from MAGGSIA, MAGGSIUI and Capture GUI.
23 ; Parameters :
24 ; MAGARRAY - array of 'Field numbers'|'Action codes' and their Values
25 ; MAGARRAY(1)="5^38" Field#: 5 Value: 38
26 ; an example of an action code is the Code for File Extension
27 ; MAGARRAY(2)="EXT^JPG" Action: EXT Value: JPG
28 ; ALL - "1" = Validate ALL fields, returning an array of error messages.
29 ; "0" = Stop validating if an error occurs, return
30 ; the error message in (0) node.
31 ; Return Variable
32 ; MAGRY() - Array
33 ; Successful MAGRY(0) = 1^Image Data is Valid.
34 ; UNsuccessful MAGRY(0) = 0^Error desc
35 ; IF ALL then MAGRY(1..N) =0^Error desc of all errors
36 N MAGGFLD,MAGGDAT,MAGFSPEC,CHKOK,MAGETXT,MAGRET,MAGRES
37 N Y,AITEM,CT,MAGERR,DFNFLAG,DAT1,X,MAX
38 N $ETRAP,$ESTACK S $ETRAP="D ERR^"_$T(+0)
39 S ALL=$G(ALL)
40 S MAGRY(0)="0^Validating the Data Array..."
41 S MAGERR="",DFNFLAG=0,CT=0
42 ; Do we have any data ?
43 I ($D(MAGARRAY)<10) S MAGRY(0)="0^No input data, Operation CANCELED" Q
44 ; Flag if from Maximus
45 S MAX=0
46 S X="" F S X=$O(MAGARRAY(X)) Q:X="" I $P(MAGARRAY(X),U,1)="TRKID"!($P(MAGARRAY(X),U,1)="108") I $P($P(MAGARRAY(X),U,2),";",1)="MAX" S MAX=1
47 ; Loop through Input Array
48 S AITEM="" F S AITEM=$O(MAGARRAY(AITEM)) Q:AITEM="" D I $L(MAGERR) Q:'ALL S CT=CT+1,MAGRY(CT)=MAGERR,MAGERR=""
49 . S MAGERR=""
50 . S MAGGFLD=$P(MAGARRAY(AITEM),U,1),MAGGDAT=$P(MAGARRAY(AITEM),U,2,99)
51 . I MAGGFLD="" S MAGERR="0^A Field Number/Action Code is required: "_" Item: "_MAGARRAY(AITEM) Q
52 . I MAGGDAT="" S MAGERR="0^A Value is required."_" Item: "_MAGARRAY(AITEM) Q
53 . I MAGGFLD=5 S DFNFLAG=1
54 . ; This inadvertently disallowed Tracking ID's on Group Images.
55 . ;I MAGGFLD=108 I $D(^MAG(2005,"ATRKID",MAGGDAT)) S MAGERR="0^Tracking ID Must be Unique !" Q
56 . I MAGGFLD=108 I ($L(MAGGDAT,";")<2) S MAGRY(0)="0^Tracking ID Must have "";"" Delimiter" Q
57 . ; Check for possible action codes that could be in the array.
58 . I $$ACTCODE(MAGGFLD) D Q
59 . . S DAT1=MAGGDAT
60 . . S Y=$$VALCODE(MAGGFLD,.MAGGDAT) S:'Y MAGERR=Y_" Item: "_MAGARRAY(AITEM)
61 . . I DAT1'=MAGGDAT S MAGARRAY(AITEM)=MAGGFLD_"^"_MAGGDAT
62 . ; If we are adding Multiple Images to a Group, they must be Validated.
63 . ; we could have multiple "2005.04^IENs" in this array. Which means we are
64 . ; adding existing Images to a New/Existing Group.
65 . I MAGGFLD=2005.04 D Q ; 2005.04 isn't the field number, #4 is the field number
66 . . I $G(MAGGDAT,0)=0 Q ;Creating a new Group, with no group entries is the usual way
67 . . ; to do it. Then make successive calls to ADD, Adding each Image to the
68 . . ; Object Group multiple of the Group Parent (fld#14) as it is created.
69 . . I '$D(^MAG(2005,MAGGDAT,0)) S MAGERR="0^Group Object "_MAGGDAT_" doesn't exist"_" Item: "_MAGARRAY(AITEM)
70 . . ; We can't allow adding an image if it already has a group parent.
71 . . I $P(^MAG(2005,MAGGDAT,0),U,10) S MAGERR="0^The Image to be added to the Group, already has a Group Parent"_" Item: "_MAGARRAY(AITEM)
72 . ; if we are getting a WP line of text for Long Desc Field. Can't validate it.
73 . I MAGGFLD=11 Q ; this is a line of the WP Long Desc field.
74 . ; NEW CALL TO VALIDATE FILE,FIELD,DATA
75 . S DAT1=MAGGDAT
76 . I '$$VALID^MAGGSIV1(2005,MAGGFLD,.MAGGDAT,.MAGRES) S MAGERR="0^"_MAGRES Q
77 . I DAT1'=MAGGDAT S MAGARRAY(AITEM)=MAGGFLD_"^"_MAGGDAT
78 . Q
79 ;
80 ; if there was an Error in data we'll quit now.
81 ; If ALL is true, then MAGRY(1...N) will exist if there were errors.
82 I $O(MAGRY(0)) S MAGRY(0)="0^Errors were found in data." Q
83 ; If ALL is false, then MAGERR will exist if there was an error.
84 I $L(MAGERR) S MAGRY(0)=MAGERR Q
85 ;
86 ; If all data is valid we get here.
87 ; Last Test, see if a Patient was in array,
88 ; (Patient is the only Required field check done in this routine).
89 I 'DFNFLAG S MAGRY(0)="0^A Patient DFN is required. " Q
90 S MAGRY(0)="1^Data is Valid."
91 Q
92ACTCODE(CODE) ;Function that returns True (1) if this code is a valid Import API Action Code
93 ; Patch 8. We're adding 107 as an action code, so it will pass validation even if the entry
94 ; in the Acquisition Device File doesn't exist;
95 ; it will be validated in PRE^MAGGSIA1 and a new Acquisition Device entry made if needed.
96 I ",107,ACQD,IEN,EXT,ABS,JB,WRITE,BIG,DICOMSN,DICOMIN,ACQS,ACQL,STATUSCB,CALLMTH,USERNAME,PASSWORD,DELFLAG,TRNSTYP,"[(","_CODE_",") Q 1
97 Q 0
98VALCODE(CODE,VALUE) ; We validate the values for the possible action codes
99 N MAGY
100 I VALUE="" Q "0^NO VALUE in Action Code string: """_X_""
101 ; Patch 8, added 107
102 I ",ACQL,CALLMTH,USERNAME,PASSWORD,"[(","_CODE_",") Q 1 ; NO VALIDATION FOR THESE CODES
103 D @CODE
104 Q MAGY
105 ; Each Tag is a valid Action code
106IEN I $D(^MAG(2005,VALUE)) S MAGY=1
107 E S MAGY="0^INVALID IMAGE IEN."
108 Q
109EXT ; code will go here to validate the extension type. i.e. we won't let types .exe .bat .com .zip ... etc.
110 ; Maybe a modification to Object Type file, to have allowable extensions in the file, and a
111 ; cross reference on a new field EXTENSION. The capture workstation wouldn't have to ask the
112 ; user for the file type of each file, and we wouldn't get WORD .DOC files that the user called Color Images
113ABS ; Meaning: Have the BP create the abstract
114JB ; Meaning: Have the BP copy the image to the JukeBox
115BIG ; Meaning: There is a big file also, set the Image File field ? to indicate there is a BIG File.
116 S MAGY=1
117 Q
118WRITE ; Meaning: This is the Internal Entry (or "PACS") of the WRITE Directory. Images will be written
119 ; here instead of the default WRITE Directory.
120 S MAGY=$$DRIVE^MAGGTU1(VALUE)
121 Q
122DICOMSN ;Meaning: DICOM Series Number. This will be entered in the Group Object multiple, field #1
123 ;We were validating this as an integer, but it can be anything, no way to validate.
124 S MAGY=1
125 Q
126DICOMIN ;Meaning: DICOM Image Number. This will be entered in the Group Object multiple, field #2
127 ; We were validating this as an integer, but it can be anything, no way to validate.
128 S MAGY=1
129 Q
130DELFLAG ;Meaning: This flag tells the Delphi Import Component to Delete the Image files after successful processing
131 I ",TRUE,FALSE,0,1,"[(","_$$UPPER(VALUE)_",") S MAGY=1
132 E S MAGY="0^INVALID Value "
133 I VALUE="1" S VALUE="TRUE"
134 I VALUE="0" S VALUE="FALSE"
135 Q
136TRNSTYP ;Meaning: This flag is for future use, for now it is ignored, defaults to "NEW"
137 S MAGY=1
138 Q
139STATUSCB ; Meaning: This is the TAG^RTN that Imaging calls to report the
140 ; status of the Import.
141 S MAGY="0^Error validating TAG^RTN: "_VALUE
142 I '$L($T(@VALUE)) S MAGY="0^Invalid Status CallBack "_VALUE
143 E S MAGY=1
144 Q
145ACQS ; We need to make sure the ACQS (Acquisition Site) is a Valid entry in Imaging Site Params.
146 S VALUE=$P(VALUE,";") ; Stop error, when old OCX sends data.
147 ; Next Block is for VIC (Maximus) that sends Station Number.
148 N ERR S ERR=0
149 I MAX D Q:ERR
150 . S X=$O(^DIC(4,"D",VALUE,""))
151 . I X="" S MAGY="0^Invalid STATION NUMBER: (ACQS): "_VALUE,ERR=1 Q
152 . S VALUE=X
153 . Q
154 I '$$CONSOLID^MAGBAPI S MAGY=1 Q
155 ;Patch 20 will have this.
156 I '$D(^MAG(2006.1,"B",VALUE)) S MAGY="0^Acquisition Site ("_VALUE_") is Not in Site Param File." Q
157 S MAGY=1
158 Q
159107 ; 107 and ACQD are the same. Calling 107 falls into validation for ACQD.
160ACQD ; 107 and ACQD are ACQUISITION DEVICE FILE (2006.04) pointers or Values.
161 ; If it is an integer, We assume the value is an IEN and validate it here.
162 I ((+VALUE)=VALUE),'$D(^MAG(2006.04,VALUE)) S MAGY="0^Invalid IEN ("_VALUE_") for ACQUISITION DEVICE File." Q
163 ; if it is not an integer, it is either a new/existing entry for 2006.04 Result is Success,
164 ; and it will be validated in PRE^MAGGSIA1 and added to File 2006.04 if needed.
165 S MAGY=1
166 Q
167UPPER(X) ;
168 Q $TR(X,"abcdefghijklmnopqrstuvwxyz","ABCDEFGHIJKLMNOPQRSTUVWXYZ")
169 ;
170ERR ; ERROR TRAP FOR Import API
171 N ERR S ERR=$$EC^%ZOSV
172 S MAGRY(0)="0^ETRAP: "_ERR
173 D @^%ZOSF("ERRTN")
174 Q
Note: See TracBrowser for help on using the repository browser.