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

BDMGEA.m

Go to the documentation of this file.
BDMGEA ; cmi/anch/maw - BDM DMS GUI Filing Routine ; 28 Oct 2014  4:31 PM
 ;;2.0;BDM DIABETES MANAGEMENT SYSTEM;**1,8,10**;JUN 14, 2007;Build 12
 ;
 ;
DEBUG(BDMRET,BDMSTR) ;-- debugger
 D DEBUG^%Serenji("REF^BDMGEA(.BDMRET,.BDMSTR)")
 Q
 ;
HF(BDMRET,BDMSTR) ;-- update dm health factors
 S X="MERR^BDMGU",@^%ZOSF("TRAP") ; m error trap
 N P,BDMDMIEN,BDMPIEN,BDMTU,BDMTB,BDMGLU,BDMBAR,BDMREAD,BDMLRN,BDMTOBD,BDMTBD,BDMSMD,BDMBLD,BDMLPD
 N BDMENDS,BDMENDSD
 S P="|"
 I $G(BDMSTR)="" D CATSTR^BDMGU(.BDMSTR,.BDMSTR)
 I $G(BDMSTR)="" S BDMRET="Error Updating BDMEDMUP Entry, Invalid String" Q
 S BDMDMIEN=$P(BDMSTR,P)
 S BDMPIEN=$P(BDMSTR,P,2)
 S BDMTU=$P(BDMSTR,P,3)
 S BDMTU=$S($G(BDMTU)]"":$O(^AUTTHF("B",BDMTU,0)),1:"")
 S BDMTB=$P(BDMSTR,P,4)
 S BDMTB=$S($G(BDMTB)]"":$O(^AUTTHF("B",BDMTB,0)),1:"")
 S BDMGLU=$P(BDMSTR,P,5)
 S BDMGLU=$S($G(BDMGLU)]"":$O(^AUTTHF("B",BDMGLU,0)),1:"")
 S BDMBAR=$P(BDMSTR,P,6)
 S BDMBAR=$S($G(BDMBAR)]"":$O(^AUTTHF("B",BDMBAR,0)),1:"")
 S BDMREAD=$P(BDMSTR,P,7)
 S BDMREAD=$S($G(BDMREAD)]"":$O(^AUTTHF("B",BDMREAD,0)),1:"")
 S BDMLRN=$P(BDMSTR,P,8)
 S BDMLRN=$S($G(BDMLRN)]"":$O(^AUTTHF("B",BDMLRN,0)),1:"")
 S BDMTOBD=$P(BDMSTR,P,9)
 S BDMTBD=$P(BDMSTR,P,10)
 S BDMSMD=$P(BDMSTR,P,11)
 S BDMBLD=$P(BDMSTR,P,12)
 S BDMLPD=$P(BDMSTR,P,13)
 S BDMENDS=$P(BDMSTR,P,14)
 S BDMENDS=$S($G(BDMENDS)]"":$O(^AUTTHF("B",BDMENDS,0)),1:"")
 S BDMENDSD=$P(BDMSTR,P,15)
 N BDMERR,BDMIENS,BDMFDA
 S BDMIENS=BDMDMIEN
 S BDMFDA(9003203.2,BDMIENS_",",.09)=BDMTU
 S BDMFDA(9003203.2,BDMIENS_",",.1)=BDMTB
 S BDMFDA(9003203.2,BDMIENS_",",1107)=BDMGLU
 S BDMFDA(9003203.2,BDMIENS_",",1108)=BDMBAR
 S BDMFDA(9003203.2,BDMIENS_",",1109)=BDMREAD
 S BDMFDA(9003203.2,BDMIENS_",",1110)=BDMLRN
 S BDMFDA(9003203.2,BDMIENS_",",1114)=BDMTOBD
 S BDMFDA(9003203.2,BDMIENS_",",1115)=BDMTBD
 S BDMFDA(9003203.2,BDMIENS_",",1116)=BDMSMD
 S BDMFDA(9003203.2,BDMIENS_",",1117)=BDMBLD
 S BDMFDA(9003203.2,BDMIENS_",",1119)=BDMLPD
 S BDMFDA(9003203.2,BDMIENS_",",1122)=BDMENDS
 S BDMFDA(9003203.2,BDMIENS_",",1123)=BDMENDSD
 D FILE^DIE("K","BDMFDA","BDMERR(1)")
 I $G(BDMERR(1)) S BDMRET="" Q
 S BDMRET=$G(BDMIENS(1))
 Q
 ;
