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

BDMGR.m

Go to the documentation of this file.
BDMGR ; IHS/CMI/LAB - BDM DMS GUI Reports ; [ 01/23/2009 4:11 PM ]
 ;;2.0;BDM DIABETES MANAGEMENT SYSTEM;**1,8**;JUN 14, 2007;Build 53
 ;
 ;
 ;cmi/anch/maw 1/25/2005 added line in FUR for uppercase dx type
 ;
DEBUG(BDMRET,BDMSTR) ;-- debugger
 D DEBUG^%Serenji("FUR^BDMGR(.BDMRET,.BDMSTR)")
 Q
 ;
HS(BDMRET,BDMSTR) ;-- get health summary data from BPC
 S X="MERR^BDMGU",@^%ZOSF("TRAP") ; m error trap
 N BDMDA,BDMI,BDMPAT,BDMTYPE,BDMCALL,P
 S P="|"
 S APCHSPAT=$P(BDMSTR,P)
 S APCHSTYP=$P(BDMSTR,P,2)
 I APCHSTYP'?.N S APCHSTYP=$O(^APCHSCTL("B",APCHSTYP,0))
 S BDMI=0
 S BDMERR=""
 K ^BDMTMP($J)
 S BDMRET="^BDMTMP("_$J_")"
 S ^BDMTMP($J,BDMI)="T00080DATA"_$C(30)
 S IOM=80
 D GUIR^XBLM("EN^APCHS","^XTMP(""BDMHS"",$J)")
 I '$D(^XTMP("BDMHS",$J)) D  Q
 . S BDMI=BDMI+1
 . S ^BDMTMP($J,BDMI)="NO DATA"_$C(30)
 . S ^BDMTMP($J,BDMI+1)=$C(31)
 S BDMDA=.5 F  S BDMDA=$O(^XTMP("BDMHS",$J,BDMDA)) Q:'BDMDA  D
 . N BDMDATA
 . S BDMI=BDMI+1
 . S BDMDATA=$G(^XTMP("BDMHS",$J,BDMDA))
 . S ^BDMTMP($J,BDMI)=BDMDATA_$C(30)
 S ^BDMTMP($J,BDMI+1)=$C(31)_BDMERR
 K ^XTMP("BDMHS",$J)
 Q
 ;
FLS(BDMRET,BDMSTR) ;-- get flow sheet data
 S X="MERR^BDMGU",@^%ZOSF("TRAP") ; m error trap
 N BDMDA,BDMI,BDMPAT,BDMTYPE,BDMCALL,P,BDMODFN
 S P="|"
 I $G(DFN) S BDMODFN=DFN
 S DFN=$P(BDMSTR,P)
 S BDMFDF=$P(BDMSTR,P,2)
 I BDMFDF'?.N S BDMFDF=$O(^APCHSFLC("B",BDMFDF,0))
 S BDMI=0
 S BDMERR=""
 D SETVARS^BDMFLOW
 K ^BDMTMP($J)
 S BDMRET="^BDMTMP("_$J_")"
 S ^BDMTMP($J,BDMI)="T00080DATA"_$C(30)
 S IOM=80
 D GUIR^XBLM("FLOWDISP^BDMFLOW","^XTMP(""BDMFLS"",$J)")
 I '$D(^XTMP("BDMFLS",$J)) D  Q
 . S BDMI=BDMI+1
 . S ^BDMTMP($J,BDMI)="NO DATA"_$C(30)
 . S ^BDMTMP($J,BDMI+1)=$C(31)
 S BDMDA=.5 F  S BDMDA=$O(^XTMP("BDMFLS",$J,BDMDA)) Q:'BDMDA  D
 . N BDMDATA
 . S BDMI=BDMI+1
 . S BDMDATA=$G(^XTMP("BDMFLS",$J,BDMDA))
 . S ^BDMTMP($J,BDMI)=BDMDATA_$C(30)
 S ^BDMTMP($J,BDMI+1)=$C(31)_BDMERR
 K ^XTMP("BDMFLS",$J)
 K BDMSPAT,BDMFDF
 I $G(BDMODFN) S DFN=BDMODFN
 Q
 ;
