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

BCHRPT4.m

Go to the documentation of this file.
BCHRPT4 ; IHS/CMI/LAB - PROCESS VISIT LIST ; 
 ;;2.0;IHS RPMS CHR SYSTEM;;OCT 23, 2012;Build 27
 ;IHS/CMI/LAB - tmp to xtmp
 ;
 ;
 ;
START ;
 D XTMP^BCHUTIL("BCHRPT","CHR RECORD LIST")
 D XTMP^BCHUTIL("BCHRAP2","CHR REPORT")
 D XTMP^BCHUTIL("BCHTEN","CHR TOP TEN DX")
 S (BCHBT,BCHBTH)=$H,BCHJOB=$J
 I $P(^BCHRCNT(BCHRPTC,0),U,11)]"" S BCHRPREP=$P(^(0),U,11) S BCHRPREP=$TR(BCHRPREP,"~","^") D @BCHRPREP
 D D,END
 Q
 ;
S ;run by search template
 S BCHR=0 F  S BCHR=$O(^DIBT(BCHSEAT,1,BCHR)) Q:BCHR'=+BCHR  I $D(^BCHR(BCHR,0)),$P(^(0),U,9),'$P(^(0),U,11) D PROC,EOJ
 Q
D ; Run by visit date
 S X1=BCHBD,X2=-1 D C^%DTC S BCHSD=X
 S BCHODAT=BCHSD_".9999" F  S BCHODAT=$O(^BCHR("B",BCHODAT)) Q:BCHODAT=""!((BCHODAT\1)>BCHED)  D V1
 Q
 ;
END ;
 I $P(^BCHRCNT(BCHRPTC,0),U,9)]"" S BCHRPOSP=$P(^(0),U,9) S BCHRPOSP=$TR(BCHRPOSP,"~","^") D @BCHRPOSP
 S BCHET=$H
 D EOJ
 Q
EOJ ;
 K BCHB,BCHI,BCHR,BCHRCNT
 Q
V1 ;
 S (BCHR,BCHRCNT)=0 F  S BCHR=$O(^BCHR("B",BCHODAT,BCHR)) Q:BCHR'=+BCHR  I $D(^BCHR(BCHR,0)),$P(^(0),U,2)]"",$P(^(0),U,3)]"" S BCHR0=^(0),DFN=$P(BCHR0,U,4) D PROC
 Q
PROC ;
 S BCHR0=^BCHR(BCHR,0)
 S BCHPAT=$P(BCHR0,U,4)
 S BCHNRPAT=$P($G(^BCHR(BCHR,11)),U,12)
 ;I 'BCHPAT,'BCHNRPAT Q   ;no patient
 I BCHREG="R",BCHPAT="" Q
 I BCHREG="N",BCHNRPAT="" Q
 I BCHPAT,BCHNRPAT S BCHNRPAT=""
 I BCHPAT Q:'$D(^DPT(BCHPAT,0))
 S BCHR11=$G(^BCHR(BCHR,11)),BCHR12=$G(^BCHR(BCHR,12)),BCHR13=$G(^BCHR(BCHR,13))
 D SCREENS
 Q:$D(BCHSKIP)
 K BCHSRT,BCHPRNT S BCHCRIT=BCHSORT,BCHX=0
 X:$D(^BCHSORT(BCHSORT,5)) ^BCHSORT(BCHSORT,5) I $G(BCHPRNT)']"" D
 . I BCHPTVS="V" S Y=$P($P(BCHR0,U),".") S BCHPRNT=Y Q
 . S BCHPRNT=$S($G(DFN):$P(^DPT(DFN,0),U),1:$P($G(^BCHR(BCHR,11)),U))
 .Q
 S BCHSRT=BCHPRNT I BCHSRT="" S BCHSRT="NONE AVAILABLE"
 I $G(BCHRPTST)]"" D @(BCHRPTST) Q
 S ^XTMP("BCHRPT",BCHJOB,BCHBTH,"RECORDS",BCHSRT,BCHR)=""
 Q
SCREENS ;
 S DFN=$P(BCHR0,U,4)
 K BCHSKIP
 S BCHI=0 F  S BCHI=$O(^BCHTRPT(BCHRPT,11,BCHI)) Q:BCHI'=+BCHI!($D(BCHSKIP))  D
 .I '$P(^BCHSORT(BCHI,0),U,8) D SINGLE Q
 .D MULT
 .Q
 Q
SINGLE ;
 S X=""
 X:$D(^BCHSORT(BCHI,1)) ^(1)
 I X="" S BCHSKIP="" Q
 I '$D(^BCHTRPT(BCHRPT,11,BCHI,11,"B",X)) S BCHSKIP="" Q
 Q
MULT ;
 K BCHFOUN,BCHSKIP,X S BCHX=0,X=""
 X:$D(^BCHSORT(BCHI,1)) ^(1)
 I '$L($O(X)) S BCHSKIP="" Q
 S Y="" F  S Y=$O(X(Y)) Q:Y=""  I $D(^BCHTRPT(BCHRPT,11,BCHI,11,"B",Y)) S BCHFOUN="" Q
 S:'$D(BCHFOUN) BCHSKIP=""
 Q