IMM(BDMRET,BDMSTR) ;-- update dm Immunizations
 S X="MERR^BDMGU",@^%ZOSF("TRAP") ; m error trap
 N P,BDMDMIEN,BDMPIEN,BDMFLU,BDMPNU,BDMTD,BDMFLUD,BDMTDD,BDMPNUD,BDMHEPBD,BDMHEPB
 S P="|"
 I $G(BDMSTR)="" D CATSTR^BDMGU(.BDMSTR,.BDMSTR)
 I $G(BDMSTR)="" S BDMRET="Error Updating BDMEDMUP Entry, Invalid String" Q
 S BDMDMIEN=$P(BDMSTR,P)
 S BDMPIEN=$P(BDMSTR,P,2)
 S BDMFLUD=$P(BDMSTR,P,3)
 S BDMFLU=$P(BDMSTR,P,4)
 S BDMFLU=$S($G(BDMFLU)]"":$O(^AUTTIMM("D",BDMFLU,0)),1:"")
 S BDMPNUD=$P(BDMSTR,P,5)
 S BDMPNU=$P(BDMSTR,P,6)
 S BDMPNU=$S($G(BDMPNU)]"":$O(^AUTTIMM("D",BDMPNU,0)),1:"")
 S BDMTDD=$P(BDMSTR,P,7)
 S BDMTD=$P(BDMSTR,P,8)
 S BDMTD=$S($G(BDMTD)]"":$O(^AUTTIMM("D",BDMTD,0)),1:"")
 S BDMHEPBD=$P(BDMSTR,P,7)
 S BDMHEPB=$P(BDMSTR,P,8)
 S BDMHEPB=$S($G(BDMHEPB)]"":$O(^AUTTIMM("D",BDMHEPB,0)),1:"")
 N BDMERR,BDMIENS,BDMFDA
 S BDMIENS=""
 S BDMFDA(9003203.2,BDMDMIEN_",",.16)=BDMFLUD
 S BDMFDA(9003203.2,BDMDMIEN_",",.17)=BDMPNUD
 S BDMFDA(9003203.2,BDMDMIEN_",",.18)=BDMTDD
 S BDMFDA(9003203.2,BDMDMIEN_",",1111)=BDMFLU
 S BDMFDA(9003203.2,BDMDMIEN_",",1112)=BDMPNU
 S BDMFDA(9003203.2,BDMDMIEN_",",1113)=BDMTD
 S BDMFDA(9003203.2,BDMDMIEN_",",1120)=BDMHEPBD
 S BDMFDA(9003203.2,BDMDMIEN_",",1121)=BDMHEPB
 D FILE^DIE("K","BDMFDA","BDMERR(1)")
 I $G(BDMERR(1)) S BDMRET="" Q
 S BDMRET=$G(BDMIENS(1))
 Q
 ;
