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

MAGGSIA1.m

Go to the documentation of this file.
  1. MAGGSIA1 ;WOIFO/GEK/SG/NST - RPC Call to Add Image File entry ; 01 Nov 2010 2:08 PM
  1. ;;3.0;IMAGING;**7,8,85,59,93,106,117,121**;Mar 19, 2002;Build 2340;Oct 20, 2011
  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. PRE(MAGERR,MAGGFDA,MAGGRP,MAGGDRV,MAGREF) ;
  1. ; Check on some possible problems: required fields etc.
  1. ; Object Type and (Patient, or Short Desc) Required.
  1. N MAGRSLT,X,Z
  1. ; Patch 106: PRE^MAGGSIA1 is called by Import API only so
  1. ; if CAPTURE APPLICATION field (#8.1) is not set we set it to "I"
  1. ; For VI Capture and DICOM Gateway the value of #8.1 is set
  1. ; in ADD^MAGGTIA
  1. I '$D(MAGGFDA(2005,"+1,",8.1)) S MAGGFDA(2005,"+1,",8.1)="I"
  1. ;
  1. D CHKRSND ; Check if this is a Rescinded Import.
  1. S:$G(MAGGFDA(2005,"+1,",113))="" MAGGFDA(2005,"+1,",113)=1 ; Patch 117 Set STATUS (#113) to Viewable (1)
  1. I '$D(MAGGFDA(2005,"+1,",3)) D OBJTYPE
  1. I '$D(MAGGFDA(2005,"+1,",3)) S MAGERR="0^Need an Object Type " Q
  1. I '$D(MAGGFDA(2005,"+1,",5)),'$D(MAGGFDA(2005,"+1,",10)) D Q
  1. . S MAGERR="0^Need Patient or Short Desc. Operation CANCELED "
  1. ; IF no Procedure text we'll give it some so crossref will set.
  1. D PATCHK(.MAGRSLT) I 'MAGRSLT S MAGERR=MAGRSLT Q
  1. ; Patch 8 IAPI We Create IXCLS (#41 CLASS) and IXPKG (#40 Package) if TYPE is in Data.
  1. ; But we are not making TYPE required yet for backward compatibility.
  1. I $D(MAGGFDA(2005,"+1,",42)) D
  1. . I $$GET1^DIQ(2005.83,MAGGFDA(2005,"+1,",42),2,"E")="INACTIVE" D S MAGRY=MAGERR Q
  1. . . S MAGERR="0^Index Type: "_$$GET1^DIQ(2005.83,MAGGFDA(2005,"+1,",42),.01,"E")_"is INACTIVE"
  1. . I '$D(MAGGFDA(2005,"+1,",41)) D MAKECLAS^MAGGSIU1 I $L(MAGERR) S MAGRY=MAGERR Q
  1. . I ($D(MAGGFDA(2005,"+1,",16)))&($$ISTYPADM(MAGGFDA(2005,"+1,",42))) D S MAGRY=MAGERR Q
  1. . . S MAGERR="0^Can't have an ADMIN TYPE with Clinical Image."
  1. . I '$D(MAGGFDA(2005,"+1,",40)) D MAKEPKG^MAGGSIU1 I $L(MAGERR) S MAGRY=MAGERR Q
  1. . I '$D(MAGGFDA(2005,"+1,",6)) D MAKEPROC^MAGGSIU1 I $L(MAGERR) S MAGRY=MAGERR Q
  1. . I '$D(MAGGFDA(2005,"+1,",45)) D MAKEORIG^MAGGSIU1 I $L(MAGERR) S MAGRY=MAGERR Q
  1. . Q
  1. ;
  1. I '$D(MAGGFDA(2005,"+1,",6)) D PROCTEXT
  1. ;
  1. ; If no Procedure/Exam Date/Time we'll give it DocDT, or NOW
  1. I '$D(MAGGFDA(2005,"+1,",15)) D
  1. . I $D(MAGGFDA(2005,"+1,",110)) S MAGGFDA(2005,"+1,",15)=MAGGFDA(2005,"+1,",110) Q
  1. . S MAGGFDA(2005,"+1,",15)=$E($$NOW^XLFDT,1,12)
  1. ; DateTime image saved.
  1. I '$D(MAGGFDA(2005,"+1,",7)) S MAGGFDA(2005,"+1,",7)=$E($$NOW^XLFDT,1,12)
  1. ; Short Description
  1. ;I '$D(MAGGFDA(2005,"+1,",10)) S MAGGFDA(2005,"+1,",10)=$$MAKENAME^MAGGSIU1(.MAGGFDA)
  1. I '$D(MAGGFDA(2005,"+1,",10)) S MAGGFDA(2005,"+1,",10)=$G(MAGGFDA(2005,"+1,",6))
  1. ; Name (.01)
  1. I '$D(MAGGFDA(2005,"+1,",.01)) S MAGGFDA(2005,"+1,",.01)=$$MAKENAME^MAGGSIU1(.MAGGFDA)
  1. I '$D(MAGGFDA(2005,"+1,",8)) S MAGGFDA(2005,"+1,",8)=$G(DUZ)
  1. ; Acquisition Site, Use it to tell where to save the file.
  1. I $D(MAGACT("ACQS")) D
  1. . ; Patch 8 Have to modify: Field 105 (Acquisition Site) is NOW Field .05
  1. . I $P(MAGACT("ACQS"),";")]"" S MAGGFDA(2005,"+1,",.05)=$P(MAGACT("ACQS"),";")
  1. ; Only get drive:dir if not a group
  1. I 'MAGGRP D I $L(MAGERR) Q
  1. . ; The value of the Action Code "WRITE^value" OVERRIDES any Write Location
  1. . ; sent as field # 2 in the input array. (The only value we check for is "PACS" from peter's code)
  1. . S X=$S($D(MAGACT("WRITE")):MAGACT("WRITE"),$D(MAGGFDA(2005,"+1,",2)):MAGGFDA(2005,"+1,",2),1:"")
  1. . ;P85 Send ACQS as second Param. $$DRIVE will use ACQS If X = ""
  1. . ;
  1. . S Z=$$DRIVE^MAGGTU1(X,$G(MAGGFDA(2005,"+1,",.05))) ;Drv:Dir to Write
  1. . I 'Z S MAGERR=Z Q
  1. . S MAGGDRV=$P(Z,U,2)
  1. . S MAGGFDA(2005,"+1,",2)=+Z ;Disk & Vol magnetic
  1. . ; if a big file is being made on workstation, put NetWork Location
  1. . ; pointer in the BIG NETWORK LOCATION field.
  1. . ; (BIG files default to same Network Location as FullRes (or PACS))
  1. . I $G(MAGACT("BIG"))=1 S MAGGFDA(2005,"+1,",102)=+Z
  1. . S MAGREF=+Z ; save network location ien for $$DIRHASH in ^MAGGSIA1
  1. . I $G(MAGACT("ABS"))="STUFFONLY" S MAGGFDA(2005,"+1,",2.1)=+Z
  1. ;
  1. I $D(MAGACT("ACQL")) S MAGGFDA(2005,"+1,",101)=MAGACT("ACQL")
  1. ; HERE we are putting PRE Processing for the Import API action codes.
  1. ; "ACQD,ACQS" If Acquisition device entry doesn't exist, create it.
  1. I $D(MAGACT("ACQD")) D
  1. . ; IF Value is a pointer to the ACQ DEVICE File Quit. If it's invalid then UPDATE will catch it.
  1. . I (+MAGACT("ACQD")=MAGACT("ACQD")) S MAGGFDA(2005,"+1,",107)=MAGACT("ACQD") Q
  1. . I $D(^MAG(2006.04,"B",MAGACT("ACQD"))) D Q
  1. . . ; IF Already exists, add it to the FDA
  1. . . S MAGGFDA(2005,"+1,",107)=$O(^MAG(2006.04,"B",MAGACT("ACQD"),""))
  1. . . ; What do we do with the Acquisition Site. IF Acq Dev already exists. ?
  1. . . ; ??
  1. . ; IF it doesn't exist, create it, and add it's ien to the image entry
  1. . N MAGDFDA,MAGDIEN,MAGDXE
  1. . S MAGDFDA(2006.04,"+1,",.01)=MAGACT("ACQD")
  1. . S MAGDFDA(2006.04,"+1,",1)=$S($D(MAGACT("ACQS")):$P(MAGACT("ACQS"),";"),1:$G(MAGGFDA(2005,"+1,",.05)))
  1. . S MAGDFDA(2006.04,"+1,",2)=$S($D(MAGACT("ACQL")):MAGACT("ACQL"),$D(MAGGFDA(2005,"+1,",101)):MAGGFDA(2005,"+1,",101),1:$P($G(MAGACT("ACQS")),";",2))
  1. . ; ACQS was a 2 ';' piece value with Acq Location (HOSPITAL LOCATION) as 2nd piece
  1. . ; now it is sent as it's own value in ACQL
  1. . D UPDATE^DIE("","MAGDFDA","MAGDIEN","MAGDXE")
  1. . S MAGGFDA(2005,"+1,",107)=MAGDIEN(1)
  1. ;~~~ Delete this comment and the following line of code when
  1. ; the IMAGE AUDIT file (#2005.1) is completely eliminated.
  1. ; If the last IEN in the IMAGE AUDIT file is greater than the
  1. ;~~~ last IEN in the IMAGE file, update the IMAGE file header.
  1. I ($O(^MAG(2005,"A"),-1)<$O(^MAG(2005.1,"A"),-1)) S $P(^MAG(2005,0),U,3)=$O(^MAG(2005.1,"A"),-1)
  1. ;
  1. Q
  1. PATCHK(MAGR) ; This uses the FDA Array and checks the Imaging Patient against the Procedure patient
  1. ;
  1. N MAGDFN,PX,PXDA,MAGY
  1. S PX=$G(MAGGFDA(2005,"+1,",16))
  1. S PXDA=$G(MAGGFDA(2005,"+1,",17))
  1. I 'PX S MAGR=1 Q ; This is a category, or an Image of a group (no parent pointer)
  1. S MAGDFN=MAGGFDA(2005,"+1,",5)
  1. I (PX=8925) D Q
  1. . I '$D(^TIU(8925,PXDA)) S MAGR="0^Invalid TIU Entry Number: "_PXDA Q
  1. . D DATA^MAGGNTI(.MAGY,PXDA)
  1. . I '(MAGDFN=$P(MAGY,U,4)) S MAGR="0^Procedure and Imaging patients don't match." Q
  1. . S MAGR=1
  1. Q
  1. OBJTYPE ; This call uses the EXT and computes an Object Type
  1. N MTYPE
  1. I '$L($G(MAGACT("EXT"))) Q
  1. S MTYPE=$O(^MAG(2005.02,"AD",MAGACT("EXT"),""))
  1. ;I 'MTYPE Q
  1. ;TODO : Answer question, do we want to have a default Image type ?
  1. I 'MTYPE S MTYPE=1
  1. S MAGGFDA(2005,"+1,",3)=MTYPE
  1. Q
  1. ISTYPADM(TYPE) ; Returns 1 if this is an Admin Type
  1. N CL
  1. I '$G(TYPE) Q 0
  1. S CL=$$GET1^DIQ(2005.83,TYPE,1,"E")
  1. Q $S($E(CL,1,5)="ADMIN":1,1:0)
  1. PROCTEXT ;This call uses flds 16 and 17 to compute fld #6 PROCEDURE TEXT [8F]
  1. ; We are here because fld #6 PROCEDURE [8F] is null.
  1. ; If a pointer to a package is in the data, (flds 16 and 17)
  1. ; get fld #6 from that , if not then treat it as an UNASSIGNED image
  1. ; i.e. Category UNASSIGNED.
  1. N MAGYPX,PARENT,PARIEN,PXDESC
  1. S PARENT=$G(MAGGFDA(2005,"+1,",16))
  1. S PARIEN=$G(MAGGFDA(2005,"+1,",17))
  1. ;
  1. I (PARENT=8925),(PARIEN]"") D Q
  1. . D DATA^MAGGNTI(.MAGYPX,PARIEN)
  1. . S MAGGFDA(2005,"+1,",6)=$P(MAGYPX,U,2)
  1. ;TODO; create calls to get default procedure desc for all specialties
  1. ; AND default to NONE if a TYPE and no PARENT data File (fld 16)
  1. ; If a Parent pointer exists, and it isn't TIU, for now set "NO Description"
  1. I PARENT]"" S MAGGFDA(2005,"+1,",6)="No Description" Q
  1. ;
  1. ; Do we have a pointer to a MAG DESCRIPTIVE CATEGORY
  1. I ($G(MAGGFDA(2005,"+1,",100))]"") D Q
  1. . S MAGGFDA(2005,"+1,",6)=$P(^MAG(2005.81,MAGGFDA(2005,"+1,",100),0),U,1)
  1. ;
  1. ; If a new child of a Group, use that Proc Desc
  1. I $G(MAGGFDA(2005,"+1,",14))]"" D Q
  1. . S MAGGFDA(2005,"+1,",6)=$P(^MAG(2005,MAGGFDA(2005,"+1,",14),0),U,8)
  1. ;
  1. ; Parent="", and no Category pointer, then we Call it UNASSIGNED
  1. S MAGGFDA(2005,"+1,",100)=$O(^MAG(2005.81,"B","UNASSIGNED",""))
  1. S MAGGFDA(2005,"+1,",6)="UNASSIGNED"
  1. Q
  1. ; ---------- CHKRSND ----------
  1. ; Import API Delphi Component/OCX only allows certain fields. To get
  1. ; around that limitation, we sometimes need to get data from the
  1. ; IMAGING WINDOWS SESSION File. (#2006.82)
  1. ;
  1. ; Here we add data to MAGGFDA from fields in Session file
  1. ; that didn't make it thought the Delphi Component/OCX
  1. CHKRSND ;
  1. N IDATA,TRKID
  1. S TRKID=$G(MAGGFDA(2005,"+1,",108)) Q:'$L(TRKID)
  1. D GETIAPID^MAGGSIUI(.IDATA,TRKID)
  1. ;
  1. ; PROCEDURE #6
  1. ; CREATION DATE #110
  1. ; LINKED IMAGE #115.1
  1. ; LINKED TYPE #115.2
  1. ; LINKED DATE #115.3 (DATE TIME)
  1. ;
  1. ; Here we can add other fields to MAGGFDA, that aren't passed through
  1. ; the delphi control, but are stored in the Session file for the Import.
  1. ; If not rescind action, then QUIT
  1. I $G(IDATA("ACTION"))'="RESCIND" Q
  1. ; get the LINKED IMAGE and associated fields #115*
  1. ; All data was already validated before added to session file.
  1. I $G(IDATA(6))'="" S MAGGFDA(2005,"+1,",6)=$G(IDATA(6))
  1. I $G(IDATA(110))'="" S MAGGFDA(2005,"+1,",110)=$G(IDATA(110))
  1. I $G(IDATA(115.1))'="" S MAGGFDA(2005,"+1,",115.1)=$G(IDATA(115.1))
  1. I $G(IDATA(115.2))'="" S MAGGFDA(2005,"+1,",115.2)=$G(IDATA(115.2))
  1. I $G(IDATA(115.3))'="" S MAGGFDA(2005,"+1,",115.3)=$G(IDATA(115.3))
  1. Q