AMHBHRP4 ; IHS/CMI/LAB - behavioral health display for GUI ;
;;4.0;IHS BEHAVIORAL HEALTH;;MAY 14, 2010
;
;
;
TEST ;
D DISPLAST(.RETVAL,40503,,"S")
Q
DISPLAST(AMHARRAY,AMHPAT,AMHPROV,AMHTYPE,AMHEFT) ;EP - AMHBH RPT LAST VISIT
NEW AMHR
S JOB=$J,AMHGUI=1,XWBWRAP=1
S ZTIO="",ZTQUEUED=1
S AMHARRAY="^XTMP(""AMHRPT"","_$J_")"
K ^XTMP("AMHRPT",JOB)
I $G(AMHPAT)="" S ^XTMP("AMHRPT",JOB,.5)=2,^XTMP("AMHRPT",JOB,1)="Invalid DFN of patient passed" D KILL Q
I $G(AMHTYPE)="" S ^XTMP("AMHRPT",JOB,.5)=2,^XTMP("AMHRPT",JOB,1)="Invalid format type passed" D KILL Q
I "ES"'[AMHTYPE S ^XTMP("AMHRPT",JOB,.5)=2,^XTMP("AMHRPT",JOB,1)="Invalid format type passed" D KILL Q
I $G(AMHPROV),'$D(^VA(200,AMHPROV,0)) S ^XTMP("AMHRPT",JOB,.5)=2,^XTMP("AMHRPT",JOB,1)="Invalid IEN of provider entry passed" D KILL Q
S AMHLVPR=$G(AMHPROV)
S AMHTYPE=$G(AMHTYPE)
S (DFN,AMHPAT,AUPNPAT)=AMHPAT
S ^XTMP("AMHRPTRUN",JOB)=""
D ^XBKSET
D GETREC
I 'AMHR S ^XTMP("AMHRPT",JOB,.5)=2,^XTMP("AMHRPT",JOB,1)="No visit found" D KILL Q
;S ZTRTN="TSK^AMHBHRP4",ZTIO="",ZTDESC="AMH LAST VISIT DISPLAY",ZTSAVE("AMH*")="",ZTSAVE("JOB")="",ZTDTH=$H D ^%ZTLOAD
;F I=1:1:120 Q:$G(^XTMP("AMHRPTRUN",$J))="DONE" H 1
D TSK
D KILL
Q
;
GETREC ;
S AMHR="",AMHEFT=$G(AMHEFT) I AMHEFT="" S AMHEFT="F"
I '$D(^AMHREC("AE",AMHPAT)) Q
I AMHLVPR="" S AMHDLAST=$O(^AMHREC("AE",AMHPAT,"")),AMHR=$O(^AMHREC("AE",AMHPAT,AMHDLAST,"")) Q
NEW D,%,P S (D,%)="" F S D=$O(^AMHREC("AE",AMHPAT,D)) Q:D'=+D!(AMHR) D
.S V=0 F S V=$O(^AMHREC("AE",AMHPAT,D,V)) Q:V'=+V I $$PPINT^AMHUTIL(V)=AMHLVPR S AMHR=V
.Q
Q
TSK ;
D ^XBKSET
S ^XTMP("AMHRPTRUN",JOB)="START"
D GUIR^XBLM($S(AMHTYPE="S":"EN1^AMHLELV",1:"^AMHLEFP2"),"^XTMP(""AMHRPT"",JOB)")
S ^XTMP("AMHRPT",JOB,.5)=$O(^XTMP("AMHRPT",JOB,""),-1)+1
S ^XTMP("AMHRPTRUN",JOB)="DONE"
Q
;
KILL ;
K DFN,AMHPAT,AUPNPAT
K AMHOA,AMHBT,AMHTOT
K AMHCTR,AMHGUI,AMHSF,DIC,JOB,X,Y,ZTDESC,ZTDTH,ZTIO,ZTRTN,ZTSAVE
D EN^XBVK("AMH")
Q
AMHBHRP4 ; IHS/CMI/LAB - behavioral health display for GUI ;
+1 ;;4.0;IHS BEHAVIORAL HEALTH;;MAY 14, 2010
+2 ;
+3 ;
+4 ;
TEST ;
+1 DO DISPLAST(.RETVAL,40503,,"S")
+2 QUIT
DISPLAST(AMHARRAY,AMHPAT,AMHPROV,AMHTYPE,AMHEFT) ;EP - AMHBH RPT LAST VISIT
+1 NEW AMHR
+2 SET JOB=$JOB
SET AMHGUI=1
SET XWBWRAP=1
+3 SET ZTIO=""
SET ZTQUEUED=1
+4 SET AMHARRAY="^XTMP(""AMHRPT"","_$JOB_")"
+5 KILL ^XTMP("AMHRPT",JOB)
+6 IF $GET(AMHPAT)=""
SET ^XTMP("AMHRPT",JOB,.5)=2
SET ^XTMP("AMHRPT",JOB,1)="Invalid DFN of patient passed"
DO KILL
QUIT
+7 IF $GET(AMHTYPE)=""
SET ^XTMP("AMHRPT",JOB,.5)=2
SET ^XTMP("AMHRPT",JOB,1)="Invalid format type passed"
DO KILL
QUIT
+8 IF "ES"'[AMHTYPE
SET ^XTMP("AMHRPT",JOB,.5)=2
SET ^XTMP("AMHRPT",JOB,1)="Invalid format type passed"
DO KILL
QUIT
+9 IF $GET(AMHPROV)
IF '$DATA(^VA(200,AMHPROV,0))
SET ^XTMP("AMHRPT",JOB,.5)=2
SET ^XTMP("AMHRPT",JOB,1)="Invalid IEN of provider entry passed"
DO KILL
QUIT
+10 SET AMHLVPR=$GET(AMHPROV)
+11 SET AMHTYPE=$GET(AMHTYPE)
+12 SET (DFN,AMHPAT,AUPNPAT)=AMHPAT
+13 SET ^XTMP("AMHRPTRUN",JOB)=""
+14 DO ^XBKSET
+15 DO GETREC
+16 IF 'AMHR
SET ^XTMP("AMHRPT",JOB,.5)=2
SET ^XTMP("AMHRPT",JOB,1)="No visit found"
DO KILL
QUIT
+17 ;S ZTRTN="TSK^AMHBHRP4",ZTIO="",ZTDESC="AMH LAST VISIT DISPLAY",ZTSAVE("AMH*")="",ZTSAVE("JOB")="",ZTDTH=$H D ^%ZTLOAD
+18 ;F I=1:1:120 Q:$G(^XTMP("AMHRPTRUN",$J))="DONE" H 1
+19 DO TSK
+20 DO KILL
+21 QUIT
+22 ;
GETREC ;
+1 SET AMHR=""
SET AMHEFT=$GET(AMHEFT)
IF AMHEFT=""
SET AMHEFT="F"
+2 IF '$DATA(^AMHREC("AE",AMHPAT))
QUIT
+3 IF AMHLVPR=""
SET AMHDLAST=$ORDER(^AMHREC("AE",AMHPAT,""))
SET AMHR=$ORDER(^AMHREC("AE",AMHPAT,AMHDLAST,""))
QUIT
+4 NEW D,%,P
SET (D,%)=""
FOR
SET D=$ORDER(^AMHREC("AE",AMHPAT,D))
IF D'=+D!(AMHR)
QUIT
Begin DoDot:1
+5 SET V=0
FOR
SET V=$ORDER(^AMHREC("AE",AMHPAT,D,V))
IF V'=+V
QUIT
IF $$PPINT^AMHUTIL(V)=AMHLVPR
SET AMHR=V
+6 QUIT
End DoDot:1
+7 QUIT
TSK ;
+1 DO ^XBKSET
+2 SET ^XTMP("AMHRPTRUN",JOB)="START"
+3 DO GUIR^XBLM($SELECT(AMHTYPE="S":"EN1^AMHLELV",1:"^AMHLEFP2"),"^XTMP(""AMHRPT"",JOB)")
+4 SET ^XTMP("AMHRPT",JOB,.5)=$ORDER(^XTMP("AMHRPT",JOB,""),-1)+1
+5 SET ^XTMP("AMHRPTRUN",JOB)="DONE"
+6 QUIT
+7 ;
KILL ;
+1 KILL DFN,AMHPAT,AUPNPAT
+2 KILL AMHOA,AMHBT,AMHTOT
+3 KILL AMHCTR,AMHGUI,AMHSF,DIC,JOB,X,Y,ZTDESC,ZTDTH,ZTIO,ZTRTN,ZTSAVE
+4 DO EN^XBVK("AMH")
+5 QUIT