PCC(BDMRET,BDMSTR) ;-- display pcc visit
 S X="MERR^BDMGU",@^%ZOSF("TRAP") ; m error trap
 N BDMDA,BDMI,BDMPAT,BDMTYPE,BDMCALL,BDMVIEN,P
 S P="|"
 S BDMPAT=$P(BDMSTR,P)
 S BDMVIEN=$P(BDMSTR,P,2)
 S BDMI=0
 S BDMERR=""
 K ^BDMTMP($J)
 S BDMRET="^BDMTMP("_$J_")"
 S ^BDMTMP($J,BDMI)="T00250DATA"_$C(30)
 I '$G(BDMVIEN) D
 . S BDMIVDT=$O(^AUPNVSIT("AA",BDMPAT,0))
 . I 'BDMIVDT D  Q
 .. S BDMI=BDMI+1
 .. S ^BDMTMP($J,BDMI)="NO DATA"_$C(30)
 .. S ^BDMTMP($J,BDMI+1)=$C(31)_BDMERR
 . S BDMVIEN=$O(^AUPNVSIT("AA",BDMPAT,BDMIVDT,0))
 Q:'$G(BDMVIEN)
 N BDMGUI
 S BDMGUI=1
 D EN^APCDVDSG(BDMVIEN,"^XTMP(""BDMLV"",$J)",BDMGUI)
 I '$D(^XTMP("BDMLV",$J)) D  Q
 . S BDMI=BDMI+1
 . S ^BDMTMP($J,BDMI)="NO DATA"_$C(30)
 . S ^BDMTMP($J,BDMI+1)=$C(31)
 S BDMDA=0 F  S BDMDA=$O(^XTMP("BDMLV",$J,BDMDA)) Q:'BDMDA  D
 . N BDMDATA
 . S BDMI=BDMI+1
 . S BDMDATA=$G(^XTMP("BDMLV",$J,BDMDA,0))
 . S ^BDMTMP($J,BDMI)=BDMDATA_$C(30)
 S ^BDMTMP($J,BDMI+1)=$C(31)_BDMERR
 K ^XTMP("BDMLV",$J)
 Q
 ;
MED(BDMRET,BDMSTR) ;-- medication profile all meds/dm meds
 S X="MERR^BDMGU",@^%ZOSF("TRAP") ; m error trap
 N BDMDA,BDMI,BDMPAT,BDMTYPE,BDMCALL,DFN,P,BDMDMO
 K BDMONLY
 S P="|"
 S DFN=$P(BDMSTR,P)
 S BDMDMO=+$P(BDMSTR,P,2)
 I $G(BDMDMO) D
 . S BDMONLY=""
 . D DMMEDS
 S BDMI=0
 S BDMERR=""
 K ^BDMTMP($J)
 S BDMREGNM="IHS DIABETES REGISTER"
 S BDMRDA=$O(^ACM(41.1,"B",BDMREGNM,0))
 S BDMRET="^BDMTMP("_$J_")"
 S ^BDMTMP($J,BDMI)="T00250DATA"_$C(30)
 D MINIT^BDMVRL1
 S BDMI=BDMI+1
 S ^BDMTMP($J,BDMI)="PATIENT NAME: "_$$GET1^DIQ(2,DFN,.01)_$C(30)
 S BDMI=BDMI+1
 S ^BDMTMP($J,BDMI)="CHART: "_$$HRN^AUPNPAT(DFN,DUZ(2))_$C(30)
 I '$D(^TMP("BDMVR",$J,2)) D  Q
 . S BDMI=BDMI+1
 . S ^BDMTMP($J,BDMI)="NO DATA"_$C(30)
 . S ^BDMTMP($J,BDMI+1)=$C(31)
 S BDMDA=0 F  S BDMDA=$O(^TMP("BDMVR",$J,BDMDA)) Q:'BDMDA  D
 . N BDMDATA
 . S BDMI=BDMI+1
 . S BDMDATA=$G(^TMP("BDMVR",$J,BDMDA,0))
 . S ^BDMTMP($J,BDMI)=BDMDATA_$C(30)
 S ^BDMTMP($J,BDMI+1)=$C(31)_BDMERR
 K ^XTMP("BDMVR",$J),BDMMEDS,BDM
 K ^TMP("BDMVR",$J)
 Q
 ;