DMEE(BDMRET,BDMSTR) ;EP - edit the entry in APCDDMUP
 S X="MERR^BDMGU",@^%ZOSF("TRAP") ; m error trap
 N P,BDMIEN,BDMPIEN,BDMON,BDMPN,BDMHD,BDMHV,BDMWD,BDMWV,BDMTU,BDMTB,BDMFTD
 N BDMEYED,BDMDEND,BDMPAPD,BDMMAMD,BDMFLUD,BDMPNUD,BDMTDD,BDMBPD,BDMBPV,BDMFTR
 N BDMEYER,BDMEKGR,BDMPPDD,BDMPPDR,BDMEKGD,BDMGLU,BDMASTR,BDMMAMP
 S P="|"
 I $G(BDMSTR)="" D CATSTR^BDMGU(.BDMSTR,.BDMSTR)
 I $G(BDMSTR)="" S BDMRET="Error Creating BDMEDMUP Entry, Invalid String" Q
 S BDMDMIEN=$P(BDMSTR,P)
 S BDMPIEN=$P(BDMSTR,P,2)
 S BDMON=$P(BDMSTR,P,3)
 S BDMPN=$P(BDMSTR,P,4)
 S BDMHD=$P(BDMSTR,P,5)
 S BDMHV=$P(BDMSTR,P,6)
 S BDMWD=$P(BDMSTR,P,7)
 S BDMWV=$P(BDMSTR,P,8)
 S BDMBPD=$P(BDMSTR,P,9)
 S BDMBPV=$P(BDMSTR,P,10)
 S BDMFTD=$P(BDMSTR,P,11)
 S BDMFTR=$P(BDMSTR,P,12)
 S BDMEYED=$P(BDMSTR,P,13)
 S BDMEYER=$P(BDMSTR,P,14)
 S BDMEKGD=$P(BDMSTR,P,15)
 S BDMEKGR=$P(BDMSTR,P,16)
 S BDMDEND=$P(BDMSTR,P,17)
 S BDMPAPD=$P(BDMSTR,P,18)
 S BDMMAMD=$P(BDMSTR,P,19)
 S BDMPPDD=$P(BDMSTR,P,20)
 S BDMPPDR=$P(BDMSTR,P,21)
 S BDMMAMP=$P(BDMSTR,P,22)
 N BDMERR,BDMIENS,BDMFDA
 S BDMIENS=""
 S BDMFDA(9003203.2,BDMDMIEN_",",.02)=DT
 S BDMFDA(9003203.2,BDMDMIEN_",",.03)=BDMON
 S BDMFDA(9003203.2,BDMDMIEN_",",.04)=BDMPN
 S BDMFDA(9003203.2,BDMDMIEN_",",.05)=BDMHD
 S BDMFDA(9003203.2,BDMDMIEN_",",.06)=BDMHV
 S BDMFDA(9003203.2,BDMDMIEN_",",.07)=BDMWD
 S BDMFDA(9003203.2,BDMDMIEN_",",.08)=BDMWV
 S BDMFDA(9003203.2,BDMDMIEN_",",.11)=BDMFTD
 S BDMFDA(9003203.2,BDMDMIEN_",",.12)=BDMEYED
 S BDMFDA(9003203.2,BDMDMIEN_",",.13)=BDMDEND
 S BDMFDA(9003203.2,BDMDMIEN_",",.14)=BDMPAPD
 S BDMFDA(9003203.2,BDMDMIEN_",",.15)=BDMMAMD
 S BDMFDA(9003203.2,BDMDMIEN_",",.19)=BDMBPD
 S BDMFDA(9003203.2,BDMDMIEN_",",.2)=BDMBPV
 S BDMFDA(9003203.2,BDMDMIEN_",",.21)=BDMFTR
 S BDMFDA(9003203.2,BDMDMIEN_",",.22)=BDMEYER
 S BDMFDA(9003203.2,BDMDMIEN_",",.23)=BDMEKGR
 S BDMFDA(9003203.2,BDMDMIEN_",",.24)=BDMMAMP
 S BDMFDA(9003203.2,BDMDMIEN_",",1103)=BDMEKGD
 S BDMFDA(9003203.2,BDMDMIEN_",",1101)=BDMPPDD
 S BDMFDA(9003203.2,BDMDMIEN_",",1102)=BDMPPDR
 D FILE^DIE("K","BDMFDA","BDMERR(1)")
 I $G(BDMERR(1)) S BDMRET="" Q
 I $G(BDMIENS(1)) S BDMRET=$G(BDMIENS(1)) Q
 S BDMRET=$P(BDMSTR,P)
 Q
 ;
