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

BDMVRL4.m

Go to the documentation of this file.
BDMVRL4 ; IHS/CMI/LAB - VIEW PT RECORD CON'T ;
 ;;2.0;DIABETES MANAGEMENT SYSTEM;**1,3,5,6,7,8,9,10,11,12**;JUN 14, 2007;Build 51
 ;LIST OF FOLLOW-UP EXAMS
 ;MOVED 'FURESULT' TO BDMVRL42 TO CONTROL ROUTINE SIZE
 ;DMS GUI INTERFACE CODE
 ;
FU ;EP;TO PRINT FOLLOW-UP NEEDED REPORTS
 D REG^BDMFUTIL
 Q:$D(BDMQUIT)
 F  D FUEN Q:$D(BDMQUIT)!$D(BDMOUT)
EXIT ;EP
 K BDM,BDMQUIT,BDMTAX,BDMFU,BDMRPDA,BDMOUT,BDMPROV,BDMFUAPP
 K L,FR,TO,BY,FLDS  ;cmi/anch/maw 8/15/2007 DIP vars that may hand around even though they aren't supposed to patch 1
 K ^TMP("BDMVR",$J),^TMP("BDMTMP",$J)
 Q
FUEN ;
 D REG^BDMFUTIL
 Q:$D(BDMQUIT)
 D EXIT
 S:'$G(VALMWD) VALMWD=80
 D CLEAR^VALM1
 W !?8,"DIABETES REGISTER - FOLLOW-UP NEEDED REPORTS"
 W !?8,"(Patients due now or within the next 30 days.)"
 W !
 D SCREEN^BDMVRL42
 S DIR(0)="FO^1:30"
 S DIR("A",1)="        Type 'ALL' to include ALL Follow-up Needed"
 S DIR("A")="        Which Report"
 W !
 D DIR^BDMFDIC
 I X=""!$D(BDMQUIT) S BDMQUIT="" Q
 ;I X=99 D PROTO^BDMVRL42 Q
 I $E(Y)?1A D  I $D(BDMQUIT) K BDMQUIT Q
 .S X=Y
 .X ^%ZOSF("UPPERCASE")
 .I Y'="ALL" S BDMQUIT="" Q
 I Y="ALL" D ALL^BDMVRL42 S BDMY=Y
 D PARSE^BDMVRL42
 D ST
 Q:$D(BDMQUIT)
 D ACTIVE
 Q:$D(BDMQUIT)
 D DX
 Q:$D(BDMQUIT)
 D APPT^BDMVRL42
 Q:$D(BDMQUIT)
 D PROVIDER^BDMVRL43
 Q:$D(BDMQUIT)
 D REPLET
 Q:$D(BDMQUIT)
 D DEMOCHK^BDMUTL(.BDMDEMO)
 I BDMDEMO=-1 Q
 D ZIS
 Q
ZIS ;DEVICE INTERFACE
 S ZTSAVE("BDM*")=""
 S (ZTRTN,BDMRTN)="FUPRINT^BDMVRL4"
 D ^BDMFZIS
 Q
BDMG(BDM) ;EP - Visual DMS Entry Point
 ;cmi/anch/maw added for GUI DMS
 D FUPRINT
 K ^XTMP("BDMTAX",BDMJOB,BDMBTH)
 Q
 ;
FUPRINT ;EP;TO DISPLAY THE FOLLOW-UP REPORT
 I $E(IOST,1,2)="C-" D
 .W !!,"Please stand by.  It could take me a while to figure this out."
 S BDMJOB=$J,BDMBTH=$H
 D BUILDSML^BDMUTL(2019)
 D FUGET ;GET ALL DATA AND SET IM ^TMP ARRAY
 D FUDISP ;DISPLAY FOLLOW-UP REPORT
 Q
FUGET ;EP;GET DATA
 S BDMP=0
 F  S BDMP=$O(BDM("PARSE",BDMP)) Q:'BDMP  D FUGET1
 Q
