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

BLRESIGR.m

Go to the documentation of this file.
  1. BLRESIGR ; IHS/OIT/MKK - Laboratory E-SIG Reports ; [ 04/12/06 4:00 PM ]
  1. ;;5.2;LR;**1022**;September 20, 2007
  1. ;
  1. ; NOTE: The LRIDT variable in the LR("BLRA") index is stored as a
  1. ; negative number. That is why, in several places, the code does a
  1. ; -(LRIDT).
  1. ;
  1. ; This routine also makes extensive use of the BLRGMENU (generic
  1. ; menu driver) routine. See notes there regarding its calls.
  1. ;
  1. ; The main reason to use the BLRGMENU routine instead of making the
  1. ; various calls OPTIONs in the OPTION file is to make certain all the
  1. ; variables used in this routine are NEWed. This means the variables
  1. ; will NOT interfere with other LAB routines.
  1. ;
  1. EEP ; Ersatz EP
  1. W $C(7),$C(7),$C(7),!
  1. W "Use Label Only",!
  1. W $C(7),$C(7),$C(7),!
  1. Q
  1. ;
  1. PEP ; "Real" EP
  1. ;
  1. ; This should never happen, BUT need to determine if IHS E-SIG
  1. ; is turned on -- if NOT, bail out
  1. I $$ADDON^BLRUTIL("LR*5.2*1013","BLRALAF",DUZ(2))'=1 D Q
  1. . W !!,"IHS LR*5.2*1013 E-SIG is NOT on.",!!
  1. . D BLRGPGR^BLRGMENU(10) ; Press RETURN prompt
  1. ;
  1. ; NEW variables so that they do not impact any other routines
  1. NEW BLRA,ESPHY,STATUS,LRIDT,LRDFN,LRAA,LRAS,LRAD,SPHY
  1. NEW BLRMMENU,BLRESIGR,ESIGIEN
  1. NEW NRESP,NSIGN,RESP,SIGN,CNT,PHYCNT,TOTCNT
  1. NEW HEADER,LINES,MAXLINES,QFLG,HLCNT
  1. NEW PATN,ACCN
  1. NEW BEGIDT,ENDIDT
  1. NEW PHYSUR,PHYSURG
  1. NEW SIGNDT,SELPHYS
  1. ;
  1. D SETMENU
  1. D MENUDRFM^BLRGMENU("LAB E-SIG Reports") ; Main Menu driver
  1. ;
  1. D ^XBCLS
  1. W !,?11,"Lab E-SIG Menu"
  1. Q
  1. ;
  1. SETMENU ; ; MAIN MENU INITIALIZATION
  1. K BLRMMENU
  1. D ADDTMENU^BLRGMENU("ALLESIGS^BLRESIGR","All E-SIG Transactions")
  1. D ADDTMENU^BLRGMENU("ALLESIGN^BLRESIGR","Signed Transactions")
  1. D ADDTMENU^BLRGMENU("ALLNSIGN^BLRESIGR","Not Signed by Responsible Physician")
  1. D ADDTMENU^BLRGMENU("NREVNSGN^BLRESRNS","Not Reviewed nor Signed Summary")
  1. ;
  1. Q
  1. ;
  1. ; All E-Sig Transactions in LAB DATA file
  1. ALLESIGS ; EP
  1. D ^XBFMK ; Clear out ALL FileMan variables
  1. S DIR("A")="Output ALL E-SIG transactions for ALL Providers"
  1. S DIR(0)="Y",DIR("B")="YES"
  1. D ^DIR
  1. I X["^" D Q
  1. . W !,?10,"Exit entered. No Report.",!
  1. . D BLRGPGR^BLRGMENU(10) ; Press Return prompt
  1. ;
  1. I Y=1 D ALLSTS
  1. I Y'=1 D SELSTS
  1. Q
  1. ;
  1. ; ALL E-Sig transactions in LAB DATA file by ALL Responsible Physicians
  1. ALLSTS ; EP
  1. D FULLCOMP
  1. D FULLRPTH
  1. D ESIGRPT("FULLRPTL")
  1. Q
  1. ;
  1. ; ALL E-Sig transactions in LAB DATA file by SELECTED
  1. ; Responsible Physician(s)
  1. SELSTS ;
  1. I $$SELCTPHY="Q" Q
  1. ;
  1. D ALLPCOMP
  1. D FULLRPTH
  1. D ESIGRPT("FULLRPTL")
  1. Q
  1. ;
  1. ; Sort E-SIG data
  1. FULLCOMP ;
  1. D DATERNGE ; Get Date Range
  1. K BLRESIGR ; Clear array
  1. ;
  1. S ESPHY="" ; E-SIG Physician
  1. F S ESPHY=$O(^LR("BLRA",ESPHY)) Q:ESPHY="" D
  1. . D GETESIGD^BLRESRCD
  1. Q
  1. ;
  1. ; Header
  1. FULLRPTH ;
  1. D ESIGRPTH("ALL LAB E-SIG ACCESSIONS")
  1. S HLCNT=HLCNT+1
  1. S HEADER(HLCNT)="RESP PHYSICIAN"
  1. S $E(HEADER(HLCNT),17)="ACC #"
  1. S $E(HEADER(HLCNT),37)="COLL DATE/TIME"
  1. S $E(HEADER(HLCNT),53)="STATUS"
  1. S $E(HEADER(HLCNT),66)="SIGN PHYSICIAN"
  1. ;
  1. Q
  1. ;
  1. ; Output line of data
  1. FULLRPTL ;
  1. D ESIGBRKO
  1. ;
  1. I LINES>MAXLINES D BLRGHWPN^BLRGMENU(.PG,.QFLG) I QFLG="Q" Q
  1. ;
  1. W $E(NRESP,1,15)
  1. W ?16,ACCN
  1. W ?36,$$FMTE^XLFDT(COLLDTT,"2MZ")
  1. W ?52,$E(STATUS,1,12)
  1. W ?65,$E(NSIGN,1,15)
  1. W !
  1. S LINES=LINES+1
  1. S CNT=CNT+1
  1. Q
  1. ;
  1. ; Initialize HEADER array
  1. ESIGRPTH(HEAD1) ;
  1. NEW RANGESTR
  1. ;
  1. S RANGESTR="DATE RANGE: "
  1. S RANGESTR=RANGESTR_$$FMTE^XLFDT(LRSDT,"2DZ")
  1. S RANGESTR=RANGESTR_" THRU "_$$FMTE^XLFDT(LRLDT,"2DZ")
  1. S RANGESTR=$$CJ^XLFSTR(RANGESTR,IOM)
  1. ;
  1. K HEADER
  1. S HEADER(1)=HEAD1
  1. S HEADER(2)="SORTED BY RESPONSIBLE PHYSICIAN"
  1. S HEADER(3)=RANGESTR
  1. S HEADER(4)=" "
  1. S HLCNT=4 ; HEADER LINE COUNT
  1. ;
  1. Q
  1. ;
  1. ESIGRPT(WOTDLINE) ;
  1. I $$GETDEV="Q" D Q
  1. . W !,"Output Device Error",!!
  1. . D BLRGPGR^BLRGMENU()
  1. ;
  1. U IO
  1. S (NRESP,PATN,LRAA,LRDFN,LRIDT)=""
  1. S CNT=0
  1. F S NRESP=$O(BLRESIGR(NRESP)) Q:NRESP=""!(QFLG="Q") D
  1. . S PHYCNT=0
  1. . F S PATN=$O(BLRESIGR(NRESP,PATN)) Q:PATN=""!(QFLG="Q") D
  1. .. F S LRAA=$O(BLRESIGR(NRESP,PATN,LRAA)) Q:LRAA=""!(QFLG="Q") D
  1. ... F S LRDFN=$O(BLRESIGR(NRESP,PATN,LRAA,LRDFN)) Q:LRDFN=""!(QFLG="Q") D
  1. .... F S LRIDT=$O(BLRESIGR(NRESP,PATN,LRAA,LRDFN,LRIDT)) Q:LRIDT=""!(QFLG="Q") D
  1. ..... D @WOTDLINE
  1. ..... S PHYCNT=PHYCNT+1
  1. . I PHYCNT>0 D
  1. .. W !
  1. .. S LINES=LINES+1
  1. ;
  1. D ^%ZISC ; Close IO port
  1. ;
  1. W !!,"Number of records = ",CNT,!!
  1. ;
  1. D BLRGPGR^BLRGMENU()
  1. Q
  1. ;
  1. GETDEV() ; EP
  1. D ^%ZIS
  1. I POP>0 Q "Q"
  1. ;
  1. S PG=0
  1. S MAXLINES=IOSL-4
  1. S LINES=MAXLINES+10
  1. S QFLG="NO"
  1. ;
  1. Q "OK"
  1. ;
  1. ; "Break out" BLRESIGR array variables
  1. ESIGBRKO ;
  1. S ACCN=$P($G(^LR(LRDFN,LRAA,LRIDT,0)),"^",6) ; Accession Number
  1. S COLLDTT=$P($G(^LR(LRDFN,LRAA,LRIDT,0)),"^",1) ; Collection Date/Time
  1. S STATUS=$P($G(^LR(LRDFN,LRAA,LRIDT,9009027)),"^",1) ; E-SIG Transaction Status
  1. S STATUS=$S(STATUS=0:"NOT REVIEWED",STATUS=1:"REVIEWED",STATUS=2:"REV & SIGNED",1:"<UNK>")
  1. ;
  1. S SIGN=$P($G(^LR(LRDFN,LRAA,LRIDT,9009027)),"^",3) ; Signing Physician's IEN
  1. I SIGN="" S NSIGN="" Q
  1. S NSIGN=$P($G(^VA(200,SIGN,0)),"^",1) ; Signing Physician's Name
  1. S SIGNDT=$P($G(^LR(LRDFN,LRAA,LRIDT,9009027)),"^",5)
  1. Q
  1. ;
  1. ; Select E-SIG participating Physician(s)
  1. SELCTPHY() ;
  1. NEW FLG,PHYCNT
  1. K SELPHYS
  1. ;
  1. S FLG="OK",PHYCNT=0
  1. F D Q:FLG'="OK"
  1. . S FLG=$$GETPHYIN
  1. . I FLG="Q" Q
  1. . ;
  1. . S SELPHYS(ESIGIEN)=""
  1. . S PHYCNT=PHYCNT+1
  1. . W !
  1. ;
  1. I PHYCNT<1 D Q "Q"
  1. . W !,"No Providers selected",!
  1. . D BLRGPGR^BLRGMENU()
  1. ;
  1. Q "OK"
  1. ;
  1. ; Get E-SIG Physician's Internal Entry Number (IEN)
  1. GETPHYIN() ;
  1. D ^XBFMK
  1. S DIC=9009027.1
  1. S DIC(0)="QEAZ"
  1. D ^DIC
  1. I Y<1 Q "Q"
  1. I X["^"!($G(X)="") Q "Q"
  1. ;
  1. S ESIGIEN=+Y
  1. Q "OK"
  1. ;
  1. ; Sort E-SIG data using Selected Physicians
  1. ALLPCOMP ;
  1. D DATERNGE ; Get Date Range
  1. K BLRESIGR ; Clear array
  1. ;
  1. S ESPHY=""
  1. F S ESPHY=$O(SELPHYS(ESPHY)) Q:ESPHY="" D
  1. . D GETESIGD^BLRESRCD
  1. ;
  1. Q
  1. ;
  1. ALLESIGN ; EP
  1. D ^XBFMK ; Clear out ALL FileMan variables
  1. S DIR("A")="Output ALL E-SIG SIGNED transactions for ALL Providers"
  1. S DIR(0)="Y",DIR("B")="YES"
  1. D ^DIR
  1. I X["^" D Q
  1. . W !,?10,"Exit entered. No Report.",!
  1. . D BLRGPGR^BLRGMENU(10) ; Press Return prompt
  1. ;
  1. I Y=1 D ASIGNSTS
  1. I Y'=1 D SSIGNSTS
  1. Q
  1. ;
  1. ; ALL E-Sig Transactions with Status = 2 ==> Reviewed & Signed
  1. ASIGNSTS ; EP
  1. D SIGNCOMP
  1. D SIGNRPT
  1. Q
  1. ;
  1. ; Sort Status = 2 E-SIG data
  1. SIGNCOMP ;
  1. D DATERNGE
  1. K BLRESIGR ; Clear array
  1. ;
  1. S STATUS=2 ; Initialize variable
  1. ;
  1. S ESPHY="" ; E-SIG Physician
  1. F S ESPHY=$O(^LR("BLRA",ESPHY)) Q:ESPHY="" D
  1. . S NRESP=$P($G(^VA(200,ESPHY,0)),"^",1)
  1. . S BLRESIGR(NRESP)=ESPHY
  1. . D GETESIG2^BLRESRCD
  1. Q
  1. ;
  1. SIGNRPT ;
  1. I $$GETDEV="Q" D Q
  1. . W !,"Output Device Error",!!
  1. . D BLRGPGR^BLRGMENU()
  1. ;
  1. D ESIGRPTH("SIGNED LAB E-SIG ACCESSIONS")
  1. ;
  1. U IO
  1. S (NRESP,PATN,LRAA,LRDFN,LRIDT)=""
  1. S CNT=0
  1. F S NRESP=$O(BLRESIGR(NRESP)) Q:NRESP=""!(QFLG="Q") D
  1. . S PHYCNT=0
  1. . F S PATN=$O(BLRESIGR(NRESP,PATN)) Q:PATN=""!(QFLG="Q") D
  1. .. F S LRAA=$O(BLRESIGR(NRESP,PATN,LRAA)) Q:LRAA=""!(QFLG="Q") D
  1. ... F S LRDFN=$O(BLRESIGR(NRESP,PATN,LRAA,LRDFN)) Q:LRDFN=""!(QFLG="Q") D
  1. .... F S LRIDT=$O(BLRESIGR(NRESP,PATN,LRAA,LRDFN,LRIDT)) Q:LRIDT=""!(QFLG="Q") D
  1. ..... D SIGNRPTL
  1. . I PHYCNT>0 D
  1. .. W !!,?10,"Number of Signed E-SIG transactions for ",NRESP," = ",PHYCNT,!
  1. . S LINES=MAXLINES+10
  1. ;
  1. D ^%ZISC ; Close IO port
  1. ;
  1. D BLRGPGR^BLRGMENU()
  1. Q
  1. ;
  1. ; Output line of data
  1. SIGNRPTL ;
  1. D ESIGBRKO
  1. ;
  1. I LINES>MAXLINES D I QFLG="Q" Q
  1. . D SURINHDR(HLCNT)
  1. . D BLRGHWPN^BLRGMENU(.PG,.QFLG)
  1. ;
  1. W ACCN
  1. W ?19,$$FMTE^XLFDT(COLLDTT,"2MZ")
  1. W ?35,$$FMTE^XLFDT(SIGNDT,"2MZ")
  1. W ?51,$E(NSIGN,1,25)
  1. W !
  1. S LINES=LINES+1
  1. S CNT=CNT+1
  1. S PHYCNT=1+$G(PHYCNT)
  1. Q
  1. ;
  1. ; Selected Physicians and their signed E-SIG transactions
  1. SSIGNSTS ;
  1. I $$SELCTPHY="Q" Q
  1. ;
  1. D SGNPCOMP
  1. D SIGNRPT
  1. Q
  1. ;
  1. SGNPCOMP ;
  1. D DATERNGE
  1. K BLRESIGR ; Clear array
  1. ;
  1. S STATUS=2 ; Initialize variable
  1. ;
  1. S ESPHY="" ; E-SIG Physician
  1. F S ESPHY=$O(SELPHYS(ESPHY)) Q:ESPHY="" D
  1. . S NRESP=$P($G(^VA(200,ESPHY,0)),"^",1)
  1. . S BLRESIGR(NRESP)=ESPHY
  1. . D GETESIG2^BLRESRCD
  1. Q
  1. ;
  1. ALLNSIGN ; EP
  1. D ^XBFMK ; Clear out ALL FileMan variables
  1. S DIR("A")="Output E-SIG transactions Not Signed by Resp Phy - ALL"
  1. S DIR(0)="Y",DIR("B")="YES"
  1. D ^DIR
  1. I X["^" D Q
  1. . W !,?10,"Exit entered. No Report.",!
  1. . D BLRGPGR^BLRGMENU(10) ; Press Return prompt
  1. ;
  1. I Y=1 D ANOSIGNR
  1. I Y'=1 D SNOSIGNR
  1. ;
  1. Q
  1. ;
  1. ; Report of NOT SIGNED by Responsible Physician for ALL Physicians
  1. ANOSIGNR ; EP
  1. D NSIGNCOM
  1. D NSIGNRPT
  1. Q
  1. ;
  1. NSIGNCOM ;
  1. D DATERNGE
  1. K BLRESIGR ; Clear array
  1. ;
  1. S STATUS=2 ; Initialize variable
  1. ;
  1. S CNT=0
  1. S ESPHY="" ; E-SIG Physician
  1. F S ESPHY=$O(^LR("BLRA",ESPHY)) Q:ESPHY="" D
  1. . S NRESP=$P($G(^VA(200,ESPHY,0)),"^",1)
  1. . S BLRESIGR(NRESP)=ESPHY
  1. . D NSIGNTXN^BLRESRCD
  1. . I CNT<1 K BLRESIGR(NRESP)
  1. Q
  1. ;
  1. ; Report of E-SIG Not Signed transaction by Responsible Physician
  1. NSIGNRPT ;
  1. I $$NSGNRPTH="Q" D Q
  1. . W !,"Output Device Error",!!
  1. . D BLRGPGR^BLRGMENU()
  1. ;
  1. U IO
  1. S (NRESP,PATN,LRAA,LRDFN,LRIDT)=""
  1. F S NRESP=$O(BLRESIGR(NRESP)) Q:NRESP=""!(QFLG="Q") D
  1. . D SURROGAT($G(BLRESIGR(NRESP)))
  1. . ;
  1. . S CNT=0
  1. . F S PATN=$O(BLRESIGR(NRESP,PATN)) Q:PATN=""!(QFLG="Q") D
  1. .. F S LRAA=$O(BLRESIGR(NRESP,PATN,LRAA)) Q:LRAA=""!(QFLG="Q") D
  1. ... F S LRDFN=$O(BLRESIGR(NRESP,PATN,LRAA,LRDFN)) Q:LRDFN=""!(QFLG="Q") D
  1. .... F S LRIDT=$O(BLRESIGR(NRESP,PATN,LRAA,LRDFN,LRIDT)) Q:LRIDT=""!(QFLG="Q") D
  1. ..... D NSGNRPTL
  1. . I CNT>0 W !,?10,"Number of records = ",CNT,!
  1. . S LINES=MAXLINES+10
  1. ;
  1. D ^%ZISC ; Close IO port
  1. ;
  1. D BLRGPGR^BLRGMENU()
  1. ;
  1. Q
  1. ;
  1. ; Get Surrogate(s) Information and store in PHYSURG array
  1. SURROGAT(RESP) ;
  1. K PHYSURG
  1. S PHYSUR=0
  1. F S PHYSUR=$O(^BLRALAB(9009027.1,RESP,1,PHYSUR)) Q:PHYSUR=""!(PHYSUR'?.N) D
  1. . S SURDATES=$P(^BLRALAB(9009027.1,RESP,1,PHYSUR,0),"^",2,3)
  1. . S SURBDT=$$FMTE^XLFDT($P(SURDATES,"^",1),"2DZ")
  1. . S SUREDT=$$FMTE^XLFDT($P(SURDATES,"^",2),"2DZ")
  1. . S PHYSURG(RESP,PHYSUR)=$P($G(^VA(200,PHYSUR,0)),"^",1)_"^"_SURBDT_"^"_SUREDT
  1. Q
  1. ;
  1. ; Initialize HEADER array and IO
  1. NSGNRPTH() ;
  1. D ESIGRPTH("REVIEWED & NOT SIGNED BY RESP PHYSICIAN")
  1. ;
  1. Q $$GETDEV
  1. ;
  1. ; Output line of data
  1. NSGNRPTL ;
  1. D ESIGBRKO
  1. ;
  1. I LINES>MAXLINES D I QFLG="Q" Q
  1. . D SURINHDR(HLCNT)
  1. . D BLRGHWPN^BLRGMENU(.PG,.QFLG)
  1. ;
  1. W ACCN
  1. W ?19,$$FMTE^XLFDT(COLLDTT,"2MZ")
  1. W ?35,$$FMTE^XLFDT(SIGNDT,"2MZ")
  1. W ?51,$E(NSIGN,1,25)
  1. W !
  1. S LINES=LINES+1
  1. S CNT=CNT+1
  1. ;
  1. Q
  1. ;
  1. ; Put Surrogate(s) information in HEADER array
  1. SURINHDR(HDCNT) ;
  1. S HDCNT=HDCNT+1
  1. F J=HDCNT:1:12 K HEADER(J) ; Clear out array
  1. ;
  1. S HEADER(HDCNT)=$$CJ^XLFSTR("RESPONSIBLE PHYSICIAN:"_NRESP,IOM)
  1. S HDCNT=HDCNT+1
  1. ;
  1. NEW RESP
  1. S RESP=$G(BLRESIGR(NRESP))
  1. ;
  1. ; SURROGATE Information
  1. NEW SURDATES,SURSTR,SURBDT,SUREDT
  1. S PHYSUR=""
  1. F S PHYSUR=$O(PHYSURG(RESP,PHYSUR)) Q:PHYSUR=""!(QFLG="Q") D
  1. . S SURSTR="SURROGATE:"_$P($G(PHYSURG(RESP,PHYSUR)),"^",1)
  1. . S SURSTR=SURSTR_" BEG DATE:"_$P($G(PHYSURG(RESP,PHYSUR)),"^",2)
  1. . S SURSTR=SURSTR_" END DATE:"_$P($G(PHYSURG(RESP,PHYSUR)),"^",3)
  1. . S HEADER(HDCNT)=$$CJ^XLFSTR(SURSTR,IOM)
  1. . S HDCNT=HDCNT+1
  1. ;
  1. S HEADER(HDCNT)=" "
  1. S HDCNT=HDCNT+1
  1. ;
  1. S HEADER(HDCNT)="ACC #"
  1. S $E(HEADER(HDCNT),20)="COLL DATE/TIME"
  1. S $E(HEADER(HDCNT),36)="SIGN DATE/TIME"
  1. S $E(HEADER(HDCNT),52)="SIGNING PHY"
  1. ;
  1. Q
  1. ;
  1. SNOSIGNR ;
  1. I $$SELCTPHY="Q" Q
  1. ;
  1. D SNSGNCOM
  1. D NSIGNRPT
  1. Q
  1. ;
  1. SNSGNCOM ;
  1. D DATERNGE
  1. K BLRESIGR ; Clear array
  1. ;
  1. S STATUS=2 ; Initialize variable
  1. ;
  1. S CNT=0
  1. S ESPHY="" ; E-SIG Physician
  1. F S ESPHY=$O(SELPHYS(ESPHY)) Q:ESPHY="" D
  1. . S NRESP=$P($G(^VA(200,ESPHY,0)),"^",1)
  1. . S BLRESIGR(NRESP)=ESPHY
  1. . D NSIGNTXN^BLRESRCD
  1. . I CNT<1 K BLRESIGR(NRESP)
  1. Q
  1. ;
  1. DATERNGE ;
  1. W !
  1. D B^LRU
  1. S BEGIDT=-(9999999-LRSDT)
  1. S ENDIDT=-(9999999-(LRLDT+1))
  1. Q