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

BDMVRL5.m

Go to the documentation of this file.
BDMVRL5 ; IHS/CMI/LAB - VIEW PT RECORD LT ;
 ;;2.0;DIABETES MANAGEMENT SYSTEM;**4,12**;JUN 14, 2007;Build 51
 ;
PAUSE ;EP; -- end of action pause
 D RETURN^BDMVU
 Q
 ;
GETPAT ;EP; -- ask user to select patient
 K DIC,DFN,BDMQUIT
 S DIC=9000001
 S DIC(0)="AEMQZ"
 S AUPNLK("INAC")=""  ;1/25/2007 allow lookup of inactive patients
 D DIC^BDMFDIC
 I $G(Y)<1 S BDMQUIT="" K AUPNLK("INAC") Q
 K AUPNLK("INAC")  ;1/25/2007 allow lookup of inactive patients
 S DFN=+Y
 S BDMPAT0=$G(Y(0,0))
 D REGPAT
 Q:$D(BDMQUIT)
 D DOB
 D AGE
 D HRN
 D RES(DFN)
 D DX
 D COMP
 K BDMQUIT
 Q
 ;
GETHSTYP ;EP; -- ask user for health summary type
 N DIC,DR,DD,X
 S X=""
 I DUZ(2),$D(^APCCCTRL(DUZ(2),0))#2 S X=$P(^(0),U,3)
 S:X="" X="ADULT REGULAR"
 S DIC="^APCHSCTL("
 S DIC(0)="AEMQ"
 S DIC("B")=X
 W !
 D DIC^BDMFDIC
 Q:Y<1
 S APCHSTYP=+Y
 Q
REGPAT ;REGISTER AND PATIENT VARIABLES
 D REG^BDMFUTIL
 Q:$D(BDMQUIT)
 S BDMRPDA=$G(^ACM(41,"AC",DFN,BDMRDA))
 I 'BDMRPDA D NEWPAT
 D PAT^BDMVRL4(DFN,BDMRPDA)
 ;D INA(DFN,BDMRPDA)
 Q
 ;
INA(DFN,ACMRPDA) ;EP - check to see if patient is inactive
 ;cmi/anch/maw 1/25/2007 added per DKR
 Q:'ACMRPDA
 Q:$P($G(^AUPNPAT(DFN,41,DUZ(2),0)),U,5)=""
 Q:$P($G(^AUPNPAT(DFN,41,DUZ(2),0)),U,5)'="I"
 S DA=ACMRPDA
 S DIE="^ACM(41,"
 S DR="1////I"
 D DIE^BDMFDIC
 Q
 ;
NEWPAT ;EP;CREATE ENTRY FOR NEW REGISTER PATIENT
 D NEWPAT^BDMVRL2
 Q
DXUPD ;EP;UPDATE PATIENT'S DIABETIC DIAGNOSIS
 N X,Y,Z
 I BDMEXT=""!(BDMEXT'=BDMEXTIN) D  Q:BDMEXT=""
 .S DA=$P($G(BDM("DX",1)),U,2)
 .Q:'DA
 .S DIK="^ACM(44,"
 .D ^DIK
 S:'$D(BDM("DX",1)) $P(BDM("DX",1),U)=$P($G(BDMEXT),U)
 S Y=$P(BDM("DX",1),U)
 I Y=$G(BDMDX) K BDMDX Q
 S:$G(BDMEXT)]"" BDMX=$O(^ACM(44.1,"B",$P(BDMEXT,U),0))
 I $G(BDMX) S BDMX=$P(^ACM(44.1,BDMX,0),U)  ;cmi/maw 9/7/06 added due to not allowed 4 slash on .01 below
 Q:$G(BDMX)=""
 S DA=""
 S X=0
 F  S X=$O(BDM("DX",X)) Q:'X  D
 .I $P(BDM("DX",X),U)=$P(BDMEXT,U) S DA=$P(BDM("DX",X),U,2)
 I DA D  Q
 .S DIE="^ACM(44,"
 .S DR=".01///"_BDMX_";2////"_$G(BDM("ONSET"))
 .D DIE^BDMFDIC
 S X=BDMX
 S DIC="^ACM(44,"
 S DIC(0)="L"
 S DIC("DR")=".02////"_DFN_";.03////"_BDMRPDA_";.04////"_BDMRDA_";2////"_$G(BDM("ONSET"))
 D FILE^BDMFDIC
 Q
