ACKQPCE2 ; HCIOFO/AG - Quasar/PCE Interface - Error Processing; August 1999
;;3.0;QUASAR;;Feb 11, 2000
Q
;
CONVERT(ACKPROB,ACKAPI,ACKRSN) ; convert the error array ACKPROB into a list of errors
;
; this label is called from the main Overnight Interface program
; ^ACKQPCE if the DATA2PCE^PXAPI returns any errors or warnings.
; this routine will format the errors and place them in the local
; array ACKRSN. a separate call to label FILE will add them on the
; database.
;
; requires ACKPROB - array generated by DATA2PCE^PXAPI
; ACKAPI - global ref of encounter data passed in to DATA2PCE
; .ACKRSN - (by reference) - the output array
;
; returns ACKRSN=n and ACKRSN(n)=text where each error is formatted
; to FIELD^INTERNAL VALUE^EXTERNAL VALUE^ERROR/WARNING MESSAGE
; eg ACKRSN(1)="PRIMARY PROVIDER^1234^BLOGGS,FRED^The Provider...
; ...does not have an ACTIVE person class!
;
N ACKI
N ACKDEBUG S ACKDEBUG="CONVERT"
K ACKRSN S ACKRSN=0
F ACKI=1:1 Q:'$D(ACKPROB($J,ACKI)) D
. I $D(ACKPROB($J,ACKI,"ERROR1")) D ERROR1
. K ACKPROB($J,ACKI) ; only error1 messages are kept, all others ignored
Q
;
ERROR1 ; process an Error 1
N ACKMSG,ACKEXT,ACKINT,ACKNUM,ACKTYP,ACKFLD,ACKSUB
;
; check for error with visit date
I $D(ACKPROB($J,ACKI,"ERROR1","ENCOUNTER","ENC D/T",1)) D
. S ACKINT=@ACKAPI@("ENCOUNTER",1,"ENC D/T")
. S ACKEXT=$$DATETIME(ACKINT)
. S ACKMSG=ACKPROB($J,ACKI,"ERROR1","ENCOUNTER","ENC D/T",1)
. D ADDRSN("ENC D/T",ACKINT,ACKEXT,ACKMSG,.ACKRSN)
. K ACKPROB($J,ACKI,"ERROR1","ENCOUNTER","ENC D/T",1)
;
; check for error with patient
I $D(ACKPROB($J,ACKI,"ERROR1","ENCOUNTER","PATIENT",1)) D
. S ACKINT=@ACKAPI@("ENCOUNTER",1,"PATIENT")
. S ACKEXT=$$PATIENT(ACKINT)
. S ACKMSG=ACKPROB($J,ACKI,"ERROR1","ENCOUNTER","PATIENT",1)
. D ADDRSN("PATIENT",ACKINT,ACKEXT,ACKMSG,.ACKRSN)
. K ACKPROB($J,ACKI,"ERROR1","ENCOUNTER","PATIENT",1)
;
; check for error with clinic
I $D(ACKPROB($J,ACKI,"ERROR1","ENCOUNTER","HOS LOC",1)) D
. S ACKINT=@ACKAPI@("ENCOUNTER",1,"HOS LOC")
. S ACKEXT=$$CLINIC(ACKINT)
. S ACKMSG=ACKPROB($J,ACKI,"ERROR1","ENCOUNTER","HOS LOC",1)
. D ADDRSN("CLINIC",ACKINT,ACKEXT,ACKMSG,.ACKRSN)
. K ACKPROB($J,ACKI,"ERROR1","ENCOUNTER","HOS LOC",1)
;
; check for any other "ENCOUNTER" errors
S ACKFLD="" F S ACKFLD=$O(ACKPROB($J,ACKI,"ERROR1","ENCOUNTER",ACKFLD)) Q:ACKFLD="" D
. I $D(ACKPROB($J,ACKI,"ERROR1","ENCOUNTER",ACKFLD,1))#10=0 Q
. I $D(@ACKAPI@("ENCOUNTER",1,ACKFLD))#10=0 Q
. S ACKMSG=ACKPROB($J,ACKI,"ERROR1","ENCOUNTER",ACKFLD,1)
. S ACKINT=@ACKAPI@("ENCOUNTER",1,ACKFLD)
. D ADDRSN(ACKFLD,ACKINT,"",ACKMSG,.ACKRSN)
. K ACKPROB($J,ACKI,"ERROR1","ENCOUNTER",ACKFLD,1)
;
; check for provider name errors
I $D(ACKPROB($J,ACKI,"ERROR1","PROVIDER","NAME")) D
. S ACKNUM="" F S ACKNUM=$O(ACKPROB($J,ACKI,"ERROR1","PROVIDER","NAME",ACKNUM)) Q:ACKNUM="" D
. . S ACKINT=@ACKAPI@("PROVIDER",ACKNUM,"NAME")
. . S ACKEXT=$$PRVNAME(ACKINT)
. . S ACKMSG=ACKPROB($J,ACKI,"ERROR1","PROVIDER","NAME",ACKNUM)
. . S ACKFLD=$S($D(@ACKAPI@("PROVIDER",ACKNUM,"PRIMARY")):"PRIMARY ",1:"")_"PROVIDER"
. . D ADDRSN(ACKFLD,ACKINT,ACKEXT,ACKMSG,.ACKRSN)
. . K ACKPROB($J,ACKI,"ERROR1","PROVIDER","NAME",ACKNUM)
;
; check for Procedure code errors
I $D(ACKPROB($J,ACKI,"ERROR1","PROCEDURE","PROCEDURE")) D
. S ACKNUM="" F S ACKNUM=$O(ACKPROB($J,ACKI,"ERROR1","PROCEDURE","PROCEDURE",ACKNUM)) Q:ACKNUM="" D
. . S ACKINT=@ACKAPI@("PROCEDURE",ACKNUM,"PROCEDURE")
. . S ACKEXT=$$CPTNAME(ACKINT)
. . S ACKMSG=ACKPROB($J,ACKI,"ERROR1","PROCEDURE","PROCEDURE",ACKNUM)
. . D ADDRSN("PROCEDURE",ACKINT,ACKEXT,ACKMSG,.ACKRSN)
. . K ACKPROB($J,ACKI,"ERROR1","PROCEDURE","PROCEDURE",ACKNUM)
;
; check for Modifier errors
S ACKSUB="MODIFIER"
F S ACKSUB=$O(ACKPROB($J,ACKI,"ERROR1","PROCEDURE",ACKSUB)) Q:$E(ACKSUB,1,8)'="MODIFIER" D
. S ACKNUM="" F S ACKNUM=$O(ACKPROB($J,ACKI,"ERROR1","PROCEDURE",ACKSUB,ACKNUM)) Q:ACKNUM="" D
. . S ACKINT="",ACKEXT=$P(ACKSUB,",",2)
. . S ACKMSG=ACKPROB($J,ACKI,"ERROR1","PROCEDURE",ACKSUB,ACKNUM)
. . S ACKMSG=ACKMSG_" (Procedure="_$G(@ACKAPI@("PROCEDURE",ACKNUM,"PROCEDURE"))_")"
. . D ADDRSN("MODIFIER",ACKINT,ACKEXT,ACKMSG,.ACKRSN)
. . K ACKPROB($J,ACKI,"ERROR1","PROCEDURE",ACKSUB,ACKNUM)
;
; check for Diagnosis code errors
I $D(ACKPROB($J,ACKI,"ERROR1","DX/PL","DIAGNOSIS")) D
. S ACKNUM="" F S ACKNUM=$O(ACKPROB($J,ACKI,"ERROR1","DX/PL","DIAGNOSIS",ACKNUM)) Q:ACKNUM="" D
. . S ACKINT=@ACKAPI@("DX/PL",ACKNUM,"DIAGNOSIS")
. . S ACKEXT=$$ICDNAME(ACKINT)
. . S ACKMSG=ACKPROB($J,ACKI,"ERROR1","DX/PL","DIAGNOSIS",ACKNUM)
. . D ADDRSN("DIAGNOSIS",ACKINT,ACKEXT,ACKMSG,.ACKRSN)
. . K ACKPROB($J,ACKI,"ERROR1","DX/PL","DIAGNOSIS",ACKNUM)
;
; check for any remaining errors not coded for
S ACKTYP="" F S ACKTYP=$O(ACKPROB($J,ACKI,"ERROR1",ACKTYP)) Q:ACKTYP="" D
. S ACKFLD="" F S ACKFLD=$O(ACKPROB($J,ACKI,"ERROR1",ACKTYP,ACKFLD)) Q:ACKFLD="" D
. . S ACKNUM="" F S ACKNUM=$O(ACKPROB($J,ACKI,"ERROR1",ACKTYP,ACKFLD,ACKNUM)) Q:ACKNUM="" D
. . . I $D(@ACKAPI@(ACKTYP,ACKNUM,ACKFLD))#10=0 Q
. . . I $D(ACKPROB($J,ACKI,"ERROR1",ACKTYP,ACKFLD,ACKNUM))#10=0 Q
. . . S ACKINT=@ACKAPI@(ACKTYP,ACKNUM,ACKFLD)
. . . S ACKMSG=ACKPROB($J,ACKI,"ERROR1",ACKTYP,ACKFLD,ACKNUM)
. . . D ADDRSN(ACKTYP_":"_ACKFLD,ACKINT,"",ACKMSG,.ACKRSN)
. . . K ACKPROB($J,ACKI,"ERROR1",ACKTYP,ACKFLD,ACKNUM)
;
; end of processing errors
Q
;
;
ADDRSN(FLD,INT,EXT,MSG,ACKRSN) ; add erorr to the output array
I +$G(ACKRSN)=0 K ACKRSN S ACKRSN=0 ; if count=0 make sure array empty
S ACKRSN=ACKRSN+1
S $P(ACKRSN(ACKRSN,0),U,1)=ACKRSN ; error number
S $P(ACKRSN(ACKRSN,0),U,2)=FLD ; field name
S $P(ACKRSN(ACKRSN,0),U,3)=INT ; internal format
S $P(ACKRSN(ACKRSN,0),U,4)=EXT ; external format
S ACKRSN(ACKRSN,1)=MSG ; error message
Q
PATIENT(ACKPAT) ; get patient name
Q $$GET1^DIQ(509850.2,ACKPAT_",",.01,"E")
PRVNAME(ACKPRV) ; get provider name
Q $$GET1^DIQ(200,ACKPRV_",",.01,"E")
CLINIC(ACKCLN) ; get clinic name
Q $$GET1^DIQ(44,ACKCLN_",",.01,"E")
CPTNAME(ACKCPT) ; get CPT procedure name
Q $$GET1^DIQ(509850.4,ACKCPT_",",.01,"E")
ICDNAME(ACKICD) ; get ICD diagnosis name
Q $$GET1^DIQ(509850.1,ACKICD_",",.01,"E")
DATETIME(Y) ; convert date/time to external
D DD^%DT
Q Y
--- Routine Detail --- with STRUCTURED ROUTINE LISTING ---[H[J[2J[HACKQPCE2 6401 printed Nov 22, 2024@17:42:25 Page 2
ACKQPCE2 ; HCIOFO/AG - Quasar/PCE Interface - Error Processing; August 1999
+1 ;;3.0;QUASAR;;Feb 11, 2000
+2 QUIT
+3 ;
CONVERT(ACKPROB,ACKAPI,ACKRSN) ; convert the error array ACKPROB into a list of errors
+1 ;
+2 ; this label is called from the main Overnight Interface program
+3 ; ^ACKQPCE if the DATA2PCE^PXAPI returns any errors or warnings.
+4 ; this routine will format the errors and place them in the local
+5 ; array ACKRSN. a separate call to label FILE will add them on the
+6 ; database.
+7 ;
+8 ; requires ACKPROB - array generated by DATA2PCE^PXAPI
+9 ; ACKAPI - global ref of encounter data passed in to DATA2PCE
+10 ; .ACKRSN - (by reference) - the output array
+11 ;
+12 ; returns ACKRSN=n and ACKRSN(n)=text where each error is formatted
+13 ; to FIELD^INTERNAL VALUE^EXTERNAL VALUE^ERROR/WARNING MESSAGE
+14 ; eg ACKRSN(1)="PRIMARY PROVIDER^1234^BLOGGS,FRED^The Provider...
+15 ; ...does not have an ACTIVE person class!
+16 ;
+17 NEW ACKI
+18 NEW ACKDEBUG
SET ACKDEBUG="CONVERT"
+19 KILL ACKRSN
SET ACKRSN=0
+20 FOR ACKI=1:1
if '$DATA(ACKPROB($JOB,ACKI))
QUIT
Begin DoDot:1
+21 IF $DATA(ACKPROB($JOB,ACKI,"ERROR1"))
DO ERROR1
+22 ; only error1 messages are kept, all others ignored
KILL ACKPROB($JOB,ACKI)
End DoDot:1
+23 QUIT
+24 ;
ERROR1 ; process an Error 1
+1 NEW ACKMSG,ACKEXT,ACKINT,ACKNUM,ACKTYP,ACKFLD,ACKSUB
+2 ;
+3 ; check for error with visit date
+4 IF $DATA(ACKPROB($JOB,ACKI,"ERROR1","ENCOUNTER","ENC D/T",1))
Begin DoDot:1
+5 SET ACKINT=@ACKAPI@("ENCOUNTER",1,"ENC D/T")
+6 SET ACKEXT=$$DATETIME(ACKINT)
+7 SET ACKMSG=ACKPROB($JOB,ACKI,"ERROR1","ENCOUNTER","ENC D/T",1)
+8 DO ADDRSN("ENC D/T",ACKINT,ACKEXT,ACKMSG,.ACKRSN)
+9 KILL ACKPROB($JOB,ACKI,"ERROR1","ENCOUNTER","ENC D/T",1)
End DoDot:1
+10 ;
+11 ; check for error with patient
+12 IF $DATA(ACKPROB($JOB,ACKI,"ERROR1","ENCOUNTER","PATIENT",1))
Begin DoDot:1
+13 SET ACKINT=@ACKAPI@("ENCOUNTER",1,"PATIENT")
+14 SET ACKEXT=$$PATIENT(ACKINT)
+15 SET ACKMSG=ACKPROB($JOB,ACKI,"ERROR1","ENCOUNTER","PATIENT",1)
+16 DO ADDRSN("PATIENT",ACKINT,ACKEXT,ACKMSG,.ACKRSN)
+17 KILL ACKPROB($JOB,ACKI,"ERROR1","ENCOUNTER","PATIENT",1)
End DoDot:1
+18 ;
+19 ; check for error with clinic
+20 IF $DATA(ACKPROB($JOB,ACKI,"ERROR1","ENCOUNTER","HOS LOC",1))
Begin DoDot:1
+21 SET ACKINT=@ACKAPI@("ENCOUNTER",1,"HOS LOC")
+22 SET ACKEXT=$$CLINIC(ACKINT)
+23 SET ACKMSG=ACKPROB($JOB,ACKI,"ERROR1","ENCOUNTER","HOS LOC",1)
+24 DO ADDRSN("CLINIC",ACKINT,ACKEXT,ACKMSG,.ACKRSN)
+25 KILL ACKPROB($JOB,ACKI,"ERROR1","ENCOUNTER","HOS LOC",1)
End DoDot:1
+26 ;
+27 ; check for any other "ENCOUNTER" errors
+28 SET ACKFLD=""
FOR
SET ACKFLD=$ORDER(ACKPROB($JOB,ACKI,"ERROR1","ENCOUNTER",ACKFLD))
if ACKFLD=""
QUIT
Begin DoDot:1
+29 IF $DATA(ACKPROB($JOB,ACKI,"ERROR1","ENCOUNTER",ACKFLD,1))#10=0
QUIT
+30 IF $DATA(@ACKAPI@("ENCOUNTER",1,ACKFLD))#10=0
QUIT
+31 SET ACKMSG=ACKPROB($JOB,ACKI,"ERROR1","ENCOUNTER",ACKFLD,1)
+32 SET ACKINT=@ACKAPI@("ENCOUNTER",1,ACKFLD)
+33 DO ADDRSN(ACKFLD,ACKINT,"",ACKMSG,.ACKRSN)
+34 KILL ACKPROB($JOB,ACKI,"ERROR1","ENCOUNTER",ACKFLD,1)
End DoDot:1
+35 ;
+36 ; check for provider name errors
+37 IF $DATA(ACKPROB($JOB,ACKI,"ERROR1","PROVIDER","NAME"))
Begin DoDot:1
+38 SET ACKNUM=""
FOR
SET ACKNUM=$ORDER(ACKPROB($JOB,ACKI,"ERROR1","PROVIDER","NAME",ACKNUM))
if ACKNUM=""
QUIT
Begin DoDot:2
+39 SET ACKINT=@ACKAPI@("PROVIDER",ACKNUM,"NAME")
+40 SET ACKEXT=$$PRVNAME(ACKINT)
+41 SET ACKMSG=ACKPROB($JOB,ACKI,"ERROR1","PROVIDER","NAME",ACKNUM)
+42 SET ACKFLD=$SELECT($DATA(@ACKAPI@("PROVIDER",ACKNUM,"PRIMARY")):"PRIMARY ",1:"")_"PROVIDER"
+43 DO ADDRSN(ACKFLD,ACKINT,ACKEXT,ACKMSG,.ACKRSN)
+44 KILL ACKPROB($JOB,ACKI,"ERROR1","PROVIDER","NAME",ACKNUM)
End DoDot:2
End DoDot:1
+45 ;
+46 ; check for Procedure code errors
+47 IF $DATA(ACKPROB($JOB,ACKI,"ERROR1","PROCEDURE","PROCEDURE"))
Begin DoDot:1
+48 SET ACKNUM=""
FOR
SET ACKNUM=$ORDER(ACKPROB($JOB,ACKI,"ERROR1","PROCEDURE","PROCEDURE",ACKNUM))
if ACKNUM=""
QUIT
Begin DoDot:2
+49 SET ACKINT=@ACKAPI@("PROCEDURE",ACKNUM,"PROCEDURE")
+50 SET ACKEXT=$$CPTNAME(ACKINT)
+51 SET ACKMSG=ACKPROB($JOB,ACKI,"ERROR1","PROCEDURE","PROCEDURE",ACKNUM)
+52 DO ADDRSN("PROCEDURE",ACKINT,ACKEXT,ACKMSG,.ACKRSN)
+53 KILL ACKPROB($JOB,ACKI,"ERROR1","PROCEDURE","PROCEDURE",ACKNUM)
End DoDot:2
End DoDot:1
+54 ;
+55 ; check for Modifier errors
+56 SET ACKSUB="MODIFIER"
+57 FOR
SET ACKSUB=$ORDER(ACKPROB($JOB,ACKI,"ERROR1","PROCEDURE",ACKSUB))
if $EXTRACT(ACKSUB,1,8)'="MODIFIER"
QUIT
Begin DoDot:1
+58 SET ACKNUM=""
FOR
SET ACKNUM=$ORDER(ACKPROB($JOB,ACKI,"ERROR1","PROCEDURE",ACKSUB,ACKNUM))
if ACKNUM=""
QUIT
Begin DoDot:2
+59 SET ACKINT=""
SET ACKEXT=$PIECE(ACKSUB,",",2)
+60 SET ACKMSG=ACKPROB($JOB,ACKI,"ERROR1","PROCEDURE",ACKSUB,ACKNUM)
+61 SET ACKMSG=ACKMSG_" (Procedure="_$GET(@ACKAPI@("PROCEDURE",ACKNUM,"PROCEDURE"))_")"
+62 DO ADDRSN("MODIFIER",ACKINT,ACKEXT,ACKMSG,.ACKRSN)
+63 KILL ACKPROB($JOB,ACKI,"ERROR1","PROCEDURE",ACKSUB,ACKNUM)
End DoDot:2
End DoDot:1
+64 ;
+65 ; check for Diagnosis code errors
+66 IF $DATA(ACKPROB($JOB,ACKI,"ERROR1","DX/PL","DIAGNOSIS"))
Begin DoDot:1
+67 SET ACKNUM=""
FOR
SET ACKNUM=$ORDER(ACKPROB($JOB,ACKI,"ERROR1","DX/PL","DIAGNOSIS",ACKNUM))
if ACKNUM=""
QUIT
Begin DoDot:2
+68 SET ACKINT=@ACKAPI@("DX/PL",ACKNUM,"DIAGNOSIS")
+69 SET ACKEXT=$$ICDNAME(ACKINT)
+70 SET ACKMSG=ACKPROB($JOB,ACKI,"ERROR1","DX/PL","DIAGNOSIS",ACKNUM)
+71 DO ADDRSN("DIAGNOSIS",ACKINT,ACKEXT,ACKMSG,.ACKRSN)
+72 KILL ACKPROB($JOB,ACKI,"ERROR1","DX/PL","DIAGNOSIS",ACKNUM)
End DoDot:2
End DoDot:1
+73 ;
+74 ; check for any remaining errors not coded for
+75 SET ACKTYP=""
FOR
SET ACKTYP=$ORDER(ACKPROB($JOB,ACKI,"ERROR1",ACKTYP))
if ACKTYP=""
QUIT
Begin DoDot:1
+76 SET ACKFLD=""
FOR
SET ACKFLD=$ORDER(ACKPROB($JOB,ACKI,"ERROR1",ACKTYP,ACKFLD))
if ACKFLD=""
QUIT
Begin DoDot:2
+77 SET ACKNUM=""
FOR
SET ACKNUM=$ORDER(ACKPROB($JOB,ACKI,"ERROR1",ACKTYP,ACKFLD,ACKNUM))
if ACKNUM=""
QUIT
Begin DoDot:3
+78 IF $DATA(@ACKAPI@(ACKTYP,ACKNUM,ACKFLD))#10=0
QUIT
+79 IF $DATA(ACKPROB($JOB,ACKI,"ERROR1",ACKTYP,ACKFLD,ACKNUM))#10=0
QUIT
+80 SET ACKINT=@ACKAPI@(ACKTYP,ACKNUM,ACKFLD)
+81 SET ACKMSG=ACKPROB($JOB,ACKI,"ERROR1",ACKTYP,ACKFLD,ACKNUM)
+82 DO ADDRSN(ACKTYP_":"_ACKFLD,ACKINT,"",ACKMSG,.ACKRSN)
+83 KILL ACKPROB($JOB,ACKI,"ERROR1",ACKTYP,ACKFLD,ACKNUM)
End DoDot:3
End DoDot:2
End DoDot:1
+84 ;
+85 ; end of processing errors
+86 QUIT
+87 ;
+88 ;
ADDRSN(FLD,INT,EXT,MSG,ACKRSN) ; add erorr to the output array
+1 ; if count=0 make sure array empty
IF +$GET(ACKRSN)=0
KILL ACKRSN
SET ACKRSN=0
+2 SET ACKRSN=ACKRSN+1
+3 ; error number
SET $PIECE(ACKRSN(ACKRSN,0),U,1)=ACKRSN
+4 ; field name
SET $PIECE(ACKRSN(ACKRSN,0),U,2)=FLD
+5 ; internal format
SET $PIECE(ACKRSN(ACKRSN,0),U,3)=INT
+6 ; external format
SET $PIECE(ACKRSN(ACKRSN,0),U,4)=EXT
+7 ; error message
SET ACKRSN(ACKRSN,1)=MSG
+8 QUIT
PATIENT(ACKPAT) ; get patient name
+1 QUIT $$GET1^DIQ(509850.2,ACKPAT_",",.01,"E")
PRVNAME(ACKPRV) ; get provider name
+1 QUIT $$GET1^DIQ(200,ACKPRV_",",.01,"E")
CLINIC(ACKCLN) ; get clinic name
+1 QUIT $$GET1^DIQ(44,ACKCLN_",",.01,"E")
CPTNAME(ACKCPT) ; get CPT procedure name
+1 QUIT $$GET1^DIQ(509850.4,ACKCPT_",",.01,"E")
ICDNAME(ACKICD) ; get ICD diagnosis name
+1 QUIT $$GET1^DIQ(509850.1,ACKICD_",",.01,"E")
DATETIME(Y) ; convert date/time to external
+1 DO DD^%DT
+2 QUIT Y