Home   Package List   Routine Alphabetical List   Global Alphabetical List   FileMan Files List   FileMan Sub-Files List   Package Component Lists   Package-Namespace Mapping  
Routine: MAGGSIV

MAGGSIV.m

Go to the documentation of this file.
  1. MAGGSIV ;WOIFO/GEK/NST - Imaging RPC Broker calls. Validate Image data array ; [ 12/27/2000 10:49 ]
  1. ;;3.0;IMAGING;**7,8,20,59,108,121**;Mar 19, 2002;Build 2340;Oct 20, 2011
  1. ;; Per VHA Directive 2004-038, this routine should not be modified.
  1. ;; +---------------------------------------------------------------+
  1. ;; | Property of the US Government. |
  1. ;; | No permission to copy or redistribute this software is given. |
  1. ;; | Use of unreleased versions of this software requires the user |
  1. ;; | to execute a written test agreement with the VistA Imaging |
  1. ;; | Development Office of the Department of Veterans Affairs, |
  1. ;; | telephone (301) 734-0100. |
  1. ;; | The Food and Drug Administration classifies this software as |
  1. ;; | a medical device. As such, it may not be changed in any way. |
  1. ;; | Modifications to this software may result in an adulterated |
  1. ;; | medical device under 21CFR820, the use of which is considered |
  1. ;; | to be a violation of US Federal Statutes. |
  1. ;; +---------------------------------------------------------------+
  1. ;;
  1. Q
  1. VAL(MAGRY,MAGARRAY,ALL) ;RPC [MAG4 VALIDATE DATA]
  1. ;Call to Validate the Image Data Array before a new image/modified entry is attempted.
  1. ; Called from MAGGSIA, MAGGSIUI and Capture GUI.
  1. ; Parameters :
  1. ; MAGARRAY - array of 'Field numbers'|'Action codes' and their Values
  1. ; MAGARRAY(1)="5^38" Field#: 5 Value: 38
  1. ; an example of an action code is the Code for File Extension
  1. ; MAGARRAY(2)="EXT^JPG" Action: EXT Value: JPG
  1. ; ALL - "1" = Validate ALL fields, returning an array of error messages.
  1. ; "0" = Stop validating if an error occurs, return
  1. ; the error message in (0) node.
  1. ; Return Variable
  1. ; MAGRY() - Array
  1. ; Successful MAGRY(0) = 1^Image Data is Valid.
  1. ; UNsuccessful MAGRY(0) = 0^Error desc
  1. ; IF ALL then MAGRY(1..N) =0^Error desc of all errors
  1. N MAGGFLD,MAGGDAT,MAGFSPEC,CHKOK,MAGETXT,MAGRET,MAGRES
  1. N Y,AITEM,CT,MAGERR,DFNFLAG,DAT1,X,MAX
  1. N $ETRAP,$ESTACK S $ETRAP="D ERR^"_$T(+0)
  1. S ALL=$G(ALL)
  1. S MAGRY(0)="0^Validating the Data Array..."
  1. S MAGERR="",DFNFLAG=0,CT=0
  1. ; Do we have any data ?
  1. I ($D(MAGARRAY)<10) S MAGRY(0)="0^No input data, Operation CANCELED" Q
  1. ; Flag if from Maximus
  1. S MAX=0
  1. 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
  1. ; Loop through Input Array
  1. S AITEM="" F S AITEM=$O(MAGARRAY(AITEM)) Q:AITEM="" D I $L(MAGERR) Q:'ALL S CT=CT+1,MAGRY(CT)=MAGERR,MAGERR=""
  1. . S MAGERR=""
  1. . S MAGGFLD=$P(MAGARRAY(AITEM),U,1),MAGGDAT=$P(MAGARRAY(AITEM),U,2,99)
  1. . I MAGGFLD="" S MAGERR="0^A Field Number/Action Code is required: "_" Item: "_MAGARRAY(AITEM) Q
  1. . I MAGGDAT="" S MAGERR="0^A Value is required."_" Item: "_MAGARRAY(AITEM) Q
  1. . I MAGGFLD=5 S DFNFLAG=1
  1. . ; This inadvertently disallowed Tracking ID's on Group Images.
  1. . ;I MAGGFLD=108 I $D(^MAG(2005,"ATRKID",MAGGDAT)) S MAGERR="0^Tracking ID Must be Unique !" Q
  1. . I MAGGFLD=108 I ($L(MAGGDAT,";")<2) S MAGRY(0)="0^Tracking ID Must have "";"" Delimiter" Q
  1. . ; Check for possible action codes that could be in the array.
  1. . I $$ACTCODE(MAGGFLD) D Q
  1. . . S DAT1=MAGGDAT
  1. . . S Y=$$VALCODE(MAGGFLD,.MAGGDAT) S:'Y MAGERR=Y_" Item: "_MAGARRAY(AITEM)
  1. . . I DAT1'=MAGGDAT S MAGARRAY(AITEM)=MAGGFLD_"^"_MAGGDAT
  1. . ; If we are adding Multiple Images to a Group, they must be Validated.
  1. . ; we could have multiple "2005.04^IENs" in this array. Which means we are
  1. . ; adding existing Images to a New/Existing Group.
  1. . I MAGGFLD=2005.04 D Q ; 2005.04 isn't the field number, #4 is the field number
  1. . . I $G(MAGGDAT,0)=0 Q ;Creating a new Group, with no group entries is the usual way
  1. . . ; to do it. Then make successive calls to ADD, Adding each Image to the
  1. . . ; Object Group multiple of the Group Parent (fld#14) as it is created.
  1. . . I '$D(^MAG(2005,MAGGDAT,0)) S MAGERR="0^Group Object "_MAGGDAT_" doesn't exist"_" Item: "_MAGARRAY(AITEM)
  1. . . ; We can't allow adding an image if it already has a group parent.
  1. . . 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)
  1. . ; if we are getting a WP line of text for Long Desc Field. Can't validate it.
  1. . I MAGGFLD=11 Q ; this is a line of the WP Long Desc field.
  1. . I (MAGGFLD=17),(MAGGDAT=0) Q ; Patch 108 BP work around don't check - a new TIU stub will be created
  1. . I MAGGFLD="ACTION" Q ; Patch 121 new ACTION Field, we skip.
  1. . ; NEW CALL TO VALIDATE FILE,FIELD,DATA
  1. . S DAT1=MAGGDAT
  1. . I '$$VALID^MAGGSIV1(2005,MAGGFLD,.MAGGDAT,.MAGRES) S MAGERR="0^"_MAGRES Q
  1. . I DAT1'=MAGGDAT S MAGARRAY(AITEM)=MAGGFLD_"^"_MAGGDAT
  1. . Q
  1. ;
  1. ; if there was an Error in data we'll quit now.
  1. ; If ALL is true, then MAGRY(1...N) will exist if there were errors.
  1. I $O(MAGRY(0)) S MAGRY(0)="0^Errors were found in data." Q
  1. ; If ALL is false, then MAGERR will exist if there was an error.
  1. I $L(MAGERR) S MAGRY(0)=MAGERR Q
  1. ;
  1. ; If all data is valid we get here.
  1. ; Last Test, see if a Patient was in array,
  1. ; (Patient is the only Required field check done in this routine).
  1. I 'DFNFLAG S MAGRY(0)="0^A Patient DFN is required. " Q
  1. S MAGRY(0)="1^Data is Valid."
  1. Q
  1. ACTCODE(CODE) ;Function that returns True (1) if this code is a valid Import API Action Code
  1. ; Patch 8. We're adding 107 as an action code, so it will pass validation even if the entry
  1. ; in the Acquisition Device File doesn't exist;
  1. ; it will be validated in PRE^MAGGSIA1 and a new Acquisition Device entry made if needed.
  1. I $E(CODE,1,8)="PXTIUTXT" Q 1 ; P108
  1. I ",107,PXSGNTYP,PXTIUTCNT,PXNEW,PXTIUTTL,ACQD,IEN,EXT,ABS,JB,WRITE,BIG,"[(","_CODE_",") Q 1
  1. I ",DICOMSN,DICOMIN,ACQS,ACQL,STATUSCB,CALLMTH,USERNAME,PASSWORD,DELFLAG,TRNSTYP,"[(","_CODE_",") Q 1
  1. I ",ACTION,"[(","_CODE_",") Q 1
  1. Q 0
  1. VALCODE(CODE,VALUE) ; We validate the values for the possible action codes
  1. N MAGY
  1. I VALUE="" Q "0^NO VALUE in Action Code string: """_X_""
  1. ; Patch 8, added 107
  1. I ",ACQL,CALLMTH,USERNAME,PASSWORD,"[(","_CODE_",") Q 1 ; NO VALIDATION FOR THESE CODES
  1. I ($E(CODE,1,8)="PXTIUTXT")!(CODE="PXTIUTCNT") Q 1 ; NO VALIDATION FOR TIU TEXT
  1. D @CODE
  1. Q MAGY
  1. ; Each Tag is a valid Action code
  1. IEN I $D(^MAG(2005,VALUE)) S MAGY=1
  1. E S MAGY="0^INVALID IMAGE IEN."
  1. Q
  1. ACTION ; Patch 121 ACTION = "RESCIND"
  1. I VALUE="RESCIND" S MAGY=1 Q
  1. S MAGY="0^Invalid ACTION: "_VALUE
  1. Q
  1. PXNEW ; New Package (TIU note)
  1. I (PXNEW'=0),(PXNEW'=1),(PXNEW'="") D
  1. . S MAGY="0^Invalid New Package Value."
  1. . S CT=CT+1,MAGRY(CT)="Invalid PXNEW value - 0, 1, or blank only!"
  1. E S MAGY=1
  1. Q
  1. PXSGNTYP ; Signature type
  1. I (PXSGNTYP'=0),(PXSGNTYP'=1),(PXSGNTYP'="") D
  1. . S MAGY="0^Invalid Signature type Value."
  1. . S CT=CT+1,MAGRY(CT)="Invalid PXSGNTYP value - 0, 1, or blank only!"
  1. E S MAGY=1
  1. Q
  1. PXTIUTTL ; Check for valid TIU title
  1. N VALIEN
  1. I $$GETTIUDA^MAGGSIV(.MAGY,VALUE,.VALIEN) S VALUE=VALIEN
  1. Q
  1. EXT ; code will go here to validate the extension type. i.e. we won't let types .exe .bat .com .zip ... etc.
  1. ; Maybe a modification to Object Type file, to have allowable extensions in the file, and a
  1. ; cross reference on a new field EXTENSION. The capture workstation wouldn't have to ask the
  1. ; user for the file type of each file, and we wouldn't get WORD .DOC files that the user called Color Images
  1. ABS ; Meaning: Have the BP create the abstract
  1. JB ; Meaning: Have the BP copy the image to the JukeBox
  1. BIG ; Meaning: There is a big file also, set the Image File field ? to indicate there is a BIG File.
  1. S MAGY=1
  1. Q
  1. WRITE ; Meaning: This is the Internal Entry (or "PACS") of the WRITE Directory. Images will be written
  1. ; here instead of the default WRITE Directory.
  1. S MAGY=$$DRIVE^MAGGTU1(VALUE)
  1. Q
  1. DICOMSN ;Meaning: DICOM Series Number. This will be entered in the Group Object multiple, field #1
  1. ;We were validating this as an integer, but it can be anything, no way to validate.
  1. S MAGY=1
  1. Q
  1. DICOMIN ;Meaning: DICOM Image Number. This will be entered in the Group Object multiple, field #2
  1. ; We were validating this as an integer, but it can be anything, no way to validate.
  1. S MAGY=1
  1. Q
  1. DELFLAG ;Meaning: This flag tells the Delphi Import Component to Delete the Image files after successful processing
  1. I ",TRUE,FALSE,0,1,"[(","_$$UPPER(VALUE)_",") S MAGY=1
  1. E S MAGY="0^INVALID Value "
  1. I VALUE="1" S VALUE="TRUE"
  1. I VALUE="0" S VALUE="FALSE"
  1. Q
  1. TRNSTYP ;Meaning: This flag is for future use, for now it is ignored, defaults to "NEW"
  1. S MAGY=1
  1. Q
  1. STATUSCB ; Meaning: This is the TAG^RTN that Imaging calls to report the
  1. ; status of the Import.
  1. S MAGY="0^Error validating TAG^RTN: "_VALUE
  1. I '$L($T(@VALUE)) S MAGY="0^Invalid Status CallBack "_VALUE
  1. E S MAGY=1
  1. Q
  1. ACQS ; We need to make sure the ACQS (Acquisition Site) is a Valid entry in Imaging Site Params.
  1. S VALUE=$P(VALUE,";") ; Stop error, when old OCX sends data.
  1. ; Next Block is for VIC (Maximus) that sends Station Number.
  1. N ERR S ERR=0
  1. I MAX D Q:ERR
  1. . S X=$O(^DIC(4,"D",VALUE,""))
  1. . I X="" S MAGY="0^Invalid STATION NUMBER: (ACQS): "_VALUE,ERR=1 Q
  1. . S VALUE=X
  1. . Q
  1. I '$$CONSOLID^MAGBAPI S MAGY=1 Q
  1. ;Patch 20 will have this.
  1. I '$D(^MAG(2006.1,"B",VALUE)) S MAGY="0^Acquisition Site ("_VALUE_") is Not in Site Param File." Q
  1. S MAGY=1
  1. Q
  1. 107 ; 107 and ACQD are the same. Calling 107 falls into validation for ACQD.
  1. ACQD ; 107 and ACQD are ACQUISITION DEVICE FILE (2006.04) pointers or Values.
  1. ; If it is an integer, We assume the value is an IEN and validate it here.
  1. I ((+VALUE)=VALUE),'$D(^MAG(2006.04,VALUE)) S MAGY="0^Invalid IEN ("_VALUE_") for ACQUISITION DEVICE File." Q
  1. ; if it is not an integer, it is either a new/existing entry for 2006.04 Result is Success,
  1. ; and it will be validated in PRE^MAGGSIA1 and added to File 2006.04 if needed.
  1. S MAGY=1
  1. Q
  1. UPPER(X) ;
  1. Q $TR(X,"abcdefghijklmnopqrstuvwxyz","ABCDEFGHIJKLMNOPQRSTUVWXYZ")
  1. ;
  1. ERR ; ERROR TRAP FOR Import API
  1. N ERR S ERR=$$EC^%ZOSV
  1. S MAGRY(0)="0^ETRAP: "_ERR
  1. D @^%ZOSF("ERRTN")
  1. Q
  1. ;
  1. ;***** Verify and return TIU Title IEN
  1. ;
  1. ; Input Parameters
  1. ; ================
  1. ; TITLE - an Integer (the IEN of file 8925.1) or Text value of the entry in 8925.1
  1. ;
  1. ; Return Values
  1. ; =============
  1. ; Returns 0 if TITLE is valid
  1. ; Returns 1 if TITLE is not valid
  1. ;
  1. ; if TITLE is not valid then MAGY = "0^error message"
  1. ; if TITLE is valid then MAGY = 1 and TIEN = TIU Title IEN
  1. ;
  1. GETTIUDA(MAGY,TITLE,TIEN) ;
  1. I TITLE="" S MAGY="0^Invalid data: Note TITLE is blank!" Q 0
  1. ; Is TITLE integer (IEN)
  1. I TITLE?1.N D Q +MAGY
  1. . I $D(^TIU(8925.1,"AT","DOC",TITLE)) S MAGY=1 S TIEN=TITLE Q
  1. . S MAGY="0^Invalid data: Note TITLE ("_TITLE_") is invalid"
  1. . Q
  1. N DONE
  1. S (DONE,TIEN)=""
  1. S TITLE=$$UP^XLFSTR(TITLE) ; IA #10104
  1. F Q:DONE S TIEN=$O(^TIU(8925.1,"B",TITLE,TIEN)) Q:TIEN="" D
  1. . I $D(^TIU(8925.1,"AT","DOC",TIEN)) S DONE=1
  1. . Q
  1. I DONE S MAGY=1 ; TIEN is already set
  1. E S MAGY="0^Invalid data: TITLE IEN ("_TITLE_") is invalid"
  1. Q +MAGY