PXCAVST ;ISL/dee & LEA/Chylton - Validates data from the PCE Device Interface for the Visit and Providers ;11/19/96
;;1.0;PCE PATIENT CARE ENCOUNTER;**14,33,74,111**;Aug 12, 1996
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
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,"^",16)
I PXCAITEM=-1 S PXCA("ERROR","ENCOUNTER",0,0,18)="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 $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
;
PXCAVST ;ISL/dee & LEA/Chylton - Validates data from the PCE Device Interface for the Visit and Providers ;11/19/96
+1 ;;1.0;PCE PATIENT CARE ENCOUNTER;**14,33,74,111**;Aug 12, 1996
+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 IF $DATA(^PX(815,1,"DHL","B",PXCAHLOC))
SET PXCA("ERROR","ENCOUNTER",0,0,3)="HOSPITAL LOCATION Can not be a disposition clinic^"_PXCAHLOC
+24 DO EVALCODE^PXCAVST2(.PXCAEVAL)
+25 DO SCC^PXUTLSCC(PXCAPAT,PXCADT,PXCAHLOC,PXCAVSIT,$PIECE(PXCAENC,"^",6,11),.PXCAOUT,.PXCAERR)
+26 SET PXCAITEM=$PIECE(PXCAERR,"^",1)
+27 IF PXCAITEM=-1
SET PXCA("ERROR","ENCOUNTER",0,0,6)="SC flag bad^"_$PIECE(PXCAENC,"^",6)
+28 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)
+29 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)
+30 SET PXCAITEM=$PIECE(PXCAERR,"^",2)
+31 IF PXCAITEM=-1
SET PXCA("ERROR","ENCOUNTER",0,0,7)="AO flag bad^"_$PIECE(PXCAENC,"^",7)
+32 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)
+33 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)
+34 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)
+35 SET PXCAITEM=$PIECE(PXCAERR,"^",3)
+36 IF PXCAITEM=-1
SET PXCA("ERROR","ENCOUNTER",0,0,8)="IR flag bad^"_$PIECE(PXCAENC,"^",8)
+37 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)
+38 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)
+39 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)
+40 SET PXCAITEM=$PIECE(PXCAERR,"^",4)
+41 IF PXCAITEM=-1
SET PXCA("ERROR","ENCOUNTER",0,0,9)="EC flag bad^"_$PIECE(PXCAENC,"^",9)
+42 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)
+43 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)
+44 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)
+45 SET PXCAITEM=$PIECE(PXCAERR,"^",5)
+46 IF PXCAITEM=-1
SET PXCA("ERROR","ENCOUNTER",0,0,10)="MST flag bad^"_$PIECE(PXCAENC,"^",10)
+47 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)
+48 SET PXCAITEM=$PIECE(PXCAERR,"^",16)
+49 IF PXCAITEM=-1
SET PXCA("ERROR","ENCOUNTER",0,0,18)="HNC flag bad^"_$PIECE(PXCAENC,"^",17)
+50 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)
+51 SET $PIECE(PXCAENC,"^",6,11)=PXCAOUT
+52 SET PXCAITEM=+$PIECE(PXCAENC,"^",13)
+53 IF PXCAITEM
Begin DoDot:1
+54 NEW PXCADILF,DIERR
+55 SET PXCAITM2=$$EXTERNAL^DILFD(9000010,.21,"",PXCAITEM,"PXCADILF")
+56 IF $DATA(DIERR)
SET PXCA("ERROR","ENCOUNTER",0,0,13)="Eligibility code not in File 8^"_PXCAITEM
+57 IF '$TEST
IF PXCAITEM=$PIECE($GET(PXCAPAT("ELIG")),"^",1)
+58 IF '$TEST
IF $DATA(PXCAPAT("ELIG",PXCAITEM))=1
+59 IF '$TEST
SET PXCA("ERROR","ENCOUNTER",0,0,13)="Eligibility code is not one of this patient's Eligibilities^"_PXCAITEM
End DoDot:1
+60 SET PXCAITEM=+$PIECE(PXCAENC,"^",14)
+61 IF PXCAITEM=0
+62 IF '$TEST
IF PXCAITEM>(DT+.7)
SET PXCA("ERROR","ENCOUNTER",0,0,14)="Check-out Date and Time is later that today^"_PXCAITEM
+63 IF '$TEST
IF PXCAITEM#1=0
SET PXCA("ERROR","ENCOUNTER",0,0,14)="Time is required for Check-out Date and Time^"_PXCAITEM
+64 IF PXCACSTP'=""
Begin DoDot:1
+65 IF '$DATA(^DIC(40.7,+PXCACSTP,0))
SET PXCA("ERROR","ENCOUNTER",0,0,17)="Optional CREDIT STOP not in File 40.7^"_PXCACSTP
+66 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
+67 ;
+68 IF PXCABULD&'$DATA(PXCA("ERROR","ENCOUNTER"))!PXCAERRS
DO VST^PXCAVST1(PXCAENC)
+69 ;
+70 DO PROVIDER^PXCAVST2
+71 ;
+72 QUIT
+73 ;