source: FOIAVistA/tag/r/IMAGING-MAG-ZMAG/MAGGSIV.m@ 1621

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

WorldVistAEHR overlayed on FOIAVistA

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