FUGET1 S BDMFU=$P(BDM("REPORT",BDMP),U)
 S BDMRDA=$O(^ACM(41.1,"B",BDMREGNM,0))
 I BDMRDA="" D  Q
 .S X="NO "_BDMREGNM_" ON FILE"
 .D Z(X)
 ;INDEPENDENT LOOKUP FOR HTN, PAP, MAMM
 ;I BDMFU="HTN" S BDM("FOLLOW-UP TYPE")="HYPERTENSION"
 ;E  I BDMFU="PAP" S BDM("FOLLOW-UP TYPE")="PAP SMEAR"
 ;E  I BDMFU="MAM" S BDM("FOLLOW-UP TYPE")="MAMMOGRAPHY"
 I BDMFU="DENT" S BDM("FOLLOW-UP TYPE")="DENTAL"
 E  D  ;Q:'$D(BDM("IEN"))
 .D IEN^BDMVRL41
 .;Q:'$D(BDM("IEN"))
 K X2
 I BDMFU="EKG" S X2=-1795
 D FULAST
 I $G(BDMRPDA) D FUPAT Q
 I $G(BDMIANL) D FUPAT Q
 S BDMRPDA=0
 F  S BDMRPDA=$O(^ACM(41,"B",BDMRDA,BDMRPDA)) Q:'BDMRPDA  D
 .D FUPAT
 .I $E(IOST,1,2)="C-" W "."
 Q
