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

AMHLESEP.m

Go to the documentation of this file.
AMHLESEP ; IHS/CMI/LAB - calls from within screenman ;
 ;;4.0;IHS BEHAVIORAL HEALTH;;MAY 14, 2010
 ;
HED ;EP - display last
 ;DISPLAY 2 YRS WORTH OF EXAMS FROM MHSS/PCC
 I '$G(AMHPAT) S AMHMSG(1)="Unknown Patient" D HLP^DDSUTL(.AMHMSG) K AMHMSG Q
 NEW AMHX,AMHD,AMHC,AMHED,X,Y,R,AMHE
 D HED1
 NEW C S C="Depression Screening Exam History for "_$P(^DPT(AMHPAT,0),U)
 D ARRAY^XBLM("^TMP(""AMHDSPEDS"",$J,",C)
 K ^TMP("AMHDSPEDS",$J),^TMP($J,"AMHGOT"),^TMP("AMHEDS",$J)
REFRESH ;
 S X=0 X ^%ZOSF("RM")
 W $P(DDGLVID,DDGLDEL,8)
 D REFRESH^DDSUTL
 Q
HED1 ;EP
 S %=$$FMADD^XLFDT(DT,-731),%1=""
 D GETMHED
 D GETPCCED
 D SETARRAY
 Q
SETARRAY ;
 K ^TMP("AMHDSPEDS",$J) S ^TMP("AMHDSPEDS",$J,0)=0
 S X=" " D S(X)
 S X=" " D S(X) S X="*** All Depression Screening Exams documented in BH ***" D S(X)
 S X="DATE",$E(X,11)="SCREENING RESULT",$E(X,44)="PROVIDER" D S(X)
 S X="----",$E(X,11)="----------------",$E(X,44)="--------" D S(X)
 S D=0 F  S D=$O(^TMP("AMHSEDS",$J,"M",D)) Q:D=""  D
 .S I=0 F  S I=$O(^TMP("AMHSEDS",$J,"M",D,I)) Q:I'=+I  S X=^TMP("AMHSEDS",$J,"M",D,I) D S(X) S R=$G(^TMP("AMHSEDS",$J,"M",D,I,1)) I R]"" S X="",$E(X,11)=R D S(X)
 S X=" " D S(X) S X="*** All Depression Screening Exams document in PCC ***" D S(X)
 S X="DATE",$E(X,11)="SCREENING RESULT",$E(X,44)="PROVIDER" D S(X)
 S X="----",$E(X,11)="----------------",$E(X,44)="--------" D S(X)
 S AMHD=0 F  S AMHD=$O(^TMP("AMHSEDS",$J,"P",AMHD)) Q:AMHD'=+AMHD  D
 .S I=0 F  S I=$O(^TMP("AMHSEDS",$J,"P",AMHD,I)) Q:I'=+I  S X=^TMP("AMHSEDS",$J,"P",AMHD,I) D S(X) S R=$G(^TMP("AMHSEDS",$J,"P",AMHD,I,1)) I R]"" S X="",$E(X,11)=R D S(X)
 Q
GETMHED ;set array ^TMP("AMHSEDS",$J,"M" OF EDS IN MH FILE
 K ^TMP("AMHSEDS",$J,"M"),^TMP($J,"AMHGOT")
 S AMHED=$$FMADD^XLFDT(DT,-731),AMHC=0
 S AMHX=0 F  S AMHX=$O(^AMHREC("C",AMHPAT,AMHX)) Q:AMHX'=+AMHX  D
 .Q:'$$ALLOWVI^AMHUTIL(DUZ,AMHX)
 .S R=$P($G(^AMHREC(AMHX,14)),U,5)
 .Q:R=""
 .S AMHD=$P($P($G(^AMHREC(AMHX,0)),U),".")
 .S C=$$VAL^XBDIQ1(9002011,AMHX,1701)
 .S P=$$VAL^XBDIQ1(9002011,AMHX,1406)
 .S R=$$VAL^XBDIQ1(9002011,AMHX,1405)
 .S AMHC=AMHC+1
 .S X=$$DATE(AMHD),$E(X,11)=R,$E(X,44)=P S ^TMP("AMHSEDS",$J,"M",(9999999-AMHD),AMHC)=X I C]"" S ^TMP("AMHSEDS",$J,"M",(9999999-AMHD),AMHC,1)=C
 .S ^TMP($J,"AMHGOT",AMHD)=""
 .Q
 Q
GETPCCED ;
 K ^TMP("AMHSEDS",$J,"P")
 S AMHE=$O(^AUTTEXAM("C",36,0))
 S AMHED=$$FMADD^XLFDT(DT,-731),AMHC=0
 S AMHX=0 F  S AMHX=$O(^AUPNVXAM("AC",AMHPAT,AMHX)) Q:AMHX'=+AMHX  D
 .S R=$P($G(^AUPNVXAM(AMHX,0)),U) I R'=AMHE Q   ;not ipv
 .S R=$P(^AUPNVXAM(AMHX,0),U,3) Q:'R
 .S AMHD=$P($P($G(^AUPNVSIT(R,0)),U),".")
 .;Q:AMHD<AMHED
 .Q:$D(^TMP($J,"AMHGOT",AMHD))
 .S R=$$VAL^XBDIQ1(9000010.13,AMHX,.04) S:R["NEGATIVE" R="NEGATIVE" S:R="" R="NO RESULT DOCUMENTED"
 .S C=$$VAL^XBDIQ1(9000010.13,AMHX,81101)
 .S P=$$VAL^XBDIQ1(9000010.13,AMHX,1204)
 .S AMHC=AMHC+1
 .S X=$$DATE(AMHD),$E(X,11)=R,$E(X,44)=P S ^TMP("AMHSEDS",$J,"P",(9999999-AMHD),AMHC)=X I C]"" S ^TMP("AMHSEDS",$J,"P",(9999999-AMHD),AMHC,1)=C
 .Q
 ;now get refusals
 S AMHD=0 F  S AMHD=$O(^AUPNPREF("AA",AMHPAT,9999999.15,AMHE,AMHD)) Q:AMHD'=+AMHD  D
 .S AMHX=$O(^AUPNPREF("AA",AMHPAT,9999999.15,AMHE,AMHD,AMHX)) Q:AMHX'=+AMHX  D
 ..Q:$D(^TMP($J,"AMHGOT",(9999999-AMHD)))
 ..S R=$$VAL^XBDIQ1(9000022,AMHX,.07) S:R["REFUSED" R="REFUSED SCREENING" S:R["NEGATIVE" R="NEGATIVE" S:R="" R="NO RESULT DOCUMENTED"
 ..S P=$$VAL^XBDIQ1(9000022,AMHX,1204)
 ..S X=$$DATE((9999999-AMHD)),$E(X,11)=R,$E(X,44)=P S ^TMP("AMHSEDS",$J,"P",AMHD,AMHC)=X I C]"" S ^TMP("AMHSEDS",$J,"P",AMHD,AMHC,1)=C
 Q
S(Y,F,C,T) ;
 I '$G(F) S F=0
 I '$G(T) S T=0
 ;blank lines
 F F=1:1:(T-1) S X=" "_X
 F %=1:1:T S X=" "_Y
 D S1
 Q
S1 ;
 S %=$P(^TMP("AMHDSPEDS",$J,0),U)+1,$P(^TMP("AMHDSPEDS",$J,0),U)=%
 S ^TMP("AMHDSPEDS",$J,%,0)=X
 Q
DATE(D) ;EP
 I D="" Q ""
 Q $E(D,4,5)_"/"_$E(D,6,7)_"/"_$E(D,2,3)
 ;