BHSAMI ;IHS/MSC/MGH - Health Summary Components for V AMI file ;03-Oct-2013 06:01;JS
;;1.0;HEALTH SUMMARY COMPONENTS;**8**;March 17, 2006;Build 22
; ==================================================================
;
AMI ;EP - display AMI visits, date limits and numbers are applicable
N BHSPAT,BHSAMI,V,Y,X,BHSIVD,BHIEN,VIEN,BHSOB,CNT,LINE,BHSOBI,TARGET,ZMAX,ZVIST
S BHSPAT=DFN
S ZMAX=$S(+($G(GMTSNDM))>0:+($G(GMTSNDM)),1:9999)
I '$D(^AUPNVAMI("AA",BHSPAT)) Q ;no AMI data for this patient
; <DISPLAY>
K BHSOB
S BHSOBI=0 F S BHSOBI=$O(^AUPNVAMI("AA",BHSPAT,BHSOBI)) Q:BHSOBI="" D
.S BHSIVD="" F S BHSIVD=$O(^AUPNVAMI("AA",BHSPAT,BHSOBI,BHSIVD)) Q:BHSIVD=""!(BHSIVD>GMTSDLM) D
..S BHIEN=0 F S BHIEN=$O(^AUPNVAMI("AA",BHSPAT,BHSOBI,BHSIVD,BHIEN)) Q:'+BHIEN D
...S VIEN=$P($G(^AUPNVAMI(BHIEN,0)),U,3)
...Q:$G(VIEN)=""
...S BHSAMI(VIEN,BHSIVD)="" ;Save off the visits by date
;Now loop through the visits and call the API to return all the problems for that visit
S VIEN="",CNT=0
D CKP^GMTSUP Q:$D(GMTSQIT)
S TARGET=$$TMPGBL
F S VIEN=$O(BHSAMI(VIEN)) Q:VIEN=""!(CNT>ZMAX)!($D(GMTSQIT)) D
.S CNT=CNT+1
.S ZVIST=$$GET1^DIQ(9000010,VIEN,.01,"E")
.W !,"Visit: "_ZVIST,!,"------------------------------------------------------------",!!
.K @TARGET
.S X=$$VAMI^BTIUVAMI(DFN,TARGET,VIEN) ;PEP - Returns AMI entry for a Visit
.S LINE=""
.F S LINE=$O(^TMP("BTIUVAMI",$J,LINE)) Q:LINE="" D
..D CKP^GMTSUP Q:$D(GMTSQIT) I GMTSNPG W !!!
..S Y=$G(^TMP("BTIUVAMI",$J,LINE,0))
..W Y,!
K @TARGET
Q
STR ;EP-Display STROKE visits, date limits and numbers are applicable
N BHSPAT,V,Y,X,BHSIVD,BHIEN,VIEN,BHSOB,CNT,LINE,BHSOBI,BHSTR,TARGET,ZMAX,ZVIST
S BHSPAT=DFN
S ZMAX=$S(+($G(GMTSNDM))>0:+($G(GMTSNDM)),1:9999)
I '$D(^AUPNVSTR("AA",BHSPAT)) Q ;no STROKE data for this patient
; <DISPLAY>
K BHSOB
S BHSOBI=0 F S BHSOBI=$O(^AUPNVSTR("AA",BHSPAT,BHSOBI)) Q:BHSOBI="" D
.S BHSIVD="" F S BHSIVD=$O(^AUPNVSTR("AA",BHSPAT,BHSOBI,BHSIVD)) Q:BHSIVD=""!(BHSIVD>GMTSDLM) D
..S BHIEN=0 F S BHIEN=$O(^AUPNVSTR("AA",BHSPAT,BHSOBI,BHSIVD,BHIEN)) Q:'+BHIEN D
...S VIEN=$P($G(^AUPNVSTR(BHIEN,0)),U,3)
...Q:$G(VIEN)=""
...S BHSTR(VIEN,BHSIVD)="" ;Save off the visits by date
;Now loop through the visits and call the API to return all the problems for that visit
S VIEN="",CNT=0
D CKP^GMTSUP Q:$D(GMTSQIT)
S TARGET=$$TMPGBL2
F S VIEN=$O(BHSTR(VIEN)) Q:VIEN=""!(CNT>ZMAX)!($D(GMTSQIT)) D
.S CNT=CNT+1
.S ZVIST=$$GET1^DIQ(9000010,VIEN,.01,"E") ; VISIT/ADMIT DATE&TIME
.W !,"Visit: "_ZVIST,!,"------------------------------------------------------------",!!
.K @TARGET
.S X=$$VSTR^BTIUVSTR(DFN,TARGET,VIEN) ;PEP - Returns STROKE entry(s) for a Visit
.S LINE=""
.F S LINE=$O(^TMP("BTIUVSTR",$J,LINE)) Q:LINE="" D
..D CKP^GMTSUP Q:$D(GMTSQIT) I GMTSNPG W !!!
..S Y=$G(^TMP("BTIUVSTR",$J,LINE,0))
..W Y,!
K @TARGET
Q
STSCORE ;EP-Display STROKE scores
N BHSPAT,BHSTR,HCNT,V,Y,X,BHSIVD,BHIEN,VIEN,BHSOB,CNT,LINE,BHSOBI,TARGET,ZMAX,ZVIST
S BHSPAT=DFN
S ZMAX=$S(+($G(GMTSNDM))>0:+($G(GMTSNDM)),1:9999)
I '$D(^AUPNVSTR("AA",BHSPAT)) Q ;no STROKE data for this patient
; <DISPLAY>
K BHSOB
S BHSOBI=0 F S BHSOBI=$O(^AUPNVSTR("AA",BHSPAT,BHSOBI)) Q:BHSOBI="" D
.S BHSIVD="" F S BHSIVD=$O(^AUPNVSTR("AA",BHSPAT,BHSOBI,BHSIVD)) Q:BHSIVD=""!(BHSIVD>GMTSDLM) D
..S BHIEN=0 F S BHIEN=$O(^AUPNVSTR("AA",BHSPAT,BHSOBI,BHSIVD,BHIEN)) Q:'+BHIEN D
...S VIEN=$P($G(^AUPNVSTR(BHIEN,0)),U,3)
...Q:$G(VIEN)=""
...S BHSTR(VIEN,BHSIVD)="" ;Save off the visits by date
;Now loop through the visits and call the API to return all the problems for that visit
S VIEN="",CNT=0
D CKP^GMTSUP Q:$D(GMTSQIT)
S HCNT=GMTSNDM
S TARGET=$$TMPGBL2
F S VIEN=$O(BHSTR(VIEN)) Q:VIEN=""!(CNT>ZMAX)!($D(GMTSQIT)) D
.S CNT=CNT+1
.S CNT=GMTSNDM=HCNT
.K @TARGET
.S X=$$STSCALE^BTIUSTSC(DFN,TARGET,VIEN,.HCNT) ;PEP - Returns STROKE scales
.S LINE=""
.F S LINE=$O(^TMP("BTIUVSTR",$J,LINE)) Q:LINE="" D
..D CKP^GMTSUP Q:$D(GMTSQIT) I GMTSNPG W !!!
..S Y=$G(^TMP("BTIUVSTR",$J,LINE,0))
..W Y,!
K @TARGET
Q
TMPGBL() ;EP
K ^TMP("BTIUVAMI",$J) Q $NA(^($J))
TMPGBL2() ;EP
K ^TMP("BTIUVSTR",$J) Q $NA(^($J))
BHSAMI ;IHS/MSC/MGH - Health Summary Components for V AMI file ;03-Oct-2013 06:01;JS
+1 ;;1.0;HEALTH SUMMARY COMPONENTS;**8**;March 17, 2006;Build 22
+2 ; ==================================================================
+3 ;
AMI ;EP - display AMI visits, date limits and numbers are applicable
+1 NEW BHSPAT,BHSAMI,V,Y,X,BHSIVD,BHIEN,VIEN,BHSOB,CNT,LINE,BHSOBI,TARGET,ZMAX,ZVIST
+2 SET BHSPAT=DFN
+3 SET ZMAX=$SELECT(+($GET(GMTSNDM))>0:+($GET(GMTSNDM)),1:9999)
+4 ;no AMI data for this patient
IF '$DATA(^AUPNVAMI("AA",BHSPAT))
QUIT
+5 ; <DISPLAY>
+6 KILL BHSOB
+7 SET BHSOBI=0
FOR
SET BHSOBI=$ORDER(^AUPNVAMI("AA",BHSPAT,BHSOBI))
IF BHSOBI=""
QUIT
Begin DoDot:1
+8 SET BHSIVD=""
FOR
SET BHSIVD=$ORDER(^AUPNVAMI("AA",BHSPAT,BHSOBI,BHSIVD))
IF BHSIVD=""!(BHSIVD>GMTSDLM)
QUIT
Begin DoDot:2
+9 SET BHIEN=0
FOR
SET BHIEN=$ORDER(^AUPNVAMI("AA",BHSPAT,BHSOBI,BHSIVD,BHIEN))
IF '+BHIEN
QUIT
Begin DoDot:3
+10 SET VIEN=$PIECE($GET(^AUPNVAMI(BHIEN,0)),U,3)
+11 IF $GET(VIEN)=""
QUIT
+12 ;Save off the visits by date
SET BHSAMI(VIEN,BHSIVD)=""
End DoDot:3
End DoDot:2
End DoDot:1
+13 ;Now loop through the visits and call the API to return all the problems for that visit
+14 SET VIEN=""
SET CNT=0
+15 DO CKP^GMTSUP
IF $DATA(GMTSQIT)
QUIT
+16 SET TARGET=$$TMPGBL
+17 FOR
SET VIEN=$ORDER(BHSAMI(VIEN))
IF VIEN=""!(CNT>ZMAX)!($DATA(GMTSQIT))
QUIT
Begin DoDot:1
+18 SET CNT=CNT+1
+19 SET ZVIST=$$GET1^DIQ(9000010,VIEN,.01,"E")
+20 WRITE !,"Visit: "_ZVIST,!,"------------------------------------------------------------",!!
+21 KILL @TARGET
+22 ;PEP - Returns AMI entry for a Visit
SET X=$$VAMI^BTIUVAMI(DFN,TARGET,VIEN)
+23 SET LINE=""
+24 FOR
SET LINE=$ORDER(^TMP("BTIUVAMI",$JOB,LINE))
IF LINE=""
QUIT
Begin DoDot:2
+25 DO CKP^GMTSUP
IF $DATA(GMTSQIT)
QUIT
IF GMTSNPG
WRITE !!!
+26 SET Y=$GET(^TMP("BTIUVAMI",$JOB,LINE,0))
+27 WRITE Y,!
End DoDot:2
End DoDot:1
+28 KILL @TARGET
+29 QUIT
STR ;EP-Display STROKE visits, date limits and numbers are applicable
+1 NEW BHSPAT,V,Y,X,BHSIVD,BHIEN,VIEN,BHSOB,CNT,LINE,BHSOBI,BHSTR,TARGET,ZMAX,ZVIST
+2 SET BHSPAT=DFN
+3 SET ZMAX=$SELECT(+($GET(GMTSNDM))>0:+($GET(GMTSNDM)),1:9999)
+4 ;no STROKE data for this patient
IF '$DATA(^AUPNVSTR("AA",BHSPAT))
QUIT
+5 ; <DISPLAY>
+6 KILL BHSOB
+7 SET BHSOBI=0
FOR
SET BHSOBI=$ORDER(^AUPNVSTR("AA",BHSPAT,BHSOBI))
IF BHSOBI=""
QUIT
Begin DoDot:1
+8 SET BHSIVD=""
FOR
SET BHSIVD=$ORDER(^AUPNVSTR("AA",BHSPAT,BHSOBI,BHSIVD))
IF BHSIVD=""!(BHSIVD>GMTSDLM)
QUIT
Begin DoDot:2
+9 SET BHIEN=0
FOR
SET BHIEN=$ORDER(^AUPNVSTR("AA",BHSPAT,BHSOBI,BHSIVD,BHIEN))
IF '+BHIEN
QUIT
Begin DoDot:3
+10 SET VIEN=$PIECE($GET(^AUPNVSTR(BHIEN,0)),U,3)
+11 IF $GET(VIEN)=""
QUIT
+12 ;Save off the visits by date
SET BHSTR(VIEN,BHSIVD)=""
End DoDot:3
End DoDot:2
End DoDot:1
+13 ;Now loop through the visits and call the API to return all the problems for that visit
+14 SET VIEN=""
SET CNT=0
+15 DO CKP^GMTSUP
IF $DATA(GMTSQIT)
QUIT
+16 SET TARGET=$$TMPGBL2
+17 FOR
SET VIEN=$ORDER(BHSTR(VIEN))
IF VIEN=""!(CNT>ZMAX)!($DATA(GMTSQIT))
QUIT
Begin DoDot:1
+18 SET CNT=CNT+1
+19 ; VISIT/ADMIT DATE&TIME
SET ZVIST=$$GET1^DIQ(9000010,VIEN,.01,"E")
+20 WRITE !,"Visit: "_ZVIST,!,"------------------------------------------------------------",!!
+21 KILL @TARGET
+22 ;PEP - Returns STROKE entry(s) for a Visit
SET X=$$VSTR^BTIUVSTR(DFN,TARGET,VIEN)
+23 SET LINE=""
+24 FOR
SET LINE=$ORDER(^TMP("BTIUVSTR",$JOB,LINE))
IF LINE=""
QUIT
Begin DoDot:2
+25 DO CKP^GMTSUP
IF $DATA(GMTSQIT)
QUIT
IF GMTSNPG
WRITE !!!
+26 SET Y=$GET(^TMP("BTIUVSTR",$JOB,LINE,0))
+27 WRITE Y,!
End DoDot:2
End DoDot:1
+28 KILL @TARGET
+29 QUIT
STSCORE ;EP-Display STROKE scores
+1 NEW BHSPAT,BHSTR,HCNT,V,Y,X,BHSIVD,BHIEN,VIEN,BHSOB,CNT,LINE,BHSOBI,TARGET,ZMAX,ZVIST
+2 SET BHSPAT=DFN
+3 SET ZMAX=$SELECT(+($GET(GMTSNDM))>0:+($GET(GMTSNDM)),1:9999)
+4 ;no STROKE data for this patient
IF '$DATA(^AUPNVSTR("AA",BHSPAT))
QUIT
+5 ; <DISPLAY>
+6 KILL BHSOB
+7 SET BHSOBI=0
FOR
SET BHSOBI=$ORDER(^AUPNVSTR("AA",BHSPAT,BHSOBI))
IF BHSOBI=""
QUIT
Begin DoDot:1
+8 SET BHSIVD=""
FOR
SET BHSIVD=$ORDER(^AUPNVSTR("AA",BHSPAT,BHSOBI,BHSIVD))
IF BHSIVD=""!(BHSIVD>GMTSDLM)
QUIT
Begin DoDot:2
+9 SET BHIEN=0
FOR
SET BHIEN=$ORDER(^AUPNVSTR("AA",BHSPAT,BHSOBI,BHSIVD,BHIEN))
IF '+BHIEN
QUIT
Begin DoDot:3
+10 SET VIEN=$PIECE($GET(^AUPNVSTR(BHIEN,0)),U,3)
+11 IF $GET(VIEN)=""
QUIT
+12 ;Save off the visits by date
SET BHSTR(VIEN,BHSIVD)=""
End DoDot:3
End DoDot:2
End DoDot:1
+13 ;Now loop through the visits and call the API to return all the problems for that visit
+14 SET VIEN=""
SET CNT=0
+15 DO CKP^GMTSUP
IF $DATA(GMTSQIT)
QUIT
+16 SET HCNT=GMTSNDM
+17 SET TARGET=$$TMPGBL2
+18 FOR
SET VIEN=$ORDER(BHSTR(VIEN))
IF VIEN=""!(CNT>ZMAX)!($DATA(GMTSQIT))
QUIT
Begin DoDot:1
+19 SET CNT=CNT+1
+20 SET CNT=GMTSNDM=HCNT
+21 KILL @TARGET
+22 ;PEP - Returns STROKE scales
SET X=$$STSCALE^BTIUSTSC(DFN,TARGET,VIEN,.HCNT)
+23 SET LINE=""
+24 FOR
SET LINE=$ORDER(^TMP("BTIUVSTR",$JOB,LINE))
IF LINE=""
QUIT
Begin DoDot:2
+25 DO CKP^GMTSUP
IF $DATA(GMTSQIT)
QUIT
IF GMTSNPG
WRITE !!!
+26 SET Y=$GET(^TMP("BTIUVSTR",$JOB,LINE,0))
+27 WRITE Y,!
End DoDot:2
End DoDot:1
+28 KILL @TARGET
+29 QUIT
TMPGBL() ;EP
+1 KILL ^TMP("BTIUVAMI",$JOB)
QUIT $NAME(^($JOB))
TMPGBL2() ;EP
+1 KILL ^TMP("BTIUVSTR",$JOB)
QUIT $NAME(^($JOB))