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

BDMLLT.m

Go to the documentation of this file.
BDMLLT ; IHS/CMI/LAB - VIEW PT RECORD LT ;
 ;;2.0;DIABETES MANAGEMENT SYSTEM;**3,4,10**;JUN 14, 2007;Build 12
 ;
EXIT ;
 D EN^XBVK("BDML")
 K ^TMP($J,"BDMLLTVR")
 K ^XTMP("BDMLLT",BDMJOB,BDMBTH)
 K BDMJOB,BDMBTH
 Q
SELECT ;EP;TO SELECT BDMLLT LETTER
 K BDMLLTQT,BDMLLTOT
 D LIST
S1 S DIR(0)="NO^1:"_BDMLLTJ
 S DIR("A")="Select LETTER NO."
 W !
 D DIR^BDMLLTD
 I +Y<1!'$G(BDMLLTTP(+Y)) S BDMLLTQT="" Q
 S BDMLDA=+BDMLLTTP(+Y)
 Q
ZIS ;EP;TO SELECT DEVICE ON WHICH TO PRINT BDMLLT LETTER
 S:$G(BDMLRTN)="" (ZTRTN,BDMLRTN)="PRINT^BDMLLT"
 S ZTDESC="PRINT BDMLLT PATIENT LETTER"
 S ZTSAVE("ACM*")=""
 S ZTSAVE("DFN")=""
 S ZTSAVE("BDM")=""
 D ^BDMLLTZ
 Q
MULTIPLE ;EP;UTILTIY TO SELECT MULTIPLE PATIENTS FOR WHICH TO PRINT BDMLLT LETTER
 Q
LINIT ;EP;TO CREATE ARRAY OF NAMES OF EXISTING LETTERS
 N X
 K ^TMP($J,"BDMLLTVR"),BDMLLTJ
 S VALMCNT=0
 K X
 S $E(X,5)="NO.  LETTER"
 D Z(X)
 K X
 S $E(X,5)="---  ------------------------------"
 D Z(X)
 S BDMLLTJ=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 BDMLLTJ=BDMLLTJ+1
 ..K X
 ..S $E(X,5)=BDMLLTJ
 ..S $E(X,10)=Y
 ..D Z(X)
 ..S BDMLLTTP(BDMLLTJ)=Z
 Q