DMMEDS ;EP - setup array for dm meds
 N S,T,TX,X,Y,Z,BDMJ
 S (T,TX)="DM AUDIT "
 F  S T=$O(^ATXAX("B",T)) Q:T=""!(T'[TX)  D
 .S X=0
 .F  S X=$O(^ATXAX("B",T,X)) Q:'X  D
 ..Q:+$P($G(^ATXAX(X,0)),U,15)'=50
 ..S BDM(X)=""
 S BDMTXDA=0
 F  S BDMTXDA=$O(BDM(BDMTXDA)) Q:'BDMTXDA  D
 .S X=0
 .F  S X=$O(^ATXAX(BDMTXDA,21,X)) Q:'X  D
 ..S Y=$P($G(^ATXAX(BDMTXDA,21,X,0)),U)
 ..Q:'Y
 ..S BDMMEDS(Y)=""
 Q:'$D(BDMMEDS)
 S DA=DFN
 Q
 ;
APP(BDMRET,BDMSTR) ;-- appointments
 S X="MERR^BDMGU",@^%ZOSF("TRAP") ; m error trap
 N BDMDA,BDMI,BDMPAT,BDMTYPE,BDMCALL,DFN,P
 S P="|"
 S DFN=$P(BDMSTR,P)
 S BDMI=0
 S BDMERR=""
 K ^BDMTMP($J)
 S BDMRET="^BDMTMP("_$J_")"
 S ^BDMTMP($J,BDMI)="T00250DATA"_$C(30)
 S BDMREGNM=$P(BDMSTR,P,2)
 S BDMRDA=$O(^ACM(41.1,"B",BDMREGNM,0))
 D APPINIT^BDMVRL
 I '$D(^TMP("BDMVR",$J,2)) D  Q
 . S BDMI=BDMI+1
 . S ^BDMTMP($J,BDMI)="NO DATA"_$C(30)
 . S ^BDMTMP($J,BDMI+1)=$C(31)
 S BDMDA=0 F  S BDMDA=$O(^TMP("BDMVR",$J,BDMDA)) Q:'BDMDA  D
 . N BDMDATA
 . S BDMI=BDMI+1
 . S BDMDATA=$G(^TMP("BDMVR",$J,BDMDA,0))
 . S ^BDMTMP($J,BDMI)=BDMDATA_$C(30)
 S ^BDMTMP($J,BDMI+1)=$C(31)_BDMERR
 K ^TMP("BDMVR",$J)
 Q
 ;
AS(BDMRET,BDMSTR) ;-- audit status
 S X="MERR^BDMGU",@^%ZOSF("TRAP") ; m error trap
 N X,BDMY,BDMZ,BDMQUIT,P
 S P="|"
 S DFN=$P(BDMSTR,P,1)
 S BDMRDA=$P(BDMSTR,P,2)
 F BDMY=91 D:'$D(BDMQUIT)
 .S X="BDMD"_BDMY
 .X ^%ZOSF("TEST")
 .I $T D  Q
 ..S BDMJOB=$J
 ..S BDMBTH=$H
 ..S BDMDMRG=BDMRDA
 ..S ^XTMP(("BDMDM"_BDMY),BDMJOB,BDMBTH,"PATS",DFN)=""
 ..S ^TMP(("BDMDM"_BDMY),BDMJOB,BDMBTH,"PATS",DFN)=""
 ..S BDMZ="TIME^BDMD"_BDMY
 ..D @BDMZ
 ..Q:$G(BDMSTP)
 ..S BDMZ="IF^BDMD"_BDMY
 ..D @BDMZ
 ..S BDMQUIT=""
 I $D(BDMQUIT) K BDMQUIT Q
 S X="BDMD99"
 X ^%ZOSF("TEST")
 I $T D  Q
 .S BDMJOB=$J
 .S BDMBTH=$H
 .S BDMDMRG=BDMRDA
 .S ^XTMP("BDMDM99",BDMJOB,BDMBTH,"PATS",DFN)=""
 .S ^TMP("BDMDM99",BDMJOB,BDMBTH,"PATS",DFN)=""
 .D TIME^BDMD99
 .Q:$G(BDMSTP)
 .D IF^BDMD99
 S BDMDFN=$O(^APCLRPT("B","APCL DIABETES PROGRAM QA AUDIT",0))
 Q:'BDMDFN
 S BDMPTS=1
 S BDMPREP=2
 S BDMCUML=0
 S ^XTMP("BDMPTS",$J,DFN)=""
 S ^TMP("BDMPTS",$J,DFN)=""
 D TIME^BDMASK
 Q:$G(BDMSTP)
 S BDMRTN="ZTM^BDMASK"
 D GUIR^XBLM(BDMRTN,"^XTMP(""BDMAS"",$J)")
 Q
 ;
CS(BDMRET,BDMSTR) ;-- case summary
 S X="MERR^BDMGU",@^%ZOSF("TRAP") ; m error trap
 N BDMDA,BDMI,BDMPAT,BDMTYPE,BDMCALL,DFN,P
 S P="|"
 S BDMCS=$P(BDMSTR,P)
 S BDMRDA=$O(^ACM(41.1,"B",BDMCS,0))
 S BDMRPDA=$P(BDMSTR,P,2)
 S DFN=$P(BDMSTR,P,3)
 S BDMI=0
 S BDMERR=""
 K ^BDMTMP($J)
 S BDMRET="^BDMTMP("_$J_")"
 S ^BDMTMP($J,BDMI)="T00250DATA"_$C(30)
 S IOM=80
 D GUIR^XBLM("CS1^BDMVRL","^XTMP(""BDMCS"",$J)")
 I '$D(^XTMP("BDMCS",$J)) D  Q
 . S BDMI=BDMI+1
 . S ^BDMTMP($J,BDMI)="NO DATA"_$C(30)
 . S ^BDMTMP($J,BDMI+1)=$C(31)
 S BDMDA=.5 F  S BDMDA=$O(^XTMP("BDMCS",$J,BDMDA)) Q:'BDMDA  D
 . N BDMDATA
 . S BDMI=BDMI+1
 . S BDMDATA=$G(^XTMP("BDMCS",$J,BDMDA))
 . S ^BDMTMP($J,BDMI)=BDMDATA_$C(30)
 S ^BDMTMP($J,BDMI+1)=$C(31)_BDMERR
 K ^TMP("BDMVR",$J)
 Q
 ;
FS(BDMRET,BDMSTR) ;-- return patient reg face sheet
 S X="MERR^BDMGU",@^%ZOSF("TRAP") ; m error trap
 N P,DFN,BDMDA,BDMI,BDMPAT,BDMTYPE,BDMCALL
 S P="|"
 S DFN=$P(BDMSTR,P)
 S BDMI=0
 S BDMERR=""
 K ^BDMTMP($J)
 S BDMRET="^BDMTMP("_$J_")"
 S ^BDMTMP($J,BDMI)="T00250DATA"_$C(30)
 S IOM=80
 D GUIR^XBLM("START^AGFACE","^XTMP(""BDMFS"",$J)")
 S BDMDA=.5 F  S BDMDA=$O(^XTMP("BDMFS",$J,BDMDA)) Q:'BDMDA  D
 . N BDMDATA
 . S BDMI=BDMI+1
 . S BDMDATA=$G(^XTMP("BDMFS",$J,BDMDA))
 . S ^BDMTMP($J,BDMI)=BDMDATA_$C(30)
 S ^BDMTMP($J,BDMI+1)=$C(31)_BDMERR
 K ^XTMP("BDMFS",$J)
 Q
 ;
LET(BDMRET,BDMSTR) ;-- return letter
 S X="MERR^BDMGU",@^%ZOSF("TRAP") ; m error trap
 N P,DFN,BDMDA,BDMI,BDMPAT,BDMTYPE,BDMCALL,BDMLDA,BDMLET
 S P="|"
 S DFN=$P(BDMSTR,P)
 S BDMLET=$P(BDMSTR,P,2)
 S BDMLDA=$O(^BDMLET("B",BDMLET,0))
 S BDMI=0
 S BDMERR=""
 K ^BDMTMP($J)
 S BDMRET="^BDMTMP("_$J_")"
 S ^BDMTMP($J,BDMI)="T00250DATA"_$C(30)
 D GUIR^XBLM("PRINT^BDMLET","^XTMP(""BDMLET"",$J)")
 S BDMDA=.5 F  S BDMDA=$O(^XTMP("BDMLET",$J,BDMDA)) Q:'BDMDA  D
 . N BDMDATA
 . S BDMI=BDMI+1
 . S BDMDATA=$G(^XTMP("BDMLET",$J,BDMDA))
 . S ^BDMTMP($J,BDMI)=BDMDATA_$C(30)
 S ^BDMTMP($J,BDMI+1)=$C(31)_BDMERR
 K ^XTMP("BDMLET",$J)
 Q
 ;
PLD(BDMRET,BDMSTR) ;-- return problem list display
 S X="MERR^BDMGU",@^%ZOSF("TRAP") ; m error trap
 N BDMPIEN,P
 S P="|"
 S BDMPIEN=$P(BDMSTR,P)
 S BDMI=0
 S BDMERR=""
 K ^BDMTMP($J)
 S BDMRET="^BDMTMP("_$J_")"
 S ^BDMTMP($J,BDMI)="T00250DATA"_$C(30)
 S DIC="^AUPNPROB(",DA=BDMPIEN,DIQ(0)="C"
 D GUIR^XBLM("EN^DIQ","^XTMP(""BDMPL"",$J)")
 S BDMDA=.5 F  S BDMDA=$O(^XTMP("BDMPL",$J,BDMDA)) Q:'BDMDA  D
 . N BDMDATA
 . S BDMI=BDMI+1
 . S BDMDATA=$G(^XTMP("BDMPL",$J,BDMDA))
 . S ^BDMTMP($J,BDMI)=BDMDATA_$C(30)
 S ^BDMTMP($J,BDMI+1)=$C(31)_BDMERR
 K ^XTMP("BDMPL",$J)
 K DIC,DA,DIQ
 Q
 ;
FUPROT(BDMRET) ;-- return the FU Protocols
 S X="MERR^BDMGU",@^%ZOSF("TRAP") ; m error trap
 S BDMI=0
 S BDMERR=""
 K ^BDMTMP($J)
 S BDMRET="^BDMTMP("_$J_")"
 S ^BDMTMP($J,BDMI)="T00250DATA"_$C(30)
 S IOM=80
 D GUIR^XBLM("PINIT^BDMVRL42","^XTMP(""BDMFUP"",$J)")
 S BDMDA=.5 F  S BDMDA=$O(^XTMP("BDMFUP",$J,BDMDA)) Q:'BDMDA  D
 . N BDMDATA
 . S BDMI=BDMI+1
 . S BDMDATA=$G(^XTMP("BDMFUP",$J,BDMDA))
 . S ^BDMTMP($J,BDMI)=BDMDATA_$C(30)
 S ^BDMTMP($J,BDMI+1)=$C(31)_BDMERR
 K ^XTMP("BDMFUP",$J)
 Q
 ;
FUR(RETVAL,BDMSTR) ;-- print the followup report
 S X="MERR^BDMGU",@^%ZOSF("TRAP") ; m error trap
 N P,R,BDMRTYP,BDMRS,BDMST,BDMPS,BDMDD,BDMPA,BDMPABD,BDMPAED
 N BDMPBY,BDMPBYV,BDMRL,BDMLP,BDM,BDMDEMO
 S P="|",R="~"
 D EXIT^BDMVRL4
 I $G(BDMSTR)="" S BDMSTR=$$CATSTR^BDMGU(.BDMSTR)
 S BDMRTYP=$P(BDMSTR,P)
 S BDMRS=$P(BDMSTR,P,2)
 S BDMST=$P(BDMSTR,P,3)
 I $G(BDMST)]"" S BDM("SEARCH TEMPLATE")=$O(^DIBT("B",BDMST,0))
 S BDMPS=$P(BDMSTR,P,4)
 S BDM("STATUS")=BDMPS
 S BDMDD=$P(BDMSTR,P,5)
 ;cmi/anch/maw 1/25/2005 added following line
 N X S X=BDMDD X ^%ZOSF("UPPERCASE") S BDMDD=Y
 S BDM("DM DIAGNOSIS")=BDMDD
 S BDMPA=$P(BDMSTR,P,6)
 I $G(BDMPA)="Y" S BDMFUAPP=""
 S BDMPABD=$P(BDMSTR,P,7)
 S BDMBEGIN=BDMPABD
 S BDMPAED=$P(BDMSTR,P,8)
 S BDMEND=BDMPAED
 S BDMPBY=$P(BDMSTR,P,9)
 I $P(BDMPBY,"-",2)="Community" S BDMFL=9999999.05,BDMK="COMMUNITY"
 I $P(BDMPBY,"-",3)="Provider" S BDMFL=200,BDMK="PROVIDER"
 S BDMPBYV=$P(BDMSTR,P,10)
 I BDMPBYV="All" S BDMPBYV=""
 F J=1:1 D  Q:$P(BDMPBYV,R,J)=""
 . Q:$P(BDMPBYV,R,J)=""
 . S BDMK($P(BDMPBYV,R,J))=$$GET1^DIQ(BDMFL,$P(BDMPBYV,R,J),.01)
 S BDMRL=$P(BDMSTR,P,11)
 S BDMFU=$P(BDMRL,"-",2)
 S BDMLP=$P(BDMSTR,P,12)
 I $G(BDMLP)]"" S BDMLDA=$O(^BDMLET("B",BDMLP,0))
 S BDMREGNM=$P(BDMSTR,P,13)
 S BDMDEMO=$P(BDMSTR,P,15)
 S IOM=80
 D GUIR^XBLM("SCREEN^BDMVRL42","^TMP($J,")
 S BDMRTYP=$TR(BDMRTYP,"~",",")
 I BDMRTYP="All" D
 . D ALL^BDMVRL42
 . S BDMY=Y
 . D PARSE^BDMVRL42
 I BDMRTYP'="All" S BDMY=BDMRTYP D PARSE^BDMVRL42
 ;N I
 ;F I=1:1 D  Q:$P(BDMRTYP,R,I)=""
 ;. ;Q:$P(BDMRTYP,R,I)=""
 ;. ;S BDM("PARSE",$P(BDMRTYP,R,I))=""
 S BDMI=0
 S BDMERR=""
 K ^BDMTMP($J)
 S RETVAL="^BDMTMP("_$J_")"
 S ^BDMTMP($J,BDMI)="T00250DATA"_$C(30)
 ;D BDMG^BDMVRL4(.BDM)
 ;D FUHEAD^BDMVRL42
 ;Q
 ;
 D BDMGA^BDMVRL4(.BDMERR,.BDM,$G(BDMFUAPP),BDMFL,.BDMK,BDMRL,BDMFU,$G(BDMLDA),BDMREGNM,1,BDMDEMO)
 ;S BDMJ=0
 ;D GUIR^XBLM("BDMG^BDMVRL4(.BDM)","^XTMP(""BDMFUR"",$J)")
 ;S BDMDA=.5 F  S BDMDA=$O(^XTMP("BDMFUR",$J,BDMDA)) Q:'BDMDA  D
 ;. N BDMDATA
 ;. S BDMI=BDMI+1
 ;. S BDMDATA=$G(^XTMP("BDMFUR",$J,BDMDA))
 ;. S ^BDMTMP($J,BDMI)=BDMDATA_$C(30)
 S ^BDMTMP($J,BDMI+1)=$C(31)_$G(BDMERR)
 D EN^XBVK("BDM")
 Q
 ;
