[623] | 1 | MAGGSIUI ;WOIFO/GEK - Utilities for Image Import API
|
---|
| 2 | ;;3.0;IMAGING;**7,8,48,20,85**;16-March-2007;;Build 1039
|
---|
| 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 | ;; | 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
|
---|
| 19 | REMOTE(MAGRY,MAGDATA) ;RPC [MAG4 REMOTE IMPORT]
|
---|
| 20 | ; Import Images from a Windows App, by sending an array.
|
---|
| 21 | I ($D(MAGDATA)<10) S MAGRY(0)="0^Missing Data Array !." Q
|
---|
| 22 | N I,J,ICT,DCT,MAGIX,IMAGES,ERR,X,Z
|
---|
| 23 | S (ERR,ICT,DCT)=0
|
---|
| 24 | S I="" F S I=$O(MAGDATA(I)) Q:I="" S X=MAGDATA(I) D Q:ERR
|
---|
| 25 | . S Z=$P(X,U)
|
---|
| 26 | . I (X="")!(Z="") S MAGRY(0)="0^INVALID Data in Input Array: Node "_I_"="""_X_"",ERR=1 Q
|
---|
| 27 | . I Z="IMAGE" S ICT=ICT+1,IMAGES(ICT)=$P(X,U,2,99) Q
|
---|
| 28 | . S DCT=DCT+1,MAGIX(Z)=$P(X,U,2,99)
|
---|
| 29 | I 'ERR D IMPORT(.MAGRY,.IMAGES,.MAGIX)
|
---|
| 30 | Q
|
---|
| 31 | ;
|
---|
| 32 | IMPORT(MAGRY,IMAGES,MAGIX) ;
|
---|
| 33 | ; "IDFN","PXPKG","PXIEN","PXDT","TRKID","ACQD","ACQS","ACQL","STSCB","ITYPE",
|
---|
| 34 | ; "CMTH","CDUZ","USERNAME","PASSWORD","GDESC","DFLG","TRTYPE","DOCCTG","DOCDT",
|
---|
| 35 | ; "IXTYPE","IXSPEC","IXPROC","IXORIGIN ;Patch 8: Added Index fields
|
---|
| 36 | ;
|
---|
| 37 | ;Index fields Package, Class ("IXPKG" and "IXCLS") aren't accepted
|
---|
| 38 | ; they are computed values.
|
---|
| 39 | ; - Convert field codes into an Input Data Array,
|
---|
| 40 | ; validate, then set the Import Queue
|
---|
| 41 | ;
|
---|
| 42 | N $ETRAP,$ESTACK S $ETRAP="D ERR^"_$T(+0)
|
---|
| 43 | K MAGRY S MAGRY(0)="0^Importing data..."
|
---|
| 44 | N APISESS,MWIN
|
---|
| 45 | S MWIN=$$BROKER^XWBLIB
|
---|
| 46 | N PRM,CT,MAGA,MAGY,MAGTN,TNODE
|
---|
| 47 | N IDFN,PXPKG,PXIEN,PXDT,TRKID,ACQD,ACQS,ACQN,ACQL,STSCB,ITYPE,CMTH,CDUZ,USERNAME,PASSWORD
|
---|
| 48 | N GDESC,DFLG,TRTYPE,DOCCTG,DOCDT,IXPKG,IXCLS,IXTYPE,IXSPEC,IXPROC,IXORIGIN,MAX,SITEPLC
|
---|
| 49 | N ERR,MAGTM,QTIME,MAGIXZ
|
---|
| 50 | S CT=0,ERR=0
|
---|
| 51 | M MAGIXZ=MAGIX
|
---|
| 52 | ; DON'T CONVERT ACQS(really a ACQN) to a REAL ACQS, leave it ACQS to be converted by MAGGSIV
|
---|
| 53 | ;
|
---|
| 54 | F PRM="IDFN","PXPKG","PXIEN","PXDT","TRKID","ACQD","ACQS","ACQN","ACQL","STSCB","ITYPE","CMTH","CDUZ","USERNAME","PASSWORD","GDESC","DFLG","TRTYPE","DOCCTG","DOCDT","IXTYPE","IXSPEC","IXPROC","IXORIGIN" D
|
---|
| 55 | . S @PRM=$G(MAGIX(PRM)) K MAGIX(PRM) ; P8T14 added K.. and next line to account for field numbers later.
|
---|
| 56 | . Q
|
---|
| 57 | S PRM="" F S PRM=$O(MAGIX(PRM)) Q:PRM="" D SA(PRM,$G(MAGIX(PRM)))
|
---|
| 58 | ;
|
---|
| 59 | S MAGTM=$$NOW^XLFDT
|
---|
| 60 | I '$G(DUZ) S MAGRY(0)="0^DUZ is undefined." Q ;D ERRTRK Q
|
---|
| 61 | ; DATATRK sets Global var. APISESS = IEN of Session File.
|
---|
| 62 | D DATATRK
|
---|
| 63 | I '$$REQPARAM^MAGGSIU2() D ERRTRK Q
|
---|
| 64 | S MAX=$P(TRKID,";",1)="MAX"
|
---|
| 65 | ;I 'MWIN W !,"----------------" ZW W !,"---------------------"
|
---|
| 66 | ; Workaround VIC (Maximus) is sending Station Number
|
---|
| 67 | ; we'll convert to Institution IEN
|
---|
| 68 | I MAX&(ACQS]"") D Q:ERR
|
---|
| 69 | . S X=$O(^DIC(4,"D",ACQS,""))
|
---|
| 70 | . I X="" S MAGRY(0)="0^Invalid Station Number:(Maximus ACQS): "_ACQS,ERR=1 Q
|
---|
| 71 | . S SITEPLC=X ; We need the Place for the Queue
|
---|
| 72 | . ;S ACQS=X Out in 85. Don't change to ACQS, that's done in VAL^MAGGSIV
|
---|
| 73 | . Q
|
---|
| 74 | ; Change to Allow ACQN - STATION NUMBER from INSTITUTION File.
|
---|
| 75 | I $L(ACQN) D Q:ERR
|
---|
| 76 | . S ACQS=$O(^DIC(4,"D",ACQN,""))
|
---|
| 77 | . I ACQS="" S MAGRY(0)="0^Invalid STATION NUMBER: (ACQN): "_ACQN,ERR=1 Q
|
---|
| 78 | . ; VAL^MAGGSIV Will fail if ACQS is real and this is Maximus
|
---|
| 79 | . I MAX S ACQS=ACQN K ACQN Q
|
---|
| 80 | . S ACQN="" ;We converted to ACQS, lets make "" so no confusion later.
|
---|
| 81 | . Q
|
---|
| 82 | ;
|
---|
| 83 | ; Set the input data array
|
---|
| 84 | D SA(5,IDFN) ;PATIENT
|
---|
| 85 | D SA(16,PXPKG) ;PARENT DATA FILE
|
---|
| 86 | D SA(17,PXIEN) ;PARENT GLOBAL ROOT
|
---|
| 87 | D SA(15,PXDT) ; PROCEDURE/EXAM DATE/TIME
|
---|
| 88 | D SA(108,TRKID) ; TRACKING ID (new)
|
---|
| 89 | D SA("ACQD",ACQD) ; ACQUISTION DEVICE ( new )
|
---|
| 90 | I 'MAX S SITEPLC=ACQS D SA(.05,ACQS) ; this used to be fld 105
|
---|
| 91 | D SA(101,ACQL)
|
---|
| 92 | D SA("STATUSCB",STSCB) ; STATUS CALLBACK (was referred to as ExceptionHandler)
|
---|
| 93 | D SA(3,ITYPE) ; OBJECT TYPE
|
---|
| 94 | D SA("CALLMTH",CMTH) ; CALL METHOD
|
---|
| 95 | D SA(8,CDUZ) ; IMAGE SAVE BY
|
---|
| 96 | D SA("USERNAME",USERNAME)
|
---|
| 97 | D SA("PASSWORD",PASSWORD)
|
---|
| 98 | D SA(10,GDESC) ; SHORT DESCRIPTION
|
---|
| 99 | D SA("DELFLAG",DFLG) ; DELETE FLAG
|
---|
| 100 | D SA("TRNSTYP",TRTYPE) ; TRANSACTION TYPE
|
---|
| 101 | D SA(100,DOCCTG) ; document Main category
|
---|
| 102 | D SA(110,DOCDT) ; document date
|
---|
| 103 | ; Patch 8 allows Index fields to be imported.
|
---|
| 104 | ;"IXTYPE","IXSPEC","IXPROC","IXORIGIN"
|
---|
| 105 | D SA(42,IXTYPE) ; Index Type
|
---|
| 106 | D SA(43,IXPROC) ; Index Proc/Event
|
---|
| 107 | D SA(44,IXSPEC) ; Index Spec/SubSpec
|
---|
| 108 | D SA(45,IXORIGIN) ; Index Origin
|
---|
| 109 | ;
|
---|
| 110 | D VAL^MAGGSIV(.MAGRY,.MAGA,1) I 'MAGRY(0) D ERRTRK Q
|
---|
| 111 | I MAX D SA(.05,ACQS) ; this used to be fld 105
|
---|
| 112 | ; Also Done in MAGGSIA when image is being Saved.
|
---|
| 113 | I '$$VALINDEX^MAGGSIV1(.MAGRY,IXTYPE,IXSPEC,IXPROC) D ERRTRK Q
|
---|
| 114 | ; Array of Images to Import
|
---|
| 115 | D SI("IMAGES",.IMAGES) I 'MAGRY(0) D ERRTRK Q
|
---|
| 116 | K MAGRY
|
---|
| 117 | ;
|
---|
| 118 | I TRTYPE="NOQUEUE" M MAGRY=MAGA S MAGRY(0)="1^" Q
|
---|
| 119 | ; This call is for BP
|
---|
| 120 | S QTIME=$$NOW^XLFDT
|
---|
| 121 | ; p85 use ACQS instead of DUZ(2)
|
---|
| 122 | S MAGY=$$IMPORT^MAGBAPI(.MAGA,STSCB,TRKID,$$PLACE^MAGBAPI(SITEPLC))
|
---|
| 123 | ; Return Queue Number
|
---|
| 124 | I 'MAGY S MAGRY(0)="0^Error Setting Queue: "_$P(MAGY,U,2),MAGY=TRKID
|
---|
| 125 | E S MAGRY(0)=MAGY_"^Data has been Queued.",MAGY=+MAGY
|
---|
| 126 | ; for Testing, we'll track input array, and results array by Queue number.
|
---|
| 127 | I 'MAGRY(0) D ERRTRK Q
|
---|
| 128 | D LOGRES^MAGGSIU3(.MAGRY,0,APISESS)
|
---|
| 129 | ;
|
---|
| 130 | Q
|
---|
| 131 | ;
|
---|
| 132 | SA(FLD,VAL) ;Set the data array with Fld,Value
|
---|
| 133 | Q:VAL=""
|
---|
| 134 | S CT=CT+1,MAGA(CT)=FLD_U_VAL
|
---|
| 135 | Q
|
---|
| 136 | SI(FLD,ARR) ;Set the images into the data array
|
---|
| 137 | ; 'CT' is a global variable.
|
---|
| 138 | S MAGRY(0)="1^Valid Image file Extensions."
|
---|
| 139 | N I,MAGEXT,MAGFN
|
---|
| 140 | S I="" F S I=$O(ARR(I)) Q:I="" D Q:'MAGRY(0)
|
---|
| 141 | . S CT=CT+1
|
---|
| 142 | . I ($L($P(ARR(I),U),".")<2) S MAGRY(0)="0^Invalid file name: "_ARR(I) Q
|
---|
| 143 | . S MAGFN=$P(ARR(I),"^")
|
---|
| 144 | . S MAGEXT=$$UP^XLFSTR($P(MAGFN,".",$L(MAGFN,".")))
|
---|
| 145 | . I '$D(^MAG(2005.021,"B",MAGEXT)) S MAGRY(0)="0^Unsupported File Type:'."_MAGEXT Q
|
---|
| 146 | . S MAGA(CT)="IMAGE"_U_ARR(I)
|
---|
| 147 | Q
|
---|
| 148 | GETARR(ARR,QNUM) ;RPC [MAG4 DATA FROM IMPORT QUEUE]
|
---|
| 149 | ; Get the Input Array from Queue Number
|
---|
| 150 | I '$G(QNUM) S ARR(0)="0^INVALID QUEUE Number: "_$G(QNUM) Q
|
---|
| 151 | D IMPAR^MAGQBUT2(.ARR,QNUM)
|
---|
| 152 | Q
|
---|
| 153 | STATUSCB(MAGRY,STAT,TAGRTN,DOCB) ;RPC [MAG4 STATUS CALLBACK]
|
---|
| 154 | ; Report Status to calling application
|
---|
| 155 | ; Now the IAPI and OCX make this call. Not BP
|
---|
| 156 | ; STAT(0)= "0^message" or "1^message"
|
---|
| 157 | ; STAT(1)=TRKID,
|
---|
| 158 | ; (2)=QNUM
|
---|
| 159 | ; (3..N)=warnings
|
---|
| 160 | ;TAGRTN : The TAG^RTN to call with Status Array
|
---|
| 161 | ;DOCB : (1|0) to suppress execution of Status Callback
|
---|
| 162 | ;
|
---|
| 163 | N APISESS,TRKID,CBMSG
|
---|
| 164 | S DOCB=$S($G(DOCB)="":1,1:+$G(DOCB)) ; Default to TRUE
|
---|
| 165 | ; Old Import API and BP that made this call, will work : DOCB defaults to 1
|
---|
| 166 | S CBMSG=$S(DOCB:"Status Callback was called",1:"Status Callback was NOT called")
|
---|
| 167 | I DOCB D @(TAGRTN_"(.STAT)")
|
---|
| 168 | S MAGRY="1^"_CBMSG
|
---|
| 169 | S STAT($O(STAT(""),-1)+1)=MAGRY
|
---|
| 170 | S TRKID=$G(STAT(1))
|
---|
| 171 | ; Log Results. Always.
|
---|
| 172 | I $L(TRKID) D
|
---|
| 173 | . S APISESS=$$SES4TRK^MAGGSIU3(TRKID) ;
|
---|
| 174 | . I APISESS D LOGRES^MAGGSIU3(.STAT,0,APISESS) ;gek/send Tracking ID to log status
|
---|
| 175 | Q
|
---|
| 176 | TESTCB(STATARR) ;TESTING. This is the Status Callback for testing.
|
---|
| 177 | ; the STATUSCB property must have a Valid "M" TAG^ROUTINE
|
---|
| 178 | ; TAG TESTCB exists so that STATUSCB validates successfully
|
---|
| 179 | Q
|
---|
| 180 | ERRTRK ;Track bad data and Quit
|
---|
| 181 | N I
|
---|
| 182 | D LOGERR^MAGGSERR("---- New Error ----",APISESS)
|
---|
| 183 | S I="" F S I=$O(MAGRY(I)) Q:I="" D LOGERR^MAGGSERR(MAGRY(I),APISESS)
|
---|
| 184 | Q
|
---|
| 185 | DATATRK ; Track the raw data being sent to the Import API.
|
---|
| 186 | ; Log the data being imported. Results are logged later.
|
---|
| 187 | N XY
|
---|
| 188 | S APISESS=$$LOG^MAGGSIU3(.XY,.MAGIXZ,.IMAGES,IDFN,ACQD,TRKID)
|
---|
| 189 | Q
|
---|
| 190 | ERR ; ERROR TRAP FOR Import API
|
---|
| 191 | N ERR S ERR=$$EC^%ZOSV
|
---|
| 192 | S MAGRY(0)="0^ETRAP: "_ERR
|
---|
| 193 | D @^%ZOSF("ERRTN")
|
---|
| 194 | I $G(APISESS) D ERRTRK
|
---|
| 195 | Q
|
---|