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

BDMGEB.m

Go to the documentation of this file.
BDMGEB ; cmi/anch/maw - BDM DMS GUI Filing Routine ;
 ;;2.0;BDM DIABETES MANAGEMENT SYSTEM;**1**;JAN 17, 2008
 ;
 ;
 ;
 ;1/25/2005 added in REGSV a check for DX
 ;3/22/2006 added diagnosis save to complications list add, subroutine CMPA
 ;
DEBUG(BDMRET,BDMSTR) ;-- debugger
 D DEBUG^%Serenji("DME^BDMGE(.BDMRET,.BDMSTR)")
 Q
 ;
CMPL(BDMRET,BDMSTR) ;-- save complications list
 N P,BDMDA,BDMIEN,BDMREG,BDMREGE,BDMCL,BDMCNT
 S P="|"
 K ^BDMTMP($J)
 S BDMRET="^BDMTMP("_$J_")"
 S ^BDMTMP($J,0)="T00050RETURN"_$C(30)
 I $G(BDMSTR)="" D CATSTR^BDMGU(.BDMSTR,.BDMSTR)
 S BDMREGE=$P(BDMSTR,P)
 S BDMCNT=0
 S BDMREG=$O(^ACM(41.1,"B",BDMREGE,0))
 I $P(BDMSTR,P,2)="" D  Q
 . N BDMDA
 . S BDMDA=0 F  S BDMDA=$O(^ACM(42.1,"RG",BDMREG,BDMDA)) Q:'BDMDA  D
 .. N BDMIEN
 .. S BDMIEN=0 F  S BDMIEN=$O(^ACM(42.1,"RG",BDMREG,BDMDA,BDMIEN)) Q:'BDMIEN  D
 ... S DA(1)=BDMDA,DA=BDMIEN,DIK="^ACM(42.1,"_DA(1)_",""RG"","
 ... D ^DIK
 F I=2:1 D  Q:$P(BDMSTR,P,I)=""
 . Q:$P(BDMSTR,P,I)=""
 . S BDMCNT=BDMCNT+1
 . S BDMCL(BDMCNT)=$P(BDMSTR,P,I)
 D CLNCL(.BDMCL,BDMREG)
 D ADDCL(.BDMCL,BDMREG)
 S ^BDMTMP($J,1)=$C(31)_$G(BDMERR)
 Q
 ;
CMPA(BDMRET,BDMSTR) ;-- add complication to list
 N P,BDMDA,BDMIEN,BDMREG,BDMREGE,BDMCL,BDMICD
 S P="|"
 K ^BDMTMP($J)
 S BDMRET="^BDMTMP("_$J_")"
 S ^BDMTMP($J,0)="T00050Error"_$C(30)
 I $G(BDMSTR)="" D CATSTR^BDMGU(.BDMSTR,.BDMSTR)
 S BDMREG=$P(BDMSTR,P)
 S BDMCL=$P(BDMSTR,P,2)
 S BDMCNT=0
 D ADDCL(BDMCL,BDMREG)
 S ^BDMTMP($J,2)=$C(31)_$G(BDMERR)
 Q
 ;
CMPDXA(BDMRET,BDMSTR) ;-- add complication diagnosis to list
 N P,BDMDA,BDMIEN,BDMREG,BDMREGE,BDMCL,BDMICD
 S P="|"
 K ^BDMTMP($J)
 S BDMRET="^BDMTMP("_$J_")"
 S ^BDMTMP($J,0)="T00050RETURN"_$C(30)
 I $G(BDMSTR)="" D CATSTR^BDMGU(.BDMSTR,.BDMSTR)
 S BDMREG=$P(BDMSTR,P)
 S BDMCL=$P(BDMSTR,P,2)
 S BDMICD=$P(BDMSTR,P,3)
 S BDMCNT=0
 D ADDCLDX(BDMCL,BDMICD)
 S ^BDMTMP($J,1)=$C(31)_$G(BDMERR)
 Q
 ;
CLNCL(CL,REG) ;-- clean up deleted complications first
 N BDMDA,BDMIEN,BDMCL
 S BDMDA=0 F  S BDMDA=$O(CL(BDMDA)) Q:'BDMDA  D
 . S BDMCL=$G(CL(BDMDA))
 . S BDMCLI=$O(^ACM(42.1,"B",BDMCL,0))
 . I BDMCLI,$D(^ACM(42.1,"RG",REG,BDMCL)) K CL(BDMDA)
 N BDMDA
 S BDMDA=0 F  S BDMDA=$O(CL(BDMDA)) Q:'BDMDA  D
 . N BDMCL,BDMIEN
 . S BDMCL=$G(CL,BDMDA)
 . S BDMCLI=$O(^ACM(42.1,"B",BDMCL,0))
 . Q:'BDMCLI
 . S BDMIEN=$O(^ACM(42.1,"RG",REG,BDMCLI,0))
 . Q:'BDMIEN
 . S DA(1)=BDMCLI,DA=BDMIEN,DIK="^ACM(42.1,"_DA(1)_",""RG"","
 . D ^DIK
 Q
 ;