FUPAT ;EP;TO GATHER FOLLOW-UP INFO ON A PATIENT
 I '$G(BDMIANL) S DFN=$P($G(^ACM(41,BDMRPDA,0)),U,2)
 Q:'DFN
 ;I DUZ=2881 Q:DFN'=1717
 ;S ^TMP("ALL DFN",$J,DFN)=""
 Q:$$DEMO^BDMUTL(DFN,$G(BDMDEMO))
 I $G(BDM("DM DIAGNOSIS"))]"" D PATDX I $D(BDMQUIT) K BDMQUIT Q
 I $G(BDM("SEARCH TEMPLATE")) Q:'$D(^DIBT(BDM("SEARCH TEMPLATE"),1,DFN))
 D PAT(DFN,BDMRPDA)
 S BDMRECST=""
 I BDMRPDA S BDMRECST=$P($G(^ACM(41,BDMRPDA,"DT")),U,1)
 I BDM("STATUS")'="Z" Q:$G(BDMRECST)'=BDM("STATUS")
 ;I BDMFU="PAP"!(BDMFU="MAM")!(BDMFU="BRST"),$P($G(^DPT(DFN,0)),U,2)'="F" Q
 K BDM("HRN")
 S BDM=""
 I BDMK["PROV" D
 .S BDM=$P($G(^AUPNPAT(DFN,0)),U,14)
 .I BDM,'$O(BDMK(0)) S BDM=$P($G(^VA(200,BDM,0)),U)
 I BDMK["COMM" D
 .D RES^BDMVRL5(DFN)
 .I '$O(BDMK(0)) S BDM=$P($G(^AUTTCOM(+$G(BDM("RES")),0)),U)
 I BDMK["WHER" D
 .S BDM=$P($G(^ACM(41,BDMRPDA,"DT")),U,10)
 .I BDM,'$O(BDMK(0)) D
 ..S BDM("HRN")=$P($G(^AUPNPAT(DFN,41,+BDM,0)),U,2)
 ..K:BDM("HRN")="" BDM("HRN")
 ..S BDM=$P($G(^DIC(4,BDM,0)),U)
 S:BDM="" BDM="NOT LISTED"
 K BDMQUIT
 I $O(BDMK(0)),BDM]"" D
 .I '$D(BDMK(BDM)) S BDMQUIT="" Q
 .S BDM=BDMK(BDM)
 I $D(BDMQUIT) K BDMQUIT Q
 S BDM("COMMUNITY")=$E(BDM,1,15)
 S:'$D(BDM("HRN")) BDM("HRN")=$P($G(^AUPNPAT(DFN,41,$S($G(BDMDUZ2):BDMDUZ2,1:DUZ(2)),0)),U,2)
 S:BDM("HRN")="" BDM("HRN")="XXXXXX"
 S BDM("PATIENT")=$E($P($G(^DPT(DFN,0)),U),1,25)
 ;INDEPENDENT LOOKUPS
 I BDMFU="HTN" D HTN^BDMVRL41 I 1
 E  I BDMFU="PAP" D LPAP^BDMVRL41 I 1
 E  I BDMFU="MAM" D LMAM^BDMVRL41 I 1
 E  I "^FTEX^EYE^DENT^DEP^EKG^"[(U_BDMFU_U) D APCLEXAM^BDMVRL41 I 1
 E  I "^NTED^EXER^GENI^"[(U_BDMFU_U) D APCLED^BDMVRL41 I 1
 E  I BDMFU="FLU" D FLUC^BDMVRL41 I 1
 E  I BDMFU="PNEU" D PNEUMOC^BDMVRL41 I 1
 E  I BDMFU="TD" D TDC^BDMVRL41 I 1
 E  I BDMFU="HEPB" D HEPBC^BDMVRL41 I 1
 E  I BDMFU="HEPC" D HEPCC^BDMVRL41 I 1
 E  D FIND I 1
 ;INDEPENDENT LOOKUPS
 K BDMQUIT
 Q
FUDISP ;DISPLAY REPORT
 I $G(BDMLET)<2!($G(BDMLET)=3) D FUD1
 I $G(BDMLET)>1 D FUL1
 Q
FUD1 D FUHEAD^BDMVRL42
 I $E(IOST,1,2)="C-" D FUVALM Q
 S X=0
 F  S X=$O(^TMP("BDMVR",$J,X)) Q:'X  D
 .S Y=$G(^TMP("BDMVR",$J,X,0))
 .W !,Y
 .D PAGE
 Q
FUL1 ;PRINT FOLLOW-UP LETTER
 K BDMQUIT
 S DFN=0
 F  S DFN=$O(^TMP("BDMTMP",$J,"FUL",DFN)) Q:'DFN!$D(BDMQUIT)  D
 .S BDMRPDA=$G(^ACM(41,"AC",DFN,BDMRDA))
 .Q:'BDMRPDA
 .D PAT(DFN,BDMRPDA)
 .D PRINT^BDMLET
 Q
PAGE ;PAGE CONTROL
 Q:IOSL-4>$Y
 S:'$G(BDMPAGE) BDMPAGE=1
 W @IOF
 I $G(BDMGUI),BDMPAGE'=1 W !,"ZZZZZZZ"
 W !?8,$S($G(BDMREGNM)]"":BDMREGNM,1:"DIABETES REGISTER")
 W !?8,"FOLLOW-UP REPORT: ",BDM("FOLLOW-UP TYPE"),?60,"PAGE: ",BDMPAGE
 W !!,"COMMUNITY",?16,"PATIENT",?42,"HRN",?49,"STATUS"
 W !,"---------------",?16,"-------------------------",?42,"------",?49,"--------------------"
 Q
FUVALM ;USE LIST MANAGER TO DISPLAY REPORT TO SCREEN
 S BDMVALM="BDM FOLLOW-UP REPORT"
 D VALM^BDMVRL(BDMVALM)
 Q
FIND ;FIND PATIENTS WITHOUT SPECIFIED ITEM
 N X,Y
 S X=BDMFU
 I BDMFU="CHOL"!(BDMFU="LDL")!(BDMFU="HDL")!(BDMFU="TRIG")!(BDMFU="CREA")!(BDMFU="HGB")!(BDMFU="LIVR")!(BDMFU="UPRO")!(BDMFU="URIN")!(BDMFU="GFR")!(BDMFU="UACR")!(BDMFU="HEPC") D LAB^BDMVRL43 Q
 I BDMFU="TD" D IMMUN^BDMVRL43 Q
 ;USE V EXAM FOR DENTAL INSTEAD OF V DENTAL
 I X="DENT" D DENT
 I X="EKG" S Y="^AUPNVDPR("
 I "^FTEX^RECT^BRST^EYE^DENT^DEP^"[(U_X_U) S Y="^AUPNVXAM"
 I X="MAM" S Y="^AUPNVRAD"
 I X="FLU"!(X="PNEU")!(X="TD") S Y="^AUPNVIMM"
 I X="PPD" S Y="^AUPNVSK"
 I X="NTED"!(X="COMP")!(X="EXER")!(X="GENI") S Y="^AUPNVPED"
 I X=(X="DIET")!(X="DISE")!(X="FUP")!(X="FTED")!(X="LIFE")!(X="MEDS") S Y="^AUPNVPED"
 I X="HGB"!(X="LIVR")!(X="UPRO")!(X="URIN")!(X="CHOL")!(X="LDL")!(X="HDL")!(X="MICR")!(X="CREA")!(X="TRIG")!(X="PAP")!(X="UPT") S Y="^AUPNVLAB"
F1 S BDMGBL=Y
 I X="LIVR" D  Q:'$D(BDMQUIT)
 .D LMEDS
 .;IF PATIENT NOT TAKING TARGET MEDS THEY DON'T NEED TO BE ON F/U LIST
 K BDMQUIT
 I BDMFU="CHOL"!(BDMFU="LDL")!(BDMFU="HDL")!(BDMFU="TRIG")!(BDMFU="CREA")!(BDMFU="HGB")!(BDMFU="LIVR")!(BDMFU="UPRO")!(BDMFU="URIN")!(BDMFU="UPT")!(BDMFU="GFR") D LAB^BDMVRL43 Q
 D FURESULT^BDMVRL42
 I $D(BDMQUIT) K BDMQUIT Q
 D ENTRY
 Q
LMEDS D LMEDS^BDMVRL2
 Q
FUNO ;EP Followup Entry
 S X="*NO* "_BDM("FOLLOW-UP TYPE")_" on record."
FUOUT ;EP;
 I $G(BDMIANL) G FUOUT1
 S ^TMP("BDMTMP",$J,BDM("COMMUNITY"),BDM("PATIENT"),BDMP,BDM("FOLLOW-UP TYPE"))=X_U_BDM("HRN")
 S ^TMP("BDMTMP",$J,BDM("COMMUNITY"),BDM("PATIENT"))=DFN
 Q:$G(BDMLET)<2
FUOUT1 S ^TMP("BDMTMP",$J,"FUL",DFN,BDMP,BDM("FOLLOW-UP TYPE"))=X
 Q
FULAST ;EP;
 S X1=DT
 S:'$G(X2) X2=-330
 D C^%DTC
 S BDM("SHOULD HAVE FOLLOW-UP AFTER")=X
 K X1,X2
 Q
LSTVST(X) ;EP;LAST VISIT
 N Y
 S Y=9999999-X
 I Y>BDM("SHOULD HAVE FOLLOW-UP AFTER") S X=""
 E  D
 .X ^DD("DD")
 .S X="last "_BDM("FOLLOW-UP TYPE")_" "_Y
 Q X
ENTRY ;EP;FOR INDEPENDENT CALLS
 I $G(Z)="" D FUNO Q
 S Z=$$LSTVST(Z)
EDONE ;EP;FOLLOW-UP DONE
 I Z="" D  Q
 .K ^TMP("BDMTMP",$J,BDM("COMMUNITY"),BDM("PATIENT"),BDMP,BDM("FOLLOW-UP TYPE"))
 .S BDMQUIT=""
 I BDMFU="PPD",$D(BDM("PPD")) D
 .I $P(BDM("PPD"),U)]"" S Z=Z_" ("_$S($E(BDM("PPD"))="N":"NEG",$E(BDM("PPD"))="P":"POS",1:"")
 .I $P(BDM("PPD"),U,2) S Z=Z_$S($P(BDM("PPD"),U)="":" (",1:"-")_$P(BDM("PPD"),U,2)_" MM)"
 .E  S:$P(BDM("PPD"),U)]""!$P(BDM("PPD"),U,2) Z=Z_")"
 .K BDM("PPD")
 S X=Z
 D FUOUT
 Q
ACTIVE ;EP;TO SELECT PATIENT STATUS
 W !!,"Select the Patient Status for this report"
 S DIR(0)="SO^A:Active;I:Inactive;T:Transient;U:Unreviewed;D:Deceased;N:Non-IHS;NON:Noncompliant;Z:All Register Patients"
 S DIR("A")="Which patients"
 S DIR("B")="Active"
 D DIR^BDMFDIC
 I Y]"","AITUDNONZ"[Y S BDM("STATUS")=Y Q
 E  S BDMQUIT=""
 Q
REPLET ;PRINT REPORT OR LETTER
 S DIR(0)="SO^1:Follow-up Report;2:Follow-up Letter;3:Both"
 S DIR("A")="Which one"
 S DIR("B")="Follow-up Report"
 D DIR^BDMFDIC
 I Y<1 S BDMQUIT="" Q
 S BDMLET=+Y
 Q:+Y=1
 D SELECT^BDMLET
 I '$G(BDMLDA) S BDMQUIT="" Q
 Q
Z(X) ;SET TMP NODE
 S VALMCNT=VALMCNT+1
 S ^TMP("BDMVR",$J,VALMCNT,0)=X
 Q
PAT(DFN,ACMRPDA) ;EP;TO CHECK PATIENT DOD STATUS
 Q:'ACMRPDA
 Q:'$G(^DPT(+DFN,.35))
 S DA=ACMRPDA
 S DIE="^ACM(41,"
 S DR="1////D"
 D DIE^BDMFDIC
 Q
ST ;SELECT SEARCH TEMPLATE OR ENTIRE REGISTER
 S DIR(0)="SO^1:Use Register Members;2:Use A Search Template"
 S DIR("A")="Which Group"
 S DIR("B")="Use Register Members"
 D DIR^BDMFDIC
 Q:Y<2
 S DIC="^DIBT("
 S DIC(0)="AEMQZ"
 S DIC("A")="Which Search Template: "
 S DIC("S")="I $D(^DIBT(+Y,1)),$P(^DIBT(+Y,0),U,4)=2!($P(^DIBT(+Y,0),U,4)=9000001)"
 D DIC^BDMFDIC
 I +Y>0 S BDM("SEARCH TEMPLATE")=+Y
 E  K BDM("SEARCH TEMPLATE")
 Q
DX ;EP;TO SELECT DIABETES DIAGNOSIS
 D DX^BDMVRL2
 Q
PATDX ;INCLUDE PATIENTS WITH SPECIFIC DIAGNOSIS
 D PATDX^BDMVRL2
 Q
DENT K BDM("IEN")
 S Y="^AUPNVDEN"
 F X=9320,9321 I $O(^AUTTADA("B",X,0)) S BDM("IEN",$O(^(0)))=""
 I '$D(BDM("IEN")) D D1 Q
 D F1
D1 D DENT^BDMVRL41
 Q
 ;
BDMGA(BDMRET,BDM,BDMFUAPP,BDMFL,BDMK,BDMRL,BDMFU,BDMLDA,BDMREG,BDMGUI,BDMDEMO) ;PEP - gui call
 S BDMJ=$J
 S BDMH=$H
 F X="BDMJOB","BDMH","BDM","BDMRS","BDMFUAP","BDMBEG","BDGEND","BDMPBYV","BDMFL","BDMK","BDMRL","BDMFU","BDMLP","BDMLDA","BDMREG" S @X=$G(@X)
 I $G(BDMJ)="" S BDMRET=-1 Q
 I $G(BDMH)="" S BDMRET=-1 Q
 ;create entry in fileman file to hold output
 N BDMOPT  ;maw
 S BDMOPT="Follow-Up Needed"
 D NOW^%DTC
 S BDMNOW=$G(%)
 K DD,D0,DIC
 S X=DUZ_"."_BDMH
 S DIC("DR")=".02////"_DUZ_";.03////"_BDMNOW_";.05///1;.06///"_$G(BDMOPT)_";.07///R"
 S DIC="^BDMGUI(",DIC(0)="L",DIADD=1,DLAYGO=9003002.4
 D FILE^DICN
 K DIADD,DLAYGO,DIC,DA
 I Y=-1 S BDMRET=-1 Q
 S BDMIEN=+Y
 S BDMRET=BDMIEN
 D ^XBFMK
 K ZTSAVE S ZTSAVE("*")=""
 ;D GUIEP  ;for interactive testing
 S ZTIO="",ZTDTH=$$NOW^XLFDT,ZTRTN="GUIEP^BDMVRL4",ZTDESC="GUI DM FOLLOW UP REPORT" D ^%ZTLOAD
 D XIT
 Q
GUIEP ;EP - called from taskman
 ;D ^FUPRINT
 K ^TMP($J,"BDMFUR")
 S IOM=80  ;cmi/maw added
 S IOSL=55
 S IOST="P"
 D GUIR^XBLM("BDMG^BDMVRL4(.BDM)","^TMP($J,""BDMFUR"",")
 ;Q:$G(BDMDSP)  ;quit if to screen
 S X=0,C=0 F  S X=$O(^TMP($J,"BDMFUR",X)) Q:'X  D
 . N BDMGDATA
 . S BDMGDATA=^TMP($J,"BDMFUR",X)
 . ;I BDMGDATA="ZZZZZZZ" S BDMGDATA=$C(12)
 . S ^BDMGUI(BDMIEN,11,X,0)=BDMGDATA
 . S C=C+1
 S ^BDMGUI(BDMIEN,11,0)="^^"_C_"^"_C_"^"_DT_"^"
 S DA=BDMIEN,DIK="^BDMGUI(" D IX1^DIK
 D ENDLOG
 S ZTREQ="@"
 Q
 ;
ENDLOG ;-- write the end of the log
 D NOW^%DTC
 S BDMNOW=$G(%)
 S DIE="^BDMGUI(",DA=BDMIEN,DR=".04////"_BDMNOW_";.07///C"
 D ^DIE
 K DIE,DR,DA
 Q
 ;
XIT ;-- remove variables and quit
 D EN^XBVK("AUPN")
 D ^XBFMK,KILL^AUPNPAT
 K ^TMP($J,"PATS")
 Q
 ;