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

MPIFDEL.m

Go to the documentation of this file.
  1. MPIFDEL ;SF/MJM,CMC-DELETE PATIENT FROM MPI ;JUL 14, 1998
  1. ;;1.0; MASTER PATIENT INDEX VISTA ;**1,3,9,19,17,21,27,28,25**;30 Apr 99
  1. ;
  1. ;Integration Agreements Utilized:
  1. ; ^DPT( - IA #2070
  1. ; $$EN^VAFCPID - IA #3015
  1. ; START^RGHLLOG - IA #2796
  1. ; EXC^RGHLLOG - IA #2796
  1. ; STOP^RGHLLOG - IA #2796
  1. ; $$DELALLTF^VAFCTFU - IA #2988
  1. ; $$EN^VAFCPID - IA #3015
  1. ;
  1. INTER ;
  1. ;Entry point for Inactivate Patient from MPI option [MPIF PAT INACT]
  1. ;No input or output variables ^DPT
  1. N DIC,DA,DFN,HL,ERROR,CNT,HLRST,ICN,DATE,MPIFCMOR,DTOUT,DUTOUT
  1. S ERROR=""
  1. S DIC=2,DIC(0)="QEAM" D ^DIC Q:+Y<0 S DFN=+Y
  1. S ICN=$P($$MPINODE^MPIFAPI(DFN),"^")
  1. I ICN=""!(ICN=-1) W !,"** Patient Does NOT have an ICN **" Q
  1. S MPIFCMOR=+$$LKUP^XUAF4(+$$GETVCCI^MPIF001(DFN))
  1. I MPIFCMOR=0 W !,"*** Could NOT Inactivate Patient from MPI: Coordinating Master of Record is Not Defined ***" Q
  1. I $$PAT^MPIFNQ(DFN)'=+$P($$SITE^VASITE,"^",3) W !,"*** Could NOT Inactivate Patient from MPI: Coordinating Master of record site is '"_$$CMOR2^MPIF001(DFN)_"'. You MUST be the CMOR ***" Q
  1. S ICN=$$GETICN^MPIF001(DFN)
  1. ;ask user if they are sure
  1. N DIR,Y S DIR(0)="Y",DIR("B")="No"
  1. S DIR("A")="Are you sure you want to Inactivate this Patient?"
  1. D ^DIR
  1. K DIR
  1. Q:$D(DTOUT)!($D(DUTOUT))!('Y)
  1. D HL7(DFN,.ERROR)
  1. I ERROR="" D DELETE(DFN) S ERROR=$$DELALLTF^VAFCTFU(+ICN),ERROR=""
  1. I ERROR=""!(ERROR=0) W !,"*** Inactivated on YOUR system, message sent to MPI to Inactivate ***"
  1. I ERROR'="" W !,"Error Occurred - "_ERROR
  1. Q
  1. ;
  1. HL7(DFN,ERROR) ; create HL7 message
  1. ; check if no subscribers
  1. N SUB,HL,CNT,ICN,%,HLDATE,TFC,IEN
  1. K HLL,MPIFDEL
  1. S ICN=$$GETICN^MPIF001(DFN),ERROR=""
  1. Q:$E(ICN,1,3)=$P($$SITE^VASITE(),"^",3)
  1. ; ^ don't generate HL7 message if local ICN
  1. S SUB=$$QUERYTF^VAFCTFU1(+ICN,"MPIFDEL"),TFC=0
  1. I $D(MPIFDEL) D
  1. .S IEN="" F S IEN=$O(MPIFDEL(IEN)) Q:IEN="" I +$G(MPIFDEL(IEN))'=$P($$SITE^VASITE,"^") S TFC=TFC+1
  1. .I TFC'=0 S ERROR="Attempted to Inactivate an ICN and Patient is Shared. Can't Inactivate patient DFN= "_DFN Q
  1. Q:ERROR'=""
  1. D NOW^%DTC S HLDATE=$$HLDATE^HLFNC(%,"DT")
  1. S HL=0,CNT=0
  1. D INIT^HLFNC2("MPIF A29 SERVER",.HL)
  1. I HL S ERROR="ERROR = "_HL_" During INIT^HLFNC2 for MPIF A29 Server for Patient DFN= "_DFN D EXC(DFN,ERROR,220)
  1. S CNT=CNT+1,HLA("HLS",CNT)="EVN"_HL("FS")_"A29"_HL("FS")_HLDATE_HL("FS")_HL("FS")_""_HL("FS")
  1. S CNT=CNT+1,HLA("HLS",CNT)=$$EN^VAFCPID(DFN,"2,3,5")
  1. ; message only goes to MPI Link
  1. D GENERATE^HLMA("MPIF A29 SERVER","LM",1,.HLRST,"",.HL)
  1. I 'HLRST S ERROR="Error During Generate for MPIF A29 Server Error= "_HLRST_" for DFN "_DFN D EXC(DFN,ERROR,220)
  1. K MPIFDEL
  1. Q
  1. ;
  1. PAT1 ;entry point for tasked job from .01 in Patient file for ZZ patients
  1. N ERR,TDA
  1. S ERR=""
  1. S TDA=DA
  1. L +^DPT("INAC",DA):2
  1. Q:'$T
  1. D PAT(DA,.ERR)
  1. S ZTREQ="@"
  1. L -^DPT("INAC",TDA)
  1. Q
  1. ;
  1. PAT(DFN,ERROR) ;Programmer API to Delete MPI entry and remove ICN data from DPT
  1. ; if CMOR not defined but is a local CMOR, inactivate and don't log exception
  1. S ERROR=""
  1. I $G(DFN)="" S ERROR="DFN not defined" Q
  1. Q:+$$GETICN^MPIF001(DFN)<0 ; incase has been inactivated already
  1. I $E($P($$GETICN^MPIF001(DFN),"^"),1,3)'=+$P($$SITE^VASITE,"^",3),+$$PAT^MPIFNQ(DFN)'=+$P($$SITE^VASITE,"^",3) S ERROR="Attempt to Inactivate Patient, DFN= "_DFN_" this site is not the CMOR for this patient" D EXC(DFN,ERROR,226) Q
  1. D HL7(DFN,.ERROR)
  1. I ERROR="" S ERROR=$$DELALLTF^VAFCTFU(+$$GETICN^MPIF001(DFN)),ERROR="" D DELETE(DFN)
  1. Q
  1. DELETE(DFN) ;
  1. N ARRAY,TMP
  1. S ARRAY(991.01)="@",ARRAY(991.02)="@",ARRAY(991.03)="@",ARRAY(991.04)="@",ARRAY(991.05)="@"
  1. S ARR="ARRAY"
  1. S TMP=$$UPDATE^MPIFAPI(DFN,ARR)
  1. K ARR
  1. Q
  1. ;
  1. EXC(DFN,ERROR,TYPE) ; subscribers, log exception
  1. D START^RGHLLOG(0)
  1. D EXC^RGHLLOG(TYPE,ERROR,$G(DFN))
  1. D STOP^RGHLLOG(0)
  1. Q
  1. ;
  1. ZZSET(DA,NAME) ;this entry point checks to see if .01 of Patient file entry
  1. ;starts with at least two Zs
  1. ;if it does and an ICN is present, it will be inactivated
  1. ;
  1. Q
  1. Q:$E(NAME,1,2)'="ZZ"
  1. ;task inactivation off
  1. I +$$GETICN^MPIF001(DA)>0 D
  1. .S ZTRTN="PAT1^MPIFDEL",ZTDESC="Inactivate ICN for 'ZZ'd patient"
  1. .S ZTIO="",ZTSAVE("DA")=DA,ZTSAVE("NAME")=NAME
  1. .S ZTDTH=$$FMADD^XLFDT($$NOW^XLFDT,0,0,1,0)
  1. .D ^%ZTLOAD
  1. .K ZTRTN,ZTDESC,ZTIO,ZTSAVE,ZTDTH,ZTREQ
  1. Q
  1. ZZKILL(DA,NAME) ;This entry point checks if there is an ICN present, if so
  1. ;if will be inactivated, following the inactivate rules
  1. Q
  1. N ERR S ERR=""
  1. I +$$GETICN^MPIF001(DA)>0 D PAT(DA,.ERR)
  1. Q
  1. SSET(DA,SSN) ; this entry point checks to see if the SSN has been changed
  1. ; to 5 leading zeros and if the ICN is present, if so, it will be
  1. ; inactivated.
  1. Q:$E(SSN,1,5)'="00000"
  1. I +$$GETICN^MPIF001(DA)>0 D
  1. .S ZTRTN="PAT1^MPIFDEL",ZTDESC="Inactivate ICN for 'ZZ'd patient"
  1. .S ZTIO="",ZTSAVE("DA")=DA,ZTSAVE("SSN")="SSN"
  1. .S ZTDTH=$$FMADD^XLFDT($$NOW^XLFDT,0,0,1,0)
  1. .D ^%ZTLOAD
  1. .K ZTRTN,ZTDESC,ZTIO,ZTSAVE,ZTDTH,ZTREQ
  1. Q