ADDCL(CL,REG) ;-- add new complications to the complications list
 N BDMDA,BDMIEN,BDMCL
 S BDMCL=CL
 S BDMCLI=$O(^ACM(42.1,"B",BDMCL,0))
 I 'BDMCLI D  Q
 . N BDMFDA,BDMIENS,BDMERR
 . S BDMIENS=""
 . S BDMFDA(9002242.1,"?+1,",.01)=BDMCL
 . S BDMFDA(9002242.11,"+2,?+1,",.01)=REG
 . D UPDATE^DIE("","BDMFDA","BDMIENS","BDMERR(1)")
 . S ^BDMTMP($J,1)=$G(BDMIENS(1))_$C(30)
 I '$D(^ACM(42.1,"RG",REG,BDMCL)) D  Q
 . N BDMFDA,BDMIENS,BDMERR
 . S BDMIENS(1)=BDMCLI
 . S BDMFDA(9002242.11,"+2,"_BDMIENS(1)_",",.01)=REG
 . D UPDATE^DIE("","BDMFDA","BDMIENS","BDMERR(1)")
 S ^BDMTMP($J,1)=BDMCLI_$C(30)
 Q
 ;
ADDCLDX(CL,ICD) ;-- add new complications diagnosis to the complication
 N BDMDA,BDMIEN,BDMCL
 N I,R
 S R="~"
 F I=1:1 D  Q:$P(ICD,R,I)=""
 . Q:$P(ICD,R,I)=""
 . N BDMICDI
 . S BDMICDI=$P(ICD,R,I)
 . N BDMFDA,BDMIENS,BDMERR
 . S BDMIENS="?+2,"_CL_","
 . S BDMFDA(9002242.11101,BDMIENS,.01)=BDMICDI
 . D UPDATE^DIE("","BDMFDA","BDMIENS","BDMERR(1)")
 . Q
 Q
 ;
NLET(BDMRET,BDMSTR) ;-- save the new letter definition in RPMS
 N P,BDMDIR,BDMFN
 S P="|"
 S BDMDIR=$P(BDMSTR,P)
 S BDMFN=$P(BDMSTR,P,2)
 N BDMFDA,BDMERR,BDMIENS,BDMI
 S BDMIENS=""
 S BDMRET="^BDMTMP("_$J_")"
 S BDMI=0
 S ^BDMTMP($J,BDMI)="T00009BMXIEN"_$C(30)
 I $O(^BDMLET("B",BDMFN,0)) D  Q
 . S ^BDMTMP($J,BDMI+1)="Letter Already Exists"_$C(31)
 S BDMFDA(9003201,"+1,",.01)=BDMFN
 S BDMFDA(9003201,"+1,",.02)=DUZ
 S BDMFDA(9003201,"+1,",.03)=DT
 S BDMFDA(9003201,"+1,",.04)=BDMDIR
 S BDMFDA(9003201,"+1,",.05)=$TR(BDMFN,"/")_".doc"
 D UPDATE^DIE("","BDMFDA","BDMIENS","BDMERR(1)")
 S ^BDMTMP($J,BDMI+1)=$G(BDMIENS(1))_$C(31)
 Q
 ;
LETE(BDMRET,BDMSTR) ;-- add directory/filename to letter
 N P,BDMDIR,BDMIEN
 S P="|"
 S BDMIEN=$P(BDMSTR,P)
 S BDMDIR=$P(BDMSTR,P,2)
 N BDMFDA,BDMERR,BDMIENS,BDMI
 S BDMIENS=BDMIEN_","
 S BDMRET="^BDMTMP("_$J_")"
 S BDMI=0
 S ^BDMTMP($J,BDMI)="T00009BMXIEN"_$C(30)
 N BDMFN
 S BDMFN=$P($G(^BDMLET(BDMIEN,0)),U)
 S BDMFDA(9003201,BDMIENS,.04)=BDMDIR
 S BDMFDA(9003201,BDMIENS,.05)=$TR(BDMFN,"/")_".doc"
 D FILE^DIE("K","BDMFDA","BDMERR(1)")
 S ^BDMTMP($J,BDMI+1)=$G(BDMIENS(1))_$C(31)
 Q
 ;
LETP(BDMRET,BDMSTR) ;-- save letter insert items
 N P,BDMLETI,BDMITEM,R
 S P="|",R="~"
 S BDMLETI=$P(BDMSTR,P)
 S BDMITEM=$P(BDMSTR,P,2)
 N BDMI
 S BDMRET="^BDMTMP("_$J_")"
 S BDMI=0
 S ^BDMTMP($J,BDMI)="T00009BMXIEN"_$C(30)
 ;S BDMLETI=$O(^BDMLET("B",BDMLET,0))
 N BDMDA
 S BDMDA=0 F  S BDMDA=$O(^BDMLET(BDMLETI,"ITEM",BDMDA)) Q:'BDMDA  D
 . S DA(1)=BDMLETI,DA=BDMDA,DIK="^BDMLET("_DA(1)_","_"""ITEM"""_","
 . D ^DIK
 N I
 F I=2:1 D  Q:$P(BDMITEM,R,I)=""
 . N BDMFDA,BDMERR,BDMIENS
 . Q:$P(BDMITEM,R,I)=""
 . S BDMIENS(1)=BDMLETI
 . S BDMIENS="?+2,"_BDMLETI_","
 . N BDMIT,BDMITI
 . S BDMIT=$P(BDMITEM,R,I)
 . S BDMITI=$O(^DD("FUNC","B",BDMIT,0))
 . S BDMFDA(9003201.02,BDMIENS,.01)=BDMITI
 . D UPDATE^DIE("","BDMFDA","BDMIENS","BDMERR(1)")
 S ^BDMTMP($J,BDMI+1)=$G(BDMIENS(1))_$C(31)
 Q
 ;