PXCAVST ;ISL/dee & LEA/Chylton - Validates data from the PCE Device Interface for the Visit and Providers ;6/6/05
;;1.0;PCE PATIENT CARE ENCOUNTER;**14,33,74,111,116,130,168**;Aug 12, 1996;Build 14
Q
;
ENCOUNT(PXCA,PXCABULD,PXCAERRS,PXCAEVAL) ;
I '($D(PXCA("ENCOUNTER"))#2) S PXCA("ERROR","ENCOUNTER",0,0,0)="ENCOUNTER node of the local data array is missing" Q
N PXCAENC
N PXCAITEM,PXCAITM2,PXCAOUT,PXCAERR
S PXCAENC=$G(PXCA("ENCOUNTER"))
I PXCAENC="" S PXCA("ERROR","ENCOUNTER",0,0,0)="ENCOUNTER data missing" Q
I '($D(^DPT(PXCAPAT,0))#2) S PXCA("ERROR","ENCOUNTER",0,0,2)="Patient missing or invalid in file 2^"_PXCAPAT
I '($D(^AUPNPAT(PXCAPAT,0))#2) S PXCA("ERROR","ENCOUNTER",0,0,2)="Patient missing or invalid in file 9000001^"_PXCAPAT
S PXCAITEM=+$P(PXCAENC,"^",1)
I 'PXCAITEM S PXCA("ERROR","ENCOUNTER",0,0,1)="Encounter Data/Time Missing^"_PXCAITEM
E I $D(^DPT(PXCAPAT,"S",PXCAITEM,0)),$D(^SC(+PXCAHLOC,0)),^DPT(PXCAPAT,"S",PXCAITEM,0),PXCAHLOC D
. ;Have an appointment at this time
. N VASD,VAERR
. S VASD("W")=345678
. S VASD("F")=PXCAITEM-.0000001
. S VASD("T")=PXCAITEM+.0000001
. S VASD("C",PXCAHLOC)=""
. D SDA^VADPT
. I $D(^UTILITY("VASD",$J)) S PXCA("ERROR","ENCOUNTER",0,0,1)="Appointment is No Show or Canceled^"_PXCAITEM
I '$D(^DPT(PXCAPAT,"S",PXCAITEM,0))!(+$G(^DPT(PXCAPAT,"S",PXCAITEM,0))'=PXCAHLOC),'(+$P(PXCAENC,"^",5)),'$D(PXCA("PROCEDURE")),'$D(^AUPNVCPT("AD",+PXCAVSIT)) D
. S PXCA("ERROR","ENCOUNTER",0,0,1)="Encounters that do not have an appointment must have a procedure^"
E I PXCAITEM>(DT+.7) S PXCA("ERROR","ENCOUNTER",0,0,1)="Encounter Date/Time is later that today^"_PXCAITEM
I '$D(^SC(PXCAHLOC,0)) S PXCA("ERROR","ENCOUNTER",0,0,3)="HOSPITAL LOCATION Missing is not in file 44^"_PXCAHLOC
;Allow a disposition clinic to be used as HOSPITAL LOCATION ;PX*1.0*116
;I $D(^PX(815,1,"DHL","B",PXCAHLOC)) S PXCA("ERROR","ENCOUNTER",0,0,3)="HOSPITAL LOCATION Can not be a disposition clinic^"_PXCAHLOC
D EVALCODE^PXCAVST2(.PXCAEVAL)
D SCC^PXUTLSCC(PXCAPAT,PXCADT,PXCAHLOC,PXCAVSIT,$P(PXCAENC,"^",6,11),.PXCAOUT,.PXCAERR)
S PXCAITEM=$P(PXCAERR,"^",1)
I PXCAITEM=-1 S PXCA("ERROR","ENCOUNTER",0,0,6)="SC flag bad^"_$P(PXCAENC,"^",6)
I PXCAITEM=-2,$P(PXCAENC,"^",6)=1 S PXCA("WARNING","ENCOUNTER",0,0,6)="SC flag must be N/A not YES for this patient^"_$P(PXCAENC,"^",6)
I PXCAITEM=1,$P($G(^PX(815,1,"DI")),"^",1) S PXCA("WARNING","ENCOUNTER",0,0,6)="SC flag is missing^"_$P(PXCAENC,"^",6)
S PXCAITEM=$P(PXCAERR,"^",2)
I PXCAITEM=-1 S PXCA("ERROR","ENCOUNTER",0,0,7)="AO flag bad^"_$P(PXCAENC,"^",7)
I PXCAITEM=-2,$P(PXCAENC,"^",7)=1 S PXCA("WARNING","ENCOUNTER",0,0,7)="AO flag must be N/A not YES for this patient^"_$P(PXCAENC,"^",7)
I PXCAITEM=-3,$P(PXCAENC,"^",7)=1 S PXCA("WARNING","ENCOUNTER",0,0,7)="AO flag must be N/A not YES because SC flag is true^"_$P(PXCAENC,"^",7)
I PXCAITEM=1,$P($G(^PX(815,1,"DI")),"^",1) S PXCA("WARNING","ENCOUNTER",0,0,7)="AO flag is missing^"_$P(PXCAENC,"^",7)
S PXCAITEM=$P(PXCAERR,"^",3)
I PXCAITEM=-1 S PXCA("ERROR","ENCOUNTER",0,0,8)="IR flag bad^"_$P(PXCAENC,"^",8)
I PXCAITEM=-2,$P(PXCAENC,"^",8)=1 S PXCA("WARNING","ENCOUNTER",0,0,8)="IR flag must be N/A not YES for this patient^"_$P(PXCAENC,"^",8)
I PXCAITEM=-3,$P(PXCAENC,"^",8)=1 S PXCA("WARNING","ENCOUNTER",0,0,8)="IR flag must be N/A not YES because SC flag is true^"_$P(PXCAENC,"^",8)
I PXCAITEM=1,$P($G(^PX(815,1,"DI")),"^",1) S PXCA("WARNING","ENCOUNTER",0,0,8)="IR flag is missing^"_$P(PXCAENC,"^",8)
S PXCAITEM=$P(PXCAERR,"^",4)
I PXCAITEM=-1 S PXCA("ERROR","ENCOUNTER",0,0,9)="EC flag bad^"_$P(PXCAENC,"^",9)
I PXCAITEM=-2,$P(PXCAENC,"^",9)=1 S PXCA("WARNING","ENCOUNTER",0,0,9)="EC flag must be N/A not YES for this patient^"_$P(PXCAENC,"^",9)
I PXCAITEM=-3,$P(PXCAENC,"^",9)=1 S PXCA("WARNING","ENCOUNTER",0,0,9)="EC flag must be N/A not YES because SC flag is true^"_$P(PXCAENC,"^",9)
I PXCAITEM=1,$P($G(^PX(815,1,"DI")),"^",1) S PXCA("WARNING","ENCOUNTER",0,0,9)="EC flag is missing^"_$P(PXCAENC,"^",9)
S PXCAITEM=$P(PXCAERR,"^",5)
I PXCAITEM=-1 S PXCA("ERROR","ENCOUNTER",0,0,10)="MST flag bad^"_$P(PXCAENC,"^",10)
I PXCAITEM=-2,$P(PXCAENC,"^",10)=1 S PXCA("WARNING","ENCOUNTER",0,0,10)="MST flag must be N/A not YES for this patient^"_$P(PXCAENC,"^",10)
S PXCAITEM=$P(PXCAERR,"^",17)
I PXCAITEM=-1 S PXCA("ERROR","ENCOUNTER",0,0,17)="HNC flag bad^"_$P(PXCAENC,"^",17)
I PXCAITEM=-2,$P(PXCAENC,"^",11)=1 S PXCA("WARNING","ENCOUNTER",0,0,17)="HNC flag must be N/A not YES for this patient^"_$P(PXCAENC,"^",17)
S PXCAITEM=$P(PXCAERR,"^",18)
I PXCAITEM=-1 S PXCA("ERROR","ENCOUNTER",0,0,18)="CV flag bad^"_$P(PXCAENC,"^",18)
I PXCAITEM=-2,$P(PXCAENC,"^",11)=1 S PXCA("WARNING","ENCOUNTER",0,0,18)="CV flag must be N/A not YES for this patient^"_$P(PXCAENC,"^",18)
S PXCAITEM=$P(PXCAERR,"^",19)
I PXCAITEM=-1 S PXCA("ERROR","ENCOUNTER",0,0,19)="PROJ 112/SHAD flag bad^"_$P(PXCAENC,"^",19)
I PXCAITEM=-2,$P(PXCAENC,"^",11)=1 S PXCA("WARNING","ENCOUNTER",0,0,19)="PROJ 112/SHAD flag must be N/A not YES for this patient^"_$P(PXCAENC,"^",19)
S $P(PXCAENC,"^",6,11)=PXCAOUT
S PXCAITEM=+$P(PXCAENC,"^",13)
I PXCAITEM D
. N PXCADILF,DIERR
. S PXCAITM2=$$EXTERNAL^DILFD(9000010,.21,"",PXCAITEM,"PXCADILF")
. I $D(DIERR) S PXCA("ERROR","ENCOUNTER",0,0,13)="Eligibility code not in File 8^"_PXCAITEM
. E I PXCAITEM=$P($G(PXCAPAT("ELIG")),"^",1)
. E I $D(PXCAPAT("ELIG",PXCAITEM))=1
. E S PXCA("ERROR","ENCOUNTER",0,0,13)="Eligibility code is not one of this patient's Eligibilities^"_PXCAITEM
S PXCAITEM=+$P(PXCAENC,"^",14)
I PXCAITEM=0
E I PXCAITEM>(DT+.7) S PXCA("ERROR","ENCOUNTER",0,0,14)="Check-out Date and Time is later that today^"_PXCAITEM
E I PXCAITEM#1=0 S PXCA("ERROR","ENCOUNTER",0,0,14)="Time is required for Check-out Date and Time^"_PXCAITEM
I PXCACSTP'="" D
. I '$D(^DIC(40.7,+PXCACSTP,0)) S PXCA("ERROR","ENCOUNTER",0,0,17)="Optional CREDIT STOP not in File 40.7^"_PXCACSTP
. E I $P(^DIC(40.7,+PXCACSTP,0),"^",3),PXCADT'<$P(^(0),"^",3) S PXCA("ERROR","ENCOUNTER",0,0,17)="Optional CREDIT STOP is inactive in file 40.7^"_PXCACSTP
;
I PXCABULD&'$D(PXCA("ERROR","ENCOUNTER"))!PXCAERRS D VST^PXCAVST1(PXCAENC)
;
D PROVIDER^PXCAVST2
;
Q
;
--- Routine Detail --- with STRUCTURED ROUTINE LISTING ---[H[J[2J[HPXCAVST 6252 printed Dec 13, 2024@02:27:45 Page 2
PXCAVST ;ISL/dee & LEA/Chylton - Validates data from the PCE Device Interface for the Visit and Providers ;6/6/05
+1 ;;1.0;PCE PATIENT CARE ENCOUNTER;**14,33,74,111,116,130,168**;Aug 12, 1996;Build 14
+2 QUIT
+3 ;
ENCOUNT(PXCA,PXCABULD,PXCAERRS,PXCAEVAL) ;
+1 IF '($DATA(PXCA("ENCOUNTER"))#2)
SET PXCA("ERROR","ENCOUNTER",0,0,0)="ENCOUNTER node of the local data array is missing"
QUIT
+2 NEW PXCAENC
+3 NEW PXCAITEM,PXCAITM2,PXCAOUT,PXCAERR
+4 SET PXCAENC=$GET(PXCA("ENCOUNTER"))
+5 IF PXCAENC=""
SET PXCA("ERROR","ENCOUNTER",0,0,0)="ENCOUNTER data missing"
QUIT
+6 IF '($DATA(^DPT(PXCAPAT,0))#2)
SET PXCA("ERROR","ENCOUNTER",0,0,2)="Patient missing or invalid in file 2^"_PXCAPAT
+7 IF '($DATA(^AUPNPAT(PXCAPAT,0))#2)
SET PXCA("ERROR","ENCOUNTER",0,0,2)="Patient missing or invalid in file 9000001^"_PXCAPAT
+8 SET PXCAITEM=+$PIECE(PXCAENC,"^",1)
+9 IF 'PXCAITEM
SET PXCA("ERROR","ENCOUNTER",0,0,1)="Encounter Data/Time Missing^"_PXCAITEM
+10 IF '$TEST
IF $DATA(^DPT(PXCAPAT,"S",PXCAITEM,0))
IF $DATA(^SC(+PXCAHLOC,0))
IF ^DPT(PXCAPAT,"S",PXCAITEM,0)
IF PXCAHLOC
Begin DoDot:1
+11 ;Have an appointment at this time
+12 NEW VASD,VAERR
+13 SET VASD("W")=345678
+14 SET VASD("F")=PXCAITEM-.0000001
+15 SET VASD("T")=PXCAITEM+.0000001
+16 SET VASD("C",PXCAHLOC)=""
+17 DO SDA^VADPT
+18 IF $DATA(^UTILITY("VASD",$JOB))
SET PXCA("ERROR","ENCOUNTER",0,0,1)="Appointment is No Show or Canceled^"_PXCAITEM
End DoDot:1
+19 IF '$DATA(^DPT(PXCAPAT,"S",PXCAITEM,0))!(+$GET(^DPT(PXCAPAT,"S",PXCAITEM,0))'=PXCAHLOC)
IF '(+$PIECE(PXCAENC,"^",5))
IF '$DATA(PXCA("PROCEDURE"))
IF '$DATA(^AUPNVCPT("AD",+PXCAVSIT))
Begin DoDot:1
+20 SET PXCA("ERROR","ENCOUNTER",0,0,1)="Encounters that do not have an appointment must have a procedure^"
End DoDot:1
+21 IF '$TEST
IF PXCAITEM>(DT+.7)
SET PXCA("ERROR","ENCOUNTER",0,0,1)="Encounter Date/Time is later that today^"_PXCAITEM
+22 IF '$DATA(^SC(PXCAHLOC,0))
SET PXCA("ERROR","ENCOUNTER",0,0,3)="HOSPITAL LOCATION Missing is not in file 44^"_PXCAHLOC
+23 ;Allow a disposition clinic to be used as HOSPITAL LOCATION ;PX*1.0*116
+24 ;I $D(^PX(815,1,"DHL","B",PXCAHLOC)) S PXCA("ERROR","ENCOUNTER",0,0,3)="HOSPITAL LOCATION Can not be a disposition clinic^"_PXCAHLOC
+25 DO EVALCODE^PXCAVST2(.PXCAEVAL)
+26 DO SCC^PXUTLSCC(PXCAPAT,PXCADT,PXCAHLOC,PXCAVSIT,$PIECE(PXCAENC,"^",6,11),.PXCAOUT,.PXCAERR)
+27 SET PXCAITEM=$PIECE(PXCAERR,"^",1)
+28 IF PXCAITEM=-1
SET PXCA("ERROR","ENCOUNTER",0,0,6)="SC flag bad^"_$PIECE(PXCAENC,"^",6)
+29 IF PXCAITEM=-2
IF $PIECE(PXCAENC,"^",6)=1
SET PXCA("WARNING","ENCOUNTER",0,0,6)="SC flag must be N/A not YES for this patient^"_$PIECE(PXCAENC,"^",6)
+30 IF PXCAITEM=1
IF $PIECE($GET(^PX(815,1,"DI")),"^",1)
SET PXCA("WARNING","ENCOUNTER",0,0,6)="SC flag is missing^"_$PIECE(PXCAENC,"^",6)
+31 SET PXCAITEM=$PIECE(PXCAERR,"^",2)
+32 IF PXCAITEM=-1
SET PXCA("ERROR","ENCOUNTER",0,0,7)="AO flag bad^"_$PIECE(PXCAENC,"^",7)
+33 IF PXCAITEM=-2
IF $PIECE(PXCAENC,"^",7)=1
SET PXCA("WARNING","ENCOUNTER",0,0,7)="AO flag must be N/A not YES for this patient^"_$PIECE(PXCAENC,"^",7)
+34 IF PXCAITEM=-3
IF $PIECE(PXCAENC,"^",7)=1
SET PXCA("WARNING","ENCOUNTER",0,0,7)="AO flag must be N/A not YES because SC flag is true^"_$PIECE(PXCAENC,"^",7)
+35 IF PXCAITEM=1
IF $PIECE($GET(^PX(815,1,"DI")),"^",1)
SET PXCA("WARNING","ENCOUNTER",0,0,7)="AO flag is missing^"_$PIECE(PXCAENC,"^",7)
+36 SET PXCAITEM=$PIECE(PXCAERR,"^",3)
+37 IF PXCAITEM=-1
SET PXCA("ERROR","ENCOUNTER",0,0,8)="IR flag bad^"_$PIECE(PXCAENC,"^",8)
+38 IF PXCAITEM=-2
IF $PIECE(PXCAENC,"^",8)=1
SET PXCA("WARNING","ENCOUNTER",0,0,8)="IR flag must be N/A not YES for this patient^"_$PIECE(PXCAENC,"^",8)
+39 IF PXCAITEM=-3
IF $PIECE(PXCAENC,"^",8)=1
SET PXCA("WARNING","ENCOUNTER",0,0,8)="IR flag must be N/A not YES because SC flag is true^"_$PIECE(PXCAENC,"^",8)
+40 IF PXCAITEM=1
IF $PIECE($GET(^PX(815,1,"DI")),"^",1)
SET PXCA("WARNING","ENCOUNTER",0,0,8)="IR flag is missing^"_$PIECE(PXCAENC,"^",8)
+41 SET PXCAITEM=$PIECE(PXCAERR,"^",4)
+42 IF PXCAITEM=-1
SET PXCA("ERROR","ENCOUNTER",0,0,9)="EC flag bad^"_$PIECE(PXCAENC,"^",9)
+43 IF PXCAITEM=-2
IF $PIECE(PXCAENC,"^",9)=1
SET PXCA("WARNING","ENCOUNTER",0,0,9)="EC flag must be N/A not YES for this patient^"_$PIECE(PXCAENC,"^",9)
+44 IF PXCAITEM=-3
IF $PIECE(PXCAENC,"^",9)=1
SET PXCA("WARNING","ENCOUNTER",0,0,9)="EC flag must be N/A not YES because SC flag is true^"_$PIECE(PXCAENC,"^",9)
+45 IF PXCAITEM=1
IF $PIECE($GET(^PX(815,1,"DI")),"^",1)
SET PXCA("WARNING","ENCOUNTER",0,0,9)="EC flag is missing^"_$PIECE(PXCAENC,"^",9)
+46 SET PXCAITEM=$PIECE(PXCAERR,"^",5)
+47 IF PXCAITEM=-1
SET PXCA("ERROR","ENCOUNTER",0,0,10)="MST flag bad^"_$PIECE(PXCAENC,"^",10)
+48 IF PXCAITEM=-2
IF $PIECE(PXCAENC,"^",10)=1
SET PXCA("WARNING","ENCOUNTER",0,0,10)="MST flag must be N/A not YES for this patient^"_$PIECE(PXCAENC,"^",10)
+49 SET PXCAITEM=$PIECE(PXCAERR,"^",17)
+50 IF PXCAITEM=-1
SET PXCA("ERROR","ENCOUNTER",0,0,17)="HNC flag bad^"_$PIECE(PXCAENC,"^",17)
+51 IF PXCAITEM=-2
IF $PIECE(PXCAENC,"^",11)=1
SET PXCA("WARNING","ENCOUNTER",0,0,17)="HNC flag must be N/A not YES for this patient^"_$PIECE(PXCAENC,"^",17)
+52 SET PXCAITEM=$PIECE(PXCAERR,"^",18)
+53 IF PXCAITEM=-1
SET PXCA("ERROR","ENCOUNTER",0,0,18)="CV flag bad^"_$PIECE(PXCAENC,"^",18)
+54 IF PXCAITEM=-2
IF $PIECE(PXCAENC,"^",11)=1
SET PXCA("WARNING","ENCOUNTER",0,0,18)="CV flag must be N/A not YES for this patient^"_$PIECE(PXCAENC,"^",18)
+55 SET PXCAITEM=$PIECE(PXCAERR,"^",19)
+56 IF PXCAITEM=-1
SET PXCA("ERROR","ENCOUNTER",0,0,19)="PROJ 112/SHAD flag bad^"_$PIECE(PXCAENC,"^",19)
+57 IF PXCAITEM=-2
IF $PIECE(PXCAENC,"^",11)=1
SET PXCA("WARNING","ENCOUNTER",0,0,19)="PROJ 112/SHAD flag must be N/A not YES for this patient^"_$PIECE(PXCAENC,"^",19)
+58 SET $PIECE(PXCAENC,"^",6,11)=PXCAOUT
+59 SET PXCAITEM=+$PIECE(PXCAENC,"^",13)
+60 IF PXCAITEM
Begin DoDot:1
+61 NEW PXCADILF,DIERR
+62 SET PXCAITM2=$$EXTERNAL^DILFD(9000010,.21,"",PXCAITEM,"PXCADILF")
+63 IF $DATA(DIERR)
SET PXCA("ERROR","ENCOUNTER",0,0,13)="Eligibility code not in File 8^"_PXCAITEM
+64 IF '$TEST
IF PXCAITEM=$PIECE($GET(PXCAPAT("ELIG")),"^",1)
+65 IF '$TEST
IF $DATA(PXCAPAT("ELIG",PXCAITEM))=1
+66 IF '$TEST
SET PXCA("ERROR","ENCOUNTER",0,0,13)="Eligibility code is not one of this patient's Eligibilities^"_PXCAITEM
End DoDot:1
+67 SET PXCAITEM=+$PIECE(PXCAENC,"^",14)
+68 IF PXCAITEM=0
+69 IF '$TEST
IF PXCAITEM>(DT+.7)
SET PXCA("ERROR","ENCOUNTER",0,0,14)="Check-out Date and Time is later that today^"_PXCAITEM
+70 IF '$TEST
IF PXCAITEM#1=0
SET PXCA("ERROR","ENCOUNTER",0,0,14)="Time is required for Check-out Date and Time^"_PXCAITEM
+71 IF PXCACSTP'=""
Begin DoDot:1
+72 IF '$DATA(^DIC(40.7,+PXCACSTP,0))
SET PXCA("ERROR","ENCOUNTER",0,0,17)="Optional CREDIT STOP not in File 40.7^"_PXCACSTP
+73 IF '$TEST
IF $PIECE(^DIC(40.7,+PXCACSTP,0),"^",3)
IF PXCADT'<$PIECE(^(0),"^",3)
SET PXCA("ERROR","ENCOUNTER",0,0,17)="Optional CREDIT STOP is inactive in file 40.7^"_PXCACSTP
End DoDot:1
+74 ;
+75 IF PXCABULD&'$DATA(PXCA("ERROR","ENCOUNTER"))!PXCAERRS
DO VST^PXCAVST1(PXCAENC)
+76 ;
+77 DO PROVIDER^PXCAVST2
+78 ;
+79 QUIT
+80 ;