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

BMCRR41.m

Go to the documentation of this file.
BMCRR41 ; IHS/PHXAO/TMJ - PROCESS REFERRAL LIST ;     [ 09/27/2006  2:15 PM ]
 ;;4.0;REFERRED CARE INFO SYSTEM;**1**;JAN 09, 2006;Build 101
 ;IHS/ITSC/FCJ ADDED TEST FOR SR
 ;4.0*1 3.7.06 IHS/OIT/FCJ ADDED ALPHA ORDER FOR PHYS
 ;
 ;
START ;
 S (BMCBT,BMCBTH)=$H,BMCJOB=$J,BMCRCNT=0
 D PROCESS,END
 Q
 ;
PROCESS ;
V ; Run by visit date
 S BMCODAT=$O(^AUPNVSIT("B",BMCSD)) I BMCODAT="" S BMCET=$H Q
 S BMCODAT=BMCSD_".9999" F  S BMCODAT=$O(^AUPNVSIT("B",BMCODAT)) Q:BMCODAT=""!((BMCODAT\1)>BMCED)  D V1
 S BMCODAT=$O(^BMCREF("B",BMCSD)) I BMCODAT="" S BMCET=$H Q
 S BMCODAT=BMCSD_".9999" F  S BMCODAT=$O(^BMCREF("B",BMCODAT)) Q:BMCODAT=""!((BMCODAT\1)>BMCED)  D R1
 ;4.0*1 3.7.06 IHS/OIT/FCJ ADD SECTION TO PRNT ALPHA ORDER FOR PHYS
 I BMCTYPE="P",$D(^XTMP("BMCRR4",BMCJOB,BMCBTH,"REFERRALS")) D
 .S BMCSORT=0
 .F  S BMCSORT=$O(^XTMP("BMCRR4",BMCJOB,BMCBTH,"REFERRALS",BMCSORT)) Q:BMCSORT'?1N.N  D
 ..S ^XTMP("BMCRR4",BMCJOB,BMCBTH,"REFERRALS",$P($G(^VA(200,BMCSORT,0)),U),BMCSORT)=""
 ;4.0*1 3.7.06 IHS/OIT/FCJ END OF CHANGES
 Q
 ;
END ;
 S BMCET=$H
 Q
V1 ;
 S BMCVDFN="" F  S BMCVDFN=$O(^AUPNVSIT("B",BMCODAT,BMCVDFN)) Q:BMCVDFN'=+BMCVDFN  I $D(^AUPNVSIT(BMCVDFN,0)) S BMCVREC=^(0) D PROCV
 Q
 ;
R1 ;
 S BMCREF="" F  S BMCREF=$O(^BMCREF("B",BMCODAT,BMCREF)) Q:BMCREF'=+BMCREF  S BMCRREC=^BMCREF(BMCREF,0) D PROCR
 Q
PROCR ;
 Q:$P(BMCRREC,U,4)="N"
 Q:$P(BMCRREC,U,15)="X"  ;skip cancelled referrals
 Q:$P(BMCRREC,U,6)=""
 Q:$P(BMCRREC,U,5)=""
 Q:$P($G(^BMCREF(BMCREF,1)),U)'=""  ;SKIP SR
 S BMCSORT=$S(BMCTYPE="P":$P(BMCRREC,U,6),1:$P(BMCRREC,U,5))
 I '$D(^XTMP("BMCRR4",BMCJOB,BMCBTH,"REFERRALS",BMCSORT)) S ^XTMP("BMCRR4",BMCJOB,BMCBTH,"REFERRALS",BMCSORT)=""
 S $P(^XTMP("BMCRR4",BMCJOB,BMCBTH,"REFERRALS",BMCSORT),U)=$P(^XTMP("BMCRR4",BMCJOB,BMCBTH,"REFERRALS",BMCSORT),U)+1
 ;S $P(^XTMP("BMCRR4",BMCJOB,BMCBTH,"REFERRALS",BMCSORT),U,2)=$P(^XTMP("BMCRR4",BMCJOB,BMCBTH,"REFERRALS",BMCSORT),U,2)+$$AVICOST^BMCRLU(BMCREF)
 Q:$P(BMCRREC,U,4)=""
 S X=$S($P(BMCRREC,U,4)="I":2,$P(BMCRREC,U,4)="O":3,$P(BMCRREC,U,4)="C":4)
 S $P(^XTMP("BMCRR4",BMCJOB,BMCBTH,"REFERRALS",BMCSORT),U,X)=$P(^XTMP("BMCRR4",BMCJOB,BMCBTH,"REFERRALS",BMCSORT),U,X)+1
 Q
PROCV ;
 Q:'$P(BMCVREC,U,9)
 Q:$P(BMCVREC,U,11)
 Q:"TCNEDXF"[$P(BMCVREC,U,7)
 Q:'$D(^AUPNVPOV("AD",BMCVDFN))
 Q:'$D(^AUPNVPRV("AD",BMCVDFN))
 Q:"CV"[$P(BMCVREC,U,3)
 D @BMCTYPE
 Q:BMCSORT=""  ;couldn't find fac or provider
 S ^(BMCSORT)=$S($D(^XTMP("BMCRR4",BMCJOB,BMCBTH,"PCC VISITS",BMCSORT)):^(BMCSORT)+1,1:1)
 Q
F ;
 S BMCSORT=$P(BMCVREC,U,6) Q:BMCSORT=""
 Q
P ;
 S BMC2=0,BMCSORT="" F  S BMC2=$O(^AUPNVPRV("AD",BMCVDFN,BMC2)) Q:BMC2=""  I $P(^AUPNVPRV(BMC2,0),U,4)="P" S BMCSORT=$P(^(0),U)
 ;if pcc converted to file 200 quit
 ;if pcc not converted, get 200 pointer from 16 pointer
 Q:'BMCSORT
 Q:$P(^AUTTSITE(1,0),U,22)  ;Test for FILE 200 conversion
 S BMCSORT=$G(^DIC(16,BMCSORT,"A3"))
 Q