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

MAGGNTI.m

Go to the documentation of this file.
  1. MAGGNTI ;WOIFO/GEK/SG/NST/JSL - Imaging interface to TIU RPC Calls etc. ; 20 Jan 2010 10:08 AM
  1. ;;3.0;IMAGING;**10,8,59,93,108,122,129**;Mar 19, 2002;Build 4607;May 10, 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. FILE(MAGRY,MAGDA,TIUDA) ;RPC [MAG3 TIU IMAGE]
  1. ; Call to file TIU and Imaging Pointers
  1. ; TIU API to add image to TIU
  1. N X
  1. ;Patch 108
  1. ; Create a new TIU note if TIUDA equals zero
  1. I (TIUDA=0),'$$SETTIUDA(.MAGRY,MAGDA,.TIUDA) Q
  1. I $P(^TIU(8925,TIUDA,0),U,2)'=$P(^MAG(2005,MAGDA,0),U,7) S MAGRY="0^Patient Mismatch." Q
  1. D PUTIMAGE^TIUSRVPL(.MAGRY,TIUDA,MAGDA) ;
  1. I 'MAGRY Q
  1. ; Now SET the Parent fields in the Image File
  1. S $P(^MAG(2005,MAGDA,2),U,6,8)=8925_U_TIUDA_U_+MAGRY
  1. ; DONE.
  1. S MAGRY="1^Image pointer filed successfully"
  1. ; Now we save the PARENT ASSOCIATION Date/Time
  1. D LINKDT^MAGGTU6(.X,MAGDA)
  1. Q
  1. DATA(MAGRY,TIUDA) ;RPC [MAG3 TIU DATA FROM DA]
  1. ; Call to get TIU data from the TIUDA
  1. ; MAGRY: returns data from fields .01,1201,.02,1202 , .05
  1. ; .01 1201 .02 1202
  1. ; TIUDA^Document Type ^Document Date^DFN^Author DUZ^Status
  1. ;
  1. ; - old code
  1. ;S MAGRY=TIUDA_U_$$GET1^DIQ(8925,TIUDA,".01","E")_U_$$GET1^DIQ(8925,TIUDA,"1201","I")_U_$$GET1^DIQ(8925,TIUDA,".02","I")_U_$$GET1^DIQ(8925,TIUDA,"1202","I")_U
  1. ;
  1. ;P122 we need 1 if Status is Complete 0 otherwise. Status is field .05
  1. ; reformat code for easier reading, and add the 1 or 0 as 6th piece.
  1. ;
  1. N RES,CDA,ST
  1. D GETS^DIQ(8925,TIUDA,".01;1201;.02;1202;.05","EI","RES")
  1. I '$D(RES) S MAGRY="" Q ;no TIU data
  1. S CDA=TIUDA_","
  1. S $P(MAGRY,U,1)=TIUDA
  1. S $P(MAGRY,U,2)=RES(8925,CDA,".01","E") ; Document Type
  1. S $P(MAGRY,U,3)=RES(8925,CDA,"1201","I") ;Document Date
  1. S $P(MAGRY,U,4)=RES(8925,CDA,".02","I") ;DFN
  1. S $P(MAGRY,U,5)=RES(8925,CDA,"1202","I") ;Author DUZ
  1. ; P122 Return Status as 6th piece of Result String
  1. S $P(MAGRY,U,6)=RES(8925,CDA,".05","E") ; Status
  1. S $P(MAGRY,U,7)="" ; future
  1. S $P(MAGRY,U,8)=$$ISADDNDM^TIULC1(TIUDA) ; NEW FOR 129T12
  1. S $P(MAGRY,U,9)="" ; put's "^" on end of string.
  1. Q
  1. IMAGES(MAGRY,TIUDA) ;RPC [MAG3 CPRS TIU NOTE]
  1. ; Call to get all images for a given TIU DA
  1. ; We first get all Image IEN's breaking groups into separate images
  1. ; Then get Image Info for each one.
  1. ; MAGRY - Return array of Image Data entries
  1. ; MAGRY(0) is 1 ^ message if successful
  1. ; 0 ^ Error message if error;
  1. ; TIUDA is IEN in ^TIU(8925
  1. ;
  1. ; Call TIU API to get list of Image IEN's
  1. N MAGARR,CT,TCT,I,J,Z K ^TMP($J,"MAGGX")
  1. N DA,MAGQI,MAGNCHK,MAGXX,MAGRSLT
  1. N TIUDFN,MAGQUIT ; MAGQI 8/22/01
  1. N MAGFILE ; MAGFILE is returned from MAGGTII
  1. ;
  1. S MAGQUIT=0 ; MAGQI 8/22/01
  1. S TIUDFN=$P($G(^TIU(8925,TIUDA,0)),U,2) ;MAGQI 8/22/01
  1. I 'TIUDFN S MAGRY(0)="0^Invalid Patient DFN for Note ID: '"_TIUDA_"'"
  1. D GETILST^TIUSRVPL(.MAGARR,TIUDA)
  1. S CT=0,TCT=0
  1. ; Now get all images for all groups and single images.
  1. S I="" F S I=$O(MAGARR(I)) Q:'I S DA=MAGARR(I) D ;Q:MAGQUIT
  1. . S Z=$$ISDELIMG(DA) I Z S TCT=TCT+1,MAGRY(TCT)="B2^"_Z Q
  1. . ; Check that array of images from selected TIUDA have
  1. . ; same patient's and valid backward pointers
  1. . I $P($G(^MAG(2005,DA,0)),U,7)'=TIUDFN S MAGQUIT=1,MAGNCHK="Patient Mismatch. TIU: "_TIUDA
  1. . I $P($G(^MAG(2005,DA,2)),U,7)'=TIUDA S MAGQUIT=1,MAGNCHK="Pointer Mismatch. TIU: "_TIUDA
  1. . I MAGQUIT S MAGXX=DA,MAGFILE=$$INFO^MAGGAII(MAGXX,"E") D Q ; D INFO^MAGGTII
  1. . . ; remove the Abstract and Image File Names ; 2/14/03 p8t14 remove c:\program files. with .\bmp\
  1. . . S $P(MAGFILE,U,2,3)="-1~Questionable Data Integrity^.\bmp\imageQA.bmp"
  1. . . ;this stops Delphi App from changing Abstract BMP to OFFLINE IMAGE
  1. . . S $P(MAGFILE,U,6)=$S(($P(MAGFILE,U,6)'=11):"99",1:11)
  1. . . S $P(MAGFILE,U,10)="M"
  1. . . ;Send the error message
  1. . . S $P(MAGFILE,U,17)=MAGNCHK
  1. . . S TCT=TCT+1,MAGRY(TCT)="B2^"_MAGFILE
  1. . ;
  1. . I $O(^MAG(2005,DA,1,0)) D Q
  1. . . ; Integrity check, if group is questionable, add it's ien to list, not it's
  1. . . ; children. Later when list is looped through, it's $$INFO^MAGGAII(MAGXX,"E") will be in
  1. . . ; list. Have to do this to allow other images in list from TIU to be processed.
  1. . . D CHK^MAGGSQI(.MAGQI,DA) I 'MAGQI(0) S CT=CT+1,^TMP($J,"MAGGX",CT)=DA Q
  1. . . S J=0 ; the following line needs to take only the first piece of the node - PMK 4/4/02
  1. . . F S J=$O(^MAG(2005,DA,1,J)) Q:'J S CT=CT+1,^TMP($J,"MAGGX",CT)=$P(^(J,0),"^")
  1. . S CT=CT+1
  1. . S ^TMP($J,"MAGGX",CT)=DA
  1. ; Now get image info for each image
  1. ;
  1. S Z=""
  1. S MAGQUIET=1
  1. F S Z=$O(^TMP($J,"MAGGX",Z)) Q:Z="" D
  1. . S TCT=TCT+1,MAGXX=^TMP($J,"MAGGX",Z)
  1. . ;GEK 8/24/00 Stopping the Invalid Image IEN's and Deleted Images
  1. . I '$D(^MAG(2005,MAGXX)) D Q
  1. . . D INVALID^MAGGTIG(MAGXX,.MAGRSLT) S MAGRY(CT)=MAGRSLT
  1. . ;D INFO^MAGGTII
  1. . S MAGFILE=$$INFO^MAGGAII(MAGXX,"E")
  1. . S MAGRY(TCT)="B2^"_MAGFILE
  1. K MAGQUIET
  1. S MAGRY(0)=TCT_"^"_TCT_" Images for the selected TIU NOTE"
  1. ; Put the Image IEN of the last image into the group IEN field.
  1. Q:'TCT
  1. S $P(MAGRY(0),U,3)=TIUDA
  1. K MAGRSLT
  1. D DATA(.MAGRSLT,TIUDA)
  1. S $P(MAGRY(0),U,4)=$$GET1^DIQ(8925,TIUDA,".02","E")_" "_$P(MAGRSLT,U,2)_" "_$$FMTE^XLFDT($P(MAGRSLT,U,3),"8")
  1. ;
  1. S $P(MAGRY(0),U,5)=$S($P($G(MAGFILE),U):$P(MAGFILE,U),$G(MAGXX):MAGXX,1:0)
  1. Q
  1. ;
  1. ISDELIMG(MAGIEN) ; Is this a deleted Image.
  1. N ERR,MAGR,MAGT,Z
  1. ;--- Check the image status
  1. I '$$ISDEL^MAGGI11(MAGIEN,.ERR) D Q:$G(MAGT)="" MAGR
  1. . I ERR'<0 S MAGR="0^Valid Image" Q
  1. . I +ERR=-43 S MAGR="0^Image IEN exists, and is Deleted !" Q
  1. . S MAGR="Invalid Image pointer",MAGT=67
  1. . Q
  1. E S MAGR="Deleted Image",MAGT=66
  1. ;--- Special processing for deleted images and errors
  1. S $P(Z,U,1,4)=MAGIEN_U_"-1~"_MAGR_U_"-1~"_MAGR_U_MAGR
  1. S $P(Z,U,6)=MAGT
  1. ;--- This stops client from changing Abstract BMP to OFFLINE IMAGE
  1. S $P(Z,U,10)="M"
  1. ;--- Return the error message
  1. S $P(Z,U,17)=$P(MAGR,U,2)
  1. Q Z
  1. ;
  1. ISDOCCL(MAGRY,IEN,TIUFILE,CLASS) ;RPC [MAGG IS DOC CLASS]
  1. ;Checks to see if IEN of TIU Files 8925 or 8925.1 is of a certain Doc Class
  1. ;MAGRY = Return String
  1. ; for Success "1^message"
  1. ; for Failure "0^message"
  1. ;IEN = Internal Entry Number in the TIUFILE
  1. ;TIUFILE = either 8925 if we need to see if a Note is of a Document Class
  1. ; or 8925.1 if we need to see if a Title is of a Document Class
  1. ;CLASS = Text Name of the Document Class example: "ADVANCE DIRECTIVE"
  1. ;
  1. S MAGRY="0^Unknown Error checking TIU Document Class"
  1. K MAGTRGT,DEFIEN,DOCCL,RES,DONE,NTTL
  1. S DONE=0
  1. ; If we're resolving a Title
  1. I TIUFILE="8925.1" D Q:DONE
  1. . S DEFIEN=IEN,NTTL="Title"
  1. . I '$D(^TIU(8925.1,DEFIEN,0)) S MAGRY="0^Invalid Title IEN",DONE=1 Q
  1. . Q
  1. ; If we're resolving a Note
  1. I TIUFILE="8925" D Q:DONE
  1. . S NTTL="Note"
  1. . I '$D(^TIU(8925,IEN)) S MAGRY="0^Invalid Note IEN",DONE=1 Q
  1. . ; Get Title IEN from Note IEN
  1. . S DEFIEN=$$GET1^DIQ(8925,IEN_",",.01,"I")
  1. . I DEFIEN="" S MAGRY="0^Error resolving Document Class from Note IEN" S DONE=1 Q
  1. . Q
  1. ;
  1. ; Find the IEN in 8925.1 for Document Class (CLASS)
  1. D FIND^DIC(8925.1,"","@;.001","X",CLASS,"","","I $P(^(0),U,4)=""DC""","","MAGTRGT")
  1. S DOCCL=$G(MAGTRGT("DILIST",2,1))
  1. ;
  1. ; See if ^TIU(8925.1,DEFIEN is of Document Class DOCCL
  1. S RES=$$ISA^TIULX(DEFIEN,DOCCL)
  1. I RES S MAGRY="1^The "_NTTL_" is of Document Class "_CLASS Q
  1. S MAGRY="0^The "_NTTL_" is Not of Document Class "_CLASS
  1. Q
  1. ;
  1. ; *******************
  1. ; Patch 108
  1. ; Create a new TIU stub using data in ^MAG(2006.82 by Tracking ID
  1. ; In this way BP doesn't need to be recompiled
  1. ;
  1. ; Return Values
  1. ; =============
  1. ; 0 for failure
  1. ; 1 for success
  1. ;
  1. ; MAGRY
  1. ; for failure "0^message"
  1. ; for success "TIU Note IEN^message"
  1. ; TIUDA - TIU Note IEN
  1. ;
  1. ; Input Parameters
  1. ; ================
  1. ; MAGDA - Image IEN in file #2005
  1. ;
  1. SETTIUDA(MAGRY,MAGDA,TIUDA) ;
  1. N TRKID,TIUTTL,TIUTCNT
  1. N MAGTEXT,MAGDFN,MAGADCL,MAGMODE,MAGES,MAGESBY,MAGDATE
  1. N MAGIAPI,TIUIEN
  1. S TRKID=$$GET1^DIQ(2005,MAGDA,"108") ; Tracking ID - it is unique
  1. I TRKID="" S MAGRY="0^TIUDA equals zero and Tracking ID is not found." Q 0
  1. ; Get import data
  1. D GETIAPID^MAGGSIUI(.MAGIAPI,TRKID)
  1. I '$D(MAGIAPI) S MAGRY="0^TIUDA equals zero and no data found by Tracking ID." Q 0 ; no data quit
  1. S TIUTTL=$G(MAGIAPI("PXTIUTTL")) ; Get TIU Title
  1. ; Validate TIU Title
  1. I '$$GETTIUDA^MAGGSIV(.MAGRY,TIUTTL,.TIUIEN) Q 0
  1. S TIUTTL=TIUIEN ; set TIUTTL to internal TIU Title in case the external value is provided
  1. ; Get Text
  1. S TIUTCNT=+$G(MAGIAPI("PXTIUTCNT")) ; TIU note Text Lines Count
  1. F I=0:1:TIUTCNT-1 D
  1. . S MAGTEXT(I)=$G(MAGIAPI("PXTIUTXT"_$TR($J(I,5)," ",0))) ; Get Text Lines
  1. . Q
  1. S MAGTEXT(TIUTCNT)=" VistA Imaging Import API - Imported Document"
  1. S MAGDFN=$$GET1^DIQ(2005,MAGDA,"5","I") ; Patient DFN
  1. S MAGADCL=+$G(MAGIAPI("PXSGNTYP")) ; Signature Type - 0 unsigned/ 1 Admin closed/ 2 Signed
  1. S MAGMODE="E"
  1. S MAGES=""
  1. S MAGESBY=$$GET1^DIQ(2005,MAGDA,"8","I") ; Image Capture by ( Signed)
  1. S MAGDATE=$G(MAGIAPI("PXDT")) ; TIU note Date
  1. ; Create a new TIU note
  1. D NEW^MAGGNTI1(.MAGRY,MAGDFN,TIUTTL,MAGADCL,MAGMODE,MAGES,MAGESBY,"",MAGDATE,"",.MAGTEXT)
  1. I $P(MAGRY,"^") S TIUDA=+MAGRY D UPDPKG^MAGGNTI(MAGDA,TIUDA) Q 1
  1. Q 0
  1. ;
  1. ; *******************
  1. ; Patch 108
  1. ; Update Package Index (#40) in #2005 based on TIU Note info.
  1. ;
  1. ; Input Parameters
  1. ; ================
  1. ; MAGDA - Image IEN in file #2005
  1. ; PXIEN - TIU Note IEN in file #8925
  1. ;
  1. UPDPKG(MAGDA,PXIEN) ;Patch 108: Update Package Index (#40) in #2005 based on TIU Note info.
  1. N PKG,MAGRY,OK,MAGGFDA,MAGGXE,MAGNOFMAUDIT
  1. S PKG=$$GET1^DIQ(2005,MAGDA_",",40)
  1. I PKG'="NONE" Q ; Quit if the package is already set to something else than "NONE"
  1. S PKG=""
  1. D DATA^MAGGNTI(.MAGRY,PXIEN)
  1. D ISCP^TIUCP(.OK,$P(MAGRY,U,2)) I OK S PKG="CP"
  1. I PKG="" D ISCNSLT^TIUCNSLT(.OK,$P(MAGRY,U,2)) I OK S PKG="CONS"
  1. I PKG="" S PKG="NOTE"
  1. S MAGGFDA(2005,MAGDA_",",40)=PKG
  1. S MAGNOFMAUDIT=1 ; Do not file the changes in Audit file.
  1. ; We are not done with initial setup
  1. D UPDATE^DIE("","MAGGFDA","","MAGGXE")
  1. Q