MAGVIM05 ;WOIFO/MAT,BT,JL,DAC,PMK - Utilities for RPC calls for DICOM file processing ;09 Sep 2021 3:13 PM
;;3.0;IMAGING;**118,138,164,166,194,278**;Mar 19, 2002;Build 138
;; Per VA Directive 6402, 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
;
;+++++ Wrap call to code underlying RPC: RAMAG EXAM COMPLETE & re-format output
;
; RPC: MAGV RAD STAT COMPLETE Private IA #5072
;
; Inputs:
; =======
;
; RETURN ...... variable to hold the results
; RADPT ....... IEN of the RAD/NUC MED PATIENT file (#70)
; RAEXAM1 ..... EXAM DATE (#.01) of the REGISTERED EXAMS sub-file (#70.02)
; RAEXAM2 ..... IEN of the EXAMINATIONS sub-file (#70.03)
; MAGVUSR ..... DUZ of the Importer 2 application user.
; MAGVUSRDV ... DUZ(2) of the Importer 2 user.
; RAIMGTYP .... TYPE OF IMAGING (#2) of the REGISTERED EXAMS sub-file (#70.02)
; [RASTDRPT] ... IEN of an entry in the STANDARD REPORTS file (#74.1)
; ---- Next two are IEN(s) of entries in the DIAGNOSTIC CODES file(#78.3)
; [RADXPRIM] .. Primary Diagnostic Code --> RAMISC Param PRIMDXCODE
; [RADXSCND] ... List of Secondary Diagnostic Codes --> RAMISC Param SECDXCODE
;
; Outputs:
; ========
;
; Notes:
; ======
;
; The parameters mirror those of the underlying call.
;
XMCOMPLT(RETURN,RADPT,RAEXAM1,RAEXAM2,MAGVUSR,MAGVUSRDV,RAIMGTYP,RASTDRPT,RADXPRIM,RADXSCND) ;
;
;--- Initialize
K RETURN
N MSG,RARESULT,SEPSTAT,SEPOUTP D ZRUSEPIN
;
;--- Validate incoming parameters.
N MAGERR,PARAM S MAGERR=0
D
. F PARAM="RADPT","RAEXAM1","RAEXAM2","MAGVUSR","MAGVUSRDV","RAIMGTYP" D Q:MAGERR
. . S:@PARAM="" MAGERR=1
. . Q
. Q
;
I MAGERR D Q
. S RETURN(0)="-1"_SEPSTAT_"Required parameter "_PARAM_" missing or invalid."
. Q
;
;--- Format incoming RAD Exam Identifiers.
S RAEXAM=RADPT_U_RAEXAM1_U_RAEXAM2
;
;--- Set IMAGING SITE PARAMETERS file (#2006.1) IEN from DUZ(2).
N MAGSITEP
D
. S MAGVUSRDV=$G(MAGVUSRDV,$G(DUZ(2))),MAGSITEP=$O(^MAG(2006.1,"B",MAGVUSRDV,"")) ;P164
. I MAGSITEP="" D ;P164 - if it is not Site IEN, try Station Number
. . ;--- Get IEN of INSTITUTION file (#4) from STATION NUMBER (Supported IA# 2171)
. . N IENINST S IENINST=$$IEN^XUAF4(MAGVUSRDV)
. . S MAGSITEP=$O(^MAG(2006.1,"B",IENINST,"")) Q:+MAGSITEP ;found the site
. . S MAGERR=1,MSG="Unable to resolve Imaging Site Parameters entry. {DUZ(2)="_MAGVUSRDV_"} "
. Q
;
I MAGERR D Q
. S RETURN(0)="-1"_SEPSTAT_MSG
. Q
;
;--- Set additional RAD Order/Exam parameters.
S MAGERR=$$MAKELIST("C",RAIMGTYP,.RAMSC,MAGVUSR,MAGSITEP)
I MAGERR D Q
. S RETURN(0)="-1"_SEPSTAT_$P(MAGERR,U,2)
. Q
;
;--- Set flag to insert Primary DX code if passed in.
D:$G(RADXPRIM)'="" OUTPUT("PRIMDXCODE^^"_RADXPRIM,.RAMSC)
;
;--- Set flag to insert Secondary DX code(s) if passed in.
D:$G(RADXSCND(0))'=""
. ;
. N CT S CT=""
. F S CT=$O(RADXSCND(CT)) Q:CT="" D OUTPUT("SECDXCODE"_U_(CT+1)_U_RADXSCND(CT),.RAMSC)
. Q
;
;--- Set flag to suppress HL7 message to dictation systems.
D OUTPUT("FLAGS^^FS",.RAMSC)
;--- Call code underlying RPC: RAMAG EXAM COMPLETE (Private IA #5072)
D COMPLETE^RAMAGRP1(.RARESULT,RAEXAM,.RAMSC)
I $G(RARESULT(1))="-11^2" D ; add the OUTSIDE STUDY and try the RPC again
. N INFO
. D ADDROOM(.INFO,RAEXAM)
. K RARESULT
. I INFO(1)<0 M RARESULT=INFO Q
. D COMPLETE^RAMAGRP1(.RARESULT,RAEXAM,.RAMSC)
. Q
;
;--- Re-format error output or return 0.
I RARESULT(0)<0 D
. ;
. S RETURN(0)=-1_SEPSTAT_$O(RARESULT("A"),-1)_" error lines returned."
. N X S X=0
. F S X=$O(RARESULT(X)) Q:X="" D
. . S RETURN(X)=$P(RARESULT(X),U,1)_SEPSTAT_$P(RARESULT(X),U,2,999)
. . Q
E D
. S RETURN(0)=0_SEPSTAT_RARESULT(0)
. N X S X=0
. F S X=$O(RARESULT(X)) Q:X="" D
. . S RETURN(X)=$TR(RARESULT(X),U,SEPOUTP)
. . Q
. ;--- Call RA* code to trigger alerts for DX codes.
. D ALERT^MAGVIMRA(RADPT,RAEXAM1,RAEXAM2,1)
. Q
Q
;+++++ Wrap call to code underlying RPC: RAMAG EXAMINED & re-format output
;
; RPC: MAGV RAD STAT EXAMINED Private IA #5071
;
; Inputs:
; =======
;
; See input parameter descriptions above tag XMCOMPLT (above).
;
XMEXAMIN(RETURN,RADFN,RAEXAM1,RAEXAM2,MAGVUSR,MAGVUSRDV,RAIMGTYP) ;
;
;--- Initialize.
K RETURN
N MSG,RARESULT,SEPSTAT,SEPOUTP D ZRUSEPIN
;--- Validate incoming parameters.
N MAGERR,PARAM S MAGERR=0
D
. F PARAM="RADFN","RAEXAM1","RAEXAM2","MAGVUSR","MAGVUSRDV","RAIMGTYP" D Q:MAGERR
. . S:@PARAM="" MAGERR=1
. . Q
. Q
;
I MAGERR D Q
. S RETURN(0)="-1"_SEPSTAT_"Required parameter "_PARAM_" missing or invalid."
. Q
;
;--- Format incoming RAD Exam Identifiers
N RAEXAM S RAEXAM=RADFN_U_RAEXAM1_U_RAEXAM2
;
;--- Set IMAGING SITE PARAMETERS file (#2006.1) IEN from DUZ(2).
N MAGSITEP
D
. S MAGVUSRDV=$G(MAGVUSRDV,$G(DUZ(2))),MAGSITEP=$O(^MAG(2006.1,"B",MAGVUSRDV,"")) ;DAC P166
. I MAGSITEP="" D ;DAC P166 - if it is not Site IEN, try Station Number
. . ;--- Get IEN of INSTITUTION file (#4) from STATION NUMBER (Supported IA# 2171)
. . N IENINST S IENINST=$$IEN^XUAF4(MAGVUSRDV)
. . I IENINST'="" S MAGSITEP=$O(^MAG(2006.1,"B",IENINST,"")) Q:+MAGSITEP ;found the site
. . S MAGERR=1,MSG="Unable to resolve Imaging Site Parameters entry. {DUZ(2)="_MAGVUSRDV_"} "
. Q
;
I MAGERR D Q
. S RETURN(0)="-1"_SEPSTAT_MSG
. Q
;
;
;--- Set required parameters
S MAGERR=$$MAKELIST("E",RAIMGTYP,.RAMSC,MAGVUSR,MAGSITEP)
I MAGERR D Q
. S RETURN(0)="-1"_SEPSTAT_$P(MAGERR,U,2)
. Q
;
;--- Set flag to suppress HL7 message to dictation systems.
D OUTPUT("FLAGS^^FS",.RAMSC)
;--- Call code underlying RPC: RAMAG EXAMINED (Private IA #5071).
D EXAMINED^RAMAGRP2(.RARESULT,RAEXAM,.RAMSC)
I $G(RARESULT(1))="-11^2" D ; add the OUTSIDE STUDY and try the RPC again
. N INFO
. D ADDROOM(.INFO,RAEXAM)
. K RARESULT
. I INFO(1)<0 M RARESULT=INFO Q
. D EXAMINED^RAMAGRP2(.RARESULT,RAEXAM,.RAMSC)
. Q
;
;--- Re-format error output or return 0.
I RARESULT(0)<0 D
. ;
. S RETURN(0)=-1_SEPSTAT_$O(RARESULT("A"),-1)_" error lines returned."
. N X S X=0
. F S X=$O(RARESULT(X)) Q:X="" D
. . S RETURN(X)=$P(RARESULT(X),U,1)_SEPSTAT_$P(RARESULT(X),U,2,999)
. . Q
E D
. S RETURN(0)=0_SEPSTAT_RARESULT(0)
. N X S X=0
. F S X=$O(RARESULT(X)) Q:X="" D
. . S RETURN(X)=$TR(RARESULT(X),U,SEPOUTP)
. . Q
. Q
Q
;+++++ Wrap calls to RPC: RAMAG EXAM ORDER & re-format output.
;
; RPC: MAGV RAD EXAM ORDER Private IA #5068
;
; Inputs:
; =======
;
; RETURN
; DFN
; RAMLC
; RADPROC
; STUDYDAT
; RACAT
; REQLOC
; REQPHYS
; REASON
; MISC
;
; Notes:
; ======
;
; The parameters are the same as those of the underlying call.
;
XMORDER(RETURN,DFN,RAMLC,RADPROC,STUDYDAT,RACAT,REQLOC,REQPHYS,REASON,MISC) ;
;
K RETURN
N SEPSTAT,SEPOUTP,I,FMDAY,MAXORDER,RAOIEN,REVERSEDAY,PROC1 D ZRUSEPIN
;
; maximum number of same procedures for same date for patient - P194 PMK/DAC 8/14/2018
S MAXORDER=$P($G(^MAG(2006.1,1,"IMPORTER")),U,6)
I MAXORDER="" S MAXORDER=10
;
S FMDAY=$$HL7TFM^XLFDT($G(STUDYDAT))
I FMDAY'>0 D Q
. S RETURN(0)=-1_SEPSTAT_"1 error line returned."
. S RETURN(1)=-1001_SEPSTAT_"Illegal or non-existent STUDYDAT="""_$G(STUDYDAT)_""""
. Q
S REVERSEDAY=9999999.9999-(FMDAY\1) ; strip the time and reverse the date
S PROC1=$P(RADPROC,U,1) ; P278 DAC - RADPROC may contain optional modifiers - Set PROC1 to the procedure IEN without modifiers
;
S RAOIEN=0
; P278 DAC - Use PROC1 (procedure) instead of RADPROC (procudure + optional modifiers)
F I=1:1:MAXORDER S RAOIEN=$O(^RAO(75.1,"AP",DFN,PROC1,REVERSEDAY,RAOIEN)) Q:'RAOIEN
I RAOIEN D Q
. S RETURN(0)=-1_SEPSTAT_"1 error line returned."
. S RETURN(1)=-1000_SEPSTAT_"Order already on file with IEN="_RAOIEN
. Q
;
;--- Private IA #5068.
D ORDER^RAMAGRP1(.ORDINFO,DFN,RAMLC,RADPROC,STUDYDAT,RACAT,REQLOC,REQPHYS,REASON,.MISC)
;
;--- Re-format error output or return new IEN in RAD/NUC MED ORDERS File (#75.1)
I ORDINFO(0)<0 D K ORDINFO
. ;
. S RETURN(0)=-1_SEPSTAT_$O(ORDINFO("A"),-1)_" error lines returned."
. N X S X=0 F S X=$O(ORDINFO(X)) Q:X="" D
. . ;
. . S RETURN(X)=$P(ORDINFO(X),U,1)_SEPSTAT_$P(ORDINFO(X),U,2,999)
. . Q
. Q
E S RETURN(0)=ORDINFO(0)
K ORDINFO
Q
;
;+++++ Wrap calls to RPC: RAMAG EXAM REGISTER & re-format output.
;
; RPC: MAGV RAD EXAM REGISTER Private IA #5069.
;
; Inputs:
; =======
;
; RETURN
; RAOIFN
; EXMDTE
; RAMSC
;
; Notes:
; ======
;
; The parameters are the same as those of the underlying call.
;
XMREGSTR(RETURN,RAOIFN,EXMDTE,RAMSC) ;
;
K RETURN
N SEPSTAT,SEPOUTP,IMAGLOC D ZRUSEPIN
;
; Check if imaging location is present - if not find outside imaging location for procedure and division
N RODATA S RODATA=$G(^RAO(75.1,RAOIFN,0))
D:$P(RODATA,U,20)=""
. N LOCINFO,PROCIEN,RAMLC S PROCIEN=$P(RODATA,U,2)
. D IMAGELOC(.RAMLC,PROCIEN,DUZ(2))
. S:$P(RAMLC,SEPSTAT)<0 RETURN(0)=RAMLC
. Q:$G(RETURN(0))
. S RAMLC=$P(RAMLC,SEPSTAT,2)
. ; call the RPC to update the radiology imaging location in the radiology order file (#75.1).
. D IMAGELOC^MAGDRPCB(.LOCINFO,RAOIFN,RAMLC)
. I $G(LOCINFO)<0 S RETURN(0)=LOCINFO ;"-1"_SEPSTAT_"Error in rpc MAG DICOM SET IMAGING LOCATION"
. Q
;
;Get imaging location IEN (#79.1)
K RAMLC,PROCIEN
S PROCIEN=$P(RODATA,U,2)
D IMAGELOC(.RAMLC,PROCIEN,DUZ(2))
S:$P(RAMLC,SEPSTAT)<0 RETURN(0)=RAMLC
Q:$G(RETURN(0))
S RAMLC=$P(RAMLC,SEPSTAT,2)
;Get corresponding hospital location IEN (#44)
S IMAGLOC=$$GET1^DIQ(79.1,.RAMLC,.01,"I")
K RAMSC
S RAMSC(1)="PRINCLIN^^"_$G(IMAGLOC)
S RAMSC(2)="FLAGS^^D"
;
Q:$G(RETURN(0))
;--- Private IA #5069.
D REGISTER^RAMAGRP1(.RARESULT,RAOIFN,EXMDTE,.RAMSC)
;
I RARESULT(0)<0 D
. ;
. S RETURN(0)=-1_SEPSTAT_$O(RARESULT("A"),-1)_" error lines returned."
. N X S X=0 F S X=$O(RARESULT(X)) Q:X="" D
. . ;
. . S RETURN(X)=$P(RARESULT(X),U,1)_SEPSTAT_$P(RARESULT(X),U,2,999)
. . Q
E D
. S RETURN(0)=0_SEPSTAT_RARESULT(0)
. N X S X=0 F S X=$O(RARESULT(X)) Q:X="" D
. . ;
. . S RETURN(X)=$TR(RARESULT(X),U,SEPOUTP)
. . Q
. Q
Q
;+++ Routine Utility: Initialize Separators
ZRUSEPIN ;
S SEPOUTP=$$OUTSEP^MAGVIM01
S SEPSTAT=$$STATSEP^MAGVIM01
Q
;
MAKELIST(RACTION,RAIMGTYP,RAMSC,MAGVUSR,MAGSITEP) ; output required fields
; Load required flags
N INFO
D EXMSTREQ^RAMAGRP2(.INFO,RACTION,RAIMGTYP)
I INFO(0)<0 Q INFO(1)
;
N TODAYHL7
S TODAYHL7=$$NOW^XLFDT()\1,$E(TODAYHL7)=$E(TODAYHL7)+17
;
N REQ,RADPVAL
;REQ001 - technologist
S REQ(1)="TECH^1^"_MAGVUSR
;
;REQ002 - resident or staff
;REQ003 - detailed procedure - taken care of already
;
;REQ004 - film entry
S RADPVAL=$$GET1^DIQ(2006.1,MAGSITEP,"RAD FILM SIZE","I")
S REQ(4)="FILMSIZE^1^"_RADPVAL_U_"0"
;
;REQ005 - diagnostic code default, if not supplied by user.
D:$G(RADXPRIM)=""
. S RADPVAL=$$GET1^DIQ(2006.1,MAGSITEP,"RAD PRIMARY DIAGNOSTIC CODE","I")
. S REQ(5)="PRIMDXCODE^^"_RADPVAL
. Q
;
;REQ006 - camera / equipment / room
S RADPVAL=$$GET1^DIQ(2006.1,MAGSITEP,"RAD PRIMARY CAMERA/EQUIP/RM","I")
S REQ(6)="PRIMCAM^^"_RADPVAL
;
;REQ007 - reserved
;REQ008 - reserved
;REQ009 - reserved
;REQ010 - reserved
;
;REQ011 - report entered
S REQ(11)="RPTDTE^^"_TODAYHL7
I $G(RASTDRPT)="" D
. S REQ(11,1)="REPORT^1^Electronically generated report for outside study."
. Q
;--- Add the REPORT text of a selected STANDARD REPORT to the RAMSC array.
E D STNDRPRT(RASTDRPT,"R",1)
;
;REQ012 - verified report
S REQ(12)="VERDTE^^"_TODAYHL7
S REQ(12,1)="RPTSTATUS^^EF"
;
;REQ013 - procedure modifiers required - previously done
;
;REQ014 - cpt modifiers
S RADPVAL=$$GET1^DIQ(2006.1,MAGSITEP,"RAD CPT MODIFIERS","I")
S:RADPVAL REQ(14)="CPTMODS^1^"_RADPVAL
;
;REQ015 - reserved
;
;REQ016 - impression
I $G(RASTDRPT)="" D
. S REQ(16)="IMPRESSION^1^Electronically generated report for outside study."
. Q
;--- Add the IMPRESSION text of a selected STANDARD REPORT to the RAMSC array.
E D STNDRPRT(RASTDRPT,"I",1)
;
N INDEX
F INDEX=1:1:16 I $P(INFO(0),"^",INDEX) D
. D:$D(REQ(INDEX)) OUTPUT(REQ(INDEX),.RAMSC)
. D:$D(REQ(INDEX,1)) OUTPUT(REQ(INDEX,1),.RAMSC)
. Q
;
Q 0
;
;+++++ Add selected STANDARD REPORT text to the Miscellaneous Parameters array.
;
STNDRPRT(RASTDRPT,SSCR,INDEX1) ;
;
N PREFIX S PREFIX=$S(SSCR="R":"REPORT",SSCR="I":"IMPRESSION")
;
N CT
S CT=0 F S CT=$O(^RA(74.1,RASTDRPT,SSCR,CT)) Q:CT="" D
. N RPTXT
. S RPTXT=PREFIX_U_(CT+INDEX1)_U_$G(^RA(74.1,RASTDRPT,SSCR,CT,0)) D OUTPUT(RPTXT,.RAMSC)
. Q
Q
;
OUTPUT(TEXT,ARRAY) ;
N I
S I=$O(ARRAY(""),-1)+1
S ARRAY(I)=TEXT
Q
;
; MAGV OUTSIDE IMAGE LOCATION
;
; Inputs:
; =======
;
; PROCIEN -- IEN of procedure in RAD/NUC MED PROCEDURES (file #71)
; DIVISION - IEN of division in INSTITUTION (file #4)
;
; Output:
; ========
;
; <0 Error message
; 0 IEN of the Outside Image Location in the IMAGE LOCATIONS (file #79.1)
;
IMAGELOC(RESULT,PROCIEN,DIVISION) ;
; return the outside imaging location for a given radiology procedure and division
N IEN,IMAGETYPE,SEPSTAT,SEPOUTP D ZRUSEPIN
K RESULT
S PROCIEN=$G(PROCIEN)
I (PROCIEN'>0)!(PROCIEN'=+PROCIEN) D Q
. S RESULT="-1"_SEPSTAT_"Invalid or missing Radiology Procedure pointer: """_PROCIEN_"""."
. Q
;
S DIVISION=$G(DIVISION)
I (DIVISION'>0)!(DIVISION'=+DIVISION) D Q
. S RESULT="-2"_SEPSTAT_"Invalid or missing Division pointer:"""_DIVISION_"""."
. Q
;
S IMAGETYPE=$$GET1^DIQ(71,PROCIEN,12,"I")
I 'IMAGETYPE D Q
. S RESULT="-3"_SEPSTAT_"Image Type could not be determined for Radiology Procedure pointer: """_PROCIEN_"""."
. Q
;
I $$GET1^DIQ(4,DIVISION,.01)="" D Q
. S RESULT="-4"_SEPSTAT_"Invalid Division (Institution) pointer:"""_DIVISION_"""."
. Q
S IEN=$O(^MAGD(2006.5759,"D",DIVISION,IMAGETYPE,""))
I IEN="" D Q
. S RESULT="-5"_SEPSTAT_"Outside Imaging Location could not be determined for Division: "_DIVISION_" & Procedure: """_PROCIEN_"""."
. Q
S RESULT=0_SEPSTAT_$$GET1^DIQ(2006.5759,IEN,.01,"I")
Q
ADDROOM(INFO,RAEXAM) ; add the OUTSIDE STUDY camera equipment room to the IMAGING LOCATION
;S RPCERR=$$CALLRPC^MAGM2VCU("MAG DICOM ADD CAMERA EQUIP RM","M",.INFO,RAEXAM)
D ADDROOM^MAGDRPCB(.INFO,RAEXAM)
Q
--- Routine Detail --- with STRUCTURED ROUTINE LISTING ---[H[J[2J[HMAGVIM05 15406 printed Oct 16, 2024@18:10:33 Page 2
MAGVIM05 ;WOIFO/MAT,BT,JL,DAC,PMK - Utilities for RPC calls for DICOM file processing ;09 Sep 2021 3:13 PM
+1 ;;3.0;IMAGING;**118,138,164,166,194,278**;Mar 19, 2002;Build 138
+2 ;; Per VA Directive 6402, this routine should not be modified.
+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 ;; | The Food and Drug Administration classifies this software as |
+11 ;; | a medical device. As such, it may not be changed in any way. |
+12 ;; | Modifications to this software may result in an adulterated |
+13 ;; | medical device under 21CFR820, the use of which is considered |
+14 ;; | to be a violation of US Federal Statutes. |
+15 ;; +---------------------------------------------------------------+
+16 ;;
+17 ;
+18 QUIT
+19 ;
+20 ;+++++ Wrap call to code underlying RPC: RAMAG EXAM COMPLETE & re-format output
+21 ;
+22 ; RPC: MAGV RAD STAT COMPLETE Private IA #5072
+23 ;
+24 ; Inputs:
+25 ; =======
+26 ;
+27 ; RETURN ...... variable to hold the results
+28 ; RADPT ....... IEN of the RAD/NUC MED PATIENT file (#70)
+29 ; RAEXAM1 ..... EXAM DATE (#.01) of the REGISTERED EXAMS sub-file (#70.02)
+30 ; RAEXAM2 ..... IEN of the EXAMINATIONS sub-file (#70.03)
+31 ; MAGVUSR ..... DUZ of the Importer 2 application user.
+32 ; MAGVUSRDV ... DUZ(2) of the Importer 2 user.
+33 ; RAIMGTYP .... TYPE OF IMAGING (#2) of the REGISTERED EXAMS sub-file (#70.02)
+34 ; [RASTDRPT] ... IEN of an entry in the STANDARD REPORTS file (#74.1)
+35 ; ---- Next two are IEN(s) of entries in the DIAGNOSTIC CODES file(#78.3)
+36 ; [RADXPRIM] .. Primary Diagnostic Code --> RAMISC Param PRIMDXCODE
+37 ; [RADXSCND] ... List of Secondary Diagnostic Codes --> RAMISC Param SECDXCODE
+38 ;
+39 ; Outputs:
+40 ; ========
+41 ;
+42 ; Notes:
+43 ; ======
+44 ;
+45 ; The parameters mirror those of the underlying call.
+46 ;
XMCOMPLT(RETURN,RADPT,RAEXAM1,RAEXAM2,MAGVUSR,MAGVUSRDV,RAIMGTYP,RASTDRPT,RADXPRIM,RADXSCND) ;
+1 ;
+2 ;--- Initialize
+3 KILL RETURN
+4 NEW MSG,RARESULT,SEPSTAT,SEPOUTP
DO ZRUSEPIN
+5 ;
+6 ;--- Validate incoming parameters.
+7 NEW MAGERR,PARAM
SET MAGERR=0
+8 Begin DoDot:1
+9 FOR PARAM="RADPT","RAEXAM1","RAEXAM2","MAGVUSR","MAGVUSRDV","RAIMGTYP"
Begin DoDot:2
+10 if @PARAM=""
SET MAGERR=1
+11 QUIT
End DoDot:2
if MAGERR
QUIT
+12 QUIT
End DoDot:1
+13 ;
+14 IF MAGERR
Begin DoDot:1
+15 SET RETURN(0)="-1"_SEPSTAT_"Required parameter "_PARAM_" missing or invalid."
+16 QUIT
End DoDot:1
QUIT
+17 ;
+18 ;--- Format incoming RAD Exam Identifiers.
+19 SET RAEXAM=RADPT_U_RAEXAM1_U_RAEXAM2
+20 ;
+21 ;--- Set IMAGING SITE PARAMETERS file (#2006.1) IEN from DUZ(2).
+22 NEW MAGSITEP
+23 Begin DoDot:1
+24 ;P164
SET MAGVUSRDV=$GET(MAGVUSRDV,$GET(DUZ(2)))
SET MAGSITEP=$ORDER(^MAG(2006.1,"B",MAGVUSRDV,""))
+25 ;P164 - if it is not Site IEN, try Station Number
IF MAGSITEP=""
Begin DoDot:2
+26 ;--- Get IEN of INSTITUTION file (#4) from STATION NUMBER (Supported IA# 2171)
+27 NEW IENINST
SET IENINST=$$IEN^XUAF4(MAGVUSRDV)
+28 ;found the site
SET MAGSITEP=$ORDER(^MAG(2006.1,"B",IENINST,""))
if +MAGSITEP
QUIT
+29 SET MAGERR=1
SET MSG="Unable to resolve Imaging Site Parameters entry. {DUZ(2)="_MAGVUSRDV_"} "
End DoDot:2
+30 QUIT
End DoDot:1
+31 ;
+32 IF MAGERR
Begin DoDot:1
+33 SET RETURN(0)="-1"_SEPSTAT_MSG
+34 QUIT
End DoDot:1
QUIT
+35 ;
+36 ;--- Set additional RAD Order/Exam parameters.
+37 SET MAGERR=$$MAKELIST("C",RAIMGTYP,.RAMSC,MAGVUSR,MAGSITEP)
+38 IF MAGERR
Begin DoDot:1
+39 SET RETURN(0)="-1"_SEPSTAT_$PIECE(MAGERR,U,2)
+40 QUIT
End DoDot:1
QUIT
+41 ;
+42 ;--- Set flag to insert Primary DX code if passed in.
+43 if $GET(RADXPRIM)'=""
DO OUTPUT("PRIMDXCODE^^"_RADXPRIM,.RAMSC)
+44 ;
+45 ;--- Set flag to insert Secondary DX code(s) if passed in.
+46 if $GET(RADXSCND(0))'=""
Begin DoDot:1
+47 ;
+48 NEW CT
SET CT=""
+49 FOR
SET CT=$ORDER(RADXSCND(CT))
if CT=""
QUIT
DO OUTPUT("SECDXCODE"_U_(CT+1)_U_RADXSCND(CT),.RAMSC)
+50 QUIT
End DoDot:1
+51 ;
+52 ;--- Set flag to suppress HL7 message to dictation systems.
+53 DO OUTPUT("FLAGS^^FS",.RAMSC)
+54 ;--- Call code underlying RPC: RAMAG EXAM COMPLETE (Private IA #5072)
+55 DO COMPLETE^RAMAGRP1(.RARESULT,RAEXAM,.RAMSC)
+56 ; add the OUTSIDE STUDY and try the RPC again
IF $GET(RARESULT(1))="-11^2"
Begin DoDot:1
+57 NEW INFO
+58 DO ADDROOM(.INFO,RAEXAM)
+59 KILL RARESULT
+60 IF INFO(1)<0
MERGE RARESULT=INFO
QUIT
+61 DO COMPLETE^RAMAGRP1(.RARESULT,RAEXAM,.RAMSC)
+62 QUIT
End DoDot:1
+63 ;
+64 ;--- Re-format error output or return 0.
+65 IF RARESULT(0)<0
Begin DoDot:1
+66 ;
+67 SET RETURN(0)=-1_SEPSTAT_$ORDER(RARESULT("A"),-1)_" error lines returned."
+68 NEW X
SET X=0
+69 FOR
SET X=$ORDER(RARESULT(X))
if X=""
QUIT
Begin DoDot:2
+70 SET RETURN(X)=$PIECE(RARESULT(X),U,1)_SEPSTAT_$PIECE(RARESULT(X),U,2,999)
+71 QUIT
End DoDot:2
End DoDot:1
+72 IF '$TEST
Begin DoDot:1
+73 SET RETURN(0)=0_SEPSTAT_RARESULT(0)
+74 NEW X
SET X=0
+75 FOR
SET X=$ORDER(RARESULT(X))
if X=""
QUIT
Begin DoDot:2
+76 SET RETURN(X)=$TRANSLATE(RARESULT(X),U,SEPOUTP)
+77 QUIT
End DoDot:2
+78 ;--- Call RA* code to trigger alerts for DX codes.
+79 DO ALERT^MAGVIMRA(RADPT,RAEXAM1,RAEXAM2,1)
+80 QUIT
End DoDot:1
+81 QUIT
+82 ;+++++ Wrap call to code underlying RPC: RAMAG EXAMINED & re-format output
+83 ;
+84 ; RPC: MAGV RAD STAT EXAMINED Private IA #5071
+85 ;
+86 ; Inputs:
+87 ; =======
+88 ;
+89 ; See input parameter descriptions above tag XMCOMPLT (above).
+90 ;
XMEXAMIN(RETURN,RADFN,RAEXAM1,RAEXAM2,MAGVUSR,MAGVUSRDV,RAIMGTYP) ;
+1 ;
+2 ;--- Initialize.
+3 KILL RETURN
+4 NEW MSG,RARESULT,SEPSTAT,SEPOUTP
DO ZRUSEPIN
+5 ;--- Validate incoming parameters.
+6 NEW MAGERR,PARAM
SET MAGERR=0
+7 Begin DoDot:1
+8 FOR PARAM="RADFN","RAEXAM1","RAEXAM2","MAGVUSR","MAGVUSRDV","RAIMGTYP"
Begin DoDot:2
+9 if @PARAM=""
SET MAGERR=1
+10 QUIT
End DoDot:2
if MAGERR
QUIT
+11 QUIT
End DoDot:1
+12 ;
+13 IF MAGERR
Begin DoDot:1
+14 SET RETURN(0)="-1"_SEPSTAT_"Required parameter "_PARAM_" missing or invalid."
+15 QUIT
End DoDot:1
QUIT
+16 ;
+17 ;--- Format incoming RAD Exam Identifiers
+18 NEW RAEXAM
SET RAEXAM=RADFN_U_RAEXAM1_U_RAEXAM2
+19 ;
+20 ;--- Set IMAGING SITE PARAMETERS file (#2006.1) IEN from DUZ(2).
+21 NEW MAGSITEP
+22 Begin DoDot:1
+23 ;DAC P166
SET MAGVUSRDV=$GET(MAGVUSRDV,$GET(DUZ(2)))
SET MAGSITEP=$ORDER(^MAG(2006.1,"B",MAGVUSRDV,""))
+24 ;DAC P166 - if it is not Site IEN, try Station Number
IF MAGSITEP=""
Begin DoDot:2
+25 ;--- Get IEN of INSTITUTION file (#4) from STATION NUMBER (Supported IA# 2171)
+26 NEW IENINST
SET IENINST=$$IEN^XUAF4(MAGVUSRDV)
+27 ;found the site
IF IENINST'=""
SET MAGSITEP=$ORDER(^MAG(2006.1,"B",IENINST,""))
if +MAGSITEP
QUIT
+28 SET MAGERR=1
SET MSG="Unable to resolve Imaging Site Parameters entry. {DUZ(2)="_MAGVUSRDV_"} "
End DoDot:2
+29 QUIT
End DoDot:1
+30 ;
+31 IF MAGERR
Begin DoDot:1
+32 SET RETURN(0)="-1"_SEPSTAT_MSG
+33 QUIT
End DoDot:1
QUIT
+34 ;
+35 ;
+36 ;--- Set required parameters
+37 SET MAGERR=$$MAKELIST("E",RAIMGTYP,.RAMSC,MAGVUSR,MAGSITEP)
+38 IF MAGERR
Begin DoDot:1
+39 SET RETURN(0)="-1"_SEPSTAT_$PIECE(MAGERR,U,2)
+40 QUIT
End DoDot:1
QUIT
+41 ;
+42 ;--- Set flag to suppress HL7 message to dictation systems.
+43 DO OUTPUT("FLAGS^^FS",.RAMSC)
+44 ;--- Call code underlying RPC: RAMAG EXAMINED (Private IA #5071).
+45 DO EXAMINED^RAMAGRP2(.RARESULT,RAEXAM,.RAMSC)
+46 ; add the OUTSIDE STUDY and try the RPC again
IF $GET(RARESULT(1))="-11^2"
Begin DoDot:1
+47 NEW INFO
+48 DO ADDROOM(.INFO,RAEXAM)
+49 KILL RARESULT
+50 IF INFO(1)<0
MERGE RARESULT=INFO
QUIT
+51 DO EXAMINED^RAMAGRP2(.RARESULT,RAEXAM,.RAMSC)
+52 QUIT
End DoDot:1
+53 ;
+54 ;--- Re-format error output or return 0.
+55 IF RARESULT(0)<0
Begin DoDot:1
+56 ;
+57 SET RETURN(0)=-1_SEPSTAT_$ORDER(RARESULT("A"),-1)_" error lines returned."
+58 NEW X
SET X=0
+59 FOR
SET X=$ORDER(RARESULT(X))
if X=""
QUIT
Begin DoDot:2
+60 SET RETURN(X)=$PIECE(RARESULT(X),U,1)_SEPSTAT_$PIECE(RARESULT(X),U,2,999)
+61 QUIT
End DoDot:2
End DoDot:1
+62 IF '$TEST
Begin DoDot:1
+63 SET RETURN(0)=0_SEPSTAT_RARESULT(0)
+64 NEW X
SET X=0
+65 FOR
SET X=$ORDER(RARESULT(X))
if X=""
QUIT
Begin DoDot:2
+66 SET RETURN(X)=$TRANSLATE(RARESULT(X),U,SEPOUTP)
+67 QUIT
End DoDot:2
+68 QUIT
End DoDot:1
+69 QUIT
+70 ;+++++ Wrap calls to RPC: RAMAG EXAM ORDER & re-format output.
+71 ;
+72 ; RPC: MAGV RAD EXAM ORDER Private IA #5068
+73 ;
+74 ; Inputs:
+75 ; =======
+76 ;
+77 ; RETURN
+78 ; DFN
+79 ; RAMLC
+80 ; RADPROC
+81 ; STUDYDAT
+82 ; RACAT
+83 ; REQLOC
+84 ; REQPHYS
+85 ; REASON
+86 ; MISC
+87 ;
+88 ; Notes:
+89 ; ======
+90 ;
+91 ; The parameters are the same as those of the underlying call.
+92 ;
XMORDER(RETURN,DFN,RAMLC,RADPROC,STUDYDAT,RACAT,REQLOC,REQPHYS,REASON,MISC) ;
+1 ;
+2 KILL RETURN
+3 NEW SEPSTAT,SEPOUTP,I,FMDAY,MAXORDER,RAOIEN,REVERSEDAY,PROC1
DO ZRUSEPIN
+4 ;
+5 ; maximum number of same procedures for same date for patient - P194 PMK/DAC 8/14/2018
+6 SET MAXORDER=$PIECE($GET(^MAG(2006.1,1,"IMPORTER")),U,6)
+7 IF MAXORDER=""
SET MAXORDER=10
+8 ;
+9 SET FMDAY=$$HL7TFM^XLFDT($GET(STUDYDAT))
+10 IF FMDAY'>0
Begin DoDot:1
+11 SET RETURN(0)=-1_SEPSTAT_"1 error line returned."
+12 SET RETURN(1)=-1001_SEPSTAT_"Illegal or non-existent STUDYDAT="""_$GET(STUDYDAT)_""""
+13 QUIT
End DoDot:1
QUIT
+14 ; strip the time and reverse the date
SET REVERSEDAY=9999999.9999-(FMDAY\1)
+15 ; P278 DAC - RADPROC may contain optional modifiers - Set PROC1 to the procedure IEN without modifiers
SET PROC1=$PIECE(RADPROC,U,1)
+16 ;
+17 SET RAOIEN=0
+18 ; P278 DAC - Use PROC1 (procedure) instead of RADPROC (procudure + optional modifiers)
+19 FOR I=1:1:MAXORDER
SET RAOIEN=$ORDER(^RAO(75.1,"AP",DFN,PROC1,REVERSEDAY,RAOIEN))
if 'RAOIEN
QUIT
+20 IF RAOIEN
Begin DoDot:1
+21 SET RETURN(0)=-1_SEPSTAT_"1 error line returned."
+22 SET RETURN(1)=-1000_SEPSTAT_"Order already on file with IEN="_RAOIEN
+23 QUIT
End DoDot:1
QUIT
+24 ;
+25 ;--- Private IA #5068.
+26 DO ORDER^RAMAGRP1(.ORDINFO,DFN,RAMLC,RADPROC,STUDYDAT,RACAT,REQLOC,REQPHYS,REASON,.MISC)
+27 ;
+28 ;--- Re-format error output or return new IEN in RAD/NUC MED ORDERS File (#75.1)
+29 IF ORDINFO(0)<0
Begin DoDot:1
+30 ;
+31 SET RETURN(0)=-1_SEPSTAT_$ORDER(ORDINFO("A"),-1)_" error lines returned."
+32 NEW X
SET X=0
FOR
SET X=$ORDER(ORDINFO(X))
if X=""
QUIT
Begin DoDot:2
+33 ;
+34 SET RETURN(X)=$PIECE(ORDINFO(X),U,1)_SEPSTAT_$PIECE(ORDINFO(X),U,2,999)
+35 QUIT
End DoDot:2
+36 QUIT
End DoDot:1
KILL ORDINFO
+37 IF '$TEST
SET RETURN(0)=ORDINFO(0)
+38 KILL ORDINFO
+39 QUIT
+40 ;
+41 ;+++++ Wrap calls to RPC: RAMAG EXAM REGISTER & re-format output.
+42 ;
+43 ; RPC: MAGV RAD EXAM REGISTER Private IA #5069.
+44 ;
+45 ; Inputs:
+46 ; =======
+47 ;
+48 ; RETURN
+49 ; RAOIFN
+50 ; EXMDTE
+51 ; RAMSC
+52 ;
+53 ; Notes:
+54 ; ======
+55 ;
+56 ; The parameters are the same as those of the underlying call.
+57 ;
XMREGSTR(RETURN,RAOIFN,EXMDTE,RAMSC) ;
+1 ;
+2 KILL RETURN
+3 NEW SEPSTAT,SEPOUTP,IMAGLOC
DO ZRUSEPIN
+4 ;
+5 ; Check if imaging location is present - if not find outside imaging location for procedure and division
+6 NEW RODATA
SET RODATA=$GET(^RAO(75.1,RAOIFN,0))
+7 if $PIECE(RODATA,U,20)=""
Begin DoDot:1
+8 NEW LOCINFO,PROCIEN,RAMLC
SET PROCIEN=$PIECE(RODATA,U,2)
+9 DO IMAGELOC(.RAMLC,PROCIEN,DUZ(2))
+10 if $PIECE(RAMLC,SEPSTAT)<0
SET RETURN(0)=RAMLC
+11 if $GET(RETURN(0))
QUIT
+12 SET RAMLC=$PIECE(RAMLC,SEPSTAT,2)
+13 ; call the RPC to update the radiology imaging location in the radiology order file (#75.1).
+14 DO IMAGELOC^MAGDRPCB(.LOCINFO,RAOIFN,RAMLC)
+15 ;"-1"_SEPSTAT_"Error in rpc MAG DICOM SET IMAGING LOCATION"
IF $GET(LOCINFO)<0
SET RETURN(0)=LOCINFO
+16 QUIT
End DoDot:1
+17 ;
+18 ;Get imaging location IEN (#79.1)
+19 KILL RAMLC,PROCIEN
+20 SET PROCIEN=$PIECE(RODATA,U,2)
+21 DO IMAGELOC(.RAMLC,PROCIEN,DUZ(2))
+22 if $PIECE(RAMLC,SEPSTAT)<0
SET RETURN(0)=RAMLC
+23 if $GET(RETURN(0))
QUIT
+24 SET RAMLC=$PIECE(RAMLC,SEPSTAT,2)
+25 ;Get corresponding hospital location IEN (#44)
+26 SET IMAGLOC=$$GET1^DIQ(79.1,.RAMLC,.01,"I")
+27 KILL RAMSC
+28 SET RAMSC(1)="PRINCLIN^^"_$GET(IMAGLOC)
+29 SET RAMSC(2)="FLAGS^^D"
+30 ;
+31 if $GET(RETURN(0))
QUIT
+32 ;--- Private IA #5069.
+33 DO REGISTER^RAMAGRP1(.RARESULT,RAOIFN,EXMDTE,.RAMSC)
+34 ;
+35 IF RARESULT(0)<0
Begin DoDot:1
+36 ;
+37 SET RETURN(0)=-1_SEPSTAT_$ORDER(RARESULT("A"),-1)_" error lines returned."
+38 NEW X
SET X=0
FOR
SET X=$ORDER(RARESULT(X))
if X=""
QUIT
Begin DoDot:2
+39 ;
+40 SET RETURN(X)=$PIECE(RARESULT(X),U,1)_SEPSTAT_$PIECE(RARESULT(X),U,2,999)
+41 QUIT
End DoDot:2
End DoDot:1
+42 IF '$TEST
Begin DoDot:1
+43 SET RETURN(0)=0_SEPSTAT_RARESULT(0)
+44 NEW X
SET X=0
FOR
SET X=$ORDER(RARESULT(X))
if X=""
QUIT
Begin DoDot:2
+45 ;
+46 SET RETURN(X)=$TRANSLATE(RARESULT(X),U,SEPOUTP)
+47 QUIT
End DoDot:2
+48 QUIT
End DoDot:1
+49 QUIT
+50 ;+++ Routine Utility: Initialize Separators
ZRUSEPIN ;
+1 SET SEPOUTP=$$OUTSEP^MAGVIM01
+2 SET SEPSTAT=$$STATSEP^MAGVIM01
+3 QUIT
+4 ;
MAKELIST(RACTION,RAIMGTYP,RAMSC,MAGVUSR,MAGSITEP) ; output required fields
+1 ; Load required flags
+2 NEW INFO
+3 DO EXMSTREQ^RAMAGRP2(.INFO,RACTION,RAIMGTYP)
+4 IF INFO(0)<0
QUIT INFO(1)
+5 ;
+6 NEW TODAYHL7
+7 SET TODAYHL7=$$NOW^XLFDT()\1
SET $EXTRACT(TODAYHL7)=$EXTRACT(TODAYHL7)+17
+8 ;
+9 NEW REQ,RADPVAL
+10 ;REQ001 - technologist
+11 SET REQ(1)="TECH^1^"_MAGVUSR
+12 ;
+13 ;REQ002 - resident or staff
+14 ;REQ003 - detailed procedure - taken care of already
+15 ;
+16 ;REQ004 - film entry
+17 SET RADPVAL=$$GET1^DIQ(2006.1,MAGSITEP,"RAD FILM SIZE","I")
+18 SET REQ(4)="FILMSIZE^1^"_RADPVAL_U_"0"
+19 ;
+20 ;REQ005 - diagnostic code default, if not supplied by user.
+21 if $GET(RADXPRIM)=""
Begin DoDot:1
+22 SET RADPVAL=$$GET1^DIQ(2006.1,MAGSITEP,"RAD PRIMARY DIAGNOSTIC CODE","I")
+23 SET REQ(5)="PRIMDXCODE^^"_RADPVAL
+24 QUIT
End DoDot:1
+25 ;
+26 ;REQ006 - camera / equipment / room
+27 SET RADPVAL=$$GET1^DIQ(2006.1,MAGSITEP,"RAD PRIMARY CAMERA/EQUIP/RM","I")
+28 SET REQ(6)="PRIMCAM^^"_RADPVAL
+29 ;
+30 ;REQ007 - reserved
+31 ;REQ008 - reserved
+32 ;REQ009 - reserved
+33 ;REQ010 - reserved
+34 ;
+35 ;REQ011 - report entered
+36 SET REQ(11)="RPTDTE^^"_TODAYHL7
+37 IF $GET(RASTDRPT)=""
Begin DoDot:1
+38 SET REQ(11,1)="REPORT^1^Electronically generated report for outside study."
+39 QUIT
End DoDot:1
+40 ;--- Add the REPORT text of a selected STANDARD REPORT to the RAMSC array.
+41 IF '$TEST
DO STNDRPRT(RASTDRPT,"R",1)
+42 ;
+43 ;REQ012 - verified report
+44 SET REQ(12)="VERDTE^^"_TODAYHL7
+45 SET REQ(12,1)="RPTSTATUS^^EF"
+46 ;
+47 ;REQ013 - procedure modifiers required - previously done
+48 ;
+49 ;REQ014 - cpt modifiers
+50 SET RADPVAL=$$GET1^DIQ(2006.1,MAGSITEP,"RAD CPT MODIFIERS","I")
+51 if RADPVAL
SET REQ(14)="CPTMODS^1^"_RADPVAL
+52 ;
+53 ;REQ015 - reserved
+54 ;
+55 ;REQ016 - impression
+56 IF $GET(RASTDRPT)=""
Begin DoDot:1
+57 SET REQ(16)="IMPRESSION^1^Electronically generated report for outside study."
+58 QUIT
End DoDot:1
+59 ;--- Add the IMPRESSION text of a selected STANDARD REPORT to the RAMSC array.
+60 IF '$TEST
DO STNDRPRT(RASTDRPT,"I",1)
+61 ;
+62 NEW INDEX
+63 FOR INDEX=1:1:16
IF $PIECE(INFO(0),"^",INDEX)
Begin DoDot:1
+64 if $DATA(REQ(INDEX))
DO OUTPUT(REQ(INDEX),.RAMSC)
+65 if $DATA(REQ(INDEX,1))
DO OUTPUT(REQ(INDEX,1),.RAMSC)
+66 QUIT
End DoDot:1
+67 ;
+68 QUIT 0
+69 ;
+70 ;+++++ Add selected STANDARD REPORT text to the Miscellaneous Parameters array.
+71 ;
STNDRPRT(RASTDRPT,SSCR,INDEX1) ;
+1 ;
+2 NEW PREFIX
SET PREFIX=$SELECT(SSCR="R":"REPORT",SSCR="I":"IMPRESSION")
+3 ;
+4 NEW CT
+5 SET CT=0
FOR
SET CT=$ORDER(^RA(74.1,RASTDRPT,SSCR,CT))
if CT=""
QUIT
Begin DoDot:1
+6 NEW RPTXT
+7 SET RPTXT=PREFIX_U_(CT+INDEX1)_U_$GET(^RA(74.1,RASTDRPT,SSCR,CT,0))
DO OUTPUT(RPTXT,.RAMSC)
+8 QUIT
End DoDot:1
+9 QUIT
+10 ;
OUTPUT(TEXT,ARRAY) ;
+1 NEW I
+2 SET I=$ORDER(ARRAY(""),-1)+1
+3 SET ARRAY(I)=TEXT
+4 QUIT
+5 ;
+6 ; MAGV OUTSIDE IMAGE LOCATION
+7 ;
+8 ; Inputs:
+9 ; =======
+10 ;
+11 ; PROCIEN -- IEN of procedure in RAD/NUC MED PROCEDURES (file #71)
+12 ; DIVISION - IEN of division in INSTITUTION (file #4)
+13 ;
+14 ; Output:
+15 ; ========
+16 ;
+17 ; <0 Error message
+18 ; 0 IEN of the Outside Image Location in the IMAGE LOCATIONS (file #79.1)
+19 ;
IMAGELOC(RESULT,PROCIEN,DIVISION) ;
+1 ; return the outside imaging location for a given radiology procedure and division
+2 NEW IEN,IMAGETYPE,SEPSTAT,SEPOUTP
DO ZRUSEPIN
+3 KILL RESULT
+4 SET PROCIEN=$GET(PROCIEN)
+5 IF (PROCIEN'>0)!(PROCIEN'=+PROCIEN)
Begin DoDot:1
+6 SET RESULT="-1"_SEPSTAT_"Invalid or missing Radiology Procedure pointer: """_PROCIEN_"""."
+7 QUIT
End DoDot:1
QUIT
+8 ;
+9 SET DIVISION=$GET(DIVISION)
+10 IF (DIVISION'>0)!(DIVISION'=+DIVISION)
Begin DoDot:1
+11 SET RESULT="-2"_SEPSTAT_"Invalid or missing Division pointer:"""_DIVISION_"""."
+12 QUIT
End DoDot:1
QUIT
+13 ;
+14 SET IMAGETYPE=$$GET1^DIQ(71,PROCIEN,12,"I")
+15 IF 'IMAGETYPE
Begin DoDot:1
+16 SET RESULT="-3"_SEPSTAT_"Image Type could not be determined for Radiology Procedure pointer: """_PROCIEN_"""."
+17 QUIT
End DoDot:1
QUIT
+18 ;
+19 IF $$GET1^DIQ(4,DIVISION,.01)=""
Begin DoDot:1
+20 SET RESULT="-4"_SEPSTAT_"Invalid Division (Institution) pointer:"""_DIVISION_"""."
+21 QUIT
End DoDot:1
QUIT
+22 SET IEN=$ORDER(^MAGD(2006.5759,"D",DIVISION,IMAGETYPE,""))
+23 IF IEN=""
Begin DoDot:1
+24 SET RESULT="-5"_SEPSTAT_"Outside Imaging Location could not be determined for Division: "_DIVISION_" & Procedure: """_PROCIEN_"""."
+25 QUIT
End DoDot:1
QUIT
+26 SET RESULT=0_SEPSTAT_$$GET1^DIQ(2006.5759,IEN,.01,"I")
+27 QUIT
ADDROOM(INFO,RAEXAM) ; add the OUTSIDE STUDY camera equipment room to the IMAGING LOCATION
+1 ;S RPCERR=$$CALLRPC^MAGM2VCU("MAG DICOM ADD CAMERA EQUIP RM","M",.INFO,RAEXAM)
+2 DO ADDROOM^MAGDRPCB(.INFO,RAEXAM)
+3 QUIT