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

MPIFEXT.m

Go to the documentation of this file.
  1. MPIFEXT ;SFCIO/CMC-EXTENDED PDAT - RPC ;9 Apr 2013 4:42 PM
  1. ;;1.0;MASTER PATIENT INDEX VISTA;**20,57**;30 Apr 99;Build 2
  1. ;
  1. ;Integration Agreements Utilized:
  1. ; ^DGCN(391.91 - #2751
  1. ; EN1^XWB2HL7 - #3144
  1. ; RPCCHK^XWB2HL7 - #3144
  1. ; RTNDATA^XEBDRPC - #3149
  1. ;
  1. PEXT(RETURN,ICN,SSN,LOCAL,ALL,SITE,RPC) ;get patient info array
  1. N MPINODE,ARRAY,DFN,TICN,TSSN
  1. I RPC="" S RPC=0 ; default is 0 for RPC
  1. I $G(ICN)=""&($G(SSN)="") S RETURN="-1^NO ICN OR SSN PASSED" Q
  1. I $G(LOCAL)=""&($G(ALL)="")&($G(SITE)="") S ALL=1
  1. ; ^ All is the default
  1. I LOCAL=1 D PATINFO^MPIFEXT2(.RETURN,ICN,SSN,0) Q
  1. I ALL=1 D ALL(.RETURN,ICN,SSN,RPC) Q
  1. I SITE'="" D SITE(.RETURN,ICN,SSN,SITE,RPC)
  1. Q
  1. ;
  1. SITE(RETS,ICN,SSN,SITE,RPC) ;
  1. ; request PDAT from one remote site
  1. I $G(SITE)="" S RETS="-1^No Site Passed" Q
  1. I $G(ICN)=""&($G(SSN)="") S RETS="-1^No ICN or SSN passed" Q
  1. I ICN="" S EXIST=$$ASK(SSN,SITE)
  1. I SSN="" S EXIST=$$ASK(ICN,SITE)
  1. I EXIST=1 D
  1. .I ICN="" S RETS(0)=$G(^XTMP("MPIF EXT PDAT"_SSN,SITE))
  1. .I SSN="" S RETS(0)=$G(^XTMP("MPIF EXT PDAT"_ICN,SITE))
  1. .I RETS(0)="" S EXIST=0
  1. I EXIST=0 D
  1. .I ICN="" K ^XTMP("MPIF EXT PDAT"_SSN,SITE)
  1. .I SSN="" K ^XTMP("MPIF EXT PDAT"_ICN,SITE)
  1. .D EN1^XWB2HL7(.RETS,SITE,"MPIF EXT PDAT REMOTE",1,ICN,SSN,1)
  1. .I $G(ICN)'="" S ^XTMP("MPIF EXT PDAT"_ICN,0)=$$FMADD^XLFDT($$NOW^XLFDT,2)_"^"_$$NOW^XLFDT_"^"_"Remote data from site",^XTMP("MPIF EXT PDAT"_ICN,SITE)=RETS(0)
  1. .I $G(SSN)'="" S ^XTMP("MPIF EXT PDAT"_SSN,0)=$$FMADD^XLFDT($$NOW^XLFDT,2)_"^"_$$NOW^XLFDT_"^"_"Remote data from site",^XTMP("MPIF EXT PDAT"_SSN,SITE)=RETS(0)
  1. ;
  1. ;**57,MVI_1414 (mko): Call RPCCHK^XWB2HL7 to check for results
  1. N CNT
  1. F CNT=1:1:10 K RES D RPCCHK^XWB2HL7(.RES,RETS(0)) Q:+RES(0)=1 Q:+RES(0)=-1 H 2
  1. I +RES(0)=-1 S RETS=RES(0) Q
  1. I +RES(0)'=1 S RETS(SITE)="Unable to get data" Q
  1. K RES D RTNDATA^XWBDRPC(.RES,RETS(0))
  1. ;S CNT=0
  1. ;AGAIN H 2 K RES D RTNDATA^XWBDRPC(.RES,RETS(0)) S CNT=CNT+1
  1. ;I +RES(0)=-1&(RES(0)["Not DONE") I CNT<10 G AGAIN
  1. ;I +RES(0)=-1&(RES(0)["Not DONE") I CNT>10 S RETS(SITE)="Unable to get data" Q
  1. ;I RES(0)="0^New" I CNT<10 G AGAIN
  1. ;I RES(0)="0^New" I CNT>10 S RETS(SITE)="Unable to get data" Q
  1. ;I +RES(0)=-1 S RETS=RES(0) Q
  1. ;I RES'="" I CNT<10 G AGAIN
  1. ;I RES'="" I CNT>10 S RETS(SITE)="Unable to get data" Q
  1. D REFORMAT(.RES)
  1. K RETS,EXIST
  1. M RETS(SITE)=RES
  1. K RES
  1. Q
  1. ;
  1. ALL(RETS2,ICN,SSN,RPC) ;
  1. ; request PDAT from ALL TFs and the MPI
  1. I $G(ICN)=""&($G(SSN)="") S RETS1="-1^No ICN or SSN passed" Q
  1. N DFN,ICN2
  1. I ICN="" S EXIST=$$ASK(SSN,1)
  1. I SSN="" S EXIST=$$ASK(ICN,1)
  1. I SSN'="" S ICN=$$GETICNS^MPIF002(SSN)
  1. F XX=1:1 S ICN2=$P(ICN,"^",XX) Q:ICN2="" D
  1. .S DFN=$$GETDFN^MPIF001(ICN2)
  1. .I +DFN<0 S RETS2(ICN2)="-1^No such ICN" Q
  1. .D ALL2(DFN,ICN2,SSN,1,.RETS2,EXIST)
  1. K EXIST
  1. Q
  1. ;
  1. ALL2(DFN,ICN,SSN,RPC,RETS1,EXIST) ;
  1. D GETTFS(DFN,.ARR)
  1. I +ARR=-1 G MPI
  1. S SITE=""
  1. F S SITE=$O(ARR(SITE)) Q:SITE="" D
  1. .K RETS1
  1. .I EXIST=1 D
  1. ..I ICN="" S RETS1(0)=$G(^XTMP("MPIF EXT PDAT"_SSN,SITE))
  1. ..I SSN="" S RETS1(0)=$G(^XTMP("MPIF EXT PDAT"_ICN,SITE))
  1. ..I RETS1(0)="" S EXIST=0
  1. .I EXIST=0 D
  1. ..I ICN="" K ^XTMP("MPIF EXT PDAT"_SSN,SITE)
  1. ..I SSN="" K ^XTMP("MPIF EXT PDAT"_ICN,SITE)
  1. ..D EN1^XWB2HL7(.RETS1,SITE,"MPIF EXT PDAT REMOTE",1,ICN,SSN,RPC)
  1. ..I $G(ICN)'="" S ^XTMP("MPIF EXT PDAT"_ICN,SITE,0)=$$FMADD^XLFDT($$NOW^XLFDT,2)_"^"_$$NOW^XLFDT_"^"_"Remote data from site",^XTMP("MPIF EXT PDAT"_ICN,SITE)=RETS1(0)
  1. ..I $G(SSN)'="" S ^XTMP("MPIF EXT PDAT"_SSN,SITE,0)=$$FMADD^XLFDT($$NOW^XLFDT,2)_"^"_$$NOW^XLFDT_"^"_"Remote data from site",^XTMP("MPIF EXT PDAT"_SSN,SITE)=RETS1(0)
  1. ;
  1. MPI K RETS1
  1. I EXIST=1 D
  1. .I ICN="" S RETS1(0)=$G(^XTMP("MPIF EXT PDAT"_SSN,"MPI"))
  1. .I SSN="" S RETS1(0)=$G(^XTMP("MPIF EXT PDAT"_ICN,"MPI"))
  1. .I RETS1(0)="" S EXIST=0
  1. I EXIST=0 D
  1. .I ICN="" K ^XTMP("MPIF EXT PDAT"_SSN,"MPI")
  1. .I SSN="" K ^XTMP("MPIF EXT PDAT"_ICN,"MPI")
  1. .D EN1^XWB2HL7(.RETS1,"MPI","MPIF EXT PDAT REMOTE",1,ICN,SSN,RPC)
  1. .I $G(ICN)'="" S ^XTMP("MPIF EXT PDAT"_ICN,"MPI",0)=$$FMADD^XLFDT($$NOW^XLFDT,2)_"^"_$$NOW^XLFDT_"^"_"Remote data from site",^XTMP("MPIF EXT PDAT"_ICN,"MPI")=RETS1(0)
  1. .I $G(SSN)'="" S ^XTMP("MPIF EXT PDAT"_SSN,"MPI",0)=$$FMADD^XLFDT($$NOW^XLFDT,2)_"^"_$$NOW^XLFDT_"^"_"Remote data from site",^XTMP("MPIF EXT PDAT"_SSN,"MPI")=RETS1(0)
  1. ;
  1. K RETS1,RES,RESS2
  1. N ZNODE,IEN
  1. H 2
  1. I SSN="" S IEN=ICN
  1. I ICN="" S IEN=SSN
  1. S SITE=""
  1. F S SITE=$O(^XTMP("MPIF EXT PDAT"_IEN,SITE)) Q:SITE="" D
  1. .S ZNODE=$G(^XTMP("MPIF EXT PDAT"_IEN,SITE))
  1. .K RES
  1. .D RET(.RES,SITE,ZNODE)
  1. .K RETS1(SITE)
  1. .M RETS1(SITE)=RES
  1. .K RES
  1. ;
  1. K RES,RESS2
  1. D PATINFO^MPIFEXT2(.RESS2,ICN,SSN,0)
  1. S SITE=$P($$SITE^VASITE,"^",3)
  1. K RETS1(SITE)
  1. M RETS1(SITE)=RESS2
  1. K RESS2,ARR
  1. Q
  1. ;
  1. RET(REST,SITE,IEN) ;
  1. ; RETRIEVING DATA
  1. ;**57,MVI_1414 (mko): Call RPCCHK^XWB2HL7 to check for results
  1. N RES1,CNT
  1. F CNT=1:1:10 K RES1 D RPCCHK^XWB2HL7(.RES1,IEN) Q:+RES1(0)=1 Q:+RES1(0)=-1 H 2
  1. I +RES1(0)=-1 S REST=RES1(0) Q
  1. I +RES1(0)'=1 S REST(SITE)="Unable to get data" Q
  1. K RES1 D RTNDATA^XWBDRPC(.RES1,IEN)
  1. ;N RES1,CNT S CNT=0
  1. ;AGAIN1 H 2 K RES1,REST D RTNDATA^XWBDRPC(.RES1,IEN) S CNT=CNT+1
  1. ;I +RES1(0)=-1&(RES1(0)["Not DONE") I CNT<10 G AGAIN1
  1. ;I +RES1(0)=-1&(RES1(0)["Not DONE") I CNT>10 S REST(SITE)="Unable to get data" Q
  1. ;I RES1(0)="0^New" I CNT<10 G AGAIN1
  1. ;I RES1(0)="0^New" I CNT>10 S REST(SITE)="Unable to get data" Q
  1. ;I +RES1(0)=-1 S REST(SITE)=RES1(0) Q
  1. ;I RES1'="" I CNT<10 G AGAIN1
  1. ;I RES1'="" I CNT>10 S REST(SITE)="Unable to get data" Q
  1. D REFORMAT(.RES1)
  1. K REST
  1. M REST=RES1
  1. Q
  1. ;
  1. GETTFS(DFN,ARRAY) ;
  1. ; get list of TF station numbers for a patient (dfn)
  1. ;
  1. N SITE,HERE,HSTN,CNT
  1. I $D(^DGCN(391.91,"APAT",DFN))="" S ARRAY="-1^No TFs" Q
  1. S HERE=+$$SITE^VASITE(),HSTN=$P($$SITE^VASITE(),"^",3)
  1. S SITE="",CNT=0
  1. F S SITE=$O(^DGCN(391.91,"APAT",DFN,SITE)) Q:SITE="" D
  1. .Q:SITE=HERE
  1. .S CNT=CNT+1
  1. .S ARRAY($P($$NNT^XUAF4(SITE),"^",2))=""
  1. I CNT=0 S ARRAY="-1^No other site TFs" Q
  1. S ARRAY=CNT
  1. Q
  1. ;
  1. REFORMAT(ARRAY) ; Reformat from RPC=1 format to RPC=0 format
  1. N XX,ARR,TARR
  1. S XX=0
  1. F S XX=$O(ARRAY(XX)) Q:XX="" D
  1. .I XX=1 S TARR=$P(ARRAY(XX),"(")
  1. .S ARR=$P(ARRAY(XX),"=")
  1. .S @ARR=$P(ARRAY(XX),"=",2)
  1. K ARRAY
  1. M ARRAY=@TARR
  1. K @TARR
  1. Q
  1. ;
  1. ASK(ICNSSN,SITE) ; Function to check if there has been a previous request
  1. ; made for this ICN/SSN. If so, ask the user if they wish to view if or
  1. ; create a new request.
  1. ;
  1. N DIR,X,Y,SITE1
  1. I '$D(^XTMP("MPIF EXT PDAT"_ICNSSN)) Q 0
  1. I SITE=1 D
  1. .S SITE1=0
  1. .W !!,"There has been a request made for this patient to site(s): "
  1. .F S SITE1=$O(^XTMP("MPIF EXT PDAT"_ICNSSN,SITE1)) Q:SITE1="" D
  1. ..I SITE1=$P($$SITE^VASITE(),"^",3) Q
  1. ..W !,SITE1,?10,$P($$NNT^XUAF4($$LKUP^XUAF4(SITE1)),"^"),?40,"made at "
  1. ..N Y S Y=$P(^XTMP("MPIF EXT PDAT"_ICNSSN,SITE1,0),"^",2) D DD^%DT
  1. ..W Y
  1. I SITE'=1,'$D(^XTMP("MPIF EXT PDAT"_ICNSSN,SITE)) Q 0
  1. I SITE'=1,SITE'=$P($$SITE^VASITE(),"^",3) D
  1. .W !!,"There has been a previous request made for this patient from the same "
  1. .W !,"site you are requesting. The request was made at "
  1. .N Y S Y=$P($G(^XTMP("MPIF EXT PDAT"_ICNSSN,SITE,0)),"^",2) D DD^%DT
  1. .W Y
  1. S DIR("A")="Would you like to view this data?"
  1. S DIR(0)="Y",DIR("B")="No"
  1. D ^DIR
  1. I Y'=1 Q 0
  1. Q 1