SCMSVDG1 ;ALB/ESD - HL7 DG1 Segment Validation ;05/08/95
;;5.3;Scheduling;**44,57,68,77,85,95,66,593**;Aug 13, 1993;Build 13
;
;
EN(DG1ARRY,HLQ,HLFS,ENCPTR,VALERR,ENCDT) ;
; Entry point to return the HL7 DG1 (Outpatient Diagnosis) validation segment
;
; Input: DG1ARRY - Array of DG1 Segments
; HLQ - HL7 null variable
; HLFS - HL7 field separator
; ENCPTR - Outpatient Encounter IEN (file #409.68)
; VALERR - The array name to put error messages in
; ENCDT - The date of the encounter
;
; Output: 1 if DG1 passed validity check
; Error message if DG1 failed validity check in form of:
; -1^"xxx failed validity check" (xxx=element in DG1 segment)
;
; NOTE: This validity check will pass if at least ONE DG1 segment in
; the DG1 array passes the validity checks.
;
; A check for occasion of service (procedure which does not
; require a diagnosis) is contained in this routine.
;
;
N DG1SEG,I,J,MSG,PROCARRY,VALID,X,Z,DATA,CNT,SCSETID,SEG,PRIOR
S MSG="-1^Element in DG1 segment failed validity check"
S (I,PRIOR)=0,X="",PROCARRY="PROCS",DG1ARRY=$G(DG1ARRY),SEG="DG1",(CNT,SCSETID)=1
S:(DG1ARRY="") DG1ARRY="^TMP(""VAFHL"",$J,""DIAGNOSIS"")"
;
;- Check for occasion of service and number od DX's found greater then zero.
; If 00s and NO DX's, kill DG1 array. If 00S and there are DX's, continue
; processing DG1 segment.
N SDCNT,SDDXY,QUIT
I ($$CHKOCC(ENCPTR)) D SET^SDCO4(ENCPTR) I 'SDCNT D G ENQ
. K @DG1ARRY
. Q
;
F S I=+$O(@DG1ARRY@(I)) Q:'I D Q:$D(QUIT)
. S J="",VALID=1
. F S J=$O(@DG1ARRY@(I,J)) Q:J="" D Q:$D(QUIT)
.. S DG1SEG=$G(@DG1ARRY@(I,J)),DG1SEG=$$CONVERT^SCMSVUT0(DG1SEG,HLFS,HLQ)
.. D VALIDATE^SCMSVUT0(SEG,DG1SEG,"0036",VALERR,.CNT)
.. I $G(@VALERR@(SEG,CNT-1))="0036" S QUIT=1 Q
.. F Z=1,2,3,4,16 DO ;;;*** SWITCHED THIS FROM 6 TO 16 NEED TO TEST
... S DATA=$P(DG1SEG,HLFS,Z)
... I Z=16,DATA=1 S PRIOR=PRIOR+1
... D VALIDATE^SCMSVUT0(SEG,DATA,$P($T(@(Z)),";",3),VALERR,.CNT)
... Q
.. Q
. Q
;
I $D(QUIT) G ENQ
D VALIDATE^SCMSVUT0(SEG,PRIOR,"5100",VALERR,.CNT)
I '$D(VALID) D VALIDATE^SCMSVUT0(SEG,"","0036",VALERR,.CNT)
;
ENQ Q $S($D(@VALERR@(SEG)):MSG,1:1)
;
;
CHKOCC(ENCPTR) ; Occasion of Service Check
;
; Input: ENCPTR - Ptr to outpatient encounter file
;
; Output: 0 if location is not an occasion of service clinic
; 1 if location is an occasion of service clinic
;
;
N ENC,LOC,STOP
S ENC=$G(^SCE(+ENCPTR,0))
S LOC=$P(ENC,"^",4),STOP=$P($G(^SC(+LOC,0)),"^",7)
Q $$EX^SDCOU2(STOP,+ENC)
;
;
;- DG1 data elements validated
;
1 ;;0035;HL7 SEGMENT NAME
2 ;;5150;HL7 SEQUENTIAL NUMBER (SET ID)
3 ;;5030;DIAGNOSIS CODING METHOD
4 ;;5000;DIAGNOSIS CODE (ICD)
16 ;;5100;DIAGNOSIS PRIORITY
--- Routine Detail --- with STRUCTURED ROUTINE LISTING ---[H[J[2J[HSCMSVDG1 2904 printed Dec 13, 2024@02:42:02 Page 2
SCMSVDG1 ;ALB/ESD - HL7 DG1 Segment Validation ;05/08/95
+1 ;;5.3;Scheduling;**44,57,68,77,85,95,66,593**;Aug 13, 1993;Build 13
+2 ;
+3 ;
EN(DG1ARRY,HLQ,HLFS,ENCPTR,VALERR,ENCDT) ;
+1 ; Entry point to return the HL7 DG1 (Outpatient Diagnosis) validation segment
+2 ;
+3 ; Input: DG1ARRY - Array of DG1 Segments
+4 ; HLQ - HL7 null variable
+5 ; HLFS - HL7 field separator
+6 ; ENCPTR - Outpatient Encounter IEN (file #409.68)
+7 ; VALERR - The array name to put error messages in
+8 ; ENCDT - The date of the encounter
+9 ;
+10 ; Output: 1 if DG1 passed validity check
+11 ; Error message if DG1 failed validity check in form of:
+12 ; -1^"xxx failed validity check" (xxx=element in DG1 segment)
+13 ;
+14 ; NOTE: This validity check will pass if at least ONE DG1 segment in
+15 ; the DG1 array passes the validity checks.
+16 ;
+17 ; A check for occasion of service (procedure which does not
+18 ; require a diagnosis) is contained in this routine.
+19 ;
+20 ;
+21 NEW DG1SEG,I,J,MSG,PROCARRY,VALID,X,Z,DATA,CNT,SCSETID,SEG,PRIOR
+22 SET MSG="-1^Element in DG1 segment failed validity check"
+23 SET (I,PRIOR)=0
SET X=""
SET PROCARRY="PROCS"
SET DG1ARRY=$GET(DG1ARRY)
SET SEG="DG1"
SET (CNT,SCSETID)=1
+24 if (DG1ARRY="")
SET DG1ARRY="^TMP(""VAFHL"",$J,""DIAGNOSIS"")"
+25 ;
+26 ;- Check for occasion of service and number od DX's found greater then zero.
+27 ; If 00s and NO DX's, kill DG1 array. If 00S and there are DX's, continue
+28 ; processing DG1 segment.
+29 NEW SDCNT,SDDXY,QUIT
+30 IF ($$CHKOCC(ENCPTR))
DO SET^SDCO4(ENCPTR)
IF 'SDCNT
Begin DoDot:1
+31 KILL @DG1ARRY
+32 QUIT
End DoDot:1
GOTO ENQ
+33 ;
+34 FOR
SET I=+$ORDER(@DG1ARRY@(I))
if 'I
QUIT
Begin DoDot:1
+35 SET J=""
SET VALID=1
+36 FOR
SET J=$ORDER(@DG1ARRY@(I,J))
if J=""
QUIT
Begin DoDot:2
+37 SET DG1SEG=$GET(@DG1ARRY@(I,J))
SET DG1SEG=$$CONVERT^SCMSVUT0(DG1SEG,HLFS,HLQ)
+38 DO VALIDATE^SCMSVUT0(SEG,DG1SEG,"0036",VALERR,.CNT)
+39 IF $GET(@VALERR@(SEG,CNT-1))="0036"
SET QUIT=1
QUIT
+40 ;;;*** SWITCHED THIS FROM 6 TO 16 NEED TO TEST
FOR Z=1,2,3,4,16
Begin DoDot:3
+41 SET DATA=$PIECE(DG1SEG,HLFS,Z)
+42 IF Z=16
IF DATA=1
SET PRIOR=PRIOR+1
+43 DO VALIDATE^SCMSVUT0(SEG,DATA,$PIECE($TEXT(@(Z)),";",3),VALERR,.CNT)
+44 QUIT
End DoDot:3
+45 QUIT
End DoDot:2
if $DATA(QUIT)
QUIT
+46 QUIT
End DoDot:1
if $DATA(QUIT)
QUIT
+47 ;
+48 IF $DATA(QUIT)
GOTO ENQ
+49 DO VALIDATE^SCMSVUT0(SEG,PRIOR,"5100",VALERR,.CNT)
+50 IF '$DATA(VALID)
DO VALIDATE^SCMSVUT0(SEG,"","0036",VALERR,.CNT)
+51 ;
ENQ QUIT $SELECT($DATA(@VALERR@(SEG)):MSG,1:1)
+1 ;
+2 ;
CHKOCC(ENCPTR) ; Occasion of Service Check
+1 ;
+2 ; Input: ENCPTR - Ptr to outpatient encounter file
+3 ;
+4 ; Output: 0 if location is not an occasion of service clinic
+5 ; 1 if location is an occasion of service clinic
+6 ;
+7 ;
+8 NEW ENC,LOC,STOP
+9 SET ENC=$GET(^SCE(+ENCPTR,0))
+10 SET LOC=$PIECE(ENC,"^",4)
SET STOP=$PIECE($GET(^SC(+LOC,0)),"^",7)
+11 QUIT $$EX^SDCOU2(STOP,+ENC)
+12 ;
+13 ;
+14 ;- DG1 data elements validated
+15 ;
1 ;;0035;HL7 SEGMENT NAME
2 ;;5150;HL7 SEQUENTIAL NUMBER (SET ID)
3 ;;5030;DIAGNOSIS CODING METHOD
4 ;;5000;DIAGNOSIS CODE (ICD)
16 ;;5100;DIAGNOSIS PRIORITY