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

BDGICS3.m

Go to the documentation of this file.
BDGICS3 ; IHS/OIT/LJF - OBSERVATIONS CODING STATUS ;  [ 04/08/2004  4:02 PM ]
 ;;5.3;PIMS;**1005,1010**;MAY 28, 2004
 ;IHS/OIT/LJF 02/16/2006 PATCH 1005 new routine
 ;cmi/anch/maw 10/20/2008 PATCH 1010 changed export date field from .14 to 1106
 ;
 NEW BDGBM,BDGEM
 S BDGBM=$$READ^BDGF("DO^::EP","Select Beginning Month") Q:BDGBM<1
 S BDGEM=$$READ^BDGF("DO^::EP","Select Ending Month") Q:BDGEM<1
 S BDGBM=$E(BDGBM,1,5)_"00",BDGEM=$E(BDGEM,1,5)_"31.24"
 ;
 D ZIS^BDGF("PQ","EN^BDGICS3","OBSERVATION CODING STATUS","BDGBM;BDGEM")
 Q
 ;
 ;
EN ;EP; -- main entry point for BDG IC CODE STATUS DS
 NEW VALMCNT
 I $E(IOST,1,2)="P-" S BDGPRT=1 D INIT,PRINT Q   ;if printing to paper
 D TERM^VALM0,CLEAR^VALM1
 D EN^VALM("BDG IC CODE STATUS OBS")
 D CLEAR^VALM1
 Q
 ;
HDR ;EP; -- header code
 NEW X
 S VALMHDR(1)=$$SP(20)_$$CONF^BDGF
 S X=$$GET1^DIQ(4,DUZ(2),.01),VALMHDR(2)=$$SP(79-$L(X)\2)_X
 S X=$$RANGE^BDGF(BDGBM,(BDGEM\1))
 S VALMHDR(3)=$$SP(79-$L(X)\2)_X
 Q
 ;
INIT ;EP; -- init variables and list array
 I '$G(BDGPRT) D MSG^BDGF("Please wait while I compile the list...",2,0)
 NEW DATE,TODAY,DFN,IEN,COUNT,VST,VH,MONTH,SUB,ADM,X,LINE,DSC,Y
 K ^TMP("BDGICS3",$J),^TMP("BDGICS3A",$J)
 S VALMCNT=0
 ;
 ; loop through observation visits for date range
 S DATE=BDGBM,TODAY=DT+.24
 F  S DATE=$O(^AUPNVSIT("B",DATE)) Q:('DATE)!(DATE>BDGEM)!(DATE>TODAY)  D
 . S MONTH=$E(DATE,1,5)
 . S VST=0 F  S VST=$O(^AUPNVSIT("B",DATE,VST)) Q:'VST  D
 .. ;
 .. Q:$$GET1^DIQ(9000010,VST,.07)'="OBSERVATION"
 .. Q:$$GET1^DIQ(9000010,VST,.11)="DELETED"
 .. Q:$$GET1^DIQ(9000010,VST,.06,"I")'=DUZ(2)  ;visit from different facility
 .. ;
 .. ;increment # observations per month
 .. S COUNT(MONTH,"OBS")=$G(COUNT(MONTH,"OBS"))+1
 .. ;
 .. ; check if uncoded
 .. S X=$O(^AUPNVPOV("AD",VST,0)),Y=$O(^AUPNVPRV("AD",VST,0))
 .. I (X="")!(Y="") D UNCODED(DATE,VST) Q
 .. ;
 .. ; check if exported
 .. S COUNT(MONTH,"COD")=$G(COUNT(MONTH,"COD"))+1
 .. ;I $$GET1^DIQ(9000010,VST,.14)]"" S COUNT(MONTH,"EXP")=$G(COUNT(MONTH,"EXP"))+1  ;cmi/maw 10/20/2008 PATCH 1010 orig line
 .. I $$GET1^DIQ(9000010,VST,1106)]"" S COUNT(MONTH,"EXP")=$G(COUNT(MONTH,"EXP"))+1  ;cmi/maw 10/20/2008 PATCH 1010 new export date
 ;
 ; build display array
 ;    monthly counts heading
 S LINE=$$PAD($$PAD("Month/Year",13)_"# Obsrv Vsts",26)
 S LINE=$$PAD(LINE_"# Coded",36)
 S LINE=$$PAD($$PAD(LINE_"# Not-Coded",50)_"# Exported",62)
 S LINE=LINE_"# Errors" D SET(LINE,.VALMCNT)
 ;    monthly counts
 S MON=0 F  S MON=$O(COUNT(MON)) Q:'MON  D
 . S LINE=$$PAD($$FMTE^XLFDT(MON_"00"),15)
 . F SUB="OBS","COD","UNC","EXP","ERR" D
 .. S LINE=LINE_$J(+$G(COUNT(MON,SUB)),4)_$$SP(8)
 . D SET(LINE,.VALMCNT)
 ;
 ;add totals for each column
 D SET($$REPEAT^XLFSTR("=",79),.VALMCNT)
 S LINE=$$SP(15)
 F SUB="OBS","COD","UNC","EXP","ERR" D
 . S TOTAL=0,MON=0
 . F  S MON=$O(COUNT(MON)) Q:'MON  S TOTAL=$G(TOTAL)+$G(COUNT(MON,SUB))
 . S LINE=LINE_$J(TOTAL,4)_$$SP(8)
 D SET(LINE,.VALMCNT)
 D SET("",.VALMCNT)
 ;
 ; list uncoded charts
 ;   if any uncoded charts, print heading
 I $D(^TMP("BDGICS3A",$J,"U")) D
 . S LINE=$$PAD($$PAD("Visit Date",15)_"Patient Name",45)
 . S LINE=$$PAD(LINE_"Chart #",58)_"Srv"
 . S LINE=$$PAD(LINE,64)_"Insurance"
 . D SET("",.VALMCNT),SET(LINE,.VALMCNT)
 ;
 S DATE=0 F  S DATE=$O(^TMP("BDGICS3A",$J,"U",DATE)) Q:'DATE  D
 . S VST=0 F  S VST=$O(^TMP("BDGICS3A",$J,"U",DATE,VST)) Q:'VST  D
 .. ;
 .. S DFN=$$GET1^DIQ(9000010,VST,.05,"I")                 ;pat ien
 .. S LINE=$$PAD($$NUMDATE^BDGF(DATE\1),15)               ;admit date
 .. S LINE=$$PAD(LINE_$E($$GET1^DIQ(2,DFN,.01),1,22),45)  ;name
 .. S LINE=$$PAD(LINE_$J($$HRCN^BDGF2(DFN,DUZ(2)),6),58)
 .. ;
 .. S ADM=$O(^DGPM("AVISIT",VST,0))
 .. I ADM S LINE=LINE_$E($$ADMSRV^BDGF1(ADM,DFN),1,3)     ;service
 .. ;
 .. ; add insurance coverage
 .. S LINE=$$PAD(LINE,64)_$$INSUR^BDGF2(DFN,DATE)
 .. D SET(LINE,.VALMCNT)
 ;
 ; add error charts to display listing
 ;     if any errors, print heading
 I $D(^TMP("BDGICS3A",$J,"E")) D
 . I $E(IOST,1,2)="P-" D SET("@@@",.VALMCNT)   ;mark errors for paper
 . S LINE=$$PAD("Visit Date",16)_"Patient Name"
 . S LINE=$$PAD($$PAD(LINE,38)_"Chart #",48)_"Error Message"
 . D SET("",.VALMCNT),SET(LINE,.VALMCNT)
 ;
 S DATE=0 F  S DATE=$O(^TMP("BDGICS3A",$J,"E",DATE)) Q:'DATE  D
 . S VST=0 F  S VST=$O(^TMP("BDGICS3A",$J,"E",DATE,VST)) Q:'VST  D
 .. ;
 .. S DFN=$$GET1^DIQ(9000010,VST,.05,"I")                    ;pat ien
 .. S LINE=$$PAD($$NUMDATE^BDGF(DATE\1),16)                  ;admit date
 .. S LINE=$$PAD(LINE_$E($$GET1^DIQ(2,DFN,.01),1,18),38)     ;name
 .. S LINE=LINE_$J($$HRCN^BDGF2(DFN,DUZ(2)),6)               ;chart #
 .. S LINE=$$PAD(LINE,48)_^TMP("BDGICS3A",$J,"E",DATE,VST)   ;err msg
 .. D SET(LINE,.VALMCNT)
 ;
 I '$D(^TMP("BDGICS3",$J)) D SET("NO DATA FOUND",.VALMCNT)
 K ^TMP("BDGICS3A",$J)
 Q
 ;
