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

MAGDTR05.m

Go to the documentation of this file.
  1. MAGDTR05 ;WOIFO/PMK,JSL,SAF,NST - Read a DICOM image file ; 18 Jan 2013 10:44 AM
  1. ;;3.0;IMAGING;**46,54,123,127**;Mar 19, 2002;Build 4231;Apr 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. LOOKUP(OUT,STATNUMB,ISPECIDX,IPROCS,STARTING,DUZREAD,DUZREAD2,LOCKTIME,STATLIST,DUZRDSTN) ; RPC = MAG DICOM CON UNREADLIST GET
  1. ; entry point to lookup entries in file
  1. ;
  1. ; OUT ------- Return array
  1. ; STATNUMB -- Acquisition Station Number
  1. ; ISPECIDX -- Index to Specialties (2005.84)
  1. ; IPROCS ---- Indexes to Procedures (2005.85) - this is a comma-delimited list
  1. ; STARTING -- Fileman date/time to begin sequential search
  1. ; DUZREAD --- User's DUZ at the Reading Site
  1. ; DUZREAD2 -- DIC(4) pointer to Reading Site
  1. ; LOCKTIME -- timeout value for LOCKTIME
  1. ; STATLIST -- status of entry (C, L, R, U, or W, in any combination)
  1. ; DUZRDSTN -- Station Number to Reading Site
  1. ;
  1. ; DUZRDSTN (Station Number, e.g. 660AA) and DUZREAD2 (IEN in INSTITUTION file (#4), e.g. 6001) describe same site
  1. ; Cannot switch to Station Number only. Old GUI client, before P127, sends DUZREAD2 (Site IEN) only
  1. N ACQSITE ;- site index in Unread List
  1. N ISTATUS ;-- counter to the status in STATLIST
  1. N IPROC ;---- counter to IPROCS
  1. N IPROCIDX ;- index to procedures (2005.85)
  1. N TIMESTMP ;- last activity date/time for the entry
  1. N SITENAME ;- name of acquisition site
  1. N STATUS1 ;-- one status out of the STATLIST
  1. N UNREAD ;--- pointer to entry in unread list
  1. ;
  1. S DUZREAD=$G(DUZREAD,0)
  1. S DUZREAD2=$$SITEIEN^MAGDTR05($G(DUZREAD2),$G(DUZRDSTN)) ; Resolve the Reading Site Station number
  1. S LOCKTIME=$G(LOCKTIME,0)
  1. S STATLIST=$$UP^MAGDFCNV($G(STATLIST))
  1. I STATLIST="" S STATLIST="CDLRUW" ; default to all STATUS values
  1. ;
  1. S ACQSITE=$$ACQSITE^MAGDTR06(STATNUMB)
  1. I ACQSITE<0 S OUT="-1, ACQUISITION STATION NUMBER "_STATNUMB_" IS NOT DEFINED IN FILE 4" Q
  1. S SITENAME=$P(ACQSITE,"^",2),ACQSITE=$P(ACQSITE,"^",1)
  1. ;
  1. I LOCKTIME,DUZREAD2 D UNLOCKER ; automatically unlock timed out studies
  1. ;
  1. K OUT
  1. I STARTING=0 D ; loop through the STATUS index because it is faster
  1. . S STATLIST=$TR(STATLIST,"D") ; remove the DELETED status from STATLIST
  1. . F ISTATUS=1:1:$L(STATLIST) S STATUS1=$E(STATLIST,ISTATUS) D
  1. . . F IPROC=1:1:$L(IPROCS,",") S IPROCIDX=$P(IPROCS,",",IPROC) D
  1. . . . S UNREAD=""
  1. . . . F S UNREAD=$O(^MAG(2006.5849,"D",ACQSITE,ISPECIDX,IPROCIDX,STATUS1,UNREAD)) Q:UNREAD="" D
  1. . . . . D LOOKUP1(UNREAD)
  1. . . . . Q
  1. . . . Q
  1. . . Q
  1. . Q
  1. E D ; retrieve just the latest events
  1. . F IPROC=1:1:$L(IPROCS,",") S IPROCIDX=$P(IPROCS,",",IPROC) D
  1. . . S TIMESTMP=STARTING ; reinitialize the starting date & time for each index to procedures
  1. . . F S TIMESTMP=$O(^MAG(2006.5849,"AC",ACQSITE,ISPECIDX,IPROCIDX,TIMESTMP)) Q:TIMESTMP="" D
  1. . . . S UNREAD=""
  1. . . . F S UNREAD=$O(^MAG(2006.5849,"AC",ACQSITE,ISPECIDX,IPROCIDX,TIMESTMP,UNREAD)) Q:UNREAD="" D
  1. . . . . D LOOKUP1(UNREAD)
  1. . . . . Q
  1. . . . Q
  1. . . Q
  1. . Q
  1. Q
  1. ;
  1. LOOKUP1(UNREAD) ; retrieve one entry from the unread list
  1. N GMRCIEN
  1. N DFN
  1. N VADM
  1. N ICN
  1. N IFCSITE,IFCSITSN,IFCIEN,IFCSITEA,IFCRTIME,IFCLTIME,IFCETIME
  1. N LISTDATA ;- read/unread list data
  1. N QUIT
  1. N READER
  1. N SHORTID
  1. N STATUS
  1. N VA,VADM,VAERR
  1. N VIPSTS ; VIP status
  1. N I,LAST,X,Z
  1. ;
  1. S LISTDATA=$G(^MAG(2006.5849,UNREAD,0))
  1. S STATUS=$P(LISTDATA,"^",11) ; status
  1. Q:STATLIST'[STATUS ; skip the entry if it is not the right STATUS
  1. ;
  1. S GMRCIEN=$P(LISTDATA,"^",1)
  1. S IFCSITE=$$GET1^DIQ(123,GMRCIEN,.07,"I") ; Routing Facility
  1. ;
  1. ; check if this consult can it be displayed to the reader
  1. S QUIT=0
  1. I DUZREAD D Q:QUIT
  1. . I IFCSITE D Q:QUIT ; IFC reading site
  1. . . I IFCSITE'=DUZREAD2 S QUIT=1
  1. . . Q
  1. . I STATUS="W" S QUIT=2 Q
  1. . I STATUS="L" D Q:QUIT
  1. . . S READER=$P(LISTDATA,"^",15) ; reader
  1. . . I READER,READER'=DUZREAD S QUIT=3
  1. . . Q
  1. . Q
  1. ;
  1. ; acquisition site identification
  1. S Z=UNREAD_"|"_GMRCIEN_"|"_STATNUMB_"|"_SITENAME
  1. ; patient information
  1. S DFN=$$GET1^DIQ(123,GMRCIEN,.02,"I")
  1. D DEM^VADPT ; Supported IA (#10061)
  1. D PTSEC^DGSEC4(.VIPSTS,DFN) ; IA #3027
  1. S ICN=$S($T(GETICN^MPIF001)'="":$$GETICN^MPIF001(DFN),1:"-1^NO MPI") ; IA #2701
  1. S X=$TR(VA("PID"),"-",""),SHORTID=$E(VADM(1),1)_$E(X,$L(X)-3,$L(X)) ;P123
  1. S Z=Z_"|"_VADM(1)_"|"_VA("PID")_"|"_ICN_"|"_SHORTID ;P123
  1. S Z=Z_"|"_VIPSTS(1) ; VIP status
  1. S Z=Z_"|"_$P(^MAG(2005.84,ISPECIDX,0),"^",1)_"|"_$P(^MAG(2005.84,ISPECIDX,2),"^",1)
  1. S Z=Z_"|"_$P(^MAG(2005.85,IPROCIDX,0),"^",1)_"|"_$P(^MAG(2005.85,IPROCIDX,2),"^",1)
  1. ; time stamps and image acquisition statistics
  1. S Z=Z_"|"_$P(LISTDATA,"^",7) ; time of first image
  1. S Z=Z_"|"_$P(LISTDATA,"^",8) ; time of last image
  1. S Z=Z_"|"_$P(LISTDATA,"^",9) ; time of last activity
  1. S Z=Z_"|"_(+$P(LISTDATA,"^",10)) ; #images
  1. S Z=Z_"|"_STATUS
  1. S Z=Z_"|"_$$GET1^DIQ(123,GMRCIEN,13,"I") ; consult/procedure flag
  1. S Z=Z_"|"_$P($$GET1^DIQ(123,GMRCIEN,5)," - ",2) ; GMRC urgency
  1. ;
  1. ; get inter-facility consult data
  1. S IFCSITE=$$GET1^DIQ(123,GMRCIEN,.07,"I") ; Routing Facility
  1. S IFCSITSN=$S(IFCSITE>0:$$STA^XUAF4(IFCSITE),1:"") ; Routing Facility Station Number ; Supported IA #2171
  1. I IFCSITE D ; inter-facility consult
  1. . S IFCIEN=$$GET1^DIQ(123,GMRCIEN,.06,"I") ; remote consult file entry
  1. . ; get IFC site abbreviation
  1. . S IFCSITEA=$S(IFCSITSN'="":IFCSITSN,1:"("_IFCSITE_")") ; Station Number or (site IEN)
  1. . S IFCLTIME=$P(LISTDATA,"^",5),IFCRTIME=$P(LISTDATA,"^",6)
  1. . I IFCLTIME,IFCRTIME S IFCETIME=$$FMDIFF^XLFDT(IFCRTIME,IFCLTIME,2)
  1. . E S IFCETIME=""
  1. . Q
  1. E D ; local consult
  1. . S (IFCIEN,IFCSITEA,IFCRTIME,IFCLTIME,IFCETIME)=""
  1. . Q
  1. S Z=Z_"|"_IFCSITE_"|"_IFCSITEA_"|"_IFCIEN
  1. S Z=Z_"|"_IFCLTIME_"|"_IFCRTIME_"|"_IFCETIME
  1. F I=12:1:16 S Z=Z_"|"_$P(LISTDATA,"^",I) ; reader identification
  1. S Z=Z_"|"_$P(LISTDATA,"^",17) ; start of reading
  1. S Z=Z_"|"_$P(LISTDATA,"^",18) ; end of reading
  1. S Z=Z_"|"_IFCSITSN ;
  1. S LAST=$G(OUT(1),1) ; first element in the array is the counter
  1. S LAST=LAST+1,OUT(LAST)=Z,OUT(1)=LAST
  1. Q
  1. ;
  1. UNLOCKER ; automatically unlock any timed out studies
  1. N GMRCIEN
  1. N IFCSITE
  1. N SECONDS ;-- date/time in seconds
  1. N STATUS
  1. N UNLOCKTM ;- earliest date/time for a lock (FM format)
  1. N UNREAD ;--- pointer to entry in unread list
  1. N X
  1. ;
  1. ; calculate the earliest automatic unlock date/time
  1. S SECONDS=86400*$H+$P($H,",",2)-(60*LOCKTIME)
  1. ; convert to FM format
  1. S UNLOCKTM=$$HTFM^XLFDT((SECONDS\86400)_","_(SECONDS#86400),0)
  1. ;
  1. ; traverse the "lock list" and unlock those that have timed out
  1. F IPROC=1:1:$L(IPROCS,",") S IPROCIDX=$P(IPROCS,",",IPROC) D
  1. . S UNREAD=""
  1. . F S UNREAD=$O(^MAG(2006.5849,"D",ACQSITE,ISPECIDX,IPROCIDX,"L",UNREAD)) Q:UNREAD="" D
  1. . . S LISTDATA=$G(^MAG(2006.5849,UNREAD,0))
  1. . . ; check for a lock timeout
  1. . . I $P(LISTDATA,"^",17)<UNLOCKTM D ; lock timeout
  1. . . . ; only unlock studies that are to be done at the reading site
  1. . . . I DUZREAD2=$P(LISTDATA,"^",16) D UNLOCK^MAGDTR04(UNREAD,.STATUS)
  1. . . . Q
  1. . . Q
  1. . Q
  1. Q
  1. ;
  1. SITEIEN(IEN,STNUMBER) ; Return Site IEN for station number STNUMBER if defined, otherwise IEN
  1. ; IEN = Site IEN in INSTITUTION file (#4) e.g. 6001
  1. ; STNUMBER = Station number, e.g. 660AA. This could be blank.
  1. N SITEIEN
  1. S SITEIEN=$$IEN^XUAF4($G(STNUMBER)) ; Supported IA #2171
  1. Q $S(SITEIEN>0:SITEIEN,1:$G(IEN,0))