LINE ;
 I $L(Y)<81 D  Q
 .S J=J+1
 .S BDMLLTTP(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 BDMLLTTP(J,0)=Z
 ..S Z=""
 .I Z="" S Z=K
 .E  S Z=Z_" "_K
 I $L(Z) S J=J+1,BDMLLTTP(J,0)=Z
 Q
PATLET ;EP;TO SELECT AND PROCESS PATIENT LETTER
 D SELECT
 Q:'$G(BDMLDA)
 S BDMLLTJB=$H_$J
 D ZIS
 Q
LIST ;LIST LETTERS
 K BDMLLTTP
 N BDML,BDMLLTX,BDMLLTY,BDMLLTZ
 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 BDMLLTJ=0
 S BDML=""
 F  S BDML=$O(^BDMLET("B",BDML)) Q:BDML=""  D
 .S BDMLLTX=0
 .F  S BDMLLTX=$O(^BDMLET("B",BDML,BDMLLTX)) Q:'BDMLLTX  D
 ..S BDMLLTY=$G(^BDMLET(BDMLLTX,0))
 ..Q:BDMLLTY=""
 ..I $G(BDMLREG),$P(BDMLLTY,U,4)'=BDMLREG Q
 ..S BDMLLTJ=BDMLLTJ+1
 ..S BDMLLTTP(BDMLLTJ)=BDMLLTX_U_BDML
 ..W:BDMLLTJ#3=1 !
 ..W:BDMLLTJ#3=2 ?27
 ..W:BDMLLTJ#3=0 ?53
 ..W $J(BDMLLTJ,2),"   "
 ..W $E(BDML,1,20)
 Q
Z(X) ;SET TMP NODE    
 S VALMCNT=VALMCNT+1
 S ^TMP($J,"BDMLLTVR",VALMCNT,0)=X
 Q
DATE ;EP;TO PRINT LETTER DATE
 N Y
 S Y=DT
 X ^DD("DD")
 S Z=Y
 Q
COHORT ;EP;TO ESTABLISH COHORT OF PATIENTS TO PRINT
 S BDMJOB=$J,BDMBTH=$H
 D SELECT
 Q:'$G(BDMLDA)
 D C1
 Q:$D(BDMLLTQT)
 S BDMLBROW=""
 Q:'$D(^XTMP("BDMLLT",BDMJOB,BDMBTH,"BDMLLT CUSTOM LETTER",BDMLLTJB))
 S BDMLRTN="CPRINT^BDMLLT"
 D ZIS
 K BDMLBROW,BDMJOB,BDMBTH,BDMLLTJB
 Q
C1 K ^XTMP("BDMLLT",BDMJOB,BDMBTH,"BDMLLT CUSTOM LETTER")
 S BDMLLTJB=$H_$J
 N DIR
 S DIR(0)="SO^1:Individual Patient(s);2:Search Template of Patients;3:Members of a Case Management Register"
 S DIR("A")="Create list for letters by"
 D ^DIR
 K DIR
 I 'Y S BDMLLTQT="" Q
 I Y=1 D PATIENT
 I Y=2 D TEMPLATE
 I Y=3 D REGISTER K BDMLREG
 I '$D(^XTMP("BDMLLT",BDMJOB,BDMBTH,"BDMLLT CUSTOM LETTER")) W !!,"No patients selected." D PAUSE Q
 Q
PATIENT ;SELECT INDIVIDUAL PATIENTS TO PRINT LETTER
 K BDMLLTQT
 F  D P1 Q:$D(BDMLLTQT)
 K BDMLLTQT
 S BDMLSTAT="Z"
 Q
P1 ;
 N DIC
 S DIC="^AUPNPAT("
 S DIC(0)="AEMQZ"
 S DIC("S")="I '$G(^DPT(+Y,.35))"
 S DIC("A")="Name, Chart No. or DOB: "
 D ^DIC
 K DIC
 I Y<1 S BDMLLTQT="" Q
 S ^XTMP("BDMLLT",BDMJOB,BDMBTH,"BDMLLT CUSTOM LETTER",BDMLLTJB,+Y)=""
 Q
TEMPLATE ;SELECT SEARCH TEMPLATE
 N DIC
 S DIC="^DIBT("
 S DIC(0)="AEMQZ"
 S DIC("S")="I $O(^DIBT(+Y,1,0))"
 D ^DIC
 K DIC
 Q:'+Y
 M ^XTMP("BDMLLT",BDMJOB,BDMBTH,"BDMLLT CUSTOM LETTER",BDMLLTJB)=^DIBT(+Y,1)
 S BDMLSTAT="Z"
 Q
CPRINT ;EP;TO PRINT LETTERS FROM LIST OR TEMPLATE
 S DFN=0
 F  S DFN=$O(^XTMP("BDMLLT",BDMJOB,BDMBTH,"BDMLLT CUSTOM LETTER",BDMLLTJB,DFN)) Q:'DFN!$D(BDMOUT)  D
 .K ^TMP("BDMTMP",$J,"FUL"),BDMOUT
 .S BDMLET=2
 .S BDMRPDA=$G(^ACM(41,"AC",DFN,BDMRDA))
 .S BDMIANL=1 D EN^XBNEW("EPPRINT^BDMLET","BDMLET;BDMRPDA,BDMRDA,BDMIANL;BDMLDA;BDMREGNM;DFN;BDMLSTAT;BDMOUT")
 K BDMIANL
 Q
PAUSE ;EP
 S DIR(0)="EO",DIR("A")="Press enter to continue...." D ^DIR K DIR S:$D(DUOUT) DIRUT=1
 Q
REGISTER ;
 K DIC,BDMLREG
 S DIC(0)="AEMQ"
 S (DIC,DIE)="^ACM(41.1,",DIC("A")="REGISTER: "
 S BDMLZDIC="^ACM(41.1)",DIC("S")="I $D(@BDMLZDIC@(+Y,""AU"",""B"",DUZ))"
 D ^DIC
 I Y=-1 W !!,"No register selected." Q
 S BDMLREG=+Y
  ;which status
 S DIR(0)="9002241,1",DIR("A")="Which status",DIR("B")="A" KILL DA D ^DIR KILL DIR
 I $D(DIRUT) Q
 S BDMLSTAT=Y,BDM("STATUS")=Y
REG1 ;
 ;gather up patients from register in ^XTMP
 K ^XTMP("BDMLLT",BDMJOB,BDMBTH,"BDMLLT CUSTOM LETTER",BDMLLTJB) S BDMLCNT=0,X=0 F  S X=$O(^ACM(41,"B",BDMLREG,X)) Q:X'=+X  D
 .I BDMLSTAT]"",$P($G(^ACM(41,X,"DT")),U,1)=BDMLSTAT S BDMLCNT=BDMLCNT+1,^XTMP("BDMLLT",BDMJOB,BDMBTH,"BDMLLT CUSTOM LETTER",BDMLLTJB,$P(^ACM(41,X,0),U,2))="" Q
 .I BDMLSTAT="" S BDMLCNT=BDMLCNT+1,^XTMP("BDMLLT",BDMJOB,BDMBTH,"BDMLLT CUSTOM LETTER",BDMLLTJB,$P(^ACM(41,X,0),U,2))=""
 I '$D(^XTMP("BDMLLT",BDMJOB,BDMBTH,"BDMLLT CUSTOM LETTER",BDMLLTJB)) W !,"No patients with that status in that register!" Q
 W !!,"There are ",BDMLCNT," patients in the ",$P(^ACM(41.1,BDMLREG,0),U)," register with a status of ",BDMLSTAT,".",!!
 D PAUSE
 Q