ERR(MSG,VST,DATE) ; increment error count and save for listing
 NEW MON
 S MON=$E(DATE,1,5)
 S COUNT(MON,"ERR")=$G(COUNT(MON,"ERR"))+1
 S ^TMP("BDGICS3A",$J,"E",DATE,VST)=MSG
 Q
 ;
UNCODED(DATE,VST) ; save uncoded visits by discharge date
 NEW MON
 S MON=$E(DATE,1,5)
 S COUNT(MON,"UNC")=$G(COUNT(MON,"UNC"))+1
 S ^TMP("BDGICS3A",$J,"U",DATE,VST)=""
 Q
 ;
SET(DATA,NUM) ; put data line into display array
 S NUM=NUM+1
 S ^TMP("BDGICS3",$J,NUM,0)=DATA
 Q
 ;
PRINT ; print report to paper
 NEW BDGL,FIRST
 U IO S FIRST=1 D HDG
 S BDGL=0 F  S BDGL=$O(^TMP("BDGICS3",$J,BDGL)) Q:'BDGL  D
 . I ^TMP("BDGICS3",$J,BDGL,0)="@@@" S FIRST=1 Q  ;beginning of errors
 . I $Y>(IOSL-4) D HDG
 . W !,^TMP("BDGICS3",$J,BDGL,0)
 D ^%ZISC,EXIT
 Q
 ;
HDG ; heading when printing to paper
 W @IOF W !?25,"OBSERVATIONS CODING STATUS REPORT"
 D HDR F I=1:1 Q:'$D(VALMHDR(I))  W !,VALMHDR(I)
 I FIRST W !,$$REPEAT^XLFSTR("=",80),! S FIRST=0 Q
 W !,"Visit Date",?24,"Patient Name",?44,"Chart #"
 W !?54,"Serv",?60,"Insurance",!,$$REPEAT^XLFSTR("=",80),!
 Q
 ;
HELP ; -- help code
 S X="?" D DISP^XQORM1 W !!
 Q
 ;
EXIT ; -- exit code
 K ^TMP("BDGICS3",$J) K BDGPRT
 Q
 ;
EXPND ; -- expand code
 Q
 ;
PAD(D,L) ;EP -- SUBRTN to pad length of data
 ; -- D=data L=length
 Q $E(D_$$REPEAT^XLFSTR(" ",L),1,L)
 ;
SP(N) ; -- SUBRTN to pad N number of spaces
 Q $$PAD(" ",N)