RGPVREJ ;BIR/PTD-REMOTE PRIMARY VIEW REJECT (PATIENT) ;10/8/06
;;1.0;CLINICAL INFO RESOURCE NETWORK;**44,47,53**;30 Apr 99;Build 2
;
;Reference to ^XWB2HL7 supported by IA #3144
;Reference to ^XWBDRPC supported by IA #3149
;
REJ ;Option only available for Primary View Reject exceptions
;From within the Exception Handler, for selection, DATA should be defined.
N RGBDT,RGICN,RGSITE,PTEN,PELV
I DATA="" W !,"No Exception Data available." Q
S PTEN=$P(DATA,"^",10) ;IEN IN 991.1
S PELV=$P(DATA,"^",11) ;IEN IN 991.12
I $P($G(^RGHL7(991.1,PTEN,1,PELV,0)),"^",3)'=234 S VALMSG="Action is ONLY for PRIMARY VIEW REJECT exceptions!" Q
I $P($G(^RGHL7(991.1,PTEN,1,PELV,0)),"^",5)=1 S VALMSG="Exception has been PROCESSED; no longer active." Q
S RGSITE=$P($$SITE^VASITE(),"^",3) I RGSITE="" W !,"No Site Data defined." Q
S RGICN=$P(DATA,"^",6) I RGICN="" W !,"No ICN defined." Q
S RGBDT=$P(DATA,"^",3) I RGBDT="" W !,"No Exception Date defined." Q
S X=RGBDT D ^%DT S RGBDT=Y ;convert Exception Date from external format to internal
;
S VALMBCK="",QUIT=0
D FULL^VALM1
SEND ;Send a remote query to the MPI for Primary View Reject report
N RETURN,RESULT,RGEDT,SNTDT
S RGEDT=$$DT^XLFDT ;End date for report internal format
NOQ ;No previous query exists for this ICN/exception date
I '$D(^XTMP("RGPVREJ"_RGICN,RGBDT)) D RPC G DISP
;
OLDQ ;Query already sent for this ICN/ exception date
I $D(^XTMP("RGPVREJ"_RGICN,RGBDT)) D
.S SNTDT=$$FMTE^XLFDT($P(^XTMP("RGPVREJ"_RGICN,RGBDT),"^",2))
.W !?3,"A query was last sent for this ICN/Exception Date on "_SNTDT
.S X=$P(SNTDT,"@") D ^%DT S SNTDT=Y ;convert to internal, strip time
.;Has data returned for existing query?
.S RETURN(0)=$P(^XTMP("RGPVREJ"_RGICN,RGBDT),"^")
.D RPCCHK^XWB2HL7(.RESULT,RETURN(0)) I +RESULT(0)=1 D Q ;Data has returned
..I RGEDT=SNTDT D ;query was sent 'today', want to use that one?
...S DIR("A")=" Do you wish to review that existing query data now? ",DIR(0)="YA"
...S DIR("?")=" Enter YES to review the existing query; NO to send a new query"
...S DIR("B")="YES" D ^DIR K DIR I $D(DIRUT) S QUIT=1 Q ;up-arrowed out
...I Y>0 K DIR Q ;yes, use existing query
...I Y=0 D Q ;no, don't use existing, send new query
....K ^XTMP("RGPVREJ"_RGICN,RGBDT)
....D RPC
....K DIR
....;
..I RGEDT'=SNTDT D ;query was NOT sent 'today', data may be old, send new query
...W !?3,"Previous Query data may be obsolete."
...K ^XTMP("RGPVREJ"_RGICN,RGBDT)
...D RPC
.;Data for existing query has NOT returned **47
.I +RESULT(0)'=1 D FAIL ;**53
;
DISP ;Display Primary View Reject Data
I QUIT'=1 D EN^RGEX07(RGICN,RGBDT)
EXIT ;Kill variables and quit
K CNT,DIR,DIRUT,QUIT,X,Y
Q
;
RPC ;Send the Remote Query
W !?3,"Sending a Remote Query to the Master Patient Index."
W !?3,"This will take some time; please be patient."
D EN1^XWB2HL7(.RETURN,"200M","RG PRIMARY VIEW REJECT",1,RGSITE,RGICN,RGBDT,RGEDT) I RETURN(0)'="" D Q
.S ^XTMP("RGPVREJ"_RGICN,0)=$$FMADD^XLFDT(DT,2)_"^"_DT_"^"_"PRIMARY VIEW REJECT"
.S ^XTMP("RGPVREJ"_RGICN,RGBDT)=RETURN(0)_"^"_$$NOW^XLFDT
.;Has data returned for this query?
.S CNT=0 F S CNT=CNT+1 D RPCCHK^XWB2HL7(.RESULT,RETURN(0)) Q:RESULT(0) H 2 I CNT>15 Q ;result(0)=status of handle
.I +RESULT(0)=1 W !?3,"Query data has returned from the MPI and is available for review."
.I +RESULT(0)'=1 D FAIL ;**53
W !!?3,"Problem with Query: ",RETURN(0)_"^"_$G(RETURN(1))
S QUIT=1
D PAUSE^VALM1
Q
;
FAIL ;Status of RPC call - unsuccessful after 30 seconds ;**53
W !?3,"Your query request has NOT returned data from the MPI after trying for"
W !?3,"30 seconds. This could be due to network issues. Please try again later."
K ^XTMP("RGPVREJ"_RGICN,RGBDT)
S QUIT=1
D PAUSE^VALM1
Q
;
--- Routine Detail --- with STRUCTURED ROUTINE LISTING ---[H[J[2J[HRGPVREJ 3805 printed Nov 22, 2024@16:52:59 Page 2
RGPVREJ ;BIR/PTD-REMOTE PRIMARY VIEW REJECT (PATIENT) ;10/8/06
+1 ;;1.0;CLINICAL INFO RESOURCE NETWORK;**44,47,53**;30 Apr 99;Build 2
+2 ;
+3 ;Reference to ^XWB2HL7 supported by IA #3144
+4 ;Reference to ^XWBDRPC supported by IA #3149
+5 ;
REJ ;Option only available for Primary View Reject exceptions
+1 ;From within the Exception Handler, for selection, DATA should be defined.
+2 NEW RGBDT,RGICN,RGSITE,PTEN,PELV
+3 IF DATA=""
WRITE !,"No Exception Data available."
QUIT
+4 ;IEN IN 991.1
SET PTEN=$PIECE(DATA,"^",10)
+5 ;IEN IN 991.12
SET PELV=$PIECE(DATA,"^",11)
+6 IF $PIECE($GET(^RGHL7(991.1,PTEN,1,PELV,0)),"^",3)'=234
SET VALMSG="Action is ONLY for PRIMARY VIEW REJECT exceptions!"
QUIT
+7 IF $PIECE($GET(^RGHL7(991.1,PTEN,1,PELV,0)),"^",5)=1
SET VALMSG="Exception has been PROCESSED; no longer active."
QUIT
+8 SET RGSITE=$PIECE($$SITE^VASITE(),"^",3)
IF RGSITE=""
WRITE !,"No Site Data defined."
QUIT
+9 SET RGICN=$PIECE(DATA,"^",6)
IF RGICN=""
WRITE !,"No ICN defined."
QUIT
+10 SET RGBDT=$PIECE(DATA,"^",3)
IF RGBDT=""
WRITE !,"No Exception Date defined."
QUIT
+11 ;convert Exception Date from external format to internal
SET X=RGBDT
DO ^%DT
SET RGBDT=Y
+12 ;
+13 SET VALMBCK=""
SET QUIT=0
+14 DO FULL^VALM1
SEND ;Send a remote query to the MPI for Primary View Reject report
+1 NEW RETURN,RESULT,RGEDT,SNTDT
+2 ;End date for report internal format
SET RGEDT=$$DT^XLFDT
NOQ ;No previous query exists for this ICN/exception date
+1 IF '$DATA(^XTMP("RGPVREJ"_RGICN,RGBDT))
DO RPC
GOTO DISP
+2 ;
OLDQ ;Query already sent for this ICN/ exception date
+1 IF $DATA(^XTMP("RGPVREJ"_RGICN,RGBDT))
Begin DoDot:1
+2 SET SNTDT=$$FMTE^XLFDT($PIECE(^XTMP("RGPVREJ"_RGICN,RGBDT),"^",2))
+3 WRITE !?3,"A query was last sent for this ICN/Exception Date on "_SNTDT
+4 ;convert to internal, strip time
SET X=$PIECE(SNTDT,"@")
DO ^%DT
SET SNTDT=Y
+5 ;Has data returned for existing query?
+6 SET RETURN(0)=$PIECE(^XTMP("RGPVREJ"_RGICN,RGBDT),"^")
+7 ;Data has returned
DO RPCCHK^XWB2HL7(.RESULT,RETURN(0))
IF +RESULT(0)=1
Begin DoDot:2
+8 ;query was sent 'today', want to use that one?
IF RGEDT=SNTDT
Begin DoDot:3
+9 SET DIR("A")=" Do you wish to review that existing query data now? "
SET DIR(0)="YA"
+10 SET DIR("?")=" Enter YES to review the existing query; NO to send a new query"
+11 ;up-arrowed out
SET DIR("B")="YES"
DO ^DIR
KILL DIR
IF $DATA(DIRUT)
SET QUIT=1
QUIT
+12 ;yes, use existing query
IF Y>0
KILL DIR
QUIT
+13 ;no, don't use existing, send new query
IF Y=0
Begin DoDot:4
+14 KILL ^XTMP("RGPVREJ"_RGICN,RGBDT)
+15 DO RPC
+16 KILL DIR
+17 ;
End DoDot:4
QUIT
End DoDot:3
+18 ;query was NOT sent 'today', data may be old, send new query
IF RGEDT'=SNTDT
Begin DoDot:3
+19 WRITE !?3,"Previous Query data may be obsolete."
+20 KILL ^XTMP("RGPVREJ"_RGICN,RGBDT)
+21 DO RPC
End DoDot:3
End DoDot:2
QUIT
+22 ;Data for existing query has NOT returned **47
+23 ;**53
IF +RESULT(0)'=1
DO FAIL
End DoDot:1
+24 ;
DISP ;Display Primary View Reject Data
+1 IF QUIT'=1
DO EN^RGEX07(RGICN,RGBDT)
EXIT ;Kill variables and quit
+1 KILL CNT,DIR,DIRUT,QUIT,X,Y
+2 QUIT
+3 ;
RPC ;Send the Remote Query
+1 WRITE !?3,"Sending a Remote Query to the Master Patient Index."
+2 WRITE !?3,"This will take some time; please be patient."
+3 DO EN1^XWB2HL7(.RETURN,"200M","RG PRIMARY VIEW REJECT",1,RGSITE,RGICN,RGBDT,RGEDT)
IF RETURN(0)'=""
Begin DoDot:1
+4 SET ^XTMP("RGPVREJ"_RGICN,0)=$$FMADD^XLFDT(DT,2)_"^"_DT_"^"_"PRIMARY VIEW REJECT"
+5 SET ^XTMP("RGPVREJ"_RGICN,RGBDT)=RETURN(0)_"^"_$$NOW^XLFDT
+6 ;Has data returned for this query?
+7 ;result(0)=status of handle
SET CNT=0
FOR
SET CNT=CNT+1
DO RPCCHK^XWB2HL7(.RESULT,RETURN(0))
if RESULT(0)
QUIT
HANG 2
IF CNT>15
QUIT
+8 IF +RESULT(0)=1
WRITE !?3,"Query data has returned from the MPI and is available for review."
+9 ;**53
IF +RESULT(0)'=1
DO FAIL
End DoDot:1
QUIT
+10 WRITE !!?3,"Problem with Query: ",RETURN(0)_"^"_$GET(RETURN(1))
+11 SET QUIT=1
+12 DO PAUSE^VALM1
+13 QUIT
+14 ;
FAIL ;Status of RPC call - unsuccessful after 30 seconds ;**53
+1 WRITE !?3,"Your query request has NOT returned data from the MPI after trying for"
+2 WRITE !?3,"30 seconds. This could be due to network issues. Please try again later."
+3 KILL ^XTMP("RGPVREJ"_RGICN,RGBDT)
+4 SET QUIT=1
+5 DO PAUSE^VALM1
+6 QUIT
+7 ;