Index: FOIAVistA/tag/r/IMAGING-MAG-ZMAG/MAGGNTI.m
===================================================================
--- FOIAVistA/trunk/r/IMAGING-MAG-ZMAG/MAGGNTI.m	(revision 631)
+++ FOIAVistA/tag/r/IMAGING-MAG-ZMAG/MAGGNTI.m	(revision 636)
@@ -1,5 +1,4 @@
 MAGGNTI ;WOIFO/GEK - Imaging interface to TIU RPC Calls etc. ; 04 Apr 2002  2:37 PM
- ;;3.0;IMAGING;**10,8,59**;Nov 27, 2007;Build 20
- ;;Per VHA Directive 2004-038, this routine should not be modified.
+ ;;3.0;IMAGING;**10,8**;Sep 15, 2004
  ;; +---------------------------------------------------------------+
  ;; | Property of the US Government.                                |
@@ -9,4 +8,5 @@
  ;; | Development Office of the Department of Veterans Affairs,     |
  ;; | telephone (301) 734-0100.                                     |
+ ;; |                                                               |
  ;; | The Food and Drug Administration classifies this software as  |
  ;; | a medical device.  As such, it may not be changed in any way. |
@@ -20,5 +20,4 @@
  ; Call to file TIU and Imaging Pointers
  ; TIU API to add image to TIU
- N X
  I $P(^TIU(8925,TIUDA,0),U,2)'=$P(^MAG(2005,MAGDA,0),U,7) S MAGRY="0^Patient Mismatch." Q
  D PUTIMAGE^TIUSRVPL(.MAGRY,TIUDA,MAGDA) ;
@@ -28,16 +27,14 @@
  ; DONE.
  S MAGRY="1^Image pointer filed successfully"
- ; Now we save the PARENT ASSOCIATION Date/Time 
- D LINKDT^MAGGTU6(.X,MAGDA)
  Q
 DATA(MAGRY,TIUDA) ;RPC [MAG3 TIU DATA FROM DA]
  ; Call to get TIU data from the TIUDA
- ; Return =     TIUDA^Document Type ^Document Date^DFN^Author DUZ
+ ; Return =     TIUDA^Document Type ^Document Date^DFN
  ;
- 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
+ S MAGRY=TIUDA_U_$$GET1^DIQ(8925,TIUDA,".01","E")_U_$$GET1^DIQ(8925,TIUDA,"1201","I")_U_$$GET1^DIQ(8925,TIUDA,".02","I")
  Q
 IMAGES(MAGRY,TIUDA) ;RPC [MAG3 CPRS TIU NOTE]
  ; Call to get all images for a given TIU DA
- ; We first get all Image IEN's breaking groups into separate images
+ ; We first get all Image IEN's breaking groups into seperate images
  ; Then get Image Info for each one.
  ; MAGRY    -     Return array of Image Data entries
@@ -47,5 +44,5 @@
  ;
  ; Call TIU API to get list of Image IEN's
- N MAGARR,CT,TCT,I,J,Z K ^TMP($J,"MAGGX")
+ N MAGARR,CT,TCT K ^TMP("MAGGX",$J)
  N DA,MAGQI,MAGNCHK,MAGXX,MAGRSLT
  N TIUDFN,MAGQUIT ; MAGQI 8/22/01
@@ -78,16 +75,16 @@
  . . ;   children.  Later when list is looped through, it's INFO^MAGGTII will be in 
  . . ;   list.  Have to do this to allow other images in list from TIU to be processed.
- . . D CHK^MAGGSQI(.MAGQI,DA) I 'MAGQI(0) S CT=CT+1,^TMP($J,"MAGGX",CT)=DA Q
+ . . D CHK^MAGGSQI(.MAGQI,DA) I 'MAGQI(0) S CT=CT+1,^TMP("MAGGX",$J,CT)=DA Q
  . . S J=0 ; the following line needs to take only the first piece of the node - PMK 4/4/02
- . . F  S J=$O(^MAG(2005,DA,1,J)) Q:'J  S CT=CT+1,^TMP($J,"MAGGX",CT)=$P(^(J,0),"^")
+ . . F  S J=$O(^MAG(2005,DA,1,J)) Q:'J  S CT=CT+1,^TMP("MAGGX",$J,CT)=$P(^(J,0),"^")
  . S CT=CT+1
- . S ^TMP($J,"MAGGX",CT)=DA
+ . S ^TMP("MAGGX",$J,CT)=DA
  ; Now get image info for each image
  ;
  S Z=""
  S MAGQUIET=1
- F  S Z=$O(^TMP($J,"MAGGX",Z)) Q:Z=""  D
- . S TCT=TCT+1,MAGXX=^TMP($J,"MAGGX",Z)
- . ;GEK 8/24/00 Stopping the Invalid Image IEN's and Deleted Images
+ F  S Z=$O(^TMP("MAGGX",$J,Z)) Q:Z=""  D
+ . S TCT=TCT+1,MAGXX=^TMP("MAGGX",$J,Z)
+ . ;GEK 8/24/00 Stoping the Invalid Image IEN's and Deleted Images
  . I '$D(^MAG(2005,MAGXX)) D  Q
  . . D INVALID^MAGGTIG(MAGXX,.MAGRSLT) S MAGRY(CT)=MAGRSLT
@@ -96,5 +93,5 @@
  K MAGQUIET
  S MAGRY(0)=TCT_"^"_TCT_" Images for the selected TIU NOTE"
- ; Put the Image IEN of the last image into the group IEN field.
+ ; PUT THE Image IEN of the last image into the group ien field.
  Q:'TCT
  S $P(MAGRY(0),U,3)=TIUDA
@@ -103,5 +100,5 @@
  S $P(MAGRY(0),U,4)=$$GET1^DIQ(8925,TIUDA,".02","E")_"  "_$P(MAGRSLT,U,2)_"  "_$$FMTE^XLFDT($P(MAGRSLT,U,3),"8")
  ;
- S $P(MAGRY(0),U,5)=$S($P($G(MAGFILE),U):$P(MAGFILE,U),$G(MAGXX):MAGXX,1:0)
+ S $P(MAGRY(0),U,5)=$S($P($G(MAGFILE),U):$P(MAGFILE,U),1:MAGXX)
  Q
  ;. S Z=ISDELIMG(DA) I Z S TCT=TCT+1,MAGRY(TCT)="B2^"_$P(Z,U,2) Q
@@ -123,38 +120,2 @@
  S $P(Z,U,17)=$P(MAGR,U,2)
  Q Z
-ISDOCCL(MAGRY,IEN,TIUFILE,CLASS) ;RPC [MAGG IS DOC CLASS]
- ;Checks to see if IEN of TIU Files 8925 or 8925.1 is of a certain Doc Class 
- ;MAGRY  = Return String  
- ;                 for Success   "1^message"
- ;                 for Failure   "0^message"
- ;IEN    = Internal Entry Number in the TIUFILE
- ;TIUFILE = either 8925   if we need to see if a Note is of a Document Class 
- ;            or   8925.1 if we need to see if a Title is of a Document Class
- ;CLASS  = Text Name of the Document Class   example: "ADVANCE DIRECTIVE"
- ;
- S MAGRY="0^Unknown Error checking TIU Document Class"
- K MAGTRGT,DEFIEN,DOCCL,RES,DONE,NTTL
- S DONE=0
- ; If we're resolving a Title
- I TIUFILE="8925.1" D  Q:DONE
- . S DEFIEN=IEN,NTTL="Title"
- . I '$D(^TIU(8925.1,DEFIEN,0)) S MAGRY="0^Invalid Title IEN",DONE=1 Q
- . Q
- ; If we're resolving a Note
- I TIUFILE="8925" D  Q:DONE
- . S NTTL="Note"
- . I '$D(^TIU(8925,IEN)) S MAGRY="0^Invalid Note IEN",DONE=1 Q
- . ; Get Title IEN from Note IEN
- . S DEFIEN=$$GET1^DIQ(8925,IEN_",",.01,"I")
- . I DEFIEN="" S MAGRY="0^Error resolving Document Class from Note IEN" S DONE=1 Q
- . Q
- ;
- ; Find the IEN in 8925.1 for Document Class (CLASS) 
- D FIND^DIC(8925.1,"","@;.001","X",CLASS,"","","I $P(^(0),U,4)=""DC""","","MAGTRGT")
- S DOCCL=$G(MAGTRGT("DILIST",2,1))
- ;
- ; See if ^TIU(8925.1,DEFIEN is of Document Class DOCCL
- S RES=$$ISA^TIULX(DEFIEN,DOCCL)
- I RES S MAGRY="1^The "_NTTL_" is of Document Class "_CLASS Q
- S MAGRY="0^The "_NTTL_" is Not of Document Class "_CLASS
- Q
