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

MAGGAII.m

Go to the documentation of this file.
  1. MAGGAII ;WOIFO/GEK/SG/JSL - RETURNS IMAGE INFO ; 2/20/09 11:37am
  1. ;;3.0;IMAGING;**93,94,122**;Mar 19, 2002;Build 92;Aug 02, 2012
  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. ;+++++ PERFORMS SPECIAL CONVERSION OF THE DATE/TIME
  1. DTE(DTI) ;
  1. Q $TR($$FMTE^XLFDT(DTI,"5Z"),"@"," ")
  1. ;
  1. ;+++++ RETURNS THE FULL NAME OF THE IMAGE FILE
  1. ;
  1. ; MAGXX IEN of the image record in the file #2005
  1. ;
  1. ; FILETYPE Type of the image: "ABSTRACT", "BIG", or "FULL"
  1. ;
  1. ; [.MAGTYPE] Reference to a local variable where the location
  1. ; code is returned to:
  1. ; A Accessible
  1. ; M Magnetic
  1. ; O Offline
  1. ; W WORM
  1. ;
  1. ; [.MAGJBOL] Reference to a local variable where the Jukebox
  1. ; offline message is returned to.
  1. ;
  1. ; Return Values
  1. ; =============
  1. ; <0 ErrorCode~ErrorMessage
  1. ; "" Name is not available or an error
  1. ;
  1. FILENAME(MAGXX,FILETYPE,MAGTYPE,MAGJBOL) ;
  1. N MAGFILE1,MAGJBCP,MAGOFFLN,MAGPREF
  1. S MAGPREF=""
  1. ;--- Don't queue a copy from the JukeBox.
  1. S MAGJBCP=0
  1. ;--- The FINDFILE^MAGFILEB returns:
  1. ; MAGFILE1 File name (e.g. "LA100066.ABS")
  1. ; if no Network Location pointer or INVALID Pointer
  1. ; then MAGFILE1=-1~NO NETWORK LOCATION POINTER
  1. ; or -1~INVALID NETWORK LOCATION POINTER
  1. ; MAGFILE1(.01) Image description (e.g. "ONE,PATIENT 111223333")
  1. ; MAGJBOL Description of the offline server
  1. ; MAGOFFLN Non-zero if the jukebox is offline
  1. ; MAGPREF Path (e.g. "C:\TEMP\LA\10\00\")
  1. ;--- MAGTYPE "MAG" or "WORM"
  1. D FINDFILE^MAGFILEB
  1. ;--- The MAGFILE1 may contain '^' in case of an error
  1. S MAGFILE1=$TR(MAGFILE1,"^","~")
  1. S:$D(MAGFILE1("ERROR")) MAGFILE1=MAGFILE1("ERROR")
  1. S MAGTYPE=$S($G(MAGOFFLN):"O",FILETYPE="FULL":"A",1:$E(MAGTYPE,1))
  1. ;--- The following line of code replicates the old functionality
  1. Q:FILETYPE'="BIG" $G(MAGPREF)_MAGFILE1
  1. ;--- Return the full name or an empty string in case of an error
  1. Q $S($E(MAGFILE1,1,2)="-1":"",1:$G(MAGPREF)_MAGFILE1)
  1. ;
  1. ;##### RETURNS THE IMAGE DESCRIPTOR
  1. ;
  1. ; MAGIEN IEN of the image record in the file #2005 or
  1. ; in file #2005.1
  1. ;
  1. ; FLAGS Flags that control the execution (can be combined):
  1. ;
  1. ; D Consider only deleted "child" images
  1. ; E Consider only existing "child" images
  1. ;
  1. ; If neither 'E' nor 'D' flag is provided, then an
  1. ; error code is returned.
  1. ;
  1. ; [[.]GRPCNTS] The $$INFO function need counts of images in the
  1. ; group. If these numbers are already available,
  1. ; they can be passed as the value of this parameter.
  1. ; ^01: Number of existing members of the group
  1. ; ^02: Number of deleted members of the group
  1. ;
  1. ; If this parameter is not defiend or empty, the
  1. ; $$INFO function calls the $$GRPCT^MAGGI14 and
  1. ; returns the counts in this parameter if it is
  1. ; passed by reference.
  1. ;
  1. ; Input Variables
  1. ; ===============
  1. ;
  1. ; MAGJOB(
  1. ; "NETPLC",...)
  1. ; "PTNM",...)
  1. ; "RPCPORT")
  1. ; "RPCSERVER")
  1. ;
  1. ; MAGNOCHK Skip the questionable integrity checks if this
  1. ; variable is defined and not zero.
  1. ;
  1. ; Output Variables
  1. ; ================
  1. ;
  1. ; MAGJOB(
  1. ; "NETPLC",...)
  1. ; "PTNM",...)
  1. ;
  1. ; Return Values
  1. ; =============
  1. ; <0 Error descriptor (see the $$ERROR^MAGUERR)
  1. ; >0 Image descriptor
  1. ; ^01: Image IEN
  1. ; ^02: Image full path and name
  1. ; ^03: Abstract full path and name
  1. ; ^04: SHORT DESCRIPTION field and description of
  1. ; offline JukeBox
  1. ; ^05: PROCEDURE/EXAM DATE/TIME field
  1. ; ^06: OBJECT TYPE
  1. ; ^07: PROCEDURE field
  1. ; ^08: display date
  1. ; ^09: PARENT DATA FILE image pointer
  1. ; ^10: ABSTYPE: 'M' magnetic, 'W' worm, 'O' offline
  1. ; ^11: 'A' accessible, 'O' offline
  1. ; ^12: DICOM Series Number
  1. ; ^13: DICOM Image Number
  1. ; ^14: Count of images in group; 1 if single image
  1. ; VISN15
  1. ; ^15: Site parameter IEN
  1. ; ^16: Site parameter CODE
  1. ; ^17: Error description of Integrity Check
  1. ; ^18: Image BIGPath and name
  1. ; ^19: Patient DFN
  1. ; ^20: Patient Name
  1. ; ^21: Image Class: Clin,Admin,Clin/Admin,Admin/Clin
  1. ; ^22: Date Time Image Saved (7)
  1. ; ^23: Document Date (110)
  1. ; ^24: Group IEN
  1. ; ^25: IEN of the 1s child of the group and child's
  1. ; type separated by colon
  1. ; ^26: RPC Broker server
  1. ; ^27: RPC Broker port
  1. ; ^28: Internal value of CONTROLLED IMAGE field (112)
  1. ; converted to a number {0|1}
  1. ; ^29: Viewable Status
  1. ; ^30: Internal value of STATUS field (113)
  1. ; ^31: Image annotated flag (0 or 1)
  1. ; ^32: Image TIU note is completed (0 or 1)
  1. ; ^33: Annotation operation Status
  1. ; ^34: Annotation operation Status Description
  1. ; ^35: Package is the package: RAD,LAB,MED,SUR,NONE,PHOTOID
  1. ;
  1. INFO(MAGIEN,FLAGS,GRPCNTS) ;
  1. N GROUP ; 1 if the entry referenced by MAGIEN is a group
  1. N GRPCH1IEN ; IEN of the first image of the group
  1. N GRPCH1NODE ; Global node of the 1st image od the group
  1. N GRPCH1TYPE ; Type of the first image of the group
  1. N GRPCHCNT ; Number of images in the group
  1. N MAGNODE ; Global node of the image referenced by MAGIEN
  1. N MAGRES ; Result value (image descriptor)
  1. ;
  1. ;N MAG3P59 ;gek/ out in P94t7
  1. N MAGMSG,MAGN0,MAGN100,MAGN2,MAGN40,MAGJBOL
  1. N MAGVST,MDFN,IEN,PLC,PLCODE,RC,TMP,X,ANNOTATED,TMPN2
  1. ;
  1. ;=== Validate control flags
  1. S FLAGS=$G(FLAGS)
  1. ;--- Unknown/Unsupported flag(s)
  1. Q:$TR(FLAGS,"DE")'="" $$IPVE^MAGUERR("FLAGS")
  1. ;--- Missing required flag
  1. Q:$TR(FLAGS,"DE")=FLAGS $$ERROR^MAGUERR(-6,,"D,E")
  1. ;
  1. ;=== Get the global node of the record
  1. S MAGNODE=$$NODE^MAGGI11(MAGIEN)
  1. ;
  1. ;=== Initialize variables
  1. S MAGRES=MAGIEN,RC=0
  1. ;gek/ out in P94t7 S MAG3P59=$D(MAGJOB("RPCSERVER"))&$D(MAGJOB("RPCPORT"))
  1. D:'$D(MAGJOB("NETPLC")) NETPLCS^MAGGTU6
  1. I MAGNODE'="" D
  1. . S MAGN0=$G(@MAGNODE@(0)),MAGN2=$G(@MAGNODE@(2))
  1. . S MAGN40=$G(@MAGNODE@(40)),MAGN100=$G(@MAGNODE@(100))
  1. E S (MAGN0,MAGN2,MAGN40,MAGN100)=""
  1. ;
  1. ;=== Cache patient names; call $$GET 1 time not 2000
  1. S MDFN=$P(MAGN0,U,7) ; PATIENT (5)
  1. I MDFN,'$D(MAGJOB("PTNM",MDFN)) D
  1. . S MAGJOB("PTNM",MDFN)=$$GET1^DIQ(2,MDFN_",",.01)
  1. . ;--- Cache no more than 10 records in the MAGJOB("PTNM")
  1. . S TMP=+$P($G(MAGJOB("PTNM")),U,10)
  1. . S MAGJOB("PTNM")=MDFN_U_$P($G(MAGJOB("PTNM")),U,1,9)
  1. . K:TMP>0 MAGJOB("PTNM",TMP)
  1. . Q
  1. ;
  1. ;=== Process the group header
  1. S GRPCHCNT=0,(GRPCH1IEN,GRPCH1NODE,GRPCH1TYPE)=""
  1. ;--- Count the images of the group
  1. S:$G(GRPCNTS)="" GRPCNTS=$$GRPCT^MAGGI14(MAGIEN)
  1. D:GRPCNTS'<0
  1. . S:FLAGS["E" GRPCHCNT=GRPCHCNT+$P(GRPCNTS,U,1) ; Existing entries
  1. . S:FLAGS["D" GRPCHCNT=GRPCHCNT+$P(GRPCNTS,U,2) ; Deleted entries
  1. . Q
  1. ;--- Check the object type
  1. S GROUP=$$ISGRP^MAGGI11(MAGIEN)
  1. I GROUP D
  1. . ;--- Get the IEN of the first image of the group
  1. . S GRPCH1IEN=$$GRPCH1^MAGGI14(MAGIEN,FLAGS)
  1. . I GRPCH1IEN'>0 S GRPCH1IEN="" Q
  1. . ;--- If we cannot get the global node of the 1st image of the
  1. . ;--- group (this should never happen) clear its IEN as well.
  1. . S GRPCH1NODE=$$NODE^MAGGI11(GRPCH1IEN,.TMP)
  1. . I GRPCH1NODE="" S GRPCH1IEN="" Q
  1. . ;--- Get the type of the first image of the group
  1. . S GRPCH1TYPE=$P(@GRPCH1NODE@(0),U,6)
  1. . Q
  1. ;--- Check the annotation info
  1. S ANNOTATED=+$P($G(^MAG(2005.002,MAGIEN,1,0)),U,4) ;p122 - add IMAGE annotated flag
  1. I 'ANNOTATED I $D(^MAG(2005,MAGIEN,210,0)) S ANNOTATED=1 ;VistARad annotation #2005.001/PS data #2005.05
  1. I 'ANNOTATED I GROUP!$D(^MAG(2005,MAGIEN,1,0)) D ;p122 - find any child w/ annotation
  1. . N NO,CH S NO=0
  1. . F S NO=$O(^MAG(2005,MAGIEN,1,NO)) Q:'NO S CH=+$G(^(NO,0)) S:CH ANNOTATED=+$P($G(^MAG(2005.002,CH,1,0)),U,4) S:$D(^MAG(2005,CH,210,0)) ANNOTATED=1 Q:ANNOTATED
  1. . Q
  1. S:ANNOTATED ANNOTATED=1
  1. ;=== If this is a group and it is not empty, then use
  1. ; the first image to get the names of image files.
  1. ;=== Otherwise, get them from the group header itself.
  1. S IEN=$S(GRPCH1IEN>0:GRPCH1IEN,1:MAGIEN)
  1. ;--- Get full path and file name of the Abstract.
  1. S $P(MAGRES,U,3)=$$FILENAME(IEN,"ABSTRACT",.TMP,.MAGJBOL)
  1. S $P(MAGRES,U,10)=TMP ; Abstract type ('M', 'O', or 'W')
  1. ;--- Get the full path and file name of the FULL RES image.
  1. S $P(MAGRES,U,2)=$$FILENAME(IEN,"FULL",.TMP)
  1. S $P(MAGRES,U,11)=TMP ; 'A' - accessible, 'O' - offline
  1. ;--- Get the full path and file name for the BIG image.
  1. S $P(MAGRES,U,18)=$$FILENAME(IEN,"BIG")
  1. ;
  1. ;=== Get the site parameters IEN and code
  1. S IEN=0
  1. I 'GROUP D
  1. . ;--- If the record is a standalone image entry, then
  1. . ;--- get the location IEN from this entry.
  1. . S IEN=+$S($P(MAGN0,U,3):$P(MAGN0,U,3),1:$P(MAGN0,U,5))
  1. . Q
  1. E I GRPCH1NODE'="" D
  1. . ;--- If the group references "child" entries of requested kind(s),
  1. . ;--- then get the network location IEN from the 1st one.
  1. . S TMP=$G(@GRPCH1NODE@(0))
  1. . S IEN=+$S($P(TMP,U,3):$P(TMP,U,3),1:$P(TMP,U,5))
  1. . Q
  1. E I (FLAGS'["D")!(FLAGS'["E") D
  1. . ;--- Otherwise, try to get the location IEN from the 1st "child"
  1. . ;--- image regardless of the requested kind (existing or deleted).
  1. . N CH1IEN,CH1NODE
  1. . S CH1IEN=$$GRPCH1^MAGGI14(MAGIEN,"DE") Q:CH1IEN'>0
  1. . S CH1NODE=$$NODE^MAGGI11(CH1IEN) Q:CH1NODE=""
  1. . S TMP=$G(@CH1NODE@(0))
  1. . S IEN=+$S($P(TMP,U,3):$P(TMP,U,3),1:$P(TMP,U,5))
  1. . Q
  1. S PLC=$P($G(MAGJOB("NETPLC",IEN)),U,1) ; Site Parameters IEN
  1. S PLCODE=$P($G(MAGJOB("NETPLC",IEN)),U,2) ; Site Code (e.g. "WAS")
  1. ;--- Groups of 0 images need this
  1. S:PLC="" PLC=$G(MAGJOB("PLC")),PLCODE=$G(MAGJOB("PLCODE"))
  1. ;
  1. ;=== SHORT DESCRIPTION field (10) and description of offline JukeBox
  1. S $P(MAGRES,U,4)=$P(MAGN2,U,4)_$G(MAGJBOL)
  1. ;
  1. ;=== Various fields
  1. S $P(MAGRES,U,5)=$P(MAGN2,U,5) ; PROCEDURE/EXAM DATE/TIME (15)
  1. S $P(MAGRES,U,6)=$P(MAGN0,U,6) ; OBJECT TYPE (3)
  1. S $P(MAGRES,U,7)=$P(MAGN0,U,8) ; PROCEDURE (6)
  1. S $P(MAGRES,U,8)=$$DTE($P(MAGN2,U,5)) ; Ext. PROCEDURE/EXAM DATE/TIME
  1. S $P(MAGRES,U,9)=$P(MAGN2,U,8) ; PARENT DATA FILE IMAGE POINTER (18)
  1. ;
  1. ;=== 2/1/99 Dicom Series number and Dicom Image Number
  1. ; $p(12) and $p(13)
  1. ;
  1. ;=== Number of images of requested kind in the group
  1. S $P(MAGRES,U,14)=$S(GRPCHCNT>0:GRPCHCNT,1:1)
  1. ;
  1. ;=== Site IEN and code
  1. S $P(MAGRES,U,15,16)=PLC_U_PLCODE
  1. ;
  1. ;=== Data integrity checks
  1. S TMP=$S('$G(MAGNOCHK):"Q",1:"")
  1. S MAGVST=$$VIEWSTAT^MAGGI12(MAGIEN,TMP,.MAGMSG)
  1. ;;W !,"MAGVST : ",$G(MAGVST) ; TESTING, TAKE OUT THIS LINE.
  1. I MAGVST["Q" D
  1. . ;--- Remove the file name of the full resolution image
  1. . S $P(MAGRES,U,2)="-1~Questionable Data Integrity"
  1. . ;--- Replace the Abstract with the special bitmap
  1. . S $P(MAGRES,U,3)=".\bmp\imageQA.bmp"
  1. . ;--- Prevent the client from changing the Questionable
  1. . ;--- Integrity abstract bitmap to the Offline bitmap.
  1. . S:$P(MAGRES,U,6)'=11 $P(MAGRES,U,6)=99
  1. . S $P(MAGRES,U,10)="M"
  1. . ;--- Return the error message
  1. . S $P(MAGRES,U,17)=MAGMSG("Q")
  1. . Q
  1. ;
  1. ;=== Various fields
  1. S $P(MAGRES,U,19)=MDFN ; Patient IEN (DFN)
  1. S $P(MAGRES,U,20)=$S(MDFN:MAGJOB("PTNM",MDFN),1:MDFN)
  1. S $P(MAGRES,U,22)=$$DTE($P(MAGN2,U)) ; DATE/TIME IMAGE SAVED (7)
  1. S $P(MAGRES,U,23)=$$DTE($P(MAGN100,U,6)) ; CREATION DATE (110)
  1. ;
  1. ;=== Name of the image class
  1. S IEN=+$P(MAGN40,U,3) ; TYPE INDEX (42)
  1. S:IEN>0 $P(MAGRES,U,21)=$$GET1^DIQ(2005.83,IEN_",",1,,,"MAGMSG")
  1. ;
  1. ;=== If the client is newer than patch 59, then we can set beyond
  1. ; 25 pieces. Additional "^" at the end of the result prevents
  1. ;=== problems on the client side.
  1. D ;gek/ out in P94t7 I MAG3P59 D
  1. . S $P(MAGRES,U,24)=$P(MAGN0,U,10) ; GROUP PARENT (14)
  1. . S:GRPCHCNT>1 $P(MAGRES,U,25)=GRPCH1IEN_":"_GRPCH1TYPE
  1. . S $P(MAGRES,U,26)=$G(MAGJOB("RPCSERVER")) ; GEK P94 put in $G
  1. . S $P(MAGRES,U,27)=$G(MAGJOB("RPCPORT")) ; GEK P94 put in $G
  1. . S TMP=+$P(MAGN100,U,7) ; CONTROLLED IMAGE (112)
  1. . S $P(MAGRES,U,28)=TMP
  1. . S:TMP $P(MAGRES,U,3)=".\bmp\magsensitive.bmp"
  1. . S TMP=+$P(MAGN100,U,8) ; STATUS (113)
  1. . S $P(MAGRES,U,29)=$$VSTCODE(MAGVST,TMP)
  1. . S $P(MAGRES,U,30)=TMP
  1. . ; patch 122 new data pieces (31-35) for annotation.
  1. . S $P(MAGRES,U,31)=$G(ANNOTATED) ;IMAGE annotated
  1. . S TMP=""
  1. . ; if it is a child of a Group, the Parent data is in the Group.
  1. . S TMPN2=MAGN2 I $P(MAGN0,U,10) S TMPN2=$G(^MAG(2005,$P(MAGN0,U,10),2))
  1. . I $P(TMPN2,U,6)=8925 D DATA^MAGGNTI(.TMP,$P(TMPN2,U,7)) S TMP=$P(TMP,U,6)
  1. . S $P(MAGRES,U,32)=$S(TMP="":"",TMP="COMPLETED":1,1:0) ; if TIU check Note status
  1. . S TMP="" ; use TMP to return Description.
  1. . S $P(MAGRES,U,33)=$$ANNSTAT^MAGGI12(MAGIEN,$P(MAGRES,U,29),.TMP) ;Annotation Status
  1. . S $P(MAGRES,U,34)=TMP ; This is Desc of Annotation Status
  1. . S $P(MAGRES,U,35)=$P(MAGN40,U,1) ;the package RAD,LAB,MED,SUR...etc
  1. . S $P(MAGRES,U,36)="" ; This forces "^" to be last character in string.
  1. . Q:GRPCH1NODE=""
  1. . ;--- If the group header is not marked as controlled but the 1st
  1. . ; image is, override the sensitivity flag so that the image
  1. . ;--- abstract is not shown in the image list.
  1. . I '$P(MAGRES,U,28) D:$P($G(@GRPCH1NODE@(100)),U,7)
  1. . . S $P(MAGRES,U,28)=1,$P(MAGRES,U,3)=".\bmp\magsensitive.bmp"
  1. . . Q
  1. . Q
  1. ;gek/ out in P94t7 E S $P(MAGRES,U,25)=""
  1. ;
  1. ;=== Stop displaying a group of 1 as a group
  1. I GROUP,GRPCHCNT=1 D
  1. . N CH1N100,CH1VST
  1. . S $P(MAGRES,U,1)=GRPCH1IEN ; IEN of the 1st image of the group
  1. . S $P(MAGRES,U,6)=GRPCH1TYPE ; OBJECT TYPE (3) of the 1st image
  1. . ;gek/ out in P94t7 Q:'MAG3P59
  1. . ;--- Get the viewable status of the 1st "child"
  1. . S TMP=$S('$G(MAGNOCHK):"Q",1:"")
  1. . S CH1VST=$$VIEWSTAT^MAGGI12(GRPCH1IEN,TMP)
  1. . ;--- Get the image status of the 1st "child"
  1. . S CH1N100=$S(GRPCH1NODE'="":$G(@GRPCH1NODE@(100)),1:"")
  1. . S TMP=+$P(CH1N100,U,8) ; STATUS (113)
  1. . ;--- Override the group's values with those of Child 1
  1. . S $P(MAGRES,U,29)=$$VSTCODE(CH1VST,TMP) ; numeric code of 'View Status'
  1. . S $P(MAGRES,U,30)=TMP ; Status
  1. . ; ANNOTATED due to only child was annotated
  1. . S $P(MAGRES,U,31)=$G(ANNOTATED,0) ; IMAGE been annotated
  1. . ; Don't change to Child for Report Parent info.
  1. . ; Parent Data values are stored in '2' node of the Group.
  1. . S TMP=""
  1. . I $P(MAGN2,U,6)=8925 D DATA^MAGGNTI(.TMP,$P(MAGN2,U,7)) S TMP=$P(TMP,U,6)
  1. . S $P(MAGRES,U,32)=$S(TMP="COMPLETED":1,1:0)
  1. . ; Now need to change the Annotation Status, cause change in 'View Status'
  1. . S TMP="" ; use TMP to return Description.
  1. . S $P(MAGRES,U,33)=$$ANNSTAT^MAGGI12(GRPCH1IEN,$P(MAGRES,U,29),.TMP) ;Annotation Status
  1. . S $P(MAGRES,U,34)=TMP ; Annotation Status Description.
  1. . ; $P(35) is package RAD,LAB,SUR,MED,NOTE etc defined in Group and Child.
  1. . Q
  1. ;
  1. ;===
  1. Q MAGRES
  1. ;
  1. ;+++++ CONVERTS THE VIEWABLE STATUS TO THE NUMERIC CODE
  1. VSTCODE(VST,STATUS) ;
  1. Q $S(VST["D":12,VST["Q":21,VST["T":22,VST["R":23,1:+STATUS)