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

BDMGUB.m

Go to the documentation of this file.
BDMGUB ; IHS/CMI/LAB - BDM DMS GUI Utilities ;
 ;;2.0;BDM DIABETES MANAGEMENT SYSTEM;**1,4**;JUN 14, 2007
 ;
 ;
 ;
 ;cmi/anch/maw 1/23/2005 added in PATCHT a quit if mult chts with same #
 ;cmi/anch/maw 2/1/2006 changed visit retrieval to ADO.NET
 ;cmi/anch/maw 3/22/2006 changed weight, bp, labs, to sort earliest to latest
 ;cmi/anch/maw 3/23/2006 changed patient lookup to not look at other names
 ;
DEBUG(BDMRET,BDMSTR) ;-- debug
 D DEBUG^%Serenji("CHK^BDMGU(.BDMRET,.BDMSTR)")
 Q
 ;
DELLET(RETVAL,BDMSTR) ;-- delete a letter out of the DMS LETTERS file
 S X="MERR^BDMGU",@^%ZOSF("TRAP") ; m error trap
 N P,R,I
 S P="|",R="~"
 S BDMERR=""
 K ^BDMTMP($J)
 S RETVAL="^BDMTMP("_$J_")"
 F I=2:1 D  Q:$P(BDMSTR,R,I)=""
 . N BDMI,BDMDA
 . Q:$P(BDMSTR,R,I)=""
 . S BDMI=$P(BDMSTR,R,I)
 . S DIK="^BDMLET(",DA=BDMI D ^DIK
 S ^BDMTMP($J,0)="T00250DATA"_$C(30)
 S ^BDMTMP($J,1)=$G(BDMERR)_$C(30)
 S ^BDMTMP($J,2)=$C(31)_BDMERR
 Q
 ;
LETI(BDMRET) ;-- get all letter Items
 S X="MERR^BDMGU",@^%ZOSF("TRAP") ; m error trap
 N BDMDA,BDMI,BDMB,BDME
 K ^BDMTMP($J)
 S BDMRET="^BDMTMP("_$J_")"
 S BDMI=0
 S BDMB="BDM"
 S ^BDMTMP($J,BDMI)="T00030Letter Item"_$C(30)
 S BDMDA=BDMB F  S BDMDA=$O(^DD("FUNC","B",BDMDA)) Q:BDMDA=""!($P(BDMDA," ")'=BDMB)  D
 . N BDMIEN
 . S BDMIEN=0 F  S BDMIEN=$O(^DD("FUNC","B",BDMDA,BDMIEN)) Q:'BDMIEN  D
 .. S BDMI=BDMI+1
 .. S ^BDMTMP($J,BDMI)=$P($P($G(^DD("FUNC",BDMIEN,0)),U)," ",2,99)_$C(30)
 S ^BDMTMP($J,BDMI+1)=$C(31)
 Q
 ;
LETS(BDMRET,BDMSTR) ;-- get all letter Items for letter
 S X="MERR^BDMGU",@^%ZOSF("TRAP") ; m error trap
 N BDMDA,BDMI,P,BDMLET
 S P="|"
 K ^BDMTMP($J)
 S BDMRET="^BDMTMP("_$J_")"
 S BDMI=0
 S BDMLET=$P(BDMSTR,P)
 S ^BDMTMP($J,BDMI)="T00030Letter Items"_$C(30)
 S BDMDA=0 F  S BDMDA=$O(^BDMLET(BDMLET,"ITEM",BDMDA)) Q:'BDMDA  D
 . N BDMLIEN
 . S BDMLIEN=$P($G(^BDMLET(BDMLET,"ITEM",BDMDA,0)),U)
 . S BDMLETS=$P($P($G(^DD("FUNC",BDMLIEN,0)),U)," ",2,99)
 . S BDMI=BDMI+1
 . S ^BDMTMP($J,BDMI)=BDMLETS_$C(30)
 S ^BDMTMP($J,BDMI+1)=$C(31)
 Q
 ;
LETD(BDMRET,BDMSTR) ;-- get letter data
 S X="MERR^BDMGU",@^%ZOSF("TRAP") ; m error trap
 N BDMDA,BDMI,P,BDMLET,BDMLETI,BDMDFN,BDMREGNM,BDMRPDA
 S P="|"
 K ^BDMTMP($J)
 S BDMRET="^BDMTMP("_$J_")"
 S BDMI=0,BDMCNT=0
 S ^BDMTMP($J,BDMI)="T32767DATA"_$C(30)
 S BDMLET=$P(BDMSTR,P)
 S BDMDFN=$P(BDMSTR,P,2)
 S BDMPDFN=$P(BDMSTR,P,3)
 S BDMREGNM=$P(BDMSTR,P,4)
 S BDMLETI=$O(^BDMLET("B",BDMLET,0))
 S BDMLDA=0 F  S BDMLDA=$O(^BDMLET(BDMLETI,"ITEM",BDMLDA)) Q:'BDMLDA  D
 . N BDMIEN,BDMT
 . S BDMIEN=$G(^BDMLET(BDMLETI,"ITEM",BDMLDA,0))
 . S BDMT=$G(^DD("FUNC",BDMIEN,0))
 . X ^DD("FUNC",BDMIEN,1)
 . S BDMCNT=BDMCNT+1
 . S $P(^BDMTMP($J,1),",",BDMCNT)=$P(BDMT," ",2,99)
 . S $P(^BDMTMP($J,2),",",BDMCNT)=X
 S ^BDMTMP($J,1)=$G(^BDMTMP($J,1))_$C(30)
 S ^BDMTMP($J,2)=$G(^BDMTMP($J,2))_$C(30)
 S ^BDMTMP($J,3)=$C(31)
 Q
 ;
FIRST(DFN) ;EP;TO PRINT PATIENT NAME IN A LETTER
 N Z
 S Z=$P($G(^DPT(DFN,0)),U)
 Q $P($P(Z,",",2)," ")
 ;
LAST(DFN) ;EP;TO PRINT PATIENT NAME IN A LETTER
 N Z
 S Z=$P($G(^DPT(DFN,0)),U)
 Q $P(Z,",")
 ;
CHT(DFN) ;EP;TO PRINT PATIENT CHART NUMBER PATCH 4
 Q $P($G(^AUPNPAT(DFN,41,DUZ(2),0)),U,2)
 ;
ADD(DFN) ;EP;TO PRINT PATIENT'S ADDRESS IN A LETTER
 N Z
 S Z=$G(^DPT(DFN,.11))
 Q $P(Z,U,1)
 ;S Z=Z_$P(Z,U,4)_", "_$P($G(^DIC(5,+$P(Z,U,5),0)),U,2)_"  "_$P(Z,U,6)
 ;
CITY(DFN) ;EP - city
 N Z
 Q $P($G(^DPT(DFN,.11)),U,4)
 ;
STATE(DFN) ;EP - state
 N Z
 Q $S($P($G(^DPT(DFN,.11)),U,5)]"":$P($G(^DIC(5,$P($G(^DPT(DFN,.11)),U,5),0)),U),1:"")
 ;
