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

RGRPDAT.m

Go to the documentation of this file.
  1. RGRPDAT ;BAY/ALS-ROUTINE TO CALL REMOTE PDAT ;09/14/01
  1. ;;1.0;CLINICAL INFO RESOURCE NETWORK;**23,27,31,55,60**;30 Apr 99;Build 2
  1. ;Reference to ^DGCN(391.91 supported by IA #2911
  1. ;Reference to EN1^XWB2HL7 supported by IA #3144
  1. ;Reference to RPCCHK^XWB2HL7 supported by IA #3144
  1. ;Reference to RTNDATA^XWBDRPC supported by IA #3149
  1. ;Reference to VAFC REMOTE PDAT supported by IA #3496
  1. ASK ;Ask For Patient
  1. K DIRUT
  1. W !!,"Patient lookup can be done by Patient Name, SSN or by ICN.",!
  1. S DFN="",ICN=""
  1. S DIC="^DPT(",DIC(0)="QEAM",DIC("A")="Select PATIENT: ",D="SSN^AICN^B^BS^BS5"
  1. D MIX^DIC1 K DIC,D
  1. I Y<0 S REXIT=1 G QUIT
  1. S DFN=+Y
  1. S ICN=+$$GETICN^MPIF001(DFN) I ICN<1 W !,"There is no Integration Control Number assigned to this patient,",!,"no treating facilities to query." G ASK
  1. Q
  1. SEND ;
  1. N TFL,X,Y,SNTDT,MPIDIR
  1. D GETTFL(ICN,.TFL)
  1. I $D(^XTMP("RGPDAT"_ICN,0)) S SNTDT=$$FMTE^XLFDT($P(^XTMP("RGPDAT"_ICN,0),"^",2)) W !,"Query last sent for this ICN on "_SNTDT,!
  1. I $P($G(TFL(0)),"^",1)=1 D
  1. . D SELTF Q:((Y="")!(Y="^"))
  1. . W !,"Remote patient data queries will be sent to: "
  1. . S CNT=0,X=0 F S X=$O(TFARR(X)) Q:'X S CNT=CNT+1
  1. . I CNT>22 D D2
  1. . I CNT<23 D D1
  1. . W ! K DIR S DIR(0)="Y",DIR("B")="Yes",DIR("A")="Do you want to continue" D ^DIR S MPIDIR=+Y K DIR
  1. . I MPIDIR=1 S X=0 F S X=$O(TFL(X)) Q:'X D
  1. .. W !?3,"Sending Remote Query to: ",X," ",$P(TFL(X),"^")
  1. .. I $D(^XTMP("RGPDAT"_ICN,X)) K ^XTMP("RGPDAT"_ICN,X)
  1. .. D REQ(ICN,.TFL,X)
  1. I '$D(TFL(0)) W !!?3,"There are no remote treating facilities listed for this patient.",!?3,"No remote query will be sent."
  1. K ICNARR,X,Y,CNT,TFARR,TFL
  1. Q
  1. SEND2 ;
  1. N REXIT S REXIT=0
  1. W !!,"This option sends a remote query to selected treating"
  1. W !,"facility site(s) for MPI/PD data for a patient."
  1. F D Q:REXIT=1
  1. . D ASK
  1. . I $D(Y) D SEND
  1. K ICN,DFN
  1. Q
  1. CHKSTAT ;check on the status for a given ICN or SSN
  1. N TFL,L,Y,ICNARR,STATUS,SL
  1. W !!,"Checking the status of remote patient data query.",!
  1. I '$D(^XTMP("RGPDAT"_ICN)) W !!,"No remote query sent for this patient." Q
  1. D GETTFL(ICN,.TFL)
  1. N FULLICN S FULLICN=$$GETICN^MPIF001(DFN) W !!,"-> For ICN "_$S(+FULLICN>0:FULLICN,1:"") ;**60 - MVI_2389 (ptd)
  1. I $D(TFL(0)) D
  1. . S X=0 F S X=$O(TFL(X)) Q:'X I '$D(^XTMP("RGPDAT"_ICN,X)) K TFL(X)
  1. D SELTF
  1. I '$D(TFARR) W !,"No remote query sent for this patient." Q
  1. Q:((Y="")!(Y="^"))
  1. S L=0 F S L=$O(TFARR(L)) Q:'L D
  1. . S SL=$P(TFARR(L),"^",1)
  1. . S STATUS=$P(TFL(SL),"^",3)
  1. . I STATUS["Handle" S STATUS="Error in Process"
  1. . E I STATUS["New" S STATUS="Request Sent"
  1. . E I STATUS["Running" S STATUS="Awaiting Response"
  1. . E I STATUS["Done" S STATUS="Response Received"
  1. . W !?3," ",$P(TFL(SL),"^")," status: (",STATUS,")"
  1. I '$D(TFL(0)) W !!?3,"There are no remote treating facilities listed for this patient.",!?3,"No remote query sent for this patient."
  1. K ICNARR,L,SL,TFARR,TFL
  1. Q
  1. CHKSTAT2 ;
  1. N REXIT S REXIT=0
  1. W !!,"This option checks the status of an existing remote patient data query."
  1. F D Q:REXIT=1
  1. . D ASK
  1. . I $D(Y) D CHKSTAT
  1. K ICN,DFN
  1. Q
  1. DISP ;display returned PDAT queries
  1. W !!,"Display data returned from remote patient data queries."
  1. W !,"(Be sure HISTORY is enabled to capture data!)",!
  1. N TFL,L,Y,ICNARR,STATUS
  1. I '$D(^XTMP("RGPDAT"_ICN)) W !!,"No remote query sent for this patient." Q
  1. D GETTFL(ICN,.TFL)
  1. N FULLICN S FULLICN=$$GETICN^MPIF001(DFN) W !!,"-> For ICN "_$S(+FULLICN>0:FULLICN,1:"") ;**60 - MVI_2389 (ptd)
  1. I $D(TFL(0)) D
  1. . S X=0 F S X=$O(TFL(X)) Q:'X I '$D(^XTMP("RGPDAT"_ICN,X)) K TFL(X)
  1. D SELTF
  1. I '$D(TFARR) W !,"No remote query sent for this patient." Q
  1. Q:((Y="")!(Y="^"))
  1. S L=0 F S L=$O(TFARR(L)) Q:'L D
  1. . S SL=$P(TFARR(L),"^",1)
  1. . S STATUS=$P(TFL(SL),"^",3)
  1. . I STATUS["Handle" S STATUS="Error in Process"
  1. . E I STATUS["New" S STATUS="Request Sent"
  1. . E I STATUS["Running" S STATUS="Awaiting Response"
  1. . E I STATUS["Done" S STATUS="Response Received"
  1. . W !?3," ",$P(TFL(SL),"^")," status: (",STATUS,")",!
  1. . D DISPLAY(ICN,$P(TFL(SL),"^",2))
  1. I '$D(TFL(0)) W !?3,"There are no remote treating facilities listed for this patient.",!?3,"No remote query exists for this patient."
  1. K ICNARR,L,SL,TFARR,TFL,STATUS,RESULT,RETURN
  1. Q
  1. DISP2 ;
  1. N REXIT S REXIT=0
  1. F D Q:REXIT=1
  1. . D ASK
  1. . I $D(Y) D DISP
  1. K ICN,DFN
  1. Q
  1. DISPLAY(ICN,LOC) ;display a remote pdat report
  1. N STATUS,RETURN,RESULT,RET,R
  1. I '$D(^XTMP("RGPDAT"_ICN,0)) W !?15," - No patient data query exists for this record."
  1. I $D(^XTMP("RGPDAT"_ICN,LOC,0)) S RETURN(0)=$P(^XTMP("RGPDAT"_ICN,LOC,0),"^") D
  1. . D RPCCHK^XWB2HL7(.RESULT,RETURN(0)) I +RESULT(0)=1 D
  1. .. D RTNDATA^XWBDRPC(.RET,RETURN(0))
  1. .. I $D(RET(0)) I RET(0)<0 W !!,"No data returned due to: "_$P(RET(0),"^",2) Q ;**31
  1. .. I $G(RET)'="",$D(@RET) S GLO=RET F S GLO=$Q(@GLO) Q:$QS(GLO,1)'=$J S TXT=@GLO W !,TXT I $Y>22 S DIR(0)="E" D ^DIR K DIR W @IOF S $Y=1 ;**31
  1. .. S R="" F S R=$O(RET(R)) Q:R="" W !,RET(R) I $Y>22 S DIR(0)="E" D ^DIR K DIR W @IOF S $Y=1 ;**31
  1. Q
  1. GETTFL(ICN,TFL) ;Check for existing Treating Facilities
  1. N LOC,HOME
  1. S HOME=$$SITE^VASITE()
  1. S TF=0 F S TF=$O(^DGCN(391.91,"APAT",DFN,TF)) Q:'TF D
  1. . S LOC=$$NNT^XUAF4(TF)
  1. . I $P(LOC,"^",2)'=$E($P(HOME,"^",3),1,3)&($P(LOC,"^",3)'="OTHER") D
  1. .. S TFL($P(LOC,"^",2))=LOC
  1. .. S LOC=$P(LOC,"^",2)
  1. .. D MONITOR(ICN,LOC,.RESULT)
  1. .. S $P(TFL(LOC),"^",3)=$P(RESULT(0),"^",2)
  1. I $O(TFL(0)) S TFL(0)=1
  1. K TF
  1. Q
  1. SELTF ;Allow the user to select treating facilites from a list
  1. K TFARR,TFARR1
  1. S I=0 F S I=$O(TFL(I)) Q:'I D
  1. . S TFARR1($P(TFL(I),"^",1))=$P(TFL(I),"^",2)_"^"_$P(TFL(I),"^",1)
  1. S I="",CNT=0 F S I=$O(TFARR1(I)) Q:I="" D
  1. . S CNT=CNT+1 S TFARR(CNT)=TFARR1(I)
  1. I CNT=1 S Y=1 Q
  1. K DIR,Y
  1. S CNT=CNT+1,TFARR(CNT)="ALL"
  1. S DIR(0)="LA^1:"_CNT
  1. S DIR("A")="Select site(s) 1-"_(CNT-1)_" or "_CNT_" for all: "
  1. W !,"Select one or more of the following: "
  1. I CNT>22 D D2
  1. I CNT<23 D D1
  1. D ^DIR K DIR
  1. I Y<1 K TFARR,TFARR1,L,I,A,CNT Q
  1. S Y=","_Y
  1. I Y[(","_CNT_",") K TFARR(CNT),TFARR1,CNT,I Q
  1. S I=0,A="" F S I=$O(TFARR(I)) Q:'I I Y'[(","_I_",") S A=$P(TFARR(I),"^",1) K TFL(A) K TFARR(I)
  1. K L,I,A,TFARR(CNT),CNT,TFARR1
  1. Q
  1. MONITOR(ICN,LOC,RESULT) ;
  1. N STATUS,RETURN
  1. I '$D(^XTMP("RGPDAT"_ICN,0)) S RESULT(0)="-1^Unknown" Q
  1. I '$D(^XTMP("RGPDAT"_ICN,LOC,0)) S RESULT(0)="-1^Unknown" Q
  1. I $D(^XTMP("RGPDAT"_ICN,LOC,0)) S RETURN(0)=$P(^XTMP("RGPDAT"_ICN,LOC,0),"^",1) D RPCCHK^XWB2HL7(.RESULT,RETURN(0))
  1. Q
  1. REQ(ICN,TFL,LOC) ;request a remote pdat report
  1. ;LOC - STATION# OF THE INSTITUTION file entry
  1. I +LOC>0 D EN1^XWB2HL7(.RETURN,LOC,"VAFC REMOTE PDAT",1,ICN,"")
  1. S ^XTMP("RGPDAT"_ICN,0)=$$FMADD^XLFDT(DT,2)_"^"_DT_"^"_"REMOTE PDAT QUERY"
  1. S ^XTMP("RGPDAT"_ICN,LOC,0)=RETURN(0)_"^"_$$NOW^XLFDT
  1. Q
  1. SENS ;Check for patient sensitivity
  1. N RESULT
  1. D PTSEC^DGSEC4(.RESULT,DFN,0,"RPC - VAFC REMOTE PDAT^Remote Patient Data Query")
  1. I RESULT(1)>0 D
  1. . I '$D(^XUSEC("DG SENSITIVITY",DUZ)) D
  1. . W !!,"PATIENT MARKED SENSITIVE."
  1. . W !,"You do not have proper security to view this record."
  1. Q
  1. D1 ;
  1. S C1=1,I=0 F S I=$O(TFARR(I)) Q:'I D
  1. . W !,C1_".",?4,"("_$P(TFARR(I),"^",1)_") "_$P(TFARR(I),"^",2) S C1=C1+1
  1. K C1,I
  1. Q
  1. D2 ;
  1. S I2=23 F I=1:1:22 D
  1. . W !,I_".",?4,"("_$P(TFARR(I),"^",1)_") "_$P(TFARR(I),"^",2)
  1. . I $D(TFARR(I2)) W ?41,I2_". ",?44,"("_$P(TFARR(I2),"^",1)_") "_$P(TFARR(I2),"^",2) S I2=I2+1
  1. K I,I2
  1. Q
  1. QUIT ;
  1. K Y
  1. Q