GRD ;EP;PATIENT REGISTER DATA
 Q:'$G(BDMRPDA)
 N X,Y,Z
 S BDMREG0=$G(^ACM(41,BDMRPDA,0))
 S BDMREGDT=$G(^ACM(41,BDMRPDA,"DT"))
 S BDMCH=$G(^ACM(41,BDMRPDA,"CH"))
 S:'$G(DFN) DFN=$P(BDMREG0,U,2)
 S X=$P($G(^DPT(+DFN,0)),U)
 D 30
 S BDM("PATIENT")=X
 S X=$P(BDMREGDT,U)
 S X=$P($P($P(^DD(9002241,1,0),U,3),(X_":"),2),";")
 D 30
 S BDM("STATUS")=X
 S X=$P(BDMREGDT,U,5)
 S X=$P($P($P(^DD(9002241,5,0),U,3),(X_":"),2),";")
 D 30
 S BDM("CASE PRIORITY")=X
 S X=$P(BDMREGDT,U,6)
 S X=$P($G(^VA(200,+X,0)),U)
 D 30
 S BDM("CASE MANAGER")=X
 S X=$P(BDMREGDT,U,7)
 S X=$P($G(^VA(200,+X,0)),U)
 D 30
 S BDM("PUBLIC HLTH NURSE")=X
 S X=$P(BDMREGDT,U,10)
 S X=$P($G(^DIC(4,+X,0)),U)
 D 30
 S BDM("WHERE FOLLOWED")=X
 S X=$P(BDMREGDT,U,13)
 D 30
 S BDM("CLIENT CONTACT")=X
 S X=$P($G(^AUPNPAT(DFN,0)),U,14)
 S X=$S($G(^DD(9000001,.14,0))[200:$P($G(^VA(200,+X,0)),U),1:$P($G(^DIC(16,+X,0)),U))
 D 30
 S BDM("PRIMARY PROVIDER")=X
 S X=$P(BDMREGDT,U,15)
 S X=$P($G(^VA(200,+X,0)),U)
 D 30
 S BDM("REGISTER PROVIDER")=X
 S X=$P(BDMREGDT,U,14)
 S X=$P($P($P(^DD(9002241,15.1,0),U,3),(X_":"),2),";")
 D 30
 S BDM("PROVIDER CATEGORY")=X
 S Y=$P(BDMREGDT,U,2)
 X ^DD("DD")
 D 15
 S BDM("DATE ACTIVATED")=Y
 S Y=$P(BDMREGDT,U,3)
 X ^DD("DD")
 D 15
 S BDM("DATE INACTIVATED")=Y
 S Y=$P(BDMREGDT,U,4)
 X ^DD("DD")
 D 15
 S BDM("INITIAL ENTRY DATE")=Y
 S Y=$P(BDMREGDT,U,11)
 X ^DD("DD")
 D 15
 S BDM("DATE LAST EDITED")=Y
 S Y=$P(BDMREGDT,U,8)
 X ^DD("DD")
 D 15
 S BDM("LAST REVIEW DATE")=Y
 S Y=$P(BDMREGDT,U,9)
 X ^DD("DD")
 D 15
 S BDM("NEXT REVIEW DATE")=Y
 D DOB
 D AGE
 D HRN
 D RES(DFN)
 D DX
 D COMP
 Q
DOB ;DATE OF BIRTH
 N X,Y,Z
 K BDM("DOB")
 S Y=$P(^DPT(DFN,0),U,3)
 S BDM("DOB")=$E(Y,4,5)_"/"_$E(Y,6,7)_"/"_$S($E(Y,1,3)>299:20_$E(Y,2,3),1:(19_$E(Y,2,3)))
 S Z=""
 S X=$G(^DPT(DFN,.11))
 F J=1:1:6 I $P(X,U,J)]"" S Y=$P(X,U,J) S:J=5 Y=$P($G(^DIC(5,+Y,0)),U,2) S Z=Z_Y S:J'=6 Z=Z_","
 S BDM("ADDRESS")=Z
 S BDM("PHONE")=$P($G(^DPT(DFN,.13)),U)
 Q
