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

BPHRCHK.m

Go to the documentation of this file.
  1. BPHRCHK ;GDIT/HS/ALA-PHR System Check ; 16 Feb 2018 11:42 AM
  1. ;;2.1;IHS PERSONAL HEALTH RECORD;**2**;Apr 01, 2014;Build 4
  1. ;
  1. EN ;EP - Check PHR connection with a patient
  1. NEW QFLG,RESULT,DFN,BPHREUID
  1. S QFLG=0 D LIP Q:QFLG
  1. I $P($G(^AUTTLOC(DUZ(2),21)),"^",5)="" D EN^DDIOL("Location "_$P(^DIC(4,DUZ(2),0),"^",1)_" does not have DIRECT email address.","","!!") Q
  1. D PAT(.RESULT,"","","")
  1. I $P($G(RESULT),"^",10)'="" D EN^DDIOL($P(RESULT,"^",10),"","!!") Q
  1. I $P($G(RESULT),"^",1)=0 D EN^DDIOL("Patient is not signed up for PHR.","","!!") Q
  1. I $P($G(RESULT),"^",1)=-1 D EN^DDIOL("Error occurred, please check error log.","","!!") Q
  1. ;accessed PHR (0=No, 1=Yes)^last date^used secure messaging (0=No, 1=Yes)^last date^direct address
  1. I $P($G(RESULT),"^",3)=1 D EN^DDIOL("Patient last accessed PHR on "_$$FMTE^XLFDT($P($G(RESULT),"^",4)),"","!!")
  1. I $P($G(RESULT),"^",7)'="" D EN^DDIOL("Patient has a DIRECT email address","","!!")
  1. Q
  1. ;
  1. EN1 ;EP - Check a patient
  1. NEW QFLG,RESULT,DFN,BPHREUID,RANGE
  1. S QFLG=0 D LIP Q:QFLG
  1. I $P($G(^AUTTLOC(DUZ(2),21)),"^",5)="" D EN^DDIOL("Location does not have DIRECT email address.","","!!") Q
  1. ;Select provider
  1. S QFLG=0 D PROV Q:QFLG
  1. ;
  1. ;Select date range
  1. S QFLG=0,RANGE="" D DAT Q:QFLG
  1. I $G(BDT)'="",$G(EDT)'="" D
  1. . S RANGE=$$FMTE^XLFDT(BDT)_"-"_$$FMTE^XLFDT(EDT)_" "
  1. . D EN^DDIOL("Report Calendar Year is "_RANGE,"","!?5")
  1. ;
  1. ;Select patient
  1. D PAT(.RESULT,BDT,EDT,PROV)
  1. I $P($G(RESULT),"^",10)'="" D EN^DDIOL($P(RESULT,"^",10),"","!!") Q
  1. I $P($G(RESULT),"^",1)=0 D EN^DDIOL("Patient is not signed up for PHR.","","!!?5") Q
  1. I $P($G(RESULT),"^",1)=-1 D EN^DDIOL("Error occurred, please check error log.","","!!?5") Q
  1. ;accessed PHR (0=No, 1=Yes)^last date^used secure messaging (0=No, 1=Yes)^last date^direct address
  1. I $P($G(RESULT),"^",3)=1 D EN^DDIOL("Patient last accessed PHR during Calendar Year "_$$FMTE^XLFDT($P($G(RESULT),"^",4)),"","!!?5")
  1. I $P($G(RESULT),"^",7)'="" D EN^DDIOL("Patient has a DIRECT email address","","!!?5")
  1. I $P($G(RESULT),"^",6)'="" D EN^DDIOL("Patient's last DIRECT message during Calendar Year was "_$$FMTE^XLFDT($P($G(RESULT),"^",6)),"","!!?5")
  1. I $P($G(RESULT),"^",6)="" D
  1. . D EN^DDIOL("Patient does not have a record of a DIRECT message.","","!!?5")
  1. D EN^DDIOL("Patient's Message Agents for Calendar Year "_RANGE_"are: ","","!!?5") D AGNT(DFN)
  1. Q
  1. ;
  1. LIP ;EN - Is this a Test or Production system
  1. NEW PROD
  1. S PROD=$$PROD^XUPROD()
  1. ; PROD=0 is a test system, PROD=1 is a production system
  1. I 'PROD D
  1. . NEW DIR,X,Y,DIRUT,DUOUT,DTOUT,DIROUT
  1. . S DIR("A")="This system has been designated as a TEST system. Is this correct",DIR(0)="Y"
  1. . D ^DIR
  1. . I Y'=1 D EN^DDIOL("Please contact the IHS HELP desk for this issue.","","!!") S QFLG=1
  1. I PROD D
  1. . NEW DIR,X,Y,DIRUT,DUOUT,DTOUT,DIROUT
  1. . S DIR("A")="This system has been designated as a PRODUCTION system. Is this correct",DIR(0)="Y"
  1. . D ^DIR
  1. . I Y'=1 D EN^DDIOL("Please contact the IHS HELP desk for this issue.","","!!") S QFLG=1
  1. Q
  1. ;
  1. PAT(RESULT,BDT,EDT,PROV) ;EP - Patient lookup
  1. D GETPAT^APCDDMUP
  1. I $G(DFN)="" D EN^DDIOL("No patient selected.","","!!") Q
  1. S BPHREUID=$P($G(^DPT(DFN,"MPI")),U,1)
  1. I BPHREUID="" D EN^DDIOL("Patient does not have an MPI EUID","","!!") Q
  1. D PHR^BPHRMUPM(DFN,$G(BDT),$G(EDT),.RESULT,$G(PROV))
  1. Q
  1. ;
  1. DAT ; EP - Date range
  1. NEW DIR,Y,X
  1. S BDT="",EDT=""
  1. K DIR W ! S DIR(0)="DO^::EXP",DIR("A")="Enter Beginning Date"
  1. D ^DIR I $D(DIRUT) S QFLG=1 Q
  1. I Y<0 S QFLG=1 Q
  1. I Y>DT W !!,"Future dates not allowed." G DAT
  1. S BDT=Y
  1. K DIR S DIR(0)="DO^:DT:EXP",DIR("A")="Enter Ending Date"
  1. D ^DIR G:Y<1 DAT
  1. S EDT=Y
  1. I EDT<BDT D G DAT
  1. . D EN^DDIOL("Sorry, Ending Date MUST not be earlier than Beginning Date.","","!!?7")
  1. S BDT=$E(BDT,1,3)_"0101",EDT=$E(BDT,1,3)_"1231"
  1. Q
  1. ;
  1. PROV ; EP - Select provider
  1. NEW DIC,D,Y
  1. D EN^DDIOL("Enter the name of the provider.","","!!")
  1. S DIC="^VA(200,",DIC(0)="AEMQ",D="AK.PROVIDER",DIC("A")="Enter PROVIDER NAME: " D MIX^DIC1 K DIC,D
  1. I Y<0 S QFLG=1 Q
  1. S PROV=+Y
  1. Q
  1. ;
  1. AGNT(DFN) ;EP = Messaging Agent for Patient
  1. NEW BDPCAT,BDPIEN,MSA,BPA,AGN,ADR,BPDATA,NBP,OK,LBP,CURR,CDT,QL
  1. S ADDR=""
  1. S BDPCAT=$$FIND1^DIC(90360.3,,"X","MESSAGE AGENT")
  1. I BDPCAT="" Q ADDR
  1. S BDPIEN=$O(^BDPRECN("AA",DFN,BDPCAT,""))
  1. I BDPIEN="" Q ADDR
  1. ;
  1. I $P(^BDPRECN(BDPIEN,0),"^",3)="" D EN^DDIOL("No Current Message Agent","","!?7")
  1. S BPA=0
  1. F S BPA=$O(^BDPRECN(BDPIEN,1,BPA)) Q:'BPA D
  1. . S BPDATA=^BDPRECN(BDPIEN,1,BPA,0)
  1. . S MSA=$P(^BDPRECN(BDPIEN,1,BPA,0),"^",1)
  1. . S AGN(BPA)=MSA_"^"_$P(BPDATA,"^",3),LBP=BPA
  1. . ; Check the next agent in the history
  1. . S NBP=$O(^BDPRECN(BDPIEN,1,BPA)) I 'NBP D Q
  1. .. S QL=0 D CMA
  1. .. I 'QL S $P(AGN(BPA),"^",3)=DT Q
  1. .. I QL S $P(AGN(BPA),"^",3)=CDT
  1. . S $P(AGN(BPA),"^",3)=$P(^BDPRECN(BDPIEN,1,NBP,0),"^",3)
  1. ;
  1. I CURR'="",$P(^BDPRECN(BDPIEN,1,LBP,0),"^",1)'=CURR D
  1. . S AGN(LBP+1)=CURR_"^"_CDT_"^"_DT
  1. ;
  1. S MS="" F S MS=$O(AGN(MS)) Q:MS="" D
  1. . S OK=0
  1. . I EDT<$P(AGN(MS),"^",2)!(BDT>$P(AGN(MS),"^",3)) Q
  1. . I BDT'<$P(AGN(MS),"^",2),BDT'>$P(AGN(MS),"^",3) S OK=1
  1. . I EDT'<$P(AGN(MS),"^",2),EDT'>$P(AGN(MS),"^",3) S OK=1
  1. . ;
  1. . I BDT'>$P(AGN(MS),"^",2),EDT'<$P(AGN(MS),"^",2) S OK=1
  1. . I BDT'>$P(AGN(MS),"^",3),EDT'<$P(AGN(MS),"^",3) S OK=1
  1. . ;
  1. . I OK D
  1. .. S MSA=$P(AGN(MS),"^",1)
  1. .. S ADR=$$LOW^XLFSTR($P($G(^BDPMSGA(MSA,0)),"^",2))
  1. .. I ADR'["direct" Q
  1. .. D EN^DDIOL(ADR_" "_$$FMTE^XLFDT($P(AGN(MS),"^",2))_" - "_$$FMTE^XLFDT($P(AGN(MS),"^",3)),"","!?7")
  1. Q
  1. ;
  1. CMA ;EP - Check for current messaging agent
  1. S CURR=$P(^BDPRECN(BDPIEN,0),"^",3),CDT=$P(^(0),"^",5)
  1. I CURR="" Q
  1. ; If the current provider is matching the last provider in the history
  1. I $P(^BDPRECN(BDPIEN,1,LBP,0),"^",1)=CURR Q
  1. S QL=1
  1. Q