SELF(RETVAL,BDMSTR) ;-- glucose self monitoring report
 N BDMRG,BDMST,BDMRT,BDME,BDMSRT,P,BDMDEMO
 S P="|"
 S BDMRG=$P(BDMSTR,P)
 S BDMRDA=$O(^ACM(41.1,"B",BDMRG,0))
 S BDMST=$P(BDMSTR,P,2)
 S BDMRT=$P(BDMSTR,P,3)
 S BDME=$P(BDMSTR,P,4)
 S BDMSRT=$P(BDMSTR,P,5)
 S BDMDEMO=$P(BDMSTR,P,6)
 S BDMI=0
 S BDMERR=""
 K ^BDMTMP($J)
 S RETVAL="^BDMTMP("_$J_")"
 S ^BDMTMP($J,BDMI)="T00250DATA"_$C(30)
 S IOM=80
 D BDMGA^BDMSELFM(.BDMERR,BDMRDA,BDMST,BDMRT,BDME,BDMSRT,1,BDMDEMO)
 S ^BDMTMP($J,1)=$C(31)_$G(BDMERR)
 D EN^XBVK("BDM")
 Q
 ;
LPA(RETVAL,BDMSTR) ;-- list patient appointments
 S X="MERR^BDMGU",@^%ZOSF("TRAP") ; m error trap
 N BDMDA,BDMI,BDMPAT,BDMTYPE,BDMCALL,BDMREGNM,BDMBEGIN,BDMEND,P
 S P="|"
 S BDMREGNM=$P(BDMSTR,P)
 S BDMBEGIN=$P(BDMSTR,P,2)
 S BDMEND=$P(BDMSTR,P,3)
 S BDMRDA=$O(^ACM(41.1,"B",BDMREGNM,0))
 S BDMI=0
 S BDMERR=""
 K ^BDMTMP($J)
 S RETVAL="^BDMTMP("_$J_")"
 S ^BDMTMP($J,BDMI)="T00250DATA"_$C(30)
 S IOM=80
 D BDMGA^BDMVRL6(.BDMERR,BDMBEGIN,BDMEND,BDMRDA,1)
 ;D APPINIT^BDMVRL6
 ;I '$D(^TMP("BDMVR",$J,2)) D  Q
 ;. S BDMI=BDMI+1
 ;. S ^BDMTMP($J,BDMI)="NO DATA"_$C(30)
 ;. S ^BDMTMP($J,BDMI+1)=$C(31)
 ;S BDMDA=0 F  S BDMDA=$O(^TMP("BDMVR",$J,BDMDA)) Q:'BDMDA  D
 ;. N BDMDATA
 ;. S BDMI=BDMI+1
 ;. S BDMDATA=$G(^TMP("BDMVR",$J,BDMDA,0))
 ;. S ^BDMTMP($J,BDMI)=BDMDATA_$C(30)
 S ^BDMTMP($J,BDMI+1)=$C(31)_BDMERR
 D EN^XBVK("BDM")
 Q
 ;