SCMSVPR1 ;ALB/ESD HL7 PR1 Segment Validation ;06/24/99
;;5.3;Scheduling;**44,66,142,180**;Aug 13, 1993
;06/24/99 ACS - Added CPT modifier to the validation process
;
EN(PR1ARRY,HLQ,HLFS,HLECH,VALERR,ENCDT) ;
; Entry point to return the HL7 PR1 (Procedure) validation segment
;
; Input: PR1ARRY - Array of PR1 Segments
; HLQ - HL7 null variable
; HLFS - HL7 field separator
; HLECH - HL7 encoding characters
; VALERR - Array to put errors in
; ENCDT - Date of encounter
;
; Output: 1 if PR1 passed validity check
; Error message if PR1 failed validity check in form of:
; -1^"xxx failed validity check" (xxx=element in PR1 segment)
;
; NOTE: This validity check will pass if at least ONE PR1 segment in
; the PR1 array passes the validity checks.
;
N I,J,MSG,OUT,PR1SEG,PR1ASEG,PRTYPE,VALID,X,CNT,SCSETID,SEG,OLD
S X="",(I,OUT)=0,MSG="-1^Element in PR1 segment failed validity check",(SCSETID,CNT)=1,SEG="PR1"
S PR1ARRY=$G(PR1ARRY)
S:(PR1ARRY="") PR1ARRY="^TMP(""VAFHL"",$J,""PROCEDURE"")"
F S I=+$O(@PR1ARRY@(I)) Q:'I D
. S VALID(I)=1
. S J="",J=$O(@PR1ARRY@(I,J)) Q:J=""
. ;S PR1SEG=$G(@PR1ARRY@(I,J))
. ;-----------------------------------------------------------
. ; After the merge, PR1SEG looks like this:
. ; PR1SEG=PR1^n^...^cpt^...
. ; PR1SEG(1)=|mod~desc~meth|mod~desc~meth|...
. ; PR1SEG(2)=|mod~desc~meth|mod~desc~meth|...
. ;-----------------------------------------------------------
. M PR1SEG=@PR1ARRY@(I,J)
. S OLD=CNT
. D VALIDATE^SCMSVUT0(SEG,PR1SEG,"0009",VALERR,.CNT)
. I $G(@VALERR@(SEG,OLD))="0009" Q
. S PR1SEG=$$CONVERT^SCMSVUT0(PR1SEG,HLFS,HLQ)
. ;
. ;- Validate procedure fields
. ;D PROCVAL(PR1SEG)
. D PROCVAL(.PR1SEG)
. Q
;
I '$D(VALID) D VALIDATE^SCMSVUT0(SEG,"","0009",VALERR,.CNT)
ENQ Q $S($D(@VALERR@(SEG)):MSG,1:1)
;
PROCVAL(PR1SEG) ; -Validate procedure fields
;
;N Z,DATA,CMPSEP
N Z,DATA,CMPSEP,REPSEP
S CMPSEP=$E(HLECH,1)
S REPSEP=$E(HLECH,2)
F Z="0101","0201","0401","0403" D
. S DATA=$P(PR1SEG,HLFS,+$E(Z,1,2))
. S DATA=$P(DATA,CMPSEP,+$E(Z,3,4))
. D VALIDATE^SCMSVUT0(SEG,DATA,$P($T(@(Z)),";",3),VALERR,.CNT)
;
;--------------------------------------------------------------
; VALIDATE PROCEDURE MODIFIER FIELDS
;
; The modifier, cpt+modifier, and modifier coding method are
; validated
;
; MODDATA = mod seq, piece 17: mod~desc~code meth|mod~desc~...
; CTR = continuation segment counter
; PROC = CPT procedure code
;--------------------------------------------------------------
;
;- validate modifier components in the first PR1 array seg
N MODDATA,PROC
S PROC=$P($P(PR1SEG,HLFS,4),CMPSEP,1)
S MODDATA=$P(PR1SEG,HLFS,17)
Q:'MODDATA
D SETUP(MODDATA,PROC)
;
;- validate modifier components in the PR1 continuation segments
N CTR,MODDATA
S CTR=1,MODDATA=""
F S MODDATA=$E($G(PR1SEG(CTR)),2,245) Q:'MODDATA D
. D SETUP(MODDATA,PROC)
. S CTR=CTR+1
. Q
Q
;
SETUP(MODDATA,PROC) ;
;
;---------------------------------------------------------------
; SET UP AND VALIDATE MODIFIER COMPONENTS
;
; INPUT: MODDATA = modifier components
; format: mod~desc~meth|mod~desc~meth|...
; PROC = CPT procedure
;
; OTHER:
; REPSEP = repetition separator ("|")
; SEG = PR1
; CNT = 1
; VALERR = error message array
; MCOMPNUM = modifier component number to validate
; REPCTR = modifier repetition counter
; MODDATA1 = each repetition of modifier info
; format: mod~desc~meth
; DATA = modifier data to validate (i.e. mod or meth)
;---------------------------------------------------------------
;
N MCOMPNUM,REPCTR,MODDATA1,DATA
S REPCTR=1
; add repetition separator to end of input data
S MODDATA=MODDATA_REPSEP
;
; validate the modifier and coding method for each repetition
F S MODDATA1=$P(MODDATA,REPSEP,REPCTR) Q:'MODDATA1 D
. F Z="1701","1703" D
.. S MCOMPNUM=$E(Z,3,4)
.. S DATA=$P(MODDATA1,"~",MCOMPNUM)
.. ;
.. ;- pass procedure AND modifier if validating modifier
.. S:MCOMPNUM="01" DATA=PROC_"~"_DATA
.. D VALIDATE^SCMSVUT0(SEG,DATA,$P($T(@(Z)),";",3),VALERR,.CNT)
.. Q
. S REPCTR=REPCTR+1
. Q
Q
;
;
;
;- PR1 data elements validated
;
;
0101 ;;0035;HL7 SEGMENT NAME
0201 ;;6250;HL7 SEQUENTIAL NUMBER (SET ID)
0401 ;;6050;PROCEDURE CODE (CPT)
0403 ;;6000;PROCEDURE CODING METHOD
1701 ;;6300;PROCEDURE MODIFIER AND PROC+MOD COMBINATION
1703 ;;6370;PROCEDURE MODIFIER CODING METHOD
--- Routine Detail --- with STRUCTURED ROUTINE LISTING ---[H[J[2J[HSCMSVPR1 4712 printed Oct 16, 2024@18:42:41 Page 2
SCMSVPR1 ;ALB/ESD HL7 PR1 Segment Validation ;06/24/99
+1 ;;5.3;Scheduling;**44,66,142,180**;Aug 13, 1993
+2 ;06/24/99 ACS - Added CPT modifier to the validation process
+3 ;
EN(PR1ARRY,HLQ,HLFS,HLECH,VALERR,ENCDT) ;
+1 ; Entry point to return the HL7 PR1 (Procedure) validation segment
+2 ;
+3 ; Input: PR1ARRY - Array of PR1 Segments
+4 ; HLQ - HL7 null variable
+5 ; HLFS - HL7 field separator
+6 ; HLECH - HL7 encoding characters
+7 ; VALERR - Array to put errors in
+8 ; ENCDT - Date of encounter
+9 ;
+10 ; Output: 1 if PR1 passed validity check
+11 ; Error message if PR1 failed validity check in form of:
+12 ; -1^"xxx failed validity check" (xxx=element in PR1 segment)
+13 ;
+14 ; NOTE: This validity check will pass if at least ONE PR1 segment in
+15 ; the PR1 array passes the validity checks.
+16 ;
+17 NEW I,J,MSG,OUT,PR1SEG,PR1ASEG,PRTYPE,VALID,X,CNT,SCSETID,SEG,OLD
+18 SET X=""
SET (I,OUT)=0
SET MSG="-1^Element in PR1 segment failed validity check"
SET (SCSETID,CNT)=1
SET SEG="PR1"
+19 SET PR1ARRY=$GET(PR1ARRY)
+20 if (PR1ARRY="")
SET PR1ARRY="^TMP(""VAFHL"",$J,""PROCEDURE"")"
+21 FOR
SET I=+$ORDER(@PR1ARRY@(I))
if 'I
QUIT
Begin DoDot:1
+22 SET VALID(I)=1
+23 SET J=""
SET J=$ORDER(@PR1ARRY@(I,J))
if J=""
QUIT
+24 ;S PR1SEG=$G(@PR1ARRY@(I,J))
+25 ;-----------------------------------------------------------
+26 ; After the merge, PR1SEG looks like this:
+27 ; PR1SEG=PR1^n^...^cpt^...
+28 ; PR1SEG(1)=|mod~desc~meth|mod~desc~meth|...
+29 ; PR1SEG(2)=|mod~desc~meth|mod~desc~meth|...
+30 ;-----------------------------------------------------------
+31 MERGE PR1SEG=@PR1ARRY@(I,J)
+32 SET OLD=CNT
+33 DO VALIDATE^SCMSVUT0(SEG,PR1SEG,"0009",VALERR,.CNT)
+34 IF $GET(@VALERR@(SEG,OLD))="0009"
QUIT
+35 SET PR1SEG=$$CONVERT^SCMSVUT0(PR1SEG,HLFS,HLQ)
+36 ;
+37 ;- Validate procedure fields
+38 ;D PROCVAL(PR1SEG)
+39 DO PROCVAL(.PR1SEG)
+40 QUIT
End DoDot:1
+41 ;
+42 IF '$DATA(VALID)
DO VALIDATE^SCMSVUT0(SEG,"","0009",VALERR,.CNT)
ENQ QUIT $SELECT($DATA(@VALERR@(SEG)):MSG,1:1)
+1 ;
PROCVAL(PR1SEG) ; -Validate procedure fields
+1 ;
+2 ;N Z,DATA,CMPSEP
+3 NEW Z,DATA,CMPSEP,REPSEP
+4 SET CMPSEP=$EXTRACT(HLECH,1)
+5 SET REPSEP=$EXTRACT(HLECH,2)
+6 FOR Z="0101","0201","0401","0403"
Begin DoDot:1
+7 SET DATA=$PIECE(PR1SEG,HLFS,+$EXTRACT(Z,1,2))
+8 SET DATA=$PIECE(DATA,CMPSEP,+$EXTRACT(Z,3,4))
+9 DO VALIDATE^SCMSVUT0(SEG,DATA,$PIECE($TEXT(@(Z)),";",3),VALERR,.CNT)
End DoDot:1
+10 ;
+11 ;--------------------------------------------------------------
+12 ; VALIDATE PROCEDURE MODIFIER FIELDS
+13 ;
+14 ; The modifier, cpt+modifier, and modifier coding method are
+15 ; validated
+16 ;
+17 ; MODDATA = mod seq, piece 17: mod~desc~code meth|mod~desc~...
+18 ; CTR = continuation segment counter
+19 ; PROC = CPT procedure code
+20 ;--------------------------------------------------------------
+21 ;
+22 ;- validate modifier components in the first PR1 array seg
+23 NEW MODDATA,PROC
+24 SET PROC=$PIECE($PIECE(PR1SEG,HLFS,4),CMPSEP,1)
+25 SET MODDATA=$PIECE(PR1SEG,HLFS,17)
+26 if 'MODDATA
QUIT
+27 DO SETUP(MODDATA,PROC)
+28 ;
+29 ;- validate modifier components in the PR1 continuation segments
+30 NEW CTR,MODDATA
+31 SET CTR=1
SET MODDATA=""
+32 FOR
SET MODDATA=$EXTRACT($GET(PR1SEG(CTR)),2,245)
if 'MODDATA
QUIT
Begin DoDot:1
+33 DO SETUP(MODDATA,PROC)
+34 SET CTR=CTR+1
+35 QUIT
End DoDot:1
+36 QUIT
+37 ;
SETUP(MODDATA,PROC) ;
+1 ;
+2 ;---------------------------------------------------------------
+3 ; SET UP AND VALIDATE MODIFIER COMPONENTS
+4 ;
+5 ; INPUT: MODDATA = modifier components
+6 ; format: mod~desc~meth|mod~desc~meth|...
+7 ; PROC = CPT procedure
+8 ;
+9 ; OTHER:
+10 ; REPSEP = repetition separator ("|")
+11 ; SEG = PR1
+12 ; CNT = 1
+13 ; VALERR = error message array
+14 ; MCOMPNUM = modifier component number to validate
+15 ; REPCTR = modifier repetition counter
+16 ; MODDATA1 = each repetition of modifier info
+17 ; format: mod~desc~meth
+18 ; DATA = modifier data to validate (i.e. mod or meth)
+19 ;---------------------------------------------------------------
+20 ;
+21 NEW MCOMPNUM,REPCTR,MODDATA1,DATA
+22 SET REPCTR=1
+23 ; add repetition separator to end of input data
+24 SET MODDATA=MODDATA_REPSEP
+25 ;
+26 ; validate the modifier and coding method for each repetition
+27 FOR
SET MODDATA1=$PIECE(MODDATA,REPSEP,REPCTR)
if 'MODDATA1
QUIT
Begin DoDot:1
+28 FOR Z="1701","1703"
Begin DoDot:2
+29 SET MCOMPNUM=$EXTRACT(Z,3,4)
+30 SET DATA=$PIECE(MODDATA1,"~",MCOMPNUM)
+31 ;
+32 ;- pass procedure AND modifier if validating modifier
+33 if MCOMPNUM="01"
SET DATA=PROC_"~"_DATA
+34 DO VALIDATE^SCMSVUT0(SEG,DATA,$PIECE($TEXT(@(Z)),";",3),VALERR,.CNT)
+35 QUIT
End DoDot:2
+36 SET REPCTR=REPCTR+1
+37 QUIT
End DoDot:1
+38 QUIT
+39 ;
+40 ;
+41 ;
+42 ;- PR1 data elements validated
+43 ;
+44 ;
0101 ;;0035;HL7 SEGMENT NAME
0201 ;;6250;HL7 SEQUENTIAL NUMBER (SET ID)
0401 ;;6050;PROCEDURE CODE (CPT)
0403 ;;6000;PROCEDURE CODING METHOD
1701 ;;6300;PROCEDURE MODIFIER AND PROC+MOD COMBINATION
1703 ;;6370;PROCEDURE MODIFIER CODING METHOD