MAGGTU31 ;WOIFO/GEK - Silent calls for Imaging ; [ 06/20/2001 08:57 ]
 ;;3.0;IMAGING;**46**;16-February-2007;;Build 1023
 ;; Per VHA Directive 2004-038, this routine should not be modified.
 ;; +---------------------------------------------------------------+
 ;; | Property of the US Government.                                |
 ;; | No permission to copy or redistribute this software is given. |
 ;; | Use of unreleased versions of this software requires the user |
 ;; | to execute a written test agreement with the VistA Imaging    |
 ;; | 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. |
 ;; | Modifications to this software may result in an adulterated   |
 ;; | medical device under 21CFR820, the use of which is considered |
 ;; | to be a violation of US Federal Statutes.                     |
 ;; +---------------------------------------------------------------+
 ;;
 Q
ATTSTAT(IEN) ; Return a sentence saying if the Image was attached
 ; to the TIU NOte before or after the Note was signed.
 ; was signed.
 N SIGNDT,NOTE,MARR,AMMEND,N2,MAGDT,NC,CLOSDT,X
 S N2=$G(^MAG(2005,IEN,2))
 I $P(N2,"^",6)'=8925 Q ""
 S MAGDT=$S($P(N2,"^",11):$P(N2,"^",11),1:$P(N2,"^",1))
 S NOTE=$P(N2,"^",7)
 S NC=NOTE_","
 D GETS^DIQ(8925,NOTE,".01;.06;1501;1606","I","MARR")
 I $D(DIERR) Q "Error: Note-"_NOTE_" : "_$G(^TMP("DIERR",$J,1,"TEXT",1))
 I (MARR(8925,NC,".01","I")=81)!(MARR(8925,NC,".06","I")>0) Q "Image is attached to an Addendum"
 S SIGNDT=MARR(8925,NC,"1501","I")
 S CLOSDT=MARR(8925,NC,"1606","I")
 I CLOSDT]"" D  Q X
 . I $P(CLOSDT,".",2)="" S MAGDT=$P(MAGDT,".",1) I MAGDT=CLOSDT S X="Image was attached Same Day as Note was Electronically Filed." Q
 . I MAGDT>CLOSDT S X="Image was attached After Note was Electronically Filed." Q
 . S X="Image was attached Before Note was Electronically Filed." Q
 . Q
 I SIGNDT="" Q "Image is attached to an UnSigned Note."
 I $P(SIGNDT,".",2)="" S MAGDT=$P(MAGDT,".",1) I MAGDT=SIGNDT Q "Image was attached Same Day as Note was Signed."
 I MAGDT>SIGNDT Q "Image was attached After the Note was Signed."
 Q "Image was attached Before the Note was Signed."
USERKEYS(MAGK) ; RPC [MAGGUSERKEYS]  (called from MAGGTU3)
 N Y
 N MAGKS ; list of keys to send to XUS KEY CHECK
 N MAGKG ; list returned from XUS KEY CHECK
 N I,J,MAGMED,MAGKEY,MAGPLC
 K MAGK
 S MAGPLC=+$$PLACE^MAGBAPI(DUZ(2)) ; DBI - SEB 9/20/2002
 S MAGKEY=+$P($G(^MAG(2006.1,MAGPLC,"KEYS")),U)
 I 'MAGKEY S MAGK(0)="CAPTURE KEYS OFF"
 E  S MAGK(0)="CAPTURE KEYS ON"
 N X S X="MAG",I=0
 F  S X=$O(^XUSEC(X)) Q:$E(X,1,3)'="MAG"  D
 . S I=I+1,MAGKS(I)=X
 D OWNSKEY^XUSRB(.MAGKG,.MAGKS)
 S I=0,J=0,MAGMED=0
 F  S I=$O(MAGKG(I)) Q:I=""  D
 . Q:MAGKG(I)=0
 . S J=J+1,MAGK(J)=MAGKS(I)
 . I MAGKS(I)["MAGCAP MED" S MAGMED=1
 I MAGMED S J=J+1,MAGK(J)="MAGCAP MED"
 Q