AGE ;PATIENT AGE
 N X,Y,Z
 K BDM("AGE")
 S X=$P(^DPT(DFN,0),U,3)
 S Y=$E(DT,1,3)
 S Z=$E(Y,1,3)-$E(X,1,3)
 S:$E(X,4,7)>$E(DT,4,7) Z=Z-1
 S BDM("AGE")=Z
 Q
HRN ;HRN
 S BDM("HRN")=$P($G(^AUPNPAT(DFN,41,+$G(DUZ(2)),0)),U,2)
 Q
RES(DFN) ;EP;CURRENT RESIDENCE      
 N X
 S X=$O(^AUPNPAT(DFN,51,99999999),-1)
 S:X X=$P($G(^AUPNPAT(DFN,51,X,0)),U,3)
 S:'X X=+$P($G(^AUPNPAT(DFN,11)),U,17)
 I 'X S X=$P($G(^AUPNPAT(DFN,11)),U,18) S:X]"" X=$O(^AUTTCOM("B",X,0))
 S (BDM,BDM("RES"))=X
 Q
DX ;DIABETIC DIAGNOSES
 K BDM("DX")
 N X,Y,Z
 S (BDMEXT,BDMEXTIN)=""
 S (X,Z)=0
 F  S X=$O(^ACM(44,"C",DFN,X)) Q:'X  D
 .S Y=$G(^ACM(44,X,0))
 .Q:'Y
 .Q:$P(Y,U,4)'=BDMRDA
 .S Y=$G(^ACM(44.1,+Y,0))
 .S Z=Z+1
 .D DD
 .S BDM("DX",Z)=$P(Y,U)_U_X_U_BDM("ONSET DISPLAY")
 .S:Z=1 (BDMEXT,BDMEXTIN)=$P(Y,U)
 S Z=1
 S X=$O(^ACM(44,"C",DFN,X))
 D:X DD
 Q
 S BDMX=1
 F  S BDMX=$O(BDM("DX",BDMX)) Q:'BDMX  D
 .S DA=$P(BDM("DX",BDMX),U,2)
 .Q:'DA
 .S DIK="^ACM(44.,"
 .D DIK^BDMFDIC
 .K BDM("DX",BDMX)
 Q
DD ;ONSET DATE
 N Y
 S Y=$P($G(^ACM(44,X,"SV")),U,2)
 X:Y ^DD("DD")
 S BDM("ONSET DISPLAY")=Y
 Q
30 ;PAD TO 30 CHARACTERS
 S X=X_$E("                              ",1,30-$L(X))
 Q
15 ;PAD TO 15 CHARACTERS
 S Y=Y_$E("               ",1,15-$L(Y))
 Q
COMP ;PATIENT'S COMPLICATIONS
 K BDM("COMP")
 N X,Y,Z
 S (X,Z)=0
 F  S X=$O(^ACM(42,"C",DFN,X)) Q:'X  D
 .S ACM0=$G(^ACM(42,X,0))
 .Q:'ACM0
 .Q:$P(ACM0,U,4)'=BDMRDA
 .S Y=$G(^ACM(42.1,+ACM0,0))
 .S Z=Z+1
 .S BDM("COMP",Z)=$P(Y,U)
 .S Y=$P($G(^ACM(42,X,"DT")),U)
 .X ^DD("DD")
 .S BDM("COMP",Z)=BDM("COMP",Z)_U_Y
 Q
