[613] | 1 | RGRPDAT ;BAY/ALS-ROUTINE TO CALL REMOTE PDAT ;09/14/01
|
---|
| 2 | ;;1.0;CLINICAL INFO RESOURCE NETWORK;**23,27,31**;30 Apr 99
|
---|
| 3 | ;Reference to ^DGCN(391.91 supported by IA #2911
|
---|
| 4 | ;Reference to EN1^XWB2HL7 supported by IA #3144
|
---|
| 5 | ;Reference to RPCCHK^XWB2HL7 supported by IA #3144
|
---|
| 6 | ;Reference to RTNDATA^XWBDRPC supported by IA #3149
|
---|
| 7 | ;Reference to VAFC REMOTE PDAT supported by IA #3496
|
---|
| 8 | ASK ;Ask For Patient
|
---|
| 9 | K DIRUT
|
---|
| 10 | W !!,"Patient lookup can be done by Patient Name, SSN or by ICN.",!
|
---|
| 11 | S DFN="",ICN=""
|
---|
| 12 | S DIC="^DPT(",DIC(0)="QEAM",DIC("A")="Select PATIENT: ",D="SSN^AICN^B^BS^BS5"
|
---|
| 13 | D MIX^DIC1 K DIC,D
|
---|
| 14 | I Y<0 S REXIT=1 G QUIT
|
---|
| 15 | S DFN=+Y
|
---|
| 16 | 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
|
---|
| 17 | Q
|
---|
| 18 | SEND ;
|
---|
| 19 | N TFL,X,Y,SNTDT,MPIDIR
|
---|
| 20 | D GETTFL(ICN,.TFL)
|
---|
| 21 | 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,!
|
---|
| 22 | I $P($G(TFL(0)),"^",1)=1 D
|
---|
| 23 | . D SELTF Q:((Y="")!(Y="^"))
|
---|
| 24 | . W !,"Remote patient data queries will be sent to: "
|
---|
| 25 | . S CNT=0,X=0 F S X=$O(TFARR(X)) Q:'X S CNT=CNT+1
|
---|
| 26 | . I CNT>22 D D2
|
---|
| 27 | . I CNT<23 D D1
|
---|
| 28 | . W ! K DIR S DIR(0)="Y",DIR("B")="Yes",DIR("A")="Do you want to continue" D ^DIR S MPIDIR=+Y K DIR
|
---|
| 29 | . I MPIDIR=1 S X=0 F S X=$O(TFL(X)) Q:'X D
|
---|
| 30 | .. W !?3,"Sending Remote Query to: ",X," ",$P(TFL(X),"^")
|
---|
| 31 | .. I $D(^XTMP("RGPDAT"_ICN,X)) K ^XTMP("RGPDAT"_ICN,X)
|
---|
| 32 | .. D REQ(ICN,.TFL,X)
|
---|
| 33 | I '$D(TFL(0)) W !!?3,"There are no remote treating facilities listed for this patient.",!?3,"No remote query will be sent."
|
---|
| 34 | K ICNARR,X,Y,CNT,TFARR,TFL
|
---|
| 35 | Q
|
---|
| 36 | SEND2 ;
|
---|
| 37 | N REXIT S REXIT=0
|
---|
| 38 | W !!,"This option sends a remote query to selected treating"
|
---|
| 39 | W !,"facility site(s) for MPI/PD data for a patient."
|
---|
| 40 | F D Q:REXIT=1
|
---|
| 41 | . D ASK
|
---|
| 42 | . I $D(Y) D SEND
|
---|
| 43 | K ICN,DFN
|
---|
| 44 | Q
|
---|
| 45 | CHKSTAT ;check on the status for a given ICN or SSN
|
---|
| 46 | N TFL,L,Y,ICNARR,STATUS,SL
|
---|
| 47 | W !!,"Checking the status of remote patient data query.",!
|
---|
| 48 | I '$D(^XTMP("RGPDAT"_ICN)) W !!,"No remote query sent for this patient." Q
|
---|
| 49 | D GETTFL(ICN,.TFL)
|
---|
| 50 | W !!,"-> For ICN ",$P(ICN,"V",1),!
|
---|
| 51 | I $D(TFL(0)) D
|
---|
| 52 | . S X=0 F S X=$O(TFL(X)) Q:'X I '$D(^XTMP("RGPDAT"_ICN,X)) K TFL(X)
|
---|
| 53 | D SELTF
|
---|
| 54 | I '$D(TFARR) W !,"No remote query sent for this patient." Q
|
---|
| 55 | Q:((Y="")!(Y="^"))
|
---|
| 56 | S L=0 F S L=$O(TFARR(L)) Q:'L D
|
---|
| 57 | . S SL=$P(TFARR(L),"^",1)
|
---|
| 58 | . S STATUS=$P(TFL(SL),"^",3)
|
---|
| 59 | . I STATUS["Handle" S STATUS="Error in Process"
|
---|
| 60 | . E I STATUS["New" S STATUS="Request Sent"
|
---|
| 61 | . E I STATUS["Running" S STATUS="Awaiting Response"
|
---|
| 62 | . E I STATUS["Done" S STATUS="Response Received"
|
---|
| 63 | . W !?3," ",$P(TFL(SL),"^")," status: (",STATUS,")"
|
---|
| 64 | I '$D(TFL(0)) W !!?3,"There are no remote treating facilities listed for this patient.",!?3,"No remote query sent for this patient."
|
---|
| 65 | K ICNARR,L,SL,TFARR,TFL
|
---|
| 66 | Q
|
---|
| 67 | CHKSTAT2 ;
|
---|
| 68 | N REXIT S REXIT=0
|
---|
| 69 | W !!,"This option checks the status of an existing remote patient data query."
|
---|
| 70 | F D Q:REXIT=1
|
---|
| 71 | . D ASK
|
---|
| 72 | . I $D(Y) D CHKSTAT
|
---|
| 73 | K ICN,DFN
|
---|
| 74 | Q
|
---|
| 75 | DISP ;display returned PDAT queries
|
---|
| 76 | W !!,"Display data returned from remote patient data queries."
|
---|
| 77 | W !,"(Be sure HISTORY is enabled to capture data!)",!
|
---|
| 78 | N TFL,L,Y,ICNARR,STATUS
|
---|
| 79 | I '$D(^XTMP("RGPDAT"_ICN)) W !!,"No remote query sent for this patient." Q
|
---|
| 80 | D GETTFL(ICN,.TFL)
|
---|
| 81 | W !!,"-> For ICN ",$P(ICN,"V",1),!
|
---|
| 82 | I $D(TFL(0)) D
|
---|
| 83 | . S X=0 F S X=$O(TFL(X)) Q:'X I '$D(^XTMP("RGPDAT"_ICN,X)) K TFL(X)
|
---|
| 84 | D SELTF
|
---|
| 85 | I '$D(TFARR) W !,"No remote query sent for this patient." Q
|
---|
| 86 | Q:((Y="")!(Y="^"))
|
---|
| 87 | S L=0 F S L=$O(TFARR(L)) Q:'L D
|
---|
| 88 | . S SL=$P(TFARR(L),"^",1)
|
---|
| 89 | . S STATUS=$P(TFL(SL),"^",3)
|
---|
| 90 | . I STATUS["Handle" S STATUS="Error in Process"
|
---|
| 91 | . E I STATUS["New" S STATUS="Request Sent"
|
---|
| 92 | . E I STATUS["Running" S STATUS="Awaiting Response"
|
---|
| 93 | . E I STATUS["Done" S STATUS="Response Received"
|
---|
| 94 | . W !?3," ",$P(TFL(SL),"^")," status: (",STATUS,")",!
|
---|
| 95 | . D DISPLAY(ICN,$P(TFL(SL),"^",2))
|
---|
| 96 | I '$D(TFL(0)) W !?3,"There are no remote treating facilities listed for this patient.",!?3,"No remote query exists for this patient."
|
---|
| 97 | K ICNARR,L,SL,TFARR,TFL
|
---|
| 98 | Q
|
---|
| 99 | DISP2 ;
|
---|
| 100 | N REXIT S REXIT=0
|
---|
| 101 | F D Q:REXIT=1
|
---|
| 102 | . D ASK
|
---|
| 103 | . I $D(Y) D DISP
|
---|
| 104 | K ICN,DFN
|
---|
| 105 | Q
|
---|
| 106 | DISPLAY(ICN,LOC) ;display a remote pdat report
|
---|
| 107 | N STATUS,RETURN,RESULT,RET,R
|
---|
| 108 | I '$D(^XTMP("RGPDAT"_ICN,0)) W !?15," - No patient data query exists for this record."
|
---|
| 109 | I $D(^XTMP("RGPDAT"_ICN,LOC,0)) S RETURN(0)=$P(^XTMP("RGPDAT"_ICN,LOC,0),"^") D
|
---|
| 110 | . D RPCCHK^XWB2HL7(.RESULT,RETURN(0)) I +RESULT(0)=1 D
|
---|
| 111 | .. D RTNDATA^XWBDRPC(.RET,RETURN(0))
|
---|
| 112 | .. I $D(RET(0)) I RET(0)<0 W !!,"No data returned due to: "_$P(RET(0),"^",2) Q ;**31
|
---|
| 113 | .. 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
|
---|
| 114 | .. 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
|
---|
| 115 | Q
|
---|
| 116 | GETTFL(ICN,TFL) ;Check for existing Treating Facilities
|
---|
| 117 | N LOC,HOME
|
---|
| 118 | S HOME=$$SITE^VASITE()
|
---|
| 119 | S TF=0 F S TF=$O(^DGCN(391.91,"APAT",DFN,TF)) Q:'TF D
|
---|
| 120 | . S LOC=$$NNT^XUAF4(TF)
|
---|
| 121 | . I $P(LOC,"^",2)'=$E($P(HOME,"^",3),1,3) D
|
---|
| 122 | .. S TFL($P(LOC,"^",2))=LOC
|
---|
| 123 | .. S LOC=$P(LOC,"^",2)
|
---|
| 124 | .. D MONITOR(ICN,LOC,.RESULT)
|
---|
| 125 | .. S $P(TFL(LOC),"^",3)=$P(RESULT(0),"^",2)
|
---|
| 126 | I $O(TFL(0)) S TFL(0)=1
|
---|
| 127 | K TF
|
---|
| 128 | Q
|
---|
| 129 | SELTF ;Allow the user to select treating facilites from a list
|
---|
| 130 | K TFARR,TFARR1
|
---|
| 131 | S I=0 F S I=$O(TFL(I)) Q:'I D
|
---|
| 132 | . S TFARR1($P(TFL(I),"^",1))=$P(TFL(I),"^",2)_"^"_$P(TFL(I),"^",1)
|
---|
| 133 | S I="",CNT=0 F S I=$O(TFARR1(I)) Q:I="" D
|
---|
| 134 | . S CNT=CNT+1 S TFARR(CNT)=TFARR1(I)
|
---|
| 135 | I CNT=1 S Y=1 Q
|
---|
| 136 | K DIR,Y
|
---|
| 137 | S CNT=CNT+1,TFARR(CNT)="ALL"
|
---|
| 138 | S DIR(0)="LA^1:"_CNT
|
---|
| 139 | S DIR("A")="Select site(s) 1-"_(CNT-1)_" or "_CNT_" for all: "
|
---|
| 140 | W !,"Select one or more of the following: "
|
---|
| 141 | I CNT>22 D D2
|
---|
| 142 | I CNT<23 D D1
|
---|
| 143 | D ^DIR K DIR
|
---|
| 144 | I Y<1 K TFARR,TFARR1,L,I,A,CNT Q
|
---|
| 145 | S Y=","_Y
|
---|
| 146 | I Y[(","_CNT_",") K TFARR(CNT),TFARR1,CNT,I Q
|
---|
| 147 | 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)
|
---|
| 148 | K L,I,A,TFARR(CNT),CNT,TFARR1
|
---|
| 149 | Q
|
---|
| 150 | MONITOR(ICN,LOC,RESULT) ;
|
---|
| 151 | N STATUS,RETURN
|
---|
| 152 | I '$D(^XTMP("RGPDAT"_ICN,0)) S RESULT(0)="-1^Unknown" Q
|
---|
| 153 | I '$D(^XTMP("RGPDAT"_ICN,LOC,0)) S RESULT(0)="-1^Unknown" Q
|
---|
| 154 | I $D(^XTMP("RGPDAT"_ICN,LOC,0)) S RETURN(0)=$P(^XTMP("RGPDAT"_ICN,LOC,0),"^",1) D RPCCHK^XWB2HL7(.RESULT,RETURN(0))
|
---|
| 155 | Q
|
---|
| 156 | REQ(ICN,TFL,LOC) ;request a remote pdat report
|
---|
| 157 | ;LOC - STATION# OF THE INSTITUTION file entry
|
---|
| 158 | I +LOC>0 D EN1^XWB2HL7(.RETURN,LOC,"VAFC REMOTE PDAT",1,ICN,"")
|
---|
| 159 | S ^XTMP("RGPDAT"_ICN,0)=$$FMADD^XLFDT(DT,2)_"^"_DT_"^"_"REMOTE PDAT QUERY"
|
---|
| 160 | S ^XTMP("RGPDAT"_ICN,LOC,0)=RETURN(0)_"^"_$$NOW^XLFDT
|
---|
| 161 | Q
|
---|
| 162 | SENS ;Check for patient sensitivity
|
---|
| 163 | N RESULT
|
---|
| 164 | D PTSEC^DGSEC4(.RESULT,DFN,0,"RPC - VAFC REMOTE PDAT^Remote Patient Data Query")
|
---|
| 165 | I RESULT(1)>0 D
|
---|
| 166 | . I '$D(^XUSEC("DG SENSITIVITY",DUZ)) D
|
---|
| 167 | . W !!,"PATIENT MARKED SENSITIVE."
|
---|
| 168 | . W !,"You do not have proper security to view this record."
|
---|
| 169 | Q
|
---|
| 170 | D1 ;
|
---|
| 171 | S C1=1,I=0 F S I=$O(TFARR(I)) Q:'I D
|
---|
| 172 | . W !,C1_".",?4,"("_$P(TFARR(I),"^",1)_") "_$P(TFARR(I),"^",2) S C1=C1+1
|
---|
| 173 | K C1,I
|
---|
| 174 | Q
|
---|
| 175 | D2 ;
|
---|
| 176 | S I2=23 F I=1:1:22 D
|
---|
| 177 | . W !,I_".",?4,"("_$P(TFARR(I),"^",1)_") "_$P(TFARR(I),"^",2)
|
---|
| 178 | . I $D(TFARR(I2)) W ?41,I2_". ",?44,"("_$P(TFARR(I2),"^",1)_") "_$P(TFARR(I2),"^",2) S I2=I2+1
|
---|
| 179 | K I,I2
|
---|
| 180 | Q
|
---|
| 181 | QUIT ;
|
---|
| 182 | K Y
|
---|
| 183 | Q
|
---|