ZIP(DFN) ;EP-Zip
 N Z
 Q $P($G(^DPT(DFN,.11)),U,6)
 ;
FUM(DFN) ;EP;TO PRINT FOLLOW-UP MESSAGE
 S BDM("STATUS")="A"
 ;S BDM("STATUS")=STAT
 S BDM("STATUS")=$E($G(BDM("STATUS"))) ;IHS/CIM/THL PATCH 5
 S BDMPDA=DFN
 D SSET^BDMVRL42 ;IHS/CIM/THL PATCH 5
 N BDMX,BDMVAL
 S BDMX=0,BDMVAL=""
 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))
 ..S BDMVAL=BDMVAL_BDMY_$P(BDMZ,U)
 Q BDMVAL
 ;
PRV(BDMRPDA) ;EP;TO PRINT PROVIDER NAME IN A LETTER
 N Z
 S Z=+$P($G(^ACM(41,BDMRPDA,"DT")),U,15)
 S Z=$P($G(^VA(200,Z,0)),U)
 S Z=$P($P(Z,",",2)," ")_" "_$P(Z,",")
 Q Z
 ;
CHK(BDMRET,BDMSTR) ;check report status
 S X="MERR^BDMGU",@^%ZOSF("TRAP") ; m error trap
 N P,BDMDUZ2,BDMI
 S P="|"
 S BDMDUZ=$P(BDMSTR,P)
 K ^BDMTMP($J)
 K ^TMP($J)
 S BDMRET="^BDMTMP("_$J_")"
 S BDMI=0
 S ^BDMTMP($J,BDMI)="T00007BMXIEN^T00030Name^T00030User^T00020Start Time^T00020End Time^T00030Option^T00020Report Status^T00030Type of Report"_$C(30)
 N BDMDA
 S BDMDA=0 F  S BDMDA=$O(^BDMGUI("AUSR",BDMDUZ,BDMDA)) Q:'BDMDA  D
 . N BDMIEN
 . S BDMIEN=0 F  S BDMIEN=$O(^BDMGUI("AUSR",BDMDUZ,BDMDA,BDMIEN)) Q:'BDMIEN  D
 .. N BDMDATA,BDMNM,BDMUSER,BDMST,BDMET,BDMTOR,BDMRS,BDMTOO,BDMSTI,BDMOPT
 .. S BDMDATA=$G(^BDMGUI(BDMIEN,0))
 .. S BDMNM=$P(BDMDATA,U)
 .. S BDMUSER=$P($G(^VA(200,$P(BDMDATA,U,2),0)),U)
 .. S BDMSTI=9999999-$P(BDMDATA,U,3)
 .. S BDMST=$$FMTE^XLFDT($P(BDMDATA,U,3))
 .. S BDMET=$$FMTE^XLFDT($P(BDMDATA,U,4))
 .. S BDMTOR=$$GET1^DIQ(9003201.4,BDMIEN,.05)
 .. S BDMOPT=$$GET1^DIQ(9003201.4,BDMIEN,.06)
 .. S BDMRS=$$GET1^DIQ(9003201.4,BDMIEN,.07)
 .. ;S BDMI=BDMI+1
 .. S ^TMP($J,BDMSTI,BDMIEN_"BDM")="A"_BDMIEN_U_BDMNM_U_BDMUSER_U_BDMST_U_BDMET_U_BDMOPT_U_BDMRS_U_BDMTOR
 N BDMDA
 S BDMDA=0 F  S BDMDA=$O(^BDMGUI("AUSR",BDMDUZ,BDMDA)) Q:'BDMDA  D
 . N BDMIEN
 . S BDMIEN=0 F  S BDMIEN=$O(^BDMGUI("AUSR",BDMDUZ,BDMDA,BDMIEN)) Q:'BDMIEN  D
 .. N BDMDATA,BDMNM,BDMUSER,BDMST,BDMET,BDMTOR,BDMRS,BDMTOO,BDMSTI,BDMOPT
 .. S BDMDATA=$G(^BDMGUI(BDMIEN,0))
 .. S BDMNM=$P(BDMDATA,U)
 .. S BDMUSER=$P($G(^VA(200,$P(BDMDATA,U,2),0)),U)
 .. S BDMSTI=9999999-$P(BDMDATA,U,3)
 .. S BDMST=$$FMTE^XLFDT($P(BDMDATA,U,3))
 .. S BDMET=$$FMTE^XLFDT($P(BDMDATA,U,4))
 .. S BDMTOR=$$GET1^DIQ(9003201.4,BDMIEN,.05)
 .. S BDMOPT=$$GET1^DIQ(9003201.4,BDMIEN,.06)
 .. S BDMRS=$$GET1^DIQ(9003201.4,BDMIEN,.07)
 .. ;S BDMI=BDMI+1
 .. S ^TMP($J,BDMSTI,BDMIEN_"BDM")="B"_BDMIEN_U_BDMNM_U_BDMUSER_U_BDMST_U_BDMET_U_BDMOPT_U_BDMRS_U_BDMTOR
 N BDMDA
 S BDMDA=0 F  S BDMDA=$O(^TMP($J,BDMDA)) Q:'BDMDA  D
 . N BDMTIEN
 . S BDMTIEN=0 F  S BDMTIEN=$O(^TMP($J,BDMDA,BDMTIEN)) Q:BDMTIEN=""  D
 .. S BDMI=BDMI+1
 .. S ^BDMTMP($J,BDMI)=$G(^TMP($J,BDMDA,BDMTIEN))_$C(30)
 S ^BDMTMP($J,BDMI+1)=$C(31)
 Q
 ;