PP ;EP;PRIMARY CARE PROVIDER
 Q
 Q:$G(^DD(9000001,.14,0))[200
 N BDMPP,BDMPP6
 I $P($G(^AUPNPAT(+$G(DFN),0)),U,14) D
 .S BDMPP6=$P(^AUPNPAT(DFN,0),U,14)
 .S BDMPP=$O(^VA(200,"A16",+$G(BDMPP6),0))
 I '$G(BDMPP) D
 .S BDMPP=$P($G(^ACM(41,BDMRPDA,"DT")),U,15)
 .Q:'BDMPP
 .S BDMPP6=$P($G(^VA(200,BDMPP,0)),U,16)
 .S DA=DFN
 .S DIE="^AUPNPAT("
 .S DR=".14////"_BDMPP6
 .D DIE^BDMFDIC
 Q:$P($G(^ACM(41,BDMRPDA,"DT")),U,15)
 S DA=BDMRPDA
 S DIE="^ACM(41,"
 S DR="15////"_BDMPP
 D DIE^BDMFDIC
 Q
CONTACT ;CLIENT CONTACT INFO
 Q:$P($G(^ACM(41,BDMRPDA,"DT")),U,13)]""
 N X,Y,Z
 S Z=""
 S X=$G(^DPT(DFN,.11))
 F J=1:1:6 I $P(X,U,J)]"" S Y=$P(X,U,J) S:J=5 Y=$P($G(^DIC(5,+Y,0)),U,2) S Z=Z_Y_","
 S X=$P($G(^DPT(DFN,.13)),U)
 S DA=BDMRPDA
 S DIE="^ACM(41,"
 S DR="14////"_Z_"  "_X
 D DIE^BDMFDIC
 Q
NOREG ;EP;NO DIABETES REGISTER ON THE SYSTEM
 D CLEAR^VALM1
 W !!,"There is no IHS DIABETES REGISTER on this system."
 S DIR(0)="YO"
 S DIR("A")="Create the IHS DIABETES REGISTER now?"
 S DIR("B")="NO"
 W !
 D DIR^BDMFDIC
 I Y'=1 S BDMQUIT="" Q
NR1 ;EP;CREATE NEW IHS DIABETES REGISTER
 D NEWREG
 D NEWDIAG
 D NEWCOMP
 D NEWHS
 Q
NEWREG ;CREATE IHS DIABETES REGISTER
 S X=BDMREGNM
 I $D(^ACM(41.1,"B",X)) S BDMRDA=$O(^(X,0)) Q:BDMRDA
 S DIC="^ACM(41.1,"
 S DIC(0)="L"
 D FILE^BDMFDIC
 S BDMRDA=+Y
 Q
NEWDIAG ;IHS DIABETES REGISTER DIAGNOSES
 F BDMX="TYPE 1","TYPE 2","GESTATIONAL DM","IMPAIRED GLUCOSE TOLERANCE" D
 .S BDMY=$O(^ACM(44.1,"B",BDMX,0))
 .I BDMY,$D(^ACM(44.1,BDMY,"RG","B",BDMRDA)) Q
 .I 'BDMY D
 ..S X=BDMX
 ..S DIC="^ACM(44.1,"
 ..S DIC(0)="L"
 ..D FILE^BDMFDIC
 ..S BDMY=+Y
 .S X=BDMRDA
 .S DA=+Y
 .S DA(1)=+Y
 .S $P(^ACM(44.1,BDMY,"RG",0),U,2)="9002244.11P"
 .S DIC="^ACM(44.1,"_DA_",""RG"","
 .S DIC(0)="L"
 .D FILE^BDMFDIC
 Q
