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

BDPLINKI.m

Go to the documentation of this file.
  1. BDPLINKI ; IHS/CMI/TMJ - LINK ROUTINE ON PARM PASS FROM THE DESG PROV PKG ;
  1. ;;2.0;IHS PCC SUITE;;MAY 14, 2009
  1. ;
  1. ;
  1. ;
  1. START ;Get Record Information
  1. ;
  1. ;
  1. UPDATE(BDPFILE,BDPFIELD,BDPDA,BDPPROV,BDPPAT,BDPLINKI) ;PEP Update Record
  1. I '$G(BDPLINKI) Q ;don't process if coming from non-bdp
  1. ;this entry point is called from xrefs on various
  1. ;files/fields to update the current designated
  1. ;provider package
  1. ;called from 90360.1
  1. ;
  1. ;I $G(BDPLNKO)=1 Q ;Quit this routine - BDPKLINKO is running
  1. ;
  1. I $G(BDPFILE)=9002086,$$INSTALLD("BW.3.0") Q ;not with version 3.0
  1. I $G(BDPFILE)="" Q
  1. I $G(BDPFIELD)="" Q
  1. I $G(BDPDA)="" Q
  1. I $G(BDPPROV)="" Q ;bdpprov is the pointer to file 200
  1. I $G(BDPPAT)="" Q
  1. D EN^XBNEW("UPDATE1^BDPLINKI","BDPFILE;BDPFIELD;BDPDA;BDPPROV;BDPPAT;BDPLINKI")
  1. Q
  1. ;
  1. UPDATE1 ;
  1. ;special code to take care of 9000001 file 6/200 issue
  1. I BDPFILE=9000001,$P(^DD(9000001,.14,0),U,2)[6 S BDPPROV=$P(^VA(200,BDPPROV,0),U,16) I BDPPROV="" Q ;can't process if no file 200 ptr
  1. ;
  1. ;
  1. ;
  1. S BDPTYPE=$P($G(^BDPRECN(BDPDA,0)),U) ;Get Type
  1. Q:BDPTYPE=""
  1. I BDPTYPE=2 D MHLINK Q
  1. I BDPTYPE=3 D SSLINK Q
  1. I BDPTYPE=4 D CDLINK Q
  1. I BDPTYPE=8 D WHLINK Q
  1. I BDPTYPE=1 D DPLINK Q
  1. E Q ;Quit if no Link
  1. Q
  1. ;
  1. ;This Adds a new record if none exist
  1. ;Updates the existing Patient Record if different Provider
  1. S BDPMHIEN=$O(^AMHPATR("B",BDPPAT,"")) ;MHIEN RECORD
  1. Q:BDPMHIEN="" ;Quit if no Record found for this patient
  1. S BDPPRVCK=$P($G(^AMHPATR(BDPMHIEN,0)),U,2) ;Existing MH Prov
  1. Q:BDPPRVCK=BDPPROV ;Quit if same Provider
  1. S DIE="^AMHPATR(",DA=BDPMHIEN,DR=".02///"_"`"_BDPPROV D ^DIE K DIE,DR,DA,DINUM
  1. Q
  1. ;
  1. ;This Adds a new record if none exist
  1. ;Updates the existing Patient Record if different Provider
  1. S BDPSSIEN=$O(^AMHPATR("B",BDPPAT,"")) ;SSIEN RECORD
  1. Q:BDPSSIEN="" ;Quit if no Record found for this patient
  1. S BDPPRVCK=$P($G(^AMHPATR(BDPSSIEN,0)),U,3) ;Existing SS Prov
  1. Q:BDPPRVCK=BDPPROV ;Quit if same Provider
  1. S DIE="^AMHPATR(",DA=BDPSSIEN,DR=".03///"_"`"_BDPPROV D ^DIE K DIE,DR,DA,DINUM
  1. Q
  1. ;
  1. ;
  1. ;This Adds a new record if none exist
  1. ;Updates the existing Patient Record if different Provider
  1. S BDPCDIEN=$O(^AMHPATR("B",BDPPAT,"")) ;CDIEN RECORD
  1. Q:BDPCDIEN="" ;Quit if no Record found for this patient
  1. S BDPPRVCK=$P($G(^AMHPATR(BDPCDIEN,0)),U,4) ;Existing CD Prov
  1. Q:BDPPRVCK=BDPPROV ;Quit if same Provider
  1. S DIE="^AMHPATR(",DA=BDPCDIEN,DR=".04///"_"`"_BDPPROV D ^DIE K DIE,DR,DA,DINUM
  1. Q
  1. ;
  1. ;This Adds a new record if none exist
  1. ;Updates the existing Patient Record if different Provider
  1. S BDPWHIEN=$O(^BWP("B",BDPPAT,"")) ;WHIEN RECORD
  1. Q:BDPWHIEN="" ;Quit if no Record found for this patient
  1. S BDPPRVCK=$P($G(^BWP(BDPWHIEN,0)),U,10) ;Existing WH Prov
  1. Q:BDPPRVCK=BDPPROV ;Quit if same Provider
  1. S DIE="^BWP(",DA=BDPWHIEN,DR=".1///"_"`"_BDPPROV D ^DIE K DIE,DR,DA,DINUM
  1. Q
  1. ;
  1. ;This Adds a new record if none exist
  1. ;Updates the existing Patient Record if different Provider
  1. S BDPDPIEN=$O(^AUPNPAT("B",BDPPAT,"")) ;DPIEN RECORD
  1. Q:BDPDPIEN="" ;Quit if no Record found for this patient
  1. S BDPPRVCK=$P($G(^AUPNPAT(BDPDPIEN,0)),U,14) ;Existing DPP Prov
  1. Q:BDPPRVCK=BDPPROV ;Quit if same Provider
  1. S DIE="^AUPNPAT(",DA=BDPDPIEN,DR=".14///"_"`"_BDPPROV D ^DIE K DIE,DR,DA,DINUM
  1. Q
  1. ;
  1. ;
  1. ;
  1. ;
  1. KILL(BDPFILE,BDPFIELD,BDPDA,BDPPROV,BDPPAT,BDPLINKI) ;PEP - called from kill side of xrefs
  1. I '$G(BDPLINKI) Q ;don't process if coming from non-bdp
  1. I $G(BDPFILE)="" Q
  1. I $G(BDPFIELD)="" Q
  1. I $G(BDPDA)="" Q
  1. I $G(BDPPROV)="" Q ;bdpprov is the pointer to file 200
  1. I $G(BDPPAT)="" Q
  1. D EN^XBNEW("KILL1^BDPLINKI","BDPFILE;BDPFIELD;BDPDA;BDPPROV;BDPPAT;BDPLINKI")
  1. Q
  1. KILL1 ;EP - CALLED FROM XBNEW
  1. ;This Adds a new record if none exist
  1. ;Updates the existing Patient Record if different Provider
  1. ;
  1. S BDPTYPE=$P($G(^BDPRECN(BDPDA,0)),U) ;Get Type
  1. Q:BDPTYPE=""
  1. I BDPTYPE=2 D MHKILL Q
  1. I BDPTYPE=3 D SSKILL Q
  1. I BDPTYPE=4 D CDKILL Q
  1. I BDPTYPE=8 D WHKILL Q
  1. I BDPTYPE=1 D DPKILL Q
  1. E Q ;Quit if no Link
  1. Q
  1. ;
  1. ;
  1. MHKILL ;Kill Mental Health Record
  1. S BDPMHIEN=$O(^AMHPATR("B",BDPPAT,"")) ;MHIEN RECORD
  1. Q:BDPMHIEN="" ;Quit if no Record found for this patient
  1. S BDPPRVCK=$P($G(^AMHPATR(BDPMHIEN,0)),U,2) ;Existing MH Prov
  1. ;Q:BDPPRVCK=BDPPROV ;Quit if same Provider
  1. ;Q:BDPTYIEN="" ;Quit if this type is not linked
  1. ;Q:BDPRIEN="" ;NO entry of this type for this patient
  1. ;now delete last current provider field
  1. S DIE="^AMHPATR(",DA=BDPMHIEN,DR=".02///@" D ^DIE
  1. D ^XBFMK
  1. Q
  1. ;
  1. SSKILL ;Social Services Kill
  1. S BDPSSIEN=$O(^AMHPATR("B",BDPPAT,"")) ;SSIEN RECORD
  1. Q:BDPSSIEN="" ;Quit if no Record found for this patient
  1. S BDPPRVCK=$P($G(^AMHPATR(BDPSSIEN,0)),U,3) ;Existing SS Prov
  1. ;Q:BDPPRVCK=BDPPROV ;Quit if same Provider
  1. ;Q:BDPTYIEN="" ;Quit if this type is not linked
  1. ;Q:BDPRIEN="" ;NO entry of this type for this patient
  1. ;now delete last current provider field
  1. S DIE="^AMHPATR(",DA=BDPSSIEN,DR=".03///@" D ^DIE
  1. D ^XBFMK
  1. Q
  1. ;
  1. CDKILL ;Chemical Dependency Kill
  1. S BDPCDIEN=$O(^AMHPATR("B",BDPPAT,"")) ;CDIEN RECORD
  1. Q:BDPCDIEN="" ;Quit if no Record found for this patient
  1. S BDPPRVCK=$P($G(^AMHPATR(BDPCDIEN,0)),U,4) ;Existing MH Prov
  1. ;Q:BDPPRVCK=BDPPROV ;Quit if same Provider
  1. ;Q:BDPTYIEN="" ;Quit if this type is not linked
  1. ;Q:BDPRIEN="" ;NO entry of this type for this patient
  1. ;now delete last current provider field
  1. S DIE="^AMHPATR(",DA=BDPCDIEN,DR=".04///@" D ^DIE
  1. D ^XBFMK
  1. Q
  1. ;
  1. WHKILL ;Womens Health Kill
  1. S BDPWHIEN=$O(^BWP("B",BDPPAT,"")) ;WHIEN RECORD
  1. Q:BDPWHIEN="" ;Quit if no Record found for this patient
  1. S BDPPRVCK=$P($G(^BWP(BDPWHIEN,0)),U,10) ;Existing MH Prov
  1. ;Q:BDPPRVCK=BDPPROV ;Quit if same Provider
  1. ;Q:BDPTYIEN="" ;Quit if this type is not linked
  1. ;Q:BDPRIEN="" ;NO entry of this type for this patient
  1. ;now delete last current provider field
  1. S DIE="^BWP(",DA=BDPWHIEN,DR=".1///@" D ^DIE
  1. D ^XBFMK
  1. Q
  1. ;
  1. DPKILL ;Patient Care Primary Provider Kill
  1. S BDPDPIEN=$O(^AUPNPAT("B",BDPPAT,"")) ;DPIEN RECORD
  1. Q:BDPDPIEN="" ;Quit if no Record found for this patient
  1. S BDPPRVCK=$P($G(^AUPNPAT(BDPDPIEN,0)),U,14) ;Existing MH Prov
  1. ;Q:BDPPRVCK=BDPPROV ;Quit if same Provider
  1. ;Q:BDPTYIEN="" ;Quit if this type is not linked
  1. ;Q:BDPRIEN="" ;NO entry of this type for this patient
  1. ;now delete last current provider field
  1. S DIE="^AUPNPAT(",DA=BDPDPIEN,DR=".14///@" D ^DIE
  1. D ^XBFMK
  1. Q
  1. ;
  1. INSTALLD(BDPSTAL) ;EP - Determine if patch BDPSTAL was installed, where
  1. ; BDPSTAL is the name of the INSTALL. E.g "AG*6.0*11".
  1. ;
  1. NEW BDPY,DIC,X,Y
  1. S X=$P(BDPSTAL,"*",1)
  1. S DIC="^DIC(9.4,",DIC(0)="FM",D="C"
  1. D IX^DIC
  1. I Y<1 Q 0
  1. S DIC=DIC_+Y_",22,",X=$P(BDPSTAL,"*",2)
  1. D ^DIC
  1. I Y<1 Q 0
  1. S DIC=DIC_+Y_",""PAH"",",X=$P(BDPSTAL,"*",3)
  1. D ^DIC
  1. S BDPY=Y
  1. Q $S(BDPY<1:0,1:1)