DCMP(BDMRET,BDMSTR) ;-- delete complications list
 S X="MERR^BDMGU",@^%ZOSF("TRAP") ; m error trap
 N P,R,I,BDMDA
 S P="|",R="~"
 S BDMERR=""
 K ^BDMTMP($J)
 S RETVAL="^BDMTMP("_$J_")"
 S BDMDA=$P(BDMSTR,P)
 F I=2:1 D  Q:$P(BDMSTR,R,I)=""
 . Q:$P(BDMSTR,R,I)=""
 . S DA(1)=$P(BDMSTR,R,I)
 . S DIK="^ACM(42.1,"_DA(1)_","_"""RG"""_",",DA=BDMDA D ^DIK
 S ^BDMTMP($J,0)="T00250DATA"_$C(30)
 S ^BDMTMP($J,1)=$G(BDMERR)_$C(30)
 S ^BDMTMP($J,2)=$C(31)_BDMERR
 Q
 ;
GETIEN(BDMRET,BDMSTR) ;-- get ien of file based on xref value passed in
 S X="MERR^BDMGU",@^%ZOSF("TRAP")  ;m error trap
 N P,BDMGFL,BDMGXRF,BDMGVAL,BDMGGLB,BDMGI,BDMGLK
 S P="|"
 S BDMGFL=$P(BDMSTR,P)
 S BDMGXRF=$P(BDMSTR,P,2)
 S BDMGVAL=$P(BDMSTR,P,3)
 S BDMGGLB=^DIC(BDMGFL,0,"GL")
 K ^BDMTMP($J)
 S BDMGI=0
 S BDMRET="^BDMTMP("_$J_")"
 S ^BDMTMP($J,BDMGI)="T00007BMXIEN"_$C(30)
 S BDMGI=BDMGI+1
 S BDMGLK=BDMGGLB_""""_BDMGXRF_""")"
 S ^BDMTMP($J,BDMGI)=$O(@BDMGLK@(BDMGVAL,0))_$C(30)
 S ^BDMTMP($J,BDMGI+1)=$C(31)
 Q
 ;