LAB(BDMRET,BDMSTR) ;-- add lab entries to APCDDMUP
 S X="MERR^BDMGU",@^%ZOSF("TRAP") ; m error trap
 N BDMDMIEN,BDMPIEN,BDMLABT,BDMLAB,BDMLABD,BDMLABR,P,R
 S P="|",R="~"
 I $G(BDMSTR)="" D CATSTR^BDMGU(.BDMSTR,.BDMSTR)
 I $G(BDMSTR)="" S BDMRET="Error Creating BDMEDMUP Lab Entry, Invalid String" Q
 S BDMDMIEN=$P(BDMSTR,P)
 S BDMPIEN=$P(BDMSTR,P,2)
 F BDMI=3:1 D  Q:$P(BDMSTR,P,BDMI)=""
 . N BDMDATA
 . S BDMDATA=$P(BDMSTR,P,BDMI)
 . Q:$G(BDMDATA)=""
 . S BDMLAB=$P(BDMDATA,R)
 . S BDMLABD=$P(BDMDATA,R,2)
 . S BDMLABR=$P(BDMDATA,R,3)
 . N BDMERR,BDMIENS,BDMFDA
 . S BDMIENS=""
 . S BDMFDA(9003203.213,"+2,"_BDMDMIEN_",",.01)=BDMLAB
 . S BDMFDA(9003203.213,"+2,"_BDMDMIEN_",",.02)=BDMLABD
 . S BDMFDA(9003203.213,"+2,"_BDMDMIEN_",",.03)=BDMLABR
 . D UPDATE^DIE("","BDMFDA","BDMIENS","BDMERR(1)")
 . I $G(BDMERR(1)) S BDMRET="" Q
 . S BDMRET=$G(BDMIENS(1))
 Q
 ;
MED(BDMRET,BDMSTR) ;-- add med entries to APCDDMUP
 S X="MERR^BDMGU",@^%ZOSF("TRAP") ; m error trap
 N BDMDMIEN,BDMPIEN,BDMMEDT,BDMMED,BDMMEDD,BDMQTY,BDMSIG,R,P
 S P="|",R="~"
 I $G(BDMSTR)="" D CATSTR^BDMGU(.BDMSTR,.BDMSTR)
 I $G(BDMSTR)="" S BDMRET="Error Creating BDMEDMUP Medication Entry, Invalid String" Q
 S BDMDMIEN=$P(BDMSTR,P)
 S BDMPIEN=$P(BDMSTR,P,2)
 F BDMI=3:1 D  Q:$P(BDMSTR,P,BDMI)=""
 . N BDMDATA
 . S BDMDATA=$P(BDMSTR,P,BDMI)
 . Q:$G(BDMDATA)=""
 . S BDMMED=$P(BDMDATA,R)
 . S BDMMEDD=$P(BDMDATA,R,2)
 . S BDMQTY=$P(BDMDATA,R,3)
 . S BDMSIG=$P(BDMDATA,R,4)
 . N BDMERR,BDMIENS,BDMFDA
 . S BDMIENS=""
 . S BDMFDA(9003203.214,"+2,"_BDMDMIEN_",",.01)=BDMMED
 . S BDMFDA(9003203.214,"+2,"_BDMDMIEN_",",.02)=BDMMEDD
 . S BDMFDA(9003203.214,"+2,"_BDMDMIEN_",",.03)=BDMQTY
 . S BDMFDA(9003203.214,"+2,"_BDMDMIEN_",",.04)=BDMSIG
 . D UPDATE^DIE("","BDMFDA","BDMIENS","BDMERR(1)")
 . I $G(BDMERR(1)) S BDMRET="" Q
 . S BDMRET=$G(BDMIENS(1))
 Q
 ;
