PXAIVSTV ;ISL/JVS,ISA/KWP - VALIDATE THE VISIT DATA ;04/28/99
;;1.0;PCE PATIENT CARE ENCOUNTER;**9,15,19,74,111**;Aug 12, 1996
;
;
Q
VALSCC ;--VALIDATE SERVICE CONNECTIVENESS
N ERR,ERR1
D SCC^PXUTLSCC($G(PXAA("PATIENT")),$G(PXAA("ENC D/T")),$G(PXAA("HOS LOC")),$G(PXAVISIT),$G(AFTER800),.AFTER8A,.ERR)
;PX*1*111 - Add HNC
I $P(ERR,"^",1)=0,$P(ERR,"^",2)=0,$P(ERR,"^",3)=0,$P(ERR,"^",4)=0,$P(ERR,"^",5)=0,$P(ERR,"^",6)=0 Q
S PXADI("DIALOG")=8390001.003
S PXAERRF=1
S PXAERR("1W")=$S($P(AFTER800,"^",1)']"":"NULL",1:$P(AFTER800,"^",1))
S PXAERR("2W")=$S($P(AFTER800,"^",2)']"":"NULL",1:$P(AFTER800,"^",2))
S PXAERR("3W")=$S($P(AFTER800,"^",3)']"":"NULL",1:$P(AFTER800,"^",3))
S PXAERR("4W")=$S($P(AFTER800,"^",4)']"":"NULL",1:$P(AFTER800,"^",4))
S PXAERR("5W")=$S($P(AFTER800,"^",5)']"":"NULL",1:$P(AFTER800,"^",5))
;PX*1*111 - Add HNC
S PXAERR("16W")=$S($P(AFTER800,"^",6)']"":"NULL",1:$P(AFTER800,"^",6))
S ERR1=$P(ERR,"^",1),PXAERR("6W")=$S(ERR1=1:"Should be a YES or NO!, not NULL",ERR1=0:"No error",ERR1=-1:"Not a valid value",ERR1=-2:"Value must be NULL",ERR1=-3:"Must be NULL because Service Connected is yes",1:"")
S ERR1=$P(ERR,"^",2),PXAERR("7W")=$S(ERR1=1:"Should be a YES or NO!, not NULL",ERR1=0:"No error",ERR1=-1:"Not a valid value",ERR1=-2:"Value must be NULL",ERR1=-3:"Must be NULL because Service Connected is yes",1:"")
S ERR1=$P(ERR,"^",3),PXAERR("8W")=$S(ERR1=1:"Should be a YES or NO!, not NULL",ERR1=0:"No error",ERR1=-1:"Not a valid value",ERR1=-2:"Value must be NULL",ERR1=-3:"Must be NULL because Service Connected is yes",1:"")
S ERR1=$P(ERR,"^",4),PXAERR("9W")=$S(ERR1=1:"Should be a YES or NO!, not NULL",ERR1=0:"No error",ERR1=-1:"Not a valid value",ERR1=-2:"Value must be NULL",ERR1=-3:"Must be NULL because Service Connected is yes",1:"")
S ERR1=$P(ERR,"^",5),PXAERR("10W")=$S(ERR1=1:"Should be a YES or NO!, not NULL",ERR1=0:"No error",ERR1=-1:"Not a valid value",ERR1=-2:"Value must be NULL",ERR1=-3:"Must be NULL because Service Connected is yes",1:"")
;PX*1*111 - Add HNC
S ERR1=$P(ERR,"^",6),PXAERR("17W")=$S(ERR1=1:"Should be a YES or NO!, not NULL",ERR1=0:"No error",ERR1=-1:"Not a valid value",ERR1=-2:"Value must be NULL",ERR1=-3:"Must be NULL because Service Connected is yes",1:"")
S PXAERR("11W")=$S($P(AFTER8A,"^",1)']"":"NULL",1:$P(AFTER8A,"^",1))
S PXAERR("12W")=$S($P(AFTER8A,"^",2)']"":"NULL",1:$P(AFTER8A,"^",2))
S PXAERR("13W")=$S($P(AFTER8A,"^",3)']"":"NULL",1:$P(AFTER8A,"^",3))
S PXAERR("14W")=$S($P(AFTER8A,"^",4)']"":"NULL",1:$P(AFTER8A,"^",4))
S PXAERR("15W")=$S($P(AFTER8A,"^",5)']"":"NULL",1:$P(AFTER8A,"^",5))
;PX*1*111 - Add HNC
S PXAERR("18W")=$S($P(AFTER8A,"^",6)']"":"NULL",1:$P(AFTER8A,"^",6))
D ERR^PXAI K PXAERRF
Q
;
VAL ;--VALIDATE ENOUGH DATA
;
;---Is the visit sent TO US valid?
I $G(PXAVISIT) D Q:$D(STOP)
.I '$D(^AUPNVSIT(PXAVISIT,0)) D Q:$G(STOP)
..S STOP=1
..S PXAERRF=1
..S PXADI("DIALOG")=8390001.001
..S PXAERR(11)=$G(PXAVISIT)
..S PXAERR(12)="The value that was sent to us is not a valid visit in the VISIT file # 9000010. The Patients name will be derived from the visit file and could cause the data to be given to the wrong patient if not correct."
..S PXAERR(13)="If the correct VISIT isn't known, set the 'ENCOUNTER' array and we will look it up or create a correct one. Setting both at the same time will only add confusion as to what data is correct."
Q:$G(PXAVISIT)
;
;----Missing a date and time of visit
I $G(PXAA("ENC D/T"))']"" D Q:$G(STOP)
.S STOP=1 ;--USED TO STOP DO LOOP
.S PXAERRF=1 ;--FLAG INDICATES THERE IS AN ERR
.S PXADI("DIALOG")=8390001.001
.S PXAERR(9)="ENC D/T"
.S PXAERR(11)=$G(PXAA("ENC D/T"))
.S PXAERR(12)="You are missing the date and time of the visit in FileManager internal format."
;
;----Missing Time and not Historical Visit
I $L($G(PXAA("ENC D/T")),".")=1,$G(PXAA("SERVICE CATEGORY"))'="E" D
.S STOP=1 ;--USED TO STOP DO LOOP
.S PXAERRF=1 ;--FLAG INDICATES THERE IS AN ERR
.S PXADI("DIALOG")=8390001.001
.S PXAERR(9)="ENC D/T"
.S PXAERR(11)=$G(PXAA("ENC D/T"))
.S PXAERR(12)="You are missing the TIME of the visit in FileManager internal format. Unless this is an HISTORICAL encounter, you must have the time."
;
;
;
;----MISSING a pointer to PATIENT/IHS FILE # 9000001
I $G(PXAA("PATIENT"))']"" D Q:$G(STOP)
.S STOP=1
.S PXAERRF=1
.S PXADI("DIALOG")=8390001.001
.S PXAERR(9)="PATIENT"
.S PXAERR(11)=$G(PXAA("PATIENT"))
.S PXAERR(12)="Missing a pointer to the PATIENT/IHS file #9000001"
;
;
;----Not a pointer to the PATIENT/IHS file #9000001
I '$D(^AUPNPAT($G(PXAA("PATIENT")),0)) D Q:$G(STOP)
.S STOP=1
.S PXAERRF=1
.S PXADI("DIALOG")=8390001.001
.S PXAERR(9)="PATIENT"
.S PXAERR(11)=$G(PXAA("PATIENT"))
.S PXAERR(12)="This value is not a pointer to file PATIENT/IHS file # 9000001"
;
;---Missing required information
I $G(PXAA("OUTSIDE LOC"))']"",$G(PXAA("HOS LOC"))']"",$G(PXAA("SERVICE CATEGORY"))'="E" D Q:$G(STOP)
.S STOP=1
.S PXAERRF=1
.S PXADI("DIALOG")=8390001.001
.S PXAERR(9)="HOS LOC or OUTSIDE LOC"
.S PXAERR(11)="BOTH ENTRIES ARE NULL AND SERVICE CATEGORY IS NOT ""E"""
.S PXAERR(12)="The HOSPITAL LOCATION (pointer to the HOSPITAL LOCATION file #44 ) needs to be sent in order to create a visit."
;
;---not a pointer to hospital location file
I $D(PXAA("HOS LOC")) D Q:$G(STOP)
.I '$D(^SC($G(PXAA("HOS LOC")),0)) D Q:$G(STOP)
..S STOP=1
..S PXAERRF=1
..S PXADI("DIALOG")=8390001.001
..S PXAERR(9)="HOS LOC"
..S PXAERR(11)=$G(PXAA("HOS LOC"))
..S PXAERR(12)="This HOSPITAL LOCATION is not a pointer to the HOSPITAL LOCATION file #44"
;---hospital location is the dispositioning location
I $D(PXAA("HOS LOC")) D Q:$G(STOP)
.I $D(^PX(815,1,"DHL","B",$G(PXAA("HOS LOC")))) D Q:$G(STOP)
..S STOP=1
..S PXAERRF=1
..S PXADI("DIALOG")=8390001.001
..S PXAERR(9)="HOS LOC"
..S PXAERR(11)=$G(PXAA("HOS LOC"))
..S PXAERR(12)="This HOSPITAL LOCATION is a dispositioning location and connot be used. Refer to entries in file#815 PCE PARAMETERS"
;--Not a service category
I '$D(PXAA("SERVICE CATEGORY")) D Q:$G(STOP)
.S STOP=1
.S PXAERRF=1
.S PXADI("DIALOG")=8390001.001
.S PXAERR(9)="SERVICE CATEGORY"
.S PXAERR(11)=$G(PXAA("SERVICE CATEGORY"))
.S PXAERR(12)="SERVICE CATEGORY is a required field"
Q
;
VPTR ;---Is the visit sent TO US valid?
I $G(PXAVISIT) D Q:$D(STOP)
.I '$D(^AUPNVSIT(PXAVISIT,0)) D Q:$G(STOP)
..S STOP=1
..S PXAK=1
..S PXAERRF=1
..S PXADI("DIALOG")=8390001.001
..S PXAERR(7)="ENCOUNTER"
..S PXAERR(9)="GENERAL NATURE"
..S PXAERR(11)=$G(PXAVISIT)
..S PXAERR(12)="The value that was sent to us is not a valid visit in the VISIT file # 9000010. The Patients name will be derived from the visit file and could cause the data to be given to the wrong patient if not correct."
..S PXAERR(13)="If the correct VISIT isn't known, set the 'ENCOUNTER' array and we will look it up or create a correct one. Setting both at the same time will only add confusion as to what data is correct."
Q:$G(PXAVISIT)
Q
PXAIVSTV ;ISL/JVS,ISA/KWP - VALIDATE THE VISIT DATA ;04/28/99
+1 ;;1.0;PCE PATIENT CARE ENCOUNTER;**9,15,19,74,111**;Aug 12, 1996
+2 ;
+3 ;
+4 QUIT
VALSCC ;--VALIDATE SERVICE CONNECTIVENESS
+1 NEW ERR,ERR1
+2 DO SCC^PXUTLSCC($GET(PXAA("PATIENT")),$GET(PXAA("ENC D/T")),$GET(PXAA("HOS LOC")),$GET(PXAVISIT),$GET(AFTER800),.AFTER8A,.ERR)
+3 ;PX*1*111 - Add HNC
+4 IF $PIECE(ERR,"^",1)=0
IF $PIECE(ERR,"^",2)=0
IF $PIECE(ERR,"^",3)=0
IF $PIECE(ERR,"^",4)=0
IF $PIECE(ERR,"^",5)=0
IF $PIECE(ERR,"^",6)=0
QUIT
+5 SET PXADI("DIALOG")=8390001.003
+6 SET PXAERRF=1
+7 SET PXAERR("1W")=$SELECT($PIECE(AFTER800,"^",1)']"":"NULL",1:$PIECE(AFTER800,"^",1))
+8 SET PXAERR("2W")=$SELECT($PIECE(AFTER800,"^",2)']"":"NULL",1:$PIECE(AFTER800,"^",2))
+9 SET PXAERR("3W")=$SELECT($PIECE(AFTER800,"^",3)']"":"NULL",1:$PIECE(AFTER800,"^",3))
+10 SET PXAERR("4W")=$SELECT($PIECE(AFTER800,"^",4)']"":"NULL",1:$PIECE(AFTER800,"^",4))
+11 SET PXAERR("5W")=$SELECT($PIECE(AFTER800,"^",5)']"":"NULL",1:$PIECE(AFTER800,"^",5))
+12 ;PX*1*111 - Add HNC
+13 SET PXAERR("16W")=$SELECT($PIECE(AFTER800,"^",6)']"":"NULL",1:$PIECE(AFTER800,"^",6))
+14 SET ERR1=$PIECE(ERR,"^",1)
SET PXAERR("6W")=$SELECT(ERR1=1:"Should be a YES or NO!, not NULL",ERR1=0:"No error",ERR1=-1:"Not a valid value",ERR1=-2:"Value must be NULL",ERR1=-3:"Must be NULL because Service Connected is yes",1:"")
+15 SET ERR1=$PIECE(ERR,"^",2)
SET PXAERR("7W")=$SELECT(ERR1=1:"Should be a YES or NO!, not NULL",ERR1=0:"No error",ERR1=-1:"Not a valid value",ERR1=-2:"Value must be NULL",ERR1=-3:"Must be NULL because Service Connected is yes",1:"")
+16 SET ERR1=$PIECE(ERR,"^",3)
SET PXAERR("8W")=$SELECT(ERR1=1:"Should be a YES or NO!, not NULL",ERR1=0:"No error",ERR1=-1:"Not a valid value",ERR1=-2:"Value must be NULL",ERR1=-3:"Must be NULL because Service Connected is yes",1:"")
+17 SET ERR1=$PIECE(ERR,"^",4)
SET PXAERR("9W")=$SELECT(ERR1=1:"Should be a YES or NO!, not NULL",ERR1=0:"No error",ERR1=-1:"Not a valid value",ERR1=-2:"Value must be NULL",ERR1=-3:"Must be NULL because Service Connected is yes",1:"")
+18 SET ERR1=$PIECE(ERR,"^",5)
SET PXAERR("10W")=$SELECT(ERR1=1:"Should be a YES or NO!, not NULL",ERR1=0:"No error",ERR1=-1:"Not a valid value",ERR1=-2:"Value must be NULL",ERR1=-3:"Must be NULL because Service Connected is yes",1:"")
+19 ;PX*1*111 - Add HNC
+20 SET ERR1=$PIECE(ERR,"^",6)
SET PXAERR("17W")=$SELECT(ERR1=1:"Should be a YES or NO!, not NULL",ERR1=0:"No error",ERR1=-1:"Not a valid value",ERR1=-2:"Value must be NULL",ERR1=-3:"Must be NULL because Service Connected is yes",1:"")
+21 SET PXAERR("11W")=$SELECT($PIECE(AFTER8A,"^",1)']"":"NULL",1:$PIECE(AFTER8A,"^",1))
+22 SET PXAERR("12W")=$SELECT($PIECE(AFTER8A,"^",2)']"":"NULL",1:$PIECE(AFTER8A,"^",2))
+23 SET PXAERR("13W")=$SELECT($PIECE(AFTER8A,"^",3)']"":"NULL",1:$PIECE(AFTER8A,"^",3))
+24 SET PXAERR("14W")=$SELECT($PIECE(AFTER8A,"^",4)']"":"NULL",1:$PIECE(AFTER8A,"^",4))
+25 SET PXAERR("15W")=$SELECT($PIECE(AFTER8A,"^",5)']"":"NULL",1:$PIECE(AFTER8A,"^",5))
+26 ;PX*1*111 - Add HNC
+27 SET PXAERR("18W")=$SELECT($PIECE(AFTER8A,"^",6)']"":"NULL",1:$PIECE(AFTER8A,"^",6))
+28 DO ERR^PXAI
KILL PXAERRF
+29 QUIT
+30 ;
VAL ;--VALIDATE ENOUGH DATA
+1 ;
+2 ;---Is the visit sent TO US valid?
+3 IF $GET(PXAVISIT)
Begin DoDot:1
+4 IF '$DATA(^AUPNVSIT(PXAVISIT,0))
Begin DoDot:2
+5 SET STOP=1
+6 SET PXAERRF=1
+7 SET PXADI("DIALOG")=8390001.001
+8 SET PXAERR(11)=$GET(PXAVISIT)
+9 SET PXAERR(12)="The value that was sent to us is not a valid visit in the VISIT file # 9000010. The Patients name will be derived from the visit file and could cause the data to be given to the wrong patient if not correct."
+10 SET PXAERR(13)="If the correct VISIT isn't known, set the 'ENCOUNTER' array and we will look it up or create a correct one. Setting both at the same time will only add confusion as to what data is correct."
End DoDot:2
IF $GET(STOP)
QUIT
End DoDot:1
IF $DATA(STOP)
QUIT
+11 IF $GET(PXAVISIT)
QUIT
+12 ;
+13 ;----Missing a date and time of visit
+14 IF $GET(PXAA("ENC D/T"))']""
Begin DoDot:1
+15 ;--USED TO STOP DO LOOP
SET STOP=1
+16 ;--FLAG INDICATES THERE IS AN ERR
SET PXAERRF=1
+17 SET PXADI("DIALOG")=8390001.001
+18 SET PXAERR(9)="ENC D/T"
+19 SET PXAERR(11)=$GET(PXAA("ENC D/T"))
+20 SET PXAERR(12)="You are missing the date and time of the visit in FileManager internal format."
End DoDot:1
IF $GET(STOP)
QUIT
+21 ;
+22 ;----Missing Time and not Historical Visit
+23 IF $LENGTH($GET(PXAA("ENC D/T")),".")=1
IF $GET(PXAA("SERVICE CATEGORY"))'="E"
Begin DoDot:1
+24 ;--USED TO STOP DO LOOP
SET STOP=1
+25 ;--FLAG INDICATES THERE IS AN ERR
SET PXAERRF=1
+26 SET PXADI("DIALOG")=8390001.001
+27 SET PXAERR(9)="ENC D/T"
+28 SET PXAERR(11)=$GET(PXAA("ENC D/T"))
+29 SET PXAERR(12)="You are missing the TIME of the visit in FileManager internal format. Unless this is an HISTORICAL encounter, you must have the time."
End DoDot:1
+30 ;
+31 ;
+32 ;
+33 ;----MISSING a pointer to PATIENT/IHS FILE # 9000001
+34 IF $GET(PXAA("PATIENT"))']""
Begin DoDot:1
+35 SET STOP=1
+36 SET PXAERRF=1
+37 SET PXADI("DIALOG")=8390001.001
+38 SET PXAERR(9)="PATIENT"
+39 SET PXAERR(11)=$GET(PXAA("PATIENT"))
+40 SET PXAERR(12)="Missing a pointer to the PATIENT/IHS file #9000001"
End DoDot:1
IF $GET(STOP)
QUIT
+41 ;
+42 ;
+43 ;----Not a pointer to the PATIENT/IHS file #9000001
+44 IF '$DATA(^AUPNPAT($GET(PXAA("PATIENT")),0))
Begin DoDot:1
+45 SET STOP=1
+46 SET PXAERRF=1
+47 SET PXADI("DIALOG")=8390001.001
+48 SET PXAERR(9)="PATIENT"
+49 SET PXAERR(11)=$GET(PXAA("PATIENT"))
+50 SET PXAERR(12)="This value is not a pointer to file PATIENT/IHS file # 9000001"
End DoDot:1
IF $GET(STOP)
QUIT
+51 ;
+52 ;---Missing required information
+53 IF $GET(PXAA("OUTSIDE LOC"))']""
IF $GET(PXAA("HOS LOC"))']""
IF $GET(PXAA("SERVICE CATEGORY"))'="E"
Begin DoDot:1
+54 SET STOP=1
+55 SET PXAERRF=1
+56 SET PXADI("DIALOG")=8390001.001
+57 SET PXAERR(9)="HOS LOC or OUTSIDE LOC"
+58 SET PXAERR(11)="BOTH ENTRIES ARE NULL AND SERVICE CATEGORY IS NOT ""E"""
+59 SET PXAERR(12)="The HOSPITAL LOCATION (pointer to the HOSPITAL LOCATION file #44 ) needs to be sent in order to create a visit."
End DoDot:1
IF $GET(STOP)
QUIT
+60 ;
+61 ;---not a pointer to hospital location file
+62 IF $DATA(PXAA("HOS LOC"))
Begin DoDot:1
+63 IF '$DATA(^SC($GET(PXAA("HOS LOC")),0))
Begin DoDot:2
+64 SET STOP=1
+65 SET PXAERRF=1
+66 SET PXADI("DIALOG")=8390001.001
+67 SET PXAERR(9)="HOS LOC"
+68 SET PXAERR(11)=$GET(PXAA("HOS LOC"))
+69 SET PXAERR(12)="This HOSPITAL LOCATION is not a pointer to the HOSPITAL LOCATION file #44"
End DoDot:2
IF $GET(STOP)
QUIT
End DoDot:1
IF $GET(STOP)
QUIT
+70 ;---hospital location is the dispositioning location
+71 IF $DATA(PXAA("HOS LOC"))
Begin DoDot:1
+72 IF $DATA(^PX(815,1,"DHL","B",$GET(PXAA("HOS LOC"))))
Begin DoDot:2
+73 SET STOP=1
+74 SET PXAERRF=1
+75 SET PXADI("DIALOG")=8390001.001
+76 SET PXAERR(9)="HOS LOC"
+77 SET PXAERR(11)=$GET(PXAA("HOS LOC"))
+78 SET PXAERR(12)="This HOSPITAL LOCATION is a dispositioning location and connot be used. Refer to entries in file#815 PCE PARAMETERS"
End DoDot:2
IF $GET(STOP)
QUIT
End DoDot:1
IF $GET(STOP)
QUIT
+79 ;--Not a service category
+80 IF '$DATA(PXAA("SERVICE CATEGORY"))
Begin DoDot:1
+81 SET STOP=1
+82 SET PXAERRF=1
+83 SET PXADI("DIALOG")=8390001.001
+84 SET PXAERR(9)="SERVICE CATEGORY"
+85 SET PXAERR(11)=$GET(PXAA("SERVICE CATEGORY"))
+86 SET PXAERR(12)="SERVICE CATEGORY is a required field"
End DoDot:1
IF $GET(STOP)
QUIT
+87 QUIT
+88 ;
VPTR ;---Is the visit sent TO US valid?
+1 IF $GET(PXAVISIT)
Begin DoDot:1
+2 IF '$DATA(^AUPNVSIT(PXAVISIT,0))
Begin DoDot:2
+3 SET STOP=1
+4 SET PXAK=1
+5 SET PXAERRF=1
+6 SET PXADI("DIALOG")=8390001.001
+7 SET PXAERR(7)="ENCOUNTER"
+8 SET PXAERR(9)="GENERAL NATURE"
+9 SET PXAERR(11)=$GET(PXAVISIT)
+10 SET PXAERR(12)="The value that was sent to us is not a valid visit in the VISIT file # 9000010. The Patients name will be derived from the visit file and could cause the data to be given to the wrong patient if not correct."
+11 SET PXAERR(13)="If the correct VISIT isn't known, set the 'ENCOUNTER' array and we will look it up or create a correct one. Setting both at the same time will only add confusion as to what data is correct."
End DoDot:2
IF $GET(STOP)
QUIT
End DoDot:1
IF $DATA(STOP)
QUIT
+12 IF $GET(PXAVISIT)
QUIT
+13 QUIT