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

BMCCLOS3.m

Go to the documentation of this file.
BMCCLOS3 ; IHS/OIT/FCJ - PROCESS REFERRAL CLOSURES ;    
 ;;4.0;REFERRED CARE INFO SYSTEM;**2**;JAN 09, 2006;Build 101
 ;IHS/OIT/FCJ DO NOT SKIP SR;REWROTE ROUTINE TO PROVIDE DOS SORT
 ;
 ;
 ;
DRI ;DATE REF INITIATED
 S BMCCT=0,BMCODAT=BMCSD
 F  S BMCODAT=$O(^BMCREF("B",BMCODAT))  Q:(BMCODAT>BMCED)!(BMCODAT'=+BMCODAT)  D
 .S BMCREF="" F  S BMCREF=$O(^BMCREF("B",BMCODAT,BMCREF))  Q:BMCREF'=+BMCREF  D PROCESS
 D END Q
DOS ;DATE OF SERVICE SORT     
 S BMCCT=0,BMCODAT=BMCSD
 F  S BMCODAT=$O(^BMCREF("BA",BMCODAT)) Q:(BMCODAT>BMCED)!(BMCODAT'=+BMCODAT)  D
 .S BMCREF="" F  S BMCREF=$O(^BMCREF("BA",BMCODAT,BMCREF)) Q:BMCREF'?1N.N  D
 ..S BMCADOS=$P(^BMCREF(BMCREF,11),U,6)
 ..I BMCADOS=+BMCADOS Q:(BMCADOS<BMCSD)!(BMCADOS>BMCED)
 ..D PROCESS
 S BMCODAT=BMCSD
 F  S BMCODAT=$O(^BMCREF("BB",BMCODAT)) Q:(BMCODAT>BMCED)!(BMCODAT'=+BMCODAT)  D
 .S BMCREF="" F  S BMCREF=$O(^BMCREF("BB",BMCODAT,BMCREF)) Q:BMCREF'=+BMCREF  S BMCR="REC2" D PROCESS
 D END Q
PROCESS ;
 S BMCRREC=^BMCREF(BMCREF,0),DFN=$P(BMCRREC,U,3)
 I BMCKIND'="A" Q:$P(BMCRREC,U,4)'=BMCKIND  ;Q NOT Ref Type
 Q:$P(BMCRREC,U,5)'=BMCFAC
 I $D(^BMCREF(BMCREF,21,"B",BMCLCAT)) Q
 S BMCRIEN=BMCREF
 S BMCTYPE=$P(BMCRREC,U,14)
 Q:BMCTYPE=""
 I BMCTYP'="B" Q:BMCTYP'=BMCTYPE  ;Q if Inpt/Outpt does not Match Ref
 Q:$$VALI^XBDIQ1(90001,BMCRIEN,".15")="C1"  ;Quit if already closed
 S BMCADOS=$$VALI^XBDIQ1(90001,BMCRIEN,1106)
 S BMCCLS=$S(BMCADOS="":"X",1:"C1")
 S DA=BMCRIEN,DIE="^BMCREF(",DR=".15////"_BMCCLS D ^DIE K DIE
 W !,?10,"Closed Referral #: "_$P(^BMCREF(BMCRIEN,0),U,2)
 W ?55,"IEN #: "_BMCRIEN W !
 S BMCCT=BMCCT+1
 Q
 ;
 ;
PCCL ;PCC Link - No Need to Link these Visits - CHS Visit Closure ONLY
 ;I $$VALI^XBDIQ1(90001,BMCRIEN,".15")="C1" D ^BMCPCCL
 ;
END ;End of Closure
 W !,"End of Auto Close of Referrals - Total Number of Referrals Closed = "_BMCCT
 Q