NEWCOMP ;IHS DIABETES REGISTER COMPLICATIONS
 S:'$G(BDMRDA) BDMRDA=$O(^ACM(41.1,"B",BDMREGNM,0))
 Q:'BDMRDA
 F BDMX="CVA (STROKE)","END STAGE RENAL DISEASE","FIXED PROTEINURIA","HIGH RISK FOOT","HYPERTENSION","LASER TX FOR RETINOPATHY","MAJOR AMPUTATION(S)","MINOR AMPUTATION(S)","RETINOPATHY" D
 .S BDMY=$O(^ACM(42.1,"B",BDMX,0))
 .I BDMY,$D(^ACM(42.1,BDMY,"RG","B",BDMRDA)) Q
 .I 'BDMY D
 ..S X=BDMX
 ..S DIC="^ACM(42.1,"
 ..S DIC(0)="L"
 ..D FILE^BDMFDIC
 ..S BDMY=+Y
 .S X=BDMRDA
 .S DA=+Y
 .S DA(1)=+Y
 .S $P(^ACM(42.1,DA,"RG",0),U,2)="9002242.11P"
 .S DIC="^ACM(42.1,"_DA_",""RG"","
 .S DIC(0)="L"
 .D FILE^BDMFDIC
 Q
NEWHS ;EP;NEW HEALTH SUMMARIES FOR DMS
 N BDMX,BDMDA
 F BDMX="DMS LAB REPORT","DMS DIABETES LAB REPORT","DMS DIABETIC FLOWSHEET" D
 .S BDMDA=""
 .I $D(^APCHSCTL("B",BDMX)) S BDMDA=$O(^APCHSCTL("B",BDMX,0))
 .I '$G(BDMDA) D
 ..S X=BDMX
 ..S DIC="^APCHSCTL("
 ..S DIC(0)="LZ"
 ..D FILE^BDMFDIC
 ..S BDMDA=+Y
 .Q:BDMDA<1
 .I BDMX["LAB REPORT" D LAB
 .I BDMX["FLOWSHEET" D FS
 Q
LAB S X=$O(^APCHSCMP("B","LABORATORY DATA",0))
 Q:'X
 K BDMQUIT
 S Y=0
 F  S Y=$O(^APCHSCTL(BDMDA,1,Y)) Q:'Y  D
 .I $P($G(^APCHSCTL(BDMDA,1,Y,0)),U,2)=X S BDMQUIT=""
 I $D(BDMQUIT) K BDMQUIT Q
 S $P(^APCHSCTL(BDMDA,1,0),U,2)="9001015.01IA"
 S (DA,DA(1))=BDMDA
 S DIC="^APCHSCTL("_DA_",1,"
 S DIC(0)="L"
 S DIC("DR")="1////"_X_";2////30;3////1Y"
 S X=5
 D FILE^BDMFDIC
 Q:Y<1
 D DMLAB^BDMFUTIL:BDMX["DIABETES LAB"
 Q
FS S X=$O(^APCHSCMP("B","FLOWSHEETS",0))
 Q:'X
 K BDMQUIT
 S Y=0
 F  S Y=$O(^APCHSCTL(BDMDA,1,Y)) Q:'Y  D
 .I $P($G(^APCHSCTL(BDMDA,1,Y,0)),U,2)=X S BDMQUIT=""
 I $D(BDMQUIT) K BDMQUIT Q
 S $P(^APCHSCTL(BDMDA,1,0),U,2)="9001015.01IA"
 S (DA,DA(1))=BDMDA
 S DIC="^APCHSCTL("_DA_",1,"
 S DIC(0)="L"
 S DIC("DR")="1////"_X_";2////10;3////1Y"
 S X=5
 D FILE^BDMFDIC
 Q:Y<1
 S X=$O(^APCHSFLC("B","DIABETIC FLOWSHEET",0))
 Q:'X
 K BDMQUIT
 S Y=0
 F  S Y=$O(^APCHSCTL(BDMDA,6,Y)) Q:'Y  D
 .I $P($G(^APCHSCTL(BDMDA,6,Y,0)),U,2)=X S BDMQUIT=""
 I $D(BDMQUIT) K BDMQUIT Q
 S (DA,DA(1))=BDMDA
 S $P(^APCHSCTL(DA,6,0),U,2)="9001015.07IA"
 S DIC="^APCHSCTL("_DA_",6,"
 S DIC(0)="L"
 S DIC("DR")="1////"_X
 S X=5
 D FILE^BDMFDIC
 Q