MAGDRPC4 ;WOIFO/EdM - Imaging RPCs ; 13 Feb 2006 1:42 PM ;;3.0;IMAGING;**11,30,51,50**;26-May-2006 ;; +---------------------------------------------------------------+ ;; | 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 ; LOOKUP(OUT,NUMBER) ; RPC = MAG DICOM LOOKUP STUDY ; Look Up for both Radiology and Consults N ACCNUM ;--- Accession Number N CPTCODE ;-- CPT code for the procedure N CPTNAME ;-- CPT name for the procedure N DFN ;------ Patient pointer N EXAMSTS ;-- Exam status (don't post images to CANCELLED exams) N EXAMTYP ;-- Type of exam (Rad or Con) N GMRCIEN ;-- Pointer for GMRC N PROCDESC ;- Procedure description N PROCIEN ;-- Radiology procedure IEN in ^RAMIS(71) N RAIX ;----- cross reference subscript for case number lookup N RADFN ;---- first level subscript in ^RADPT N RADTI ;---- second level subscript in ^RADPT (after "DT") N RACNI ;---- third level subscript in ^RADPT (after "P") N RARPT ;---- Radiology Report pointer N I,LIST,NOUT,X,Z ; K OUT S NOUT=1 I $G(NUMBER)="" S OUT(1)="-1,No Case or Consult Number Specified" Q I $E(NUMBER,2)="`" D Q . ; lookup the image by the IEN . D IENLOOK^MAGDRPC9 . Q ; S EXAMTYP=$E(NUMBER,1) I "RC"[EXAMTYP S NUMBER=$E(NUMBER,2,$L(NUMBER)) E S EXAMTYP="" K DFN D ; First try Radiology candidates . I EXAMTYP'="",EXAMTYP'="R" Q . D ; Look for the patient/study in ^RADPT using the Radiology Case Number . . N RAIX ;----- cross reference subscript for case number lookup . . S RAIX=$S($D(^RADPT("C")):"C",1:"AE") ; for Radiology Patch RA*5*7 . . S RAIX=$S(NUMBER["-":"ADC",1:RAIX) ; select the cross-reference . . S RADFN=$O(^RADPT(RAIX,NUMBER,"")) I 'RADFN D Q:'RADFN . . . I NUMBER'["-" S OUT(1)="-2,No Study Date Specified" Q . . . S X=$P(NUMBER,"-",1) . . . I $L(X)'=6 S OUT(1)="-3,Invalid study date """_X_"""." Q . . . S SDATE=$S($E(X,5,6)<30:3,1:2)_$E(X,5,6)_$E(X,1,4) . . . D:SDATE . . . . ; 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 %,%I,II,RCASE,TODAY,X,Y . . . . S RCASE=$S(NUMBER["-":$P(NUMBER,"-",2),1:NUMBER) Q:'RCASE . . . . D NOW^%DTC S TODAY=X . . . . ; . . . . ; 1-3 days prior study date . . . . F II=1:1:3 S RADFN=$$FIND(SDATE,RCASE,-II) Q:RADFN . . . . Q:RADFN . . . . ; . . . . ; Wild goose chase but check for today's case . . . . S RADFN=$O(^RADPT("ADC",$$MMDDYY(TODAY)_"-"_RCASE,"")) Q:RADFN . . . . ; . . . . Q:SDATE'