EDU(BDMRET,BDMSTR) ;-- add EDU entries to APCDDMUP
 S X="MERR^BDMGU",@^%ZOSF("TRAP") ; m error trap
 N BDMDMIEN,BDMPIEN,BDMEDUT,BDMEDU,BDMPRVE,BDMPRV,BDMLOU,BDMEDUD,P,R
 N BDMTS,BDMIG,BDMOBJ,BDMBC
 S P="|",R="~"
 I $G(BDMSTR)="" D CATSTR^BDMGU(.BDMSTR,.BDMSTR)
 I $G(BDMSTR)="" S BDMRET="Error Creating BDMEDMUP Education Entry, Invalid String" Q
 S BDMDMIEN=$P(BDMSTR,P)
 S BDMPIEN=$P(BDMSTR,P,2)
 F BDMI=3:1 D  Q:$P(BDMSTR,P,BDMI)=""
 . N BDMDATA
 . S BDMDATA=$P(BDMSTR,P,BDMI)
 . Q:$G(BDMDATA)=""
 . S BDMEDUT=$P(BDMDATA,R)
 . S BDMEDU=$O(^AUTTEDT("B",BDMEDUT,0))
 . S BDMEDUD=$P(BDMDATA,R,2)
 . S BDMPRV=$P(BDMDATA,R,3)
 . S BDMLOU=$P(BDMDATA,R,4)
 . S BDMTS=$P(BDMDATA,R,5)
 . S BDMIG=$P(BDMDATA,R,6)
 . S BDMOBJ=$P(BDMDATA,R,7)
 . S BDMBC=$P(BDMDATA,R,8)
 . N BDMERR,BDMIENS,BDMFDA
 . S BDMIENS=""
 . S BDMFDA(9003203.212,"+2,"_BDMDMIEN_",",.01)=BDMEDU
 . S BDMFDA(9003203.212,"+2,"_BDMDMIEN_",",.02)=BDMEDUD
 . S BDMFDA(9003203.212,"+2,"_BDMDMIEN_",",.04)=BDMPRV
 . S BDMFDA(9003203.212,"+2,"_BDMDMIEN_",",.03)=BDMLOU
 . S BDMFDA(9003203.212,"+2,"_BDMDMIEN_",",.05)=BDMOBJ
 . S BDMFDA(9003203.212,"+2,"_BDMDMIEN_",",.06)=BDMIG
 . S BDMFDA(9003203.212,"+2,"_BDMDMIEN_",",.07)=BDMTS
 . S BDMFDA(9003203.212,"+2,"_BDMDMIEN_",",.08)=BDMBC
 . D UPDATE^DIE("","BDMFDA","BDMIENS","BDMERR(1)")
 . I $G(BDMERR(1)) S BDMRET="" Q
 . S BDMRET=$G(BDMIENS(1))
 Q
 ;
REF(BDMRET,BDMSTR) ;-- refusals
 S X="MERR^BDMGU",@^%ZOSF("TRAP") ; m error trap
 N P,R,BDMDMIEN,BDMPIEN
 S P="|",R="~"
 I BDMSTR="" S BDMSTR=$$CATSTR^BDMGU(.BDMSTR,.BDMSTR)
 I $G(BDMSTR)="" S BDMRET="Error Concatenating String for Refusals" Q
 S BDMDMIEN=$P(BDMSTR,P)
 S BDMPIEN=$P(BDMSTR,P,2)
 N BDMI
 F BDMI=3:1 D  Q:$P(BDMSTR,P,BDMI)=""
 . N BDMDATA,BDMFDA,BDMTERM,BDMIENS,BDMERR,BDMRES,BDMREFT,BDMREFR,BDMREFDT,BDMVAL
 . S BDMIENS=""
 . S BDMDATA=$P(BDMSTR,P,BDMI)
 . Q:$G(BDMDATA)=""
 . S BDMTERM=$P(BDMDATA,R)
 . S BDMTIEN=$O(^AUTTREFT("B",BDMTERM,0))
 . S BDMFILE=$P($G(^AUTTREFT(BDMTIEN,0)),U,2)
 . S BDMFLD=$P($G(^AUTTREFT(BDMTIEN,0)),U,3)
 . S BDMREFDT=$P(BDMDATA,R,2)
 . S BDMREFT=$P(BDMDATA,R,3)
 . S BDMREFR=$P(BDMDATA,R,4)
 . S BDMVAL=$$FIND1^DIC(BDMFILE,,"MX",BDMREFT,,,"BDMERR(1)")
 . S BDMFDA(9000022,"+1,",.01)=BDMTIEN
 . S BDMFDA(9000022,"+1,",.02)=BDMPIEN
 . S BDMFDA(9000022,"+1,",.03)=BDMREFDT
 . S BDMFDA(9000022,"+1,",.04)=BDMREFT
 . S BDMFDA(9000022,"+1,",.05)=BDMFILE
 . S BDMFDA(9000022,"+1,",.06)=BDMVAL
 . S BDMFDA(9000022,"+1,",.07)=BDMREFR
 . D UPDATE^DIE("","BDMFDA","BDMIENS","BDMERR(1)")
 . I $D(BDMERR) S BDMRET=$G(BDMERR(1)) Q
 Q
 ;
