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

MAGVIM07.m

Go to the documentation of this file.
  1. MAGVIM07 ;;WOIFO/PMK/MLS/SG/DAC/MAT/BT - Imaging RPCs for Importer II; 29 Nov 2011 4:28 PM ; 12 Apr 2012 6:02 PM
  1. ;;3.0;IMAGING;**118**;Mar 19, 2002;Build 4525;May 01, 2013
  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. ;
  1. ;--- Copied from MAGDRPCB. Changed REQUEST STATUS filter at ORDERS+24.
  1. ;
  1. ;
  1. ; Notes
  1. ; =====
  1. ;
  1. ; Modification is for MAG*3.0*118 only. The original RPC name appears for
  1. ; reference only.
  1. ;
  1. ORDERS(ARRAY,DFN) ; RPC = MAG DICOM GET RAD ORDERS ** Modified for MAG*3.0*118 only.
  1. ; look up radiology orders
  1. N ACNUMB,CASENUMB,DIERR,EXAMDATA,EXAMDATE,EXAMSTAT,ERROR,SKIP,FIELDS,I,IENS,IMAGLOCN,INACTDAT
  1. N ORDER,MAGEXAM,MAGMSG,MAGTMPEXAM,MAGTMPMOD,MODCOUNT,MODDATA
  1. N MODIEN,MODIFIER,MSG,PROCIEN,RACNI,RADFN,RADTI,RAOIEN,RC,STATUS,STUDYDAT,TODAY,X,Z
  1. K ARRAY
  1. S DFN=$G(DFN),TODAY=$$DT^XLFDT()
  1. I (DFN'>0)!(DFN'=+DFN) D Q
  1. . S ARRAY(1)="-1,Invalid or missing patient identifier: """_DFN_"""."
  1. . Q
  1. ;
  1. ; Make sure that the patient is registered in the RAD/NUC MED PATIENT file (#70)
  1. ;
  1. S RC=$$RAPTREG^RAMAGU04(DFN) I RC<0 D Q ; ICR 5519
  1. . S ARRAY(1)="-2,Patient with DFN #"_DFN_" is not defined in the RAD/NUC MED PATIENT file (#70)."
  1. . S ARRAY(2)=RC
  1. . Q
  1. ;
  1. ; Use MUMPS global reads to get data from ^RAO because of possible bad data
  1. ; that would cause FileMan to throw an error and not return any results.
  1. ;
  1. S (ARRAY(1),ERROR,RAOIEN)=0
  1. F S RAOIEN=$O(^RAO(75.1,"B",DFN,RAOIEN)) Q:ERROR Q:RAOIEN="" D ; ICR 3074
  1. . S STATUS=$$GET1^DIQ(75.1,RAOIEN,5) ; request status
  1. . ;--- MAG*3.0*118 -- Removed "^COMPLETE^" from the list of statuses to filter.
  1. . I "^^DISCONTINUED^UNRELEASED^"[("^"_STATUS_"^") Q ; quit if status is null too
  1. . S Z=$G(^RAO(75.1,RAOIEN,0))
  1. . K ORDER S $P(ORDER,"^",11)="" ; initialize ORDER string
  1. . S $P(ORDER,"^",1)=RAOIEN ; file 75.1 IEN
  1. . S PROCIEN=$P(Z,"^",2) ; procedure
  1. . Q:PROCIEN="" Q:'$D(^RAMIS(71,PROCIEN,0)) ; null or bad PROCIEN
  1. . S INACTDAT=$P($G(^RAMIS(71,PROCIEN,"I")),U)
  1. . I INACTDAT,INACTDAT<TODAY Q ; ignore inactive procedures
  1. . S $P(ORDER,"^",2)=PROCIEN ; procedure
  1. . ; piece 3 of ORDER is modifier(s)
  1. . S $P(ORDER,"^",4)=STATUS ; request status
  1. . S $P(ORDER,"^",5)=$P(Z,"^",16) ; request entered date
  1. . S $P(ORDER,"^",6)=$$GET1^DIQ(75.1,RAOIEN,1.1) ; reason for study
  1. . S SKIP=0
  1. . I $D(^RADPT("AO",RAOIEN)) D
  1. . . S RADFN=$O(^RADPT("AO",RAOIEN,"")) ; ICR 1172
  1. . . S RADTI=$O(^RADPT("AO",RAOIEN,RADFN,""))
  1. . . S RACNI=$O(^RADPT("AO",RAOIEN,RADFN,RADTI,""))
  1. . . S $P(ORDER,"^",7)=RADTI
  1. . . S $P(ORDER,"^",8)=RACNI
  1. . . S MAGTMPEXAM=$NA(^TMP($T(+0),$J,"EXAM"))
  1. . . S IENS=RACNI_","_RADTI_","_RADFN_","
  1. . . S EXAMDATA=$NA(@MAGTMPEXAM@(70.03,IENS))
  1. . . I $T(ACCFIND^RAAPI)'="" S FIELDS=".01;31;3;" ; requires RA*5.0*47
  1. . . E S FIELDS=".01;3;" ; no accession number field (#31)
  1. . . K @MAGTMPEXAM,MAGMSG
  1. . . D GETS^DIQ(70.03,IENS,FIELDS,"EI",MAGTMPEXAM,"MAGMSG") ; ICR 1172
  1. . . I $D(MAGMSG) D ORDERERR(.ARRAY,.MAGMSG,-3) S ERROR=-3 Q ; fatal FileMan error
  1. . . S EXAMSTAT=$G(@EXAMDATA@(3,"E"))
  1. . . I EXAMSTAT="CANCELLED" S SKIP=1 Q ; do not include cancelled exam
  1. . . S EXAMDATE=$$GET1^DIQ(70.02,(RADTI_","_RADFN),.01,"I") ; ICR 1172
  1. . . S ACNUMB=$G(@EXAMDATA@(31,"E"))
  1. . . I ACNUMB="" D
  1. . . . S CASENUMB=@EXAMDATA@(.01,"E")
  1. . . . S ACNUMB=$E(EXAMDATE,4,7)_$E(EXAMDATE,2,3)_"-"_CASENUMB
  1. . . . Q
  1. . . S $P(ORDER,"^",9)=ACNUMB,$P(ORDER,"^",10)=EXAMDATE
  1. . . S IMAGLOCN=$$GET1^DIQ(70.02,(RADTI_","_RADFN),4) ; ICR 1172
  1. . . S $P(ORDER,"^",11)=IMAGLOCN
  1. . . Q
  1. . ;
  1. . I ERROR Q ; FileMan error encountered in exam lookup
  1. . I SKIP Q ; do not include this record
  1. . ;
  1. . ; get procedure modifier(s)
  1. . S MAGTMPMOD=$NA(^TMP($T(+0),$J,"MODIFIER")),MODDATA=$NA(@MAGTMPMOD@("DILIST"))
  1. . K @MAGTMPMOD,MAGMSG
  1. . D LIST^DIC(75.1125,","_RAOIEN_",","@;.01;.01I;IX","",,,,,,,MAGTMPMOD,"MAGMSG") ; ICR 3074
  1. . I $D(MAGMSG) D ORDERERR(.ARRAY,.MAGMSG,-4) Q ; fatal FileMan error
  1. . S MODCOUNT=+@MODDATA@(0)
  1. . S MODIFIER=""
  1. . F I=1:1:MODCOUNT D
  1. . . S:$L(MODIFIER) MODIFIER=MODIFIER_"~"
  1. . . S MODIEN=@MODDATA@(2,I)
  1. . . S MODIFIER=MODIFIER_@MODDATA@("ID",MODIEN,.01,"E")_"|"_^("I")
  1. . . Q
  1. . S $P(ORDER,"^",3)=MODIFIER
  1. . ;
  1. . S ARRAY(1)=ARRAY(1)+1,ARRAY(ARRAY(1)+1)=ORDER
  1. . Q
  1. K:$D(MAGTMPEXAM) @MAGTMPEXAM K:$D(MAGTMPMOD) @MAGTMPMOD ; cleanup
  1. Q
  1. ;
  1. ORDERERR(ARRAY,MSG,ERRNUMB) ; handle FileMan errors in ORDER subroutine
  1. N I,NODE
  1. K ARRAY
  1. S I=1,NODE="MSG"
  1. F S NODE=$Q(@NODE) Q:NODE="" D
  1. . S I=I+1,ARRAY(I)=NODE
  1. . I $D(@NODE) S ARRAY(I)=ARRAY(I)_"="_@NODE
  1. . Q
  1. S ARRAY(1)="-100,Fatal FileMan error #"_ERRNUMB
  1. Q
  1. ;
  1. IMAGELOC(RESULT,RAOIEN,RAMLC) ; RPC = MAG DICOM SET IMAGING LOCATION
  1. N DIERR,MAGFDA,MAGMSG
  1. ;
  1. K RESULT
  1. S RAOIEN=$G(RAOIEN)
  1. I (RAOIEN'>0)!(RAOIEN'=+RAOIEN) D Q
  1. . S RESULT="-1,Invalid or missing Radiology Order pointer: """_RAOIEN_"""."
  1. . Q
  1. ;
  1. S RAMLC=$G(RAMLC)
  1. I (RAMLC'>0)!(RAMLC'=+RAMLC) D Q
  1. . S RESULT="-2,Invalid or missing Radiology Image Location identifier: """_RAMLC_"""."
  1. . Q
  1. ;
  1. I $$GET1^DIQ(75.1,RAOIEN,.01)="" D Q ; ICR 3074
  1. . S RESULT="-3,Missing Radiology Order for pointer: """_RAOIEN_"""."
  1. . Q
  1. ;
  1. I $$GET1^DIQ(79.1,RAMLC,.01)="" D Q ; ICR 5357
  1. . S RESULT="-4,Missing Radiology Image Location for pointer: """_RAMLC_"""."
  1. . Q
  1. ;
  1. I $$GET1^DIQ(75.1,RAOIEN,20)="" D Q ; ICR 3074
  1. . S MAGFDA(75.1,RAOIEN_",",20)=RAMLC ; IMAGING LOCATION
  1. . D FILE^DIE("","MAGFDA","MAGMSG") ; ICR 3074
  1. . I $D(MAGMSG) S RESULT="-5,Error setting Radiology Image Location" Q
  1. . S RESULT="1,Radiology Image Location set for pointer: """_RAOIEN_"""."
  1. . Q
  1. E D
  1. . S RESULT="2,Radiology Image Location already set for pointer: """_RAOIEN_""", operation ignored."
  1. . Q
  1. Q
  1. ;
  1. ADDROOM(RETURN,RAEXAM) ; RPC = MAG DICOM ADD CAMERA EQUIP RM
  1. N HIT,I,IENS,LOCNAME,OUTSIDESTUDY,MAGFDA,MAGMSG,RADIMGLOC,ROOMS
  1. K RETURN
  1. ;
  1. I $L($G(RAEXAM),"^")<2 S RETURN(0)="-1,Invalid or missing Radiology Exam pointer: """_RAEXAM_"""." Q
  1. ;
  1. ; get the Radiology IMAGING LOCATION
  1. S IENS=$P(RAEXAM,"^",2)_","_$P(RAEXAM,"^",1)_","
  1. S RADIMGLOC=$$GET1^DIQ(70.02,IENS,4,"I") ; ICR 1172
  1. I 'RADIMGLOC S RETURN(0)="-2,Invalid or missing Radiology IMAGING LOCATION for Exam pointer: """_RAEXAM_"""." Q
  1. S LOCNAME=$$GET1^DIQ(79.1,RADIMGLOC,.01)
  1. ;
  1. ; check if the IMAGING LOCATION has the OUTSIDE STUDY Camera/Equipment/Room
  1. S OUTSIDESTUDY="OUTSIDE STUDY" ; designated name
  1. D LIST^DIC(79.12,","_RADIMGLOC_",","@;.01","",,,,,,,"ROOMS","MAGMSG")
  1. I $D(MAGMSG) D ORDERERR(.RETURN,.MAGMSG,-3) Q ; fatal FileMan error
  1. S HIT=0 F I=1:1:ROOMS("DILIST",0) D Q:HIT
  1. . I ROOMS("DILIST","ID",I,".01")=OUTSIDESTUDY S HIT=1
  1. . Q
  1. I HIT S RETURN(0)="2,"_OUTSIDESTUDY_" is already defined for """_LOCNAME_"""." Q
  1. ;
  1. ; add the OUTSIDE STUDY Camera/Equipment/Room to the IMAGING LOCATION
  1. S MAGFDA(79.12,"+1,"_RADIMGLOC_",",.01)=OUTSIDESTUDY
  1. D UPDATE^DIE("E","MAGFDA","MAGIENS","MAGMSG") ; ICR 5357
  1. I $D(MAGMSG) D ORDERERR(.RETURN,.MAGMSG,-4) Q ; fatal FileMan error
  1. S RETURN(0)="1,"_OUTSIDESTUDY_" has been added for """_LOCNAME_"""."
  1. Q
  1. ;
  1. ;+++ FileMan Screen code for the RAD TECHNOLOGIST field (#300) of the
  1. ; IMAGING SITE PARAMETERS file (#2006.1).
  1. ;
  1. ; The direct "ARC" cross-reference read is supported by IA #3544.
  1. ;
  1. YNRADIST(DUZ,RADCLASS) ;
  1. ;
  1. N YN S YN=0
  1. N X F X=1:1:$L(RADCLASS) I $D(^VA(200,"ARC",$E(RADCLASS,X),DUZ)) S YN=1 Q
  1. Q YN
  1. ;
  1. ; MAGVIM07