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

BDMSELFM.m

Go to the documentation of this file.
  1. BDMSELFM ; IHS/CMI/LAB - print Self Monitoring Pts for dm patients ;
  1. ;;2.0;DIABETES MANAGEMENT SYSTEM;**3,4,8,10**;JUN 14, 2007;Build 12
  1. ;SELF MONITORING REPORT
  1. ;
  1. ;This routine will go through the any selected Register
  1. ;and then see if the patient has an Self Monitoring Glucose Health Factor
  1. ;or SELF MONITORING DRUG TAXONOMY
  1. EP ;EP - called from option interactive
  1. D EOJ
  1. W:$D(IOF) @IOF
  1. W !!,"This option will provide a list of patients on a register"
  1. W !,"(e.g. IHS Diabetes) that either are doing Self Monitoring of"
  1. W !,"Glucose or who are not doing Self Monitoring of Glucose."
  1. W !,"The following definitions/logic is used:"
  1. W !?5,"Yes, Doing self monitoring:"
  1. W !?7,"- the last health factor documented in the 365 days prior to the"
  1. W !?7,"end date is SELF MONITORING BLOOD GLUCOSE-YES"
  1. W !?7,"- the patient has had strips dispensed through pharmacy in "
  1. W !?7,"the 365 days prior to the end date."
  1. W !?5,"No, not doing self monitoring"
  1. W !?7,"- the last health factor documented in the 365 days prior to"
  1. W !?7,"the end date is SELF MONITORING BLOOD GLUCOSE-NO or SELF MONITORING"
  1. W !?7,"BLOOD GLUCOSE-REFUSED"
  1. W !?7,"- the patient has had no strips dispensed through pharmacy"
  1. W !?7,"- the patient has had neither strips dispensed nor a health"
  1. W !?7,"factor documented in the 365 days prior to the end date"
  1. W !!,"In the case of the following conflict: the patient's last"
  1. W !,"health factor states NO or REFUSED but they have had strips"
  1. W !,"dispensed they will show up on each report with a status of"
  1. W !,"Maybe."
  1. ;W !!,"This option will print a list of all patients on a register"
  1. REGISTER ;get register name
  1. S BDMREG=""
  1. W ! S DIC="^ACM(41.1,",DIC(0)="AEMQ",DIC("A")="Enter the Name of the Register: " D ^DIC
  1. I Y=-1 S BDMREG="" W !,"No Register Selected." G EOJ
  1. S BDMREG=+Y
  1. ;get status
  1. S BDMSTAT=""
  1. S DIR(0)="Y",DIR("A")="Do you want to select register patients with a particular status",DIR("B")="Y" KILL DA D ^DIR KILL DIR
  1. I $D(DIRUT) G REGISTER
  1. I Y=0 S BDMSTAT="" G REPORT
  1. ;which status
  1. S DIR(0)="9002241,1",DIR("A")="Which status",DIR("B")="A" KILL DA D ^DIR KILL DIR
  1. I $D(DIRUT) G REGISTER
  1. S BDMSTAT=Y
  1. REPORT ;
  1. S BDMRPT=""
  1. S DIR(0)="S^Y:YES, Doing Self Monitoring;N:NO, Not doing Self Monitoring;B:Both",DIR("A")="What list of patients do you want",DIR("B")="N" K DA D ^DIR KILL DIR
  1. I $D(DIRUT) G REGISTER
  1. S BDMRPT=Y
  1. ENDDATE ;
  1. S BDMED=""
  1. W !!,"Enter the end date to use in calculating the 365 day time period."
  1. S DIR(0)="D^::EPX",DIR("A")="Enter the End Date" KILL DA D ^DIR KILL DIR
  1. I $D(DIRUT) G REPORT
  1. S BDMED=Y
  1. SORTED ;
  1. K DIR S DIR(0)="SO^H:HRN;P:PATIENT NAME;C:COMMUNITY OF RESIDENCE",DIR("A")="How would you like the report sorted",DIR("B")="H" KILL DA D ^DIR KILL DIR
  1. I $D(DIRUT) G ENDDATE
  1. S BDMSORT=Y
  1. ZIS ;
  1. D DEMOCHK^BDMUTL(.BDMDEMO)
  1. I BDMDEMO=-1 Q
  1. S XBRP="PRINT^BDMSELFM",XBRC="PROC^BDMSELFM",XBRX="EOJ^BDMSELFM",XBNS="BDM"
  1. D ^XBDBQUE
  1. Q
  1. EOJ ;
  1. D ^XBFMK
  1. K DIC,DIR
  1. D EN^XBVK("BDM")
  1. Q
  1. ;
  1. PROC ;
  1. S BDMJ=$J,BDMH=$H
  1. S ^XTMP("BDMSELFM",0)=$$FMADD^XLFDT(DT,14)_"^"_DT_"^"_"REGISTER PTS WITH SELF MONITORING"
  1. S BDMDMX=0 F S BDMDMX=$O(^ACM(41,"B",BDMREG,BDMDMX)) Q:BDMDMX'=+BDMDMX D
  1. .;check to see if patient has Self Monitoring or not
  1. .;check register status
  1. .I BDMSTAT]"",$P($G(^ACM(41,BDMDMX,"DT")),U,1)'=BDMSTAT Q
  1. .S DFN=$P(^ACM(41,BDMDMX,0),U,2)
  1. .Q:$$DOD^AUPNPAT(DFN)]"" ;don't display deceased patients
  1. .Q:$$DEMO^BDMUTL(DFN,$G(BDMDEMO))
  1. .S BDMHF=$$LASTHF(DFN,"DIABETES SELF MONITORING",$$FMADD^XLFDT(BDMED,-365),"B")
  1. .I BDMHF["YES" S BDMHFG=1
  1. .I BDMHF="" S BDMHFG=""
  1. .I BDMHF["NO" S BDMHFG=0
  1. .I BDMHF["REFUSE" S BDMHFG=0
  1. .K BDMMED
  1. .S X=DFN_"^MEDS [DM AUDIT SELF MONITOR DRUGS"_";DURING "_$$FMADD^XLFDT(BDMED,-365)_"-"_BDMED S E=$$START1^APCLDF(X,"BDMMED(")
  1. .I $D(BDMMED(1)) S BDMMEDG=1
  1. .I '$D(BDMMED(1)) S BDMMEDG=0
  1. .D SETVAL
  1. .I BDMRPT="Y",BDMVAL="N" Q
  1. .I BDMRPT="N",BDMVAL="Y" Q
  1. .S ^XTMP("BDMSELFM",BDMJ,BDMH,"SELF",$$SORT(DFN,BDMSORT),DFN)=BDMHF_"||"_$G(BDMMED(1))_"||"_BDMVAL
  1. .Q
  1. Q
  1. SORT(P,BDMSORT) ;
  1. NEW X S X=""
  1. I BDMSORT="H" S X=$$HRN^AUPNPAT(P,DUZ(2))
  1. I BDMSORT="P" S X=$P(^DPT(P,0),U)
  1. I BDMSORT="C" S X=$$COMMRES^AUPNPAT(P)
  1. I X="" S X="----"
  1. Q X
  1. SETVAL ;
  1. S BDMVAL=""
  1. I BDMMEDG=1,BDMHFG=1 S BDMVAL="Y" Q
  1. I BDMMEDG=1,BDMHFG="" S BDMVAL="Y" Q
  1. I BDMMEDG=1,BDMHFG=0 S BDMVAL="M" Q
  1. I BDMHFG=1 S BDMVAL="Y" Q
  1. I BDMHFG=0 S BDMVAL="N" Q
  1. I BDMHFG="" S BDMVAL="N" Q
  1. Q
  1. DONE ;
  1. I $E(IOST)="C",IO=IO(0) S DIR(0)="EO",DIR("A")="End of report. PRESS ENTER" D ^DIR K DIR S:$D(DUOUT) DIRUT=1
  1. W:$D(IOF) @IOF
  1. K BDMTS,BDMS,BDMM,BDMET
  1. K ^XTMP("BDMSELFM",BDMJ,BDMH),BDMJ,BDMH
  1. Q
  1. ;
  1. PRINT ;EP - called from xbdbque
  1. K BDMQ S BDMPG=0 D HEADER
  1. I '$D(^XTMP("BDMSELFM",BDMJ,BDMH)) W !!,"NO DATA TO REPORT",! G DONE
  1. S BDMSV="" F S BDMSV=$O(^XTMP("BDMSELFM",BDMJ,BDMH,"SELF",BDMSV)) Q:BDMSV=""!($D(BDMQ)) D
  1. .S DFN=0 F S DFN=$O(^XTMP("BDMSELFM",BDMJ,BDMH,"SELF",BDMSV,DFN)) Q:DFN'=+DFN!($D(BDMQ)) D
  1. ..I $Y>(IOSL-4) D HEADER Q:$D(BDMQ)
  1. ..I BDMRPT="Y" W !
  1. ..W !,$$HRN^AUPNPAT(DFN,DUZ(2)),?7,$E($P(^DPT(DFN,0),U),1,28),?38,$E($$COMMRES^AUPNPAT(DFN,"E"),1,15),?54,$$LASTVD^APCLV1(DFN,"E")
  1. ..S BDMVAL=$P(^XTMP("BDMSELFM",BDMJ,BDMH,"SELF",BDMSV,DFN),"||",3)
  1. ..S BDMMED=$P(^XTMP("BDMSELFM",BDMJ,BDMH,"SELF",BDMSV,DFN),"||",2)
  1. ..S BDMHF=$P(^XTMP("BDMSELFM",BDMJ,BDMH,"SELF",BDMSV,DFN),"||",1)
  1. ..S X="",BDMLHF="",BDMLMED=""
  1. ..I BDMVAL="Y" S X="Yes"
  1. ..I BDMVAL="N" S X="No"
  1. ..I BDMVAL="M" S X="Maybe"
  1. ..;I BDMHF="",BDMMED="" S BDMLHF="Not documented" G PRINT1
  1. ..S BDMLHF=BDMHF
  1. ..S BDMLMED=$P(BDMMED,U,2)_$S($P(BDMMED,U,2)]"":" on ",1:"")_$$FMTE^XLFDT($P(BDMMED,U),2)
  1. PRINT1 ..W ?75,X
  1. ..I BDMLHF]"" W !?3,"Health Factor: ",BDMLHF
  1. ..I BDMLMED]"" W !?3,"Medication Dispensed: ",BDMLMED
  1. D DONE
  1. Q
  1. G:'BDMPG HEADER1
  1. K DIR I $E(IOST)="C",IO=IO(0) W ! S DIR(0)="EO" D ^DIR K DIR I Y=0!(Y="^")!($D(DTOUT)) S BDMQ="" Q
  1. HEADER1 ;
  1. W:$D(IOF) @IOF S BDMPG=BDMPG+1
  1. I $G(BDMGUI),BDMPG'=1 W !,"ZZZZZZZ"
  1. W !?3,$P(^VA(200,DUZ,0),U,2),?35,$$FMTE^XLFDT(DT),?70,"Page ",BDMPG,!
  1. W !,$$CTR("PATIENTS ON THE "_$P(^ACM(41.1,BDMREG,0),U)_" REGISTER - BLOOD GLUCOSE SELF MONITORING",80),!
  1. I BDMRPT="Y" W $$CTR("Patients Doing Self Monitoring",80),!
  1. I BDMRPT="N" W $$CTR("Patients NOT Doing Self Monitoring",80),!
  1. I BDMRPT="B" W $$CTR("List of Patients w/Self Monitoring of Blood Glucose Status",80),!
  1. S X="End Date: "_$$FMTE^XLFDT(BDMED) W $$CTR(X,80),!
  1. W !,"HRN",?7,"PATIENT NAME",?38,"COMMUNITY",?54,"LAST VISIT",?75,"SMBG?"
  1. W !,$TR($J("",80)," ","-")
  1. Q
  1. CTR(X,Y) ;EP - Center X in a field Y wide.
  1. Q $J("",$S($D(Y):Y,1:IOM)-$L(X)\2)_X
  1. ;----------
  1. EOP ;EP - End of page.
  1. Q:$E(IOST)'="C"
  1. Q:$D(ZTQUEUED)!'(IOT="TRM")!$D(IO("S"))
  1. NEW DIR
  1. K DIRUT,DFOUT,DLOUT,DTOUT,DUOUT
  1. S DIR("A")="End of report. Press Enter",DIR(0)="E" D ^DIR
  1. Q
  1. ;----------
  1. USR() ;EP - Return name of current user from ^VA(200.
  1. Q $S($G(DUZ):$S($D(^VA(200,DUZ,0)):$P(^(0),U),1:"UNKNOWN"),1:"DUZ UNDEFINED OR 0")
  1. ;----------
  1. LOC() ;EP - Return location name from file 4 based on DUZ(2).
  1. Q $S($G(DUZ(2)):$S($D(^DIC(4,DUZ(2),0)):$P(^(0),U),1:"UNKNOWN"),1:"DUZ(2) UNDEFINED OR 0")
  1. ;----------
  1. POST ;
  1. NEW X
  1. S X=$$ADD^XPDMENU("BDM M MAIN DM MENU","BDM DM REG APPT CLN","BDM")
  1. I 'X W "Attempt to new appt list of reg pats failed.." H 3
  1. Q
  1. LASTHF(P,C,BDATE,F) ;EP - get last factor in category C for patient P
  1. I '$G(P) Q ""
  1. I $G(C)="" Q ""
  1. I $G(F)="" S F=""
  1. S C=$O(^AUTTHF("B",C,0)) ;ien of category passed
  1. I '$G(C) Q ""
  1. NEW H,D,O S H=0 K O
  1. F S H=$O(^AUTTHF("AC",C,H)) Q:'+H D
  1. . Q:'$D(^AUPNVHF("AA",P,H))
  1. . S D=$O(^AUPNVHF("AA",P,H,""))
  1. . Q:'D
  1. . Q:(9999999-D)<BDATE
  1. . S O(D)=$O(^AUPNVHF("AA",P,H,D,""))
  1. . Q
  1. S D=$O(O(0))
  1. I D="" Q D
  1. I F="N" Q $$VAL^XBDIQ1(9000010.23,O(D),.01)
  1. I F="S" Q $P($G(^AUPNVHF(O(D),0)),U,6)
  1. I F="B" Q $$VAL^XBDIQ1(9000010.23,O(D),.01)_" "_$$FMTE^XLFDT((9999999-D),2)
  1. Q 9999999-D
  1. ;
  1. BDMGA(BDMRET,BDMREG,BDMSTAT,BDMRPT,BDMED,BDMSORT,BDMGUI,BDMDEMO) ;PEP - gui call
  1. S BDMJ=$J
  1. S BDMH=$H
  1. I $G(BDMJ)="" S BDMRET=-1 Q
  1. I $G(BDMH)="" S BDMRET=-1 Q
  1. ;create entry in fileman file to hold output
  1. N BDMOPT ;maw
  1. S BDMOPT="Glucose Self Monitoring"
  1. D NOW^%DTC
  1. S BDMNOW=$G(%)
  1. K DD,D0,DIC
  1. S X=DUZ_"."_BDMH
  1. S DIC("DR")=".02////"_DUZ_";.03////"_BDMNOW_";.05///1;.06///"_$G(BDMOPT)_";.07///R"
  1. S DIC="^BDMGUI(",DIC(0)="L",DIADD=1,DLAYGO=9003002.4
  1. D FILE^DICN
  1. K DIADD,DLAYGO,DIC,DA
  1. I Y=-1 S BDMRET=-1 Q
  1. S BDMIEN=+Y
  1. S BDMRET=BDMIEN
  1. D ^XBFMK
  1. K ZTSAVE S ZTSAVE("*")=""
  1. ;D GUIEP ;for interactive testing
  1. S ZTIO="",ZTDTH=$$NOW^XLFDT,ZTRTN="GUIEP^BDMSELFM",ZTDESC="GUI GLUCOSE SELF MONITORING" D ^%ZTLOAD
  1. D EOJ
  1. Q
  1. GUIEP ;EP - called from taskman ;Visiual DMS Entry Point
  1. D PROC
  1. K ^TMP($J,"BDMSELFM")
  1. S IOM=80 ;cmi/maw added
  1. D GUIR^XBLM("PRINT^BDMSELFM","^TMP($J,""BDMSELFM"",")
  1. ;Q:$G(BDMDSP) ;quit if to screen
  1. S X=0,C=0 F S X=$O(^TMP($J,"BDMSELFM",X)) Q:'X D
  1. . N BDMGDATA
  1. . S BDMGDATA=^TMP($J,"BDMSELFM",X)
  1. . ;I BDMGDATA="ZZZZZZZ" S BDMGDATA=$C(12)
  1. . S ^BDMGUI(BDMIEN,11,X,0)=BDMGDATA
  1. . S C=C+1
  1. S ^BDMGUI(BDMIEN,11,0)="^^"_C_"^"_C_"^"_DT_"^"
  1. S DA=BDMIEN,DIK="^BDMGUI(" D IX1^DIK
  1. D ENDLOG
  1. S ZTREQ="@"
  1. Q
  1. ;
  1. ENDLOG ;-- write the end of the log
  1. D NOW^%DTC
  1. S BDMNOW=$G(%)
  1. S DIE="^BDMGUI(",DA=BDMIEN,DR=".04////"_BDMNOW_";.07///C"
  1. D ^DIE
  1. K DIE,DR,DA
  1. Q
  1. ;