PCC(BDMRET,BDMSTR) ;-- return pcc data errors/result
 S X="MERR^BDMGU",@^%ZOSF("TRAP") ; m error trap
 K BDMDIEN,BDMEBSDV,BDMEDA,BDMEDMDT,BDMEDMPT,BDMEIN,BDMEMTYP,BDMEREC,BDMEREC1  ;p10
 D EN^BDMEDMUP(BDMSTR,.PCCRET)
 N BDMPCC,BDMI,BDMERR,BDMIEN
 K ^BDMTMP($J)
 S BDMRET="^BDMTMP("_$J_")"
 S BDMI=0
 S BDMERR=""
 S ^BDMTMP($J,BDMI)="T00080PCC"_$C(30)
 I '$D(PCCRET(1)) D  Q
 . S BDMI=BDMI+1
 . S ^BDMTMP($J,BDMI)="PCC Data Filed Successfully"_$C(30)
 . S ^BDMTMP($J,BDMI+1)=$C(31)_$G(BDMERR)
 S BDMDA=0 F  S BDMDA=$O(PCCRET(BDMDA)) Q:'BDMDA  D
 . S BDMI=BDMI+1
 . S ^BDMTMP($J,BDMI)=$G(PCCRET(BDMDA))_$C(30)
 S ^BDMTMP($J,BDMI+1)=$C(31)_$G(BDMERR)
 Q
 ;
TAX(BDMRET,BDMSTR) ;-- save taxonomy
 S X="MERR^BDMGU",@^%ZOSF("TRAP") ; m error trap
 N P,BDMFL,BDMTAXN,BDMTAXF,BDMTAX,BDMI,BDMP,BDMERR,BDMTAXM,BDMTXG,BDMTXF,BDMTAXPF,BDMLOOK,BDMTX,BDMTXM
 I BDMSTR="" D CATSTR^BDMGU(.BDMSTR,.BDMSTR)
 I $G(BDMSTR)="" S BDMRET="Error Concatenating String for Taxonomy" Q
 K ^BDMTMP($J)
 S BDMRET="^BDMTMP("_$J_")"
 S BDMI=0
 S BDMERR=""
 S ^BDMTMP($J,BDMI)="T00080TAXONOMYSAVE"_$C(30)
 S P="|"
 S BDMTAXN=$P(BDMSTR,P)
 S BDMTAXF=$P(BDMSTR,P,2)
 S BDMTXG="^ATXAX(""B"")"
 S BDMTX="^ATXAX("
 S BDMTXF=9002226
 S BDMTXM=9002226.02101
 I BDMTAXF="Lab" D
 . S BDMTXG="^ATXLAB(""B"")"
 . S BDMTX="^ATXLAB("
 . S BDMTXF=9002228
 . S BDMTXM=9002228.02101
 . S BDMFL=60
 S BDMTAX=$O(@BDMTXG@(BDMTAXN,0))
 S BDMLOOK=0
 I 'BDMTAX S BDMRET="Taxonomy does not exist on System" Q
 S BDMLOOK=0
 I '$$GET1^DIQ(BDMTXF,BDMTAX,.13) S BDMLOOK=1
 D CLEANTAX(BDMTX,BDMTAX)
 F BDMP=3:1 S BDMTAXM=$P(BDMSTR,P,BDMP) Q:$G(BDMTAXM)=""  D
 . N BDMIENS,BDMFDA
 . S BDMIENS="+2,"_BDMTAX_","
 . I BDMLOOK D
 .. N BDMGLF
 .. I '$G(BDMFL) S BDMFL=$P($G(^ATXAX(BDMTAX,0)),U,15)
 .. S BDMGLF=$G(^DIC(BDMFL,0,"GL"))
 .. S BDMGLF=BDMGLF_"""B"")"
 .. S BDMTAXM=$O(@BDMGLF@(BDMTAXM,0))
 . I 'BDMLOOK D
 .. S BDMTAXM=$P(BDMTAXM,"-")
 .. S BDMTAXM=BDMTAXM_" "
 . Q:$G(BDMTAXM)=""
 . S BDMFDA(BDMTXM,BDMIENS,.01)=BDMTAXM
 . I BDMTXM=9002226.02101 S BDMFDA(BDMTXM,BDMIENS,.02)=BDMTAXM
 . D UPDATE^DIE("","BDMFDA","BDMIENS","BDMERR(1)")
 S ^BDMTMP($J,BDMI+1)=$C(31)_$G(BDMERR)
 Q
 ;
CLEANTAX(TAXF,TAX) ;-- remove existing entries from 21 multiple before adding
 N BDMDA,TAXI,BDMAA
 S TAXI=TAXF_TAX_",21)"
 S DIK=TAXF_TAX_",21,",DA(1)=TAX
 S BDMDA=0 F  S BDMDA=$O(@TAXI@(BDMDA)) Q:'BDMDA  D
 . S DA=BDMDA
 . D ^DIK
 S BDMAA=TAXF_TAX_",21)"
 K @BDMAA@("AA")
 K DIK,DA
 Q
 ;
AU(BDMRET,BDMSTR) ;-- file the Authorized User
 N P,R,BDMREGE,BDMREG,BDMAU,BDMMK,BDMU
 S P="|",R="~"
 K ^BDMTMP($J)
 S BDMRET="^BDMTMP("_$J_")"
 S ^BDMTMP($J,0)="T00080RETURN"_$C(30)
 I $G(BDMSTR)="" D CATSTR^BDMGU(.BDMSTR,.BDMSTR)
 S BDMREGE=$P(BDMSTR,P)
 S BDMREG=$O(^ACM(41.1,"B",BDMREGE,0))
 F I=2:1 D  Q:$P(BDMSTR,P,I)=""
 . Q:$P(BDMSTR,P,I)=""
 . S BDMAU=$P($P(BDMSTR,P,I),R)
 . S BDMMK=$P($P(BDMSTR,P,I),R,2)
 . S BDMU(BDMAU)=BDMMK
 N BDMDA
 D CLNAU(BDMREG,.BDMU)
 S BDMDA=0 F  S BDMDA=$O(BDMU(BDMDA)) Q:'BDMDA  D
 . N BDMM
 . S BDMM=$G(BDMU(BDMDA))
 . D CHKKEY(BDMDA,BDMM)
 . Q:$D(^ACM(41.1,BDMREG,"AU",BDMDA))
 . N BDMFDA,BDMIENS,BDMERR
 . S BDMIENS(1)=BDMREG
 . S BDMIENS(2)=BDMDA
 . ;S BDMFDA(9002241,"?1,",.01)=BDMREGE
 . S BDMFDA(9002241.12,"+2,"_BDMIENS(1)_",",.01)=BDMDA
 . D UPDATE^DIE("","BDMFDA","BDMIENS","BDMERR(1)")
 . I $G(BDMERR) Q
 S ^BDMTMP($J,1)="DMS User Updated"_$C(30)
 S ^BDMTMP($J,2)=$C(31)
 Q
 ;
CHKKEY(PT,MM) ;-- check to see if the user holds the key and is auth
 N BDMKEY
 S BDMKEY=$O(^DIC(19.1,"B","BDMZ REGISTER MAINTENANCE",0))
 I $G(MM)="Y" D  Q
 . Q:$D(^VA(200,PT,51,BDMKEY,0))
 . N BDMIENS,BDMFDA,BDMERR
 . S BDMIENS(1)=PT
 . S BDMIENS(2)=BDMKEY
 . S BDMFDA(200.051,"+2,"_BDMIENS(1)_",",.01)=BDMKEY
 . S BDMFDA(200.051,"+2,"_BDMIENS(1)_",",1)=DUZ
 . D UPDATE^DIE("","BDMFDA","BDMIENS","BDMERR(1)")
 . I $G(BDMERR) Q
 Q:'$D(^VA(200,PT,51,BDMKEY))
 S DA(1)=PT,DA=BDMKEY,DIK="^VA(200,"_DA(1)_",51,"
 D ^DIK
 Q
 ;
CLNAU(REG,DMU) ;-- clean up authorized user first
 N BDMDA
 S BDMDA=0 F  S BDMDA=$O(^ACM(41.1,REG,"AU",BDMDA)) Q:'BDMDA  D
 . I '$D(DMU(BDMDA)) D
 .. S DA(1)=REG,DA=BDMDA,DIK="^ACM(41.1,"_DA(1)_",""AU"","
 .. D ^DIK
 Q
 ;