STCNT(BDMRET,BDMSTR) ;-- get search template count and return result
 N P,BDMTRNE,BDMTRN,BDMI,BDMRG,BDMRGE
 S P="|"
 S BDMTRNE=$P(BDMSTR,P,2)
 S BDMTRN=$O(^DIBT("B",BDMTRNE,0))
 S BDMRGE=$P(BDMSTR,P)
 S BDMRG=$O(^ACM(41.1,"B",BDMRGE,0))
 S BDMRET="^BDMTMP("_$J_")"
 K ^BDMTMP($J)
 S ^BDMTMP($J,0)="T10000TEXT"_$C(30)
 S BDMI=0
 N BDMDA,BDMCNT
 S BDMCNT=0
 S BDMDA=0 F  S BDMDA=$O(^DIBT(BDMTRN,1,BDMDA)) Q:'BDMDA  D
 . S BDMCNT=BDMCNT+1
 S ^BDMTMP($J,1)="There are "_BDMCNT_" patients in this search template"_$C(30)
 S ^BDMTMP($J,2)="The following transfer has been selected:"_$C(30)
 S ^BDMTMP($J,3)="From SEARCH TEMPLATE: "_BDMTRNE_$C(30)
 S ^BDMTMP($J,4)="To CMS register: "_BDMRGE_$C(30)
 S ^BDMTMP($J,5)="Transfer Status: A - ACTIVE"_$C(30)
 S ^BDMTMP($J,6)=$C(31)
 Q
 ;
CHKPN(BDMRET,BDMSTR) ;-- check the problem number on DMU
 N P,BDMPN,AUPNPAT
 S P="|"
 S BDMPN=$P(BDMSTR,P)
 S AUPNPAT=$P(BDMSTR,P,2)
 S BDMRET="^BDMTMP("_$J_")"
 K ^BDMTMP($J)
 S ^BDMTMP($J,0)="T00007VALIDPROBLEMNUMBER"_$C(30)
 N BDMVPN
 S BDMVPN=$$PROBNUM^APCDDMUP(BDMPN)
 S ^BDMTMP($J,1)=BDMVPN_$C(30)
 S ^BDMTMP($J,2)=$C(31)
 Q
 ;
LOCG(RETVAL,BDMSTR) ;-- get the local option entry
 N P,BDMIEN,BDMCODE,BDMTEXT
 S P="|"
 S BDMIEN=$P(BDMSTR,P)
 S RETVAL="^BDMTMP("_$J_")"
 K ^BDMTMP($J)
 S @RETVAL@(0)="T00001Code^T00030Text"_$C(30)
 S BDMCODE=$$GET1^DIQ(9002241,BDMIEN,1101)
 S BDMTEXT=$$GET1^DIQ(9002241,BDMIEN,1102)
 S @RETVAL@(1)=BDMCODE_U_BDMTEXT_$C(30)
 S @RETVAL@(2)=$C(31)
 Q
 ;
LOCS(RETVAL,BDMSTR) ;-- save the local option entry
 N P,BDMIEN,BDMCODE,BDMTEXT,BDMRET
 S P="|"
 S BDMIEN=$P(BDMSTR,P)
 S BDMCODE=$P(BDMSTR,P,2)
 S BDMTEXT=$P(BDMSTR,P,3)
 S RETVAL="^BDMTMP("_$J_")"
 K ^BDMTMP($J)
 S @RETVAL@(0)="T00001return"_$C(30)
 N FDA,FIENS,FERR
 S FIENS=BDMIEN_","
 S FDA(9002241,FIENS,1101)=BDMCODE
 S FDA(9002241,FIENS,1102)=BDMTEXT
 D UPDATE^DIE("K","FDA","FERR(1)")
 S BDMRET=$S($D(FERR(1)):1,1:0)
 S @RETVAL@(1)=BDMRET_$C(30)
 S @RETVAL@(2)=$C(31)
 Q
 ;