MAGDRPC3 ;WOIFO/EdM - Imaging RPCs ; 12/15/2006 13:50 ;;3.0;IMAGING;**11,30,51,50,85**;16-March-2007;;Build 1039 ;; Per VHA Directive 2004-038, this routine should not be modified. ;; +---------------------------------------------------------------+ ;; | Property of the US Government. | ;; | No permission to copy or redistribute this software is given. | ;; | Use of unreleased versions of this software requires the user | ;; | to execute a written test agreement with the VistA Imaging | ;; | Development Office of the Department of Veterans Affairs, | ;; | telephone (301) 734-0100. | ;; | The Food and Drug Administration classifies this software as | ;; | a medical device. As such, it may not be changed in any way. | ;; | Modifications to this software may result in an adulterated | ;; | medical device under 21CFR820, the use of which is considered | ;; | to be a violation of US Federal Statutes. | ;; +---------------------------------------------------------------+ ;; Q ; RADLKUP(OUT,CASENUMB,STUDYDAT) ; RPC = MAG DICOM LOOKUP RAD STUDY ; Radiology patient/study lookup N ACCNUM ;--- Accession Number N CPTCODE ;-- CPT code for the procedure N CPTNAME ;-- CPT name for the procedure N DATETIME ;- Timestamp N EXAMSTS ;-- Exam status (don't post images to CANCELLED exams) N PROCDESC ;- Procedure description N PROCIEN ;-- radiology procedure ien in ^RAMIS(71) N RAIX ;----- cross reference subscript for case number lookup N RADPT1 ;--- first level subscript in ^RADPT N RADPT2 ;--- second level subscript in ^RADPT (after "DT") N RADPT3 ;--- third level subscript in ^RADPT (after "P") N D1,I,LIST,X,Z ; ; find the patient/study in ^RADPT using the Radiology Case Number K OUT D . I $G(CASENUMB)="" S OUT(1)="-1,No Case Number Specified" Q . S RAIX=$S($D(^RADPT("C")):"C",1:"AE") ; for Radiology Patch RA*5*7 . S RAIX=$S(CASENUMB["-":"ADC",1:RAIX) ; select the cross-reference . S RADPT1=$O(^RADPT(RAIX,CASENUMB,"")) I 'RADPT1 D Q:'RADPT1 . . I '$G(STUDYDAT) S OUT(1)="-2,No Study Date Specified",RADPT1=0 Q . . ; . . ; Search 1-3 days prior the study date OR a day in advance but only . . ; if the study date is not equal to today or greater than today. . . ; Has to be long case number or must have an image study date . . ; . . N II,RCASE,SDATE,TODAY,X,Y,%,%I . . ; . . S RCASE=$S(CASENUMB["-":$P(CASENUMB,"-",2),1:CASENUMB) . . I 'RCASE S RADPT1=0 Q . . ; . . D NOW^%DTC S TODAY=X . . S X=$P(STUDYDAT,"."),SDATE=$E(X,1,4)-1700_$E(X,5,8) ; FileMan date . . ; . . ; 1-3 days prior study date . . F II=1:1:3 S RADPT1=$$FIND(SDATE,RCASE,-II) Q:RADPT1 . . Q:RADPT1 . . ; . . ; Wild goose chase, but check for today's case . . S RADPT1=$O(^RADPT("ADC",$$MMDDYY(TODAY)_"-"_RCASE,"")) Q:RADPT1 . . ; . . I SDATE'3 . N XMERR,XMID,XMSUB,XMY . S PROBLEM(1)="Error while queueing image for Transmission:" . S PROBLEM(2)=LOG . S PROBLEM(3)=" " . ; --- send MailMan message... . S XMID=$G(DUZ) S:'XMID XMID=.5 . S XMY(XMID)="" . S:$G(EMAIL)'="" XMY(EMAIL)="" . S XMSUB=$E("Cannot transmit image(s) to "_APPNAM,1,63) . D SENDMSG^XMXAPI(XMID,XMSUB,"PROBLEM",.XMY,,.XMZ,) . Q:'$G(XMERR) . M XMERR=^TMP("XMERR",$J) S $EC=",U13-Cannot send MailMan message," . Q S OUT=1 Q ; ENQUEUE(IMAGE,D0,PRIOR) ; Add an image to the DICOM send image request queue sub-file Q:'IMAGE 0 N D1,I,OLD,X D CHK^MAGGSQI(.X,IMAGE) I +$G(X(0))'=1 D Q 0 . S PROBLEM=PROBLEM+1,PROBLEM(PROBLEM)=" " . S PROBLEM=PROBLEM+1,PROBLEM(PROBLEM)="Image # "_IMAGE_":" . S I="" F S I=$O(X(I)) Q:I="" S PROBLEM=PROBLEM+1,PROBLEM(PROBLEM)=X(I) . Q ; ; Enter each image at most once in each transmission request S (D1,OLD)=0 F S D1=$O(^MAGDOUTP(2006.574,D0,1,D1)) Q:'D1 D Q:OLD . S:$P($G(^MAGDOUTP(2006.574,D0,1,D1,0)),"^",1)=IMAGE OLD=1 . Q Q:OLD 1 ; L +^MAGDOUTP(2006.574,D0,1,0):19 ; Background Process MUST wait S X=$G(^MAGDOUTP(2006.574,D0,1,0)) S $P(X,"^",1,2)="^2006.5744" S D1=$O(^MAGDOUTP(2006.574,D0,1," "),-1)+1,$P(X,"^",3)=D1 S $P(X,"^",4)=$P(X,"^",4)+1,OUT=$P(X,"^",4) S ^MAGDOUTP(2006.574,D0,1,0)=X S ^MAGDOUTP(2006.574,D0,1,D1,0)=IMAGE_"^WAITING^"_$H S ^MAGDOUTP(2006.574,"STS",LOCATION,PRIOR,"WAITING",D0,D1)="" L -^MAGDOUTP(2006.574,D0,1,0) Q 1 ; FIND(DATE,CASE,NUM) ; ADC x-reference (Radiology patient file) N X,X1,X2,Y Q:'$G(DATE) 0 S (X,X1)=DATE,X2=NUM D:NUM C^%DTC Q:X<1 0 Q $O(^RADPT("ADC",$$MMDDYY(X)_"-"_CASE,"")) ; MMDDYY(DAY) ; YYYMMDD --> MMDDYY I DAY'?7N Q 0 Q $E(DAY,4,7)_$E(DAY,2,3) ;