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

BDMLET.m

Go to the documentation of this file.
BDMLET ; IHS/CMI/LAB - VIEW PT RECORD LT ; 05 Dec 2016  2:14 PM
 ;;2.0;DIABETES MANAGEMENT SYSTEM;**1,3,4,5,10**;JUN 14, 2007;Build 12
 ;Education Text Inserts to the Letter
 ;Education Followup Text Insert
 ;
 ;
 ;cmi/maw 7/31/2007 PATCH 1 added item 25 and code CENTER to allow centering of text
 ;
 ;
EN S BDMVALM="BDM LETTER"
 D VALM^BDMVRL(BDMVALM)
 Q
EXIT K BDMQUIT,BDMOUT,BDMLDA
 K ^TMP("BDMVR",$J)
 Q
ADD ;EP;TO ADD DMS LETTERS
 D EXIT
 D A1
 D E11:$G(BDMLDA)
 Q
A1 D CLEAR^VALM1
 K BDMLDA
 S:$G(DIC(0))="" DIC(0)="AELMQZ"
 S DIC="^BDMLET("
 S DIC("A")="NAME OF LETTER: "
 S:DIC(0)["L" DIC("DR")=".02////"_DUZ_";.03////"_DT,DLAYGO=9003201
 W !?16,"------------------------------"
 D DIC^BDMFDIC
 S:+Y>0 BDMLDA=+Y
BACK S VALMBCK="R"
 Q
WHICH ;EP;TO IDENTIFY WHICH LETTER TO USE
 S DIC(0)="AEMQZ"
 D A1
 Q
SELECT ;EP;TO SELECT DMS LETTER
 K BDMQUIT,BDMOUT
 D LIST
S1 S DIR(0)="NO^1:"_BDMJ
 S DIR("A")="Select LETTER NO."
 W !
 D DIR^BDMFDIC
 I +Y<1!'$G(BDMTMP(+Y)) S BDMQUIT="" Q
 S BDMLDA=+BDMTMP(+Y)
 Q
EDIT ;EP;TO EDIT DMS LETTER
 D EXIT
 D S1
 I $D(BDMQUIT) K BDMQUIT D BACK Q
E11 D CLEAR^VALM1
 S DA=BDMLDA
 S DIE="^BDMLET("
 S DR=1
 D DIE^BDMFDIC
 D PARSE
 D BACK
 Q
EPPRINT ;EP;TO PRINT LETTER FROM XBNEW CALL
 S BDM("STATUS")=BDMLSTAT
 D PRINT
 Q
PRINT ;EP;TO PRINT DMS LETTER
 Q:'$G(BDMLDA)!'$G(DFN)
 D CLEAR^VALM1:IO=IO(0)&(IOST["C-")
 W @IOF
 N A,B,C,D,X,Y,Z
 S X=0
 F  S X=$O(^BDMLET(BDMLDA,1,X)) Q:'X  D
 .S Y=$G(^BDMLET(BDMLDA,1,X,0))
 .I Y["|" D INTP
 .W !,Y
 D PAUSE^BDMFMENU
 Q
INTP ;INTERPRET VARIABLES
 N ZZ,ZZZ,X,K,E,M
 S X=Y
 X ^%ZOSF("UPPERCASE")
 S ZZ=Y
 S ZZZ=$P(Y,"|")
 F I=2:2 S J=$P(Y,"|",I) Q:J=""  D
 .S E=$O(^BDMLETI("B",J,0))
 .I 'E S E=$O(^BDMLETI("B",$E(J,1,8),0))
 .I 'E Q
 .S M=$G(^BDMLETI(E,1))
 .I M="" Q
 .X M  ;THE mumps code must set Z equal to the value
 .;K is the mumps code to execute
 .;S K=$E($P(J," "),1,8)
 .;I $T(@K)="" S ZZ="" Q
 .;D @K
 .S ZZ=$P(ZZ,("|"_J_"|"))_Z_$P(ZZ,("|"_J_"|"),2)
 S Y=ZZ
 Q
INTPF ;EP;TO ENTER EDUCATION TEXT WITH FOLLOWUP ITEM
 N ZZ,ZZZ,X,K
 Q:BDMZ=""
 Q:BDMZ["OTHER"
 Q:BDMZ["LDL"
 Q:BDMZ["HDL"
 Q:BDMZ["CHOL"
 Q:BDMZ["DEPR"
 Q:BDMZ["EKG"
 Q:BDMZ["GFR"
 W !
 I BDMZ["FOOT" S X="FOOT EXAM EDUCATION"
 I BDMZ["DENTAL" S X="DENTAL EXAM EDUCATION"
 I BDMZ["EYE" S X="EYE EXAM EDUCATION"
 I BDMZ["FLU" S X="FLU SHOT EDUCATION"
 I BDMZ["PNEUMO" S X="PNEUMO EDUCATION"
 I BDMZ["HEP" S X="HEP B EDUCATION"
 I BDMZ["TD" S X="TETANUS EDUCATION"
 I BDMZ["PPD" S X="TB TEST EDUCATION"
 I BDMZ["A1C" S X="A1C HEMOGLOBIN EDUCATION"
 I BDMZ["CREATIN" S X="CREATININE EDUCATION"
 I BDMZ["URINE" S X="URINE PROTEIN TEST EDUCATION"
 I BDMZ["LIPID" S X="LIPID PANEL EDUCATION"
 I BDMZ["TRIG" S X="LIPID PANEL EDUCATION"
 I BDMZ["NUTRI" S X="NUTRITION EDUCATION"
 I BDMZ["PHYSCIAL" S X="PHYSICAL ACTIVITY EDUCATION"
 I BDMZ["A/C" S X="A/C RATIO EDUCATION"
 S Y=$O(^BDMLETI("B",X,0))
 D EDUCP
 Q
 ;
ZIS ;EP;TO SELECT DEVICE ON WHICH TO PRINT DMS LETTER
 S (ZTRTN,BDMRTN)="PRINT^BDMLET"
 S ZTDESC="PRINT DMS PATIENT LETTER"
 S ZTSAVE("BDM*")=""
 S ZTSAVE("DFN")=""
 D ^BDMFZIS
 Q
MULTIPLE ;EP;UTILTIY TO SELECT MULTIPLE PATIENTS FOR WHICH TO PRINT DMS LETTER
 Q
LINIT ;EP;TO CREATE ARRAY OF NAMES OF EXISTING LETTERS
 N X
 K ^TMP("BDMVR",$J),BDMJ
 S VALMCNT=0
 K X
 ;S $E(X,5)="NO.  LETTER"
 ;D Z(X)
 ;K X
 ;S $E(X,5)="---  ------------------------------"
 ;D Z(X)
 S BDMJ=0
 S Y=""
 F  S Y=$O(^BDMLET("B",Y)) Q:Y=""  D
 .S Z=0
 .F  S Z=$O(^BDMLET("B",Y,Z)) Q:'Z  D
 ..S BDMJ=BDMJ+1
 ..K X
 ..S $E(X,5)=BDMJ
 ..S $E(X,10)=Y
 ..D Z(X)
 ..S BDMTMP(BDMJ)=Z
 Q
INSERT ;EP;TO LIST INSERT ITEMS
 S BDMVALM="BDM LETTER ITEMS"
 D TERM^VALM0
 D CLEAR^VALM1
 D EN^VALM(BDMVALM)
 D CLEAR^VALM1
 D BACK
 Q
IHDR ;
 S VALMHDR(1)="NO.    INSERT"
 ;S $E(VALMHDR(2),"-",78)=""
 Q
ILIST ;LIST ITEM TEXT
 K BDMLETI
 N X,C,Y
 S (X,C)=0
 F  S X=$O(^BDMLETI("C",X)) Q:X'=+X  D
 .S Y=0 F  S Y=$O(^BDMLETI("C",X,Y)) Q:Y'=+Y  D
 ..S C=C+1
 ..S BDMLETI(C,0)=C,$E(BDMLETI(C,0),10)=$P(^BDMLETI(Y,0),U,1)
 ..S BDMLETI("IDX",C,C)=Y
 S (VALMCNT,BDMLETIC)=C
 Q
PARSE ;DIVIDE UP THE LETTER CONTENT
 N I,J,K,X,Y,Z,ZZ,BDMTMP
 S (Z,ZZ)=""
 S (J,X)=0
 F  S X=$O(^BDMLET(BDMLDA,1,X)) Q:'X  D
 .S Y=$G(^BDMLET(BDMLDA,1,X,0))
 .Q:Y=""
 .I Y["|" D VARS
 .D LINE
 Q:'$D(BDMTMP)
 S %X="BDMTMP("
 S %Y="^BDMLET("_BDMLDA_",1,"
 D %XY^%RCR
 Q
VARS ;CONVERT VARIABLES
 N I,J,K,X,Z,E
 ;S ZZ="ZL BDMLET S X=""I""_J,X=$T(@X)"
 F I=2:2 S J=$P(Y,"|",I) Q:J=""  D:J
 .;X ZZ
 .S E=$O(^BDMLETI("C",J,0))
 .;S Z=$P(X,";;",3)
 .S X=$P(^BDMLETI(E,0),U,1)
 .S Y=$P(Y,("|"_J_"|"))_"|"_X_"|"_$P(Y,("|"_J_"|"),2)
 Q
LINE ;
 I $L(Y)<81 D  Q
 .S J=J+1
 .S BDMTMP(J,0)=Y
 F I=1:1 S K=$P(Y," ",I) Q:$P(Y," ",I,99)=""  D
 .I $L(Z_" "_K)>80 D  Q
 ..S J=J+1
 ..S BDMTMP(J,0)=Z
 ..S Z=""
 .I Z="" S Z=K
 .E  S Z=Z_" "_K
 I $L(Z) S J=J+1,BDMTMP(J,0)=Z
 Q
PATLET ;EP;TO SELECT AND PROCESS PATIENT LETTER
 D SELECT
 Q:'$G(BDMLDA)
 D ZIS
 Q
LIST ;LIST LETTERS
 K BDMTMP
 N BDM,BDMX,BDMY,BDMZ
 W @IOF
 W !!?5,"DMS letters currently on file:"
 W !!,"NO.  LETTER"
 W ?27,"NO.  LETTER"
 W ?54,"NO.  LETTER"
 W !,"---  --------------------"
 W ?27,"---  --------------------"
 W ?54,"---  --------------------"
 S BDMJ=0
 S BDM=""
 F  S BDM=$O(^BDMLET("B",BDM)) Q:BDM=""  D
 .S BDMX=0
 .F  S BDMX=$O(^BDMLET("B",BDM,BDMX)) Q:'BDMX  D
 ..S BDMY=$G(^BDMLET(BDMX,0))
 ..Q:BDMY=""
 ..S BDMJ=BDMJ+1
 ..S BDMTMP(BDMJ)=BDMX_U_BDM
 ..W:BDMJ#3=1 !
 ..W:BDMJ#3=2 ?27
 ..W:BDMJ#3=0 ?53
 ..W $J(BDMJ,2),"   "
 ..W $E(BDM,1,20)
 Q
CHART ;EP;TO PRINT PATIENT CHART NUMBER
 S Z="CHART NO.: "_$P($G(^AUPNPAT(DFN,41,DUZ(2),0)),U,2)
 Q
EDUCATE ;EP - to print all education
 S Z=""
 NEW Y,X,E
 S E=0 F  S E=$O(^BDMLETI("C",E)) Q:E'=+E  D
 .S Y=0 F  S Y=$O(^BDMLETI("C",E,Y)) Q:Y'=+Y  D
 ..Q:'$P(^BDMLETI(Y,0),U,3)
 ..D EDUCP
 ..Q
 .Q
 Q
EDUCP ;EP - print education text
 S Z=""
 Q:'Y
 NEW X
 S X=0 F  S X=$O(^BDMLETI(Y,2,X)) Q:X'=+X  W !,^BDMLETI(Y,2,X,0)
 W !
 Q
ADDRESS ;EP;TO PRINT PATIENT'S ADDRESS IN A LETTER
 S Z=$G(^DPT(DFN,.11))
 W !
 W:$G(ZZZ)]"" ?$L(ZZZ)
 W $P(Z,U)
 I $P(Z,U,2) D
 .W !
 .W:$G(ZZZ)]"" ?$L(ZZZ)
 .W $P(Z,U,2)
 I $P(Z,U,3) D
 .W !
 .W:$G(ZZZ)]"" ?$L(ZZZ)
 .W $P(Z,U,3)
 W !
 W:$G(ZZZ)]"" ?$L(ZZZ)
 W $P(Z,U,4),", ",$P($G(^DIC(5,+$P(Z,U,5),0)),U,2),"  ",$P(Z,U,6)
 S (Z,ZZ)=""
 Q
 ;
CENTER ;-- try and center the text here
 ;
 N T,L,N,I
 S Z=""
 S T=$P(X,"|",3)
 S L=$L(T)/2
 S N=(80/2)-L
 F I=1:1:N S Z=Z_" "
 Q
 ;
FOLLOW ;EP;TO PRINT FOLLOW-UP MESSAGE
 S BDM("STATUS")=$E($G(BDM("STATUS")))
 S BDMPDA=DFN
 D SSET^BDMVRL42
 N BDMX
 S BDMX=0
 F  S BDMX=$O(^TMP("BDMTMP",$J,"FUL",DFN,BDMX)) Q:'BDMX!$D(BDMQUIT)  D
 .S BDMY=""
 .F  S BDMY=$O(^TMP("BDMTMP",$J,"FUL",DFN,BDMX,BDMY)) Q:BDMY=""!$D(BDMQUIT)  D
 ..S BDMZ=$G(^TMP("BDMTMP",$J,"FUL",DFN,BDMX,BDMY))
 ..W !?5,BDMY,?28,"----------",?40,$P(BDMZ,U)
 S (Z,ZZ)=""
 Q
 ;
TEXT ;FOLLOWUP LETTER WITH EDUCATION INSERTS;
 S BDM("STATUS")=$E($G(BDM("STATUS")))
 S BDMPDA=DFN
 D SSET^BDMVRL42
 N BDMX
 S BDMX=0
 F  S BDMX=$O(^TMP("BDMTMP",$J,"FUL",DFN,BDMX)) Q:'BDMX!$D(BDMQUIT)  D
 .S BDMY=""
 .F  S BDMY=$O(^TMP("BDMTMP",$J,"FUL",DFN,BDMX,BDMY)) Q:BDMY=""!$D(BDMQUIT)  D
 ..S BDMZ=$G(^TMP("BDMTMP",$J,"FUL",DFN,BDMX,BDMY))
 ..W !?5,BDMY,?28,"----------",?40,$P(BDMZ,U)
 ..D INTPF
 S (Z,ZZ)=""
 Q
 ;
REGISTER ;EP;TO PRINT PROVIDER NAME IN A LETTER
 S BDMRPDA=$G(^ACM(41,"AC",DFN,BDMRDA))
 I 'BDMRPDA S Z="" Q
 S Z=$P($G(^ACM(41,BDMRPDA,"DT")),U,15)
 I Z="" Q
 S Z=$P($G(^VA(200,Z,0)),U)
 S Z=$P($P(Z,",",2)," ")_" "_$P(Z,",")
 Q
DELETE ;DELETE LETTER
 D S1
 I $D(BDMQUIT) K BDMQUIT D BACK Q
 S DA=BDMLDA
 S DIK="^BDMLET("
 D ^DIK
 D BACK
 Q
Z(X) ;SET TMP NODE    
 S VALMCNT=VALMCNT+1
 S ^TMP("BDMVR",$J,VALMCNT,0)=X
 Q
PRIMARY ;EP;TO PRINT PCP PROVIDER NAME IN A LETTER
 K R
 D ALLDP^BDPAPI(DFN,"DESIGNATED PRIMARY PROVIDER",.R)
 S Z=$P($G(R("DESIGNATED PRIMARY PROVIDER")),U,1)
 I Z]"" S Z=$P($P(Z,",",2)," ")_" "_$P(Z,",")
 Q
PHARTEXT ;FOLLOWUP LETTER WITH EDUCATION INSERTS;  NOEL PHARES, NOT EDUCATION OR DEP SCR
 S BDM("STATUS")=$E($G(BDM("STATUS")))
 S BDMPDA=DFN
 D SSET^BDMVRL42
 N BDMX
 S BDMX=0
 F  S BDMX=$O(^TMP("BDMTMP",$J,"FUL",DFN,BDMX)) Q:'BDMX!$D(BDMQUIT)  D
 .S BDMY=""
 .F  S BDMY=$O(^TMP("BDMTMP",$J,"FUL",DFN,BDMX,BDMY)) Q:BDMY=""!$D(BDMQUIT)  D
 ..Q:BDMY="DEPRESSION SCR"
 ..Q:BDMY="NUTRITION ED"
 ..Q:BDMY="EXERCISE ED"
 ..Q:BDMY="OTHER ED"
 ..S BDMZ=$G(^TMP("BDMTMP",$J,"FUL",DFN,BDMX,BDMY))
 ..W !?5,BDMY,?28,"----------",?40,$P(BDMZ,U)
 ..D INTPFP
 S (Z,ZZ)=""
 Q
 ;
INTPFP ;EP;TO ENTER EDUCATION TEXT WITH FOLLOWUP ITEM
 N ZZ,ZZZ,X,K
 Q:BDMZ=""
 Q:BDMZ["OTHER"
 Q:BDMZ["LDL"
 Q:BDMZ["HDL"
 Q:BDMZ["CHOL"
 Q:BDMZ["DEPR"
 ;Q:BDMZ["EKG"
 ;Q:BDMZ["GFR"
 W !
 I BDMZ["FOOT" S X="FOOT EXAM EDUCATION"
 I BDMZ["DENTAL" S X="DENTAL EXAM EDUCATION"
 I BDMZ["EYE" S X="EYE EXAM EDUCATION"
 I BDMZ["FLU" S X="FLU SHOT EDUCATION"
 I BDMZ["PNEUMO" S X="PNEUMO EDUCATION"
 I BDMZ["HEP" S X="HEP B EDUCATION"
 I BDMZ["TD" S X="TETANUS EDUCATION"
 I BDMZ["PPD" S X="TB TEST EDUCATION"
 I BDMZ["A1C" S X="A1C HEMOGLOBIN EDUCATION"
 I BDMZ["CREATIN" S X="CREATININE EDUCATION"
 I BDMZ["URINE" S X="URINE PROTEIN TEST EDUCATION"
 I BDMZ["LIPID" S X="LIPID PANEL EDUCATION"
 I BDMZ["TRIG" S X="LIPID PANEL EDUCATION"
 I BDMZ["NUTRI" S X="NUTRITION EDUCATION"
 I BDMZ["PHYSICAL" S X="PHYSICAL ACTIVITY EDUCATION"
 I BDMZ["A/C" S X="A/C RATIO EDUCATION"
 I BDMZ["EKG" S X="EKG"
 I BDMZ["GFR" S X="eGFR"
 S Y=$O(^BDMLETI("B",X,0))
 D EDUCP
 Q