DGENUPL2 ;ALB/CJM,RTK,TMK,ISA/KWP/RMM/CKN,EG,ERC,PWC - PROCESS INCOMING (Z11 EVENT TYPE) HL7 MESSAGES ; 2/14/11 2:45pm
;;5.3;PIMS;**147,222,232,310,314,367,397,677,631,675,672,673,716,653,688,1015,1016**;JUN 30, 2012;Build 20
;
;**************************************************************
;The following procedures parse particular segment types.
;Input:SEG(),MSGID
;Output:DGPAT(),DGELG(),DGENR(),DGCDIS(),DGNTR(),DGOEIF(),ERROR
;**************************************************************
;
PID ;
S DGPAT("SSN")=SEG(19)
Q
;
ZPD ;
D ZPD^DGENUPLA ;code removed due to size of DGENUPLA - DG*5.3*688
Q
;
ZIE ;
S DGPAT("INELDATE")=$$CONVERT^DGENUPL1(SEG(2),"DATE",.ERROR)
I ERROR D Q
.D ADDERROR^DGENUPL(MSGID,$G(DGPAT("SSN")),"BAD VALUE, ZIE SEGMENT, SEQ 2",.ERRCOUNT)
S DGPAT("INELREA")=$$CONVERT^DGENUPL1(SEG(3))
S DGPAT("INELDEC")=$$CONVERT^DGENUPL1(SEG(4))
Q
;
ZIO ;New segment - DG*5.3*653
D ZIO^DGENUPLA ;Code for ZIO has moved to DGENUPLA
Q
;
ZEL(COUNT) ;
D ZEL^DGENUPLA(COUNT) ;code for ZEL segment has moved to DGENUPLA
Q
;
ZEN ;
N SUB
S DGENR("DATE")=$$CONVERT^DGENUPL1(SEG(2),"DATE",.ERROR)
I ERROR D Q
.D ADDERROR^DGENUPL(MSGID,$G(DGPAT("SSN")),"BAD VALUE, ZEN SEGMENT, SEQ 2",.ERRCOUNT)
S DGENR("SOURCE")=$$CONVERT^DGENUPL1(SEG(3))
S DGENR("STATUS")=$$CONVERT^DGENUPL1(SEG(4))
S ERROR=$$PEND(DFN,DGENR("STATUS"))
I ERROR D Q
.D ADDERROR^DGENUPL(MSGID,$G(DGPAT("SSN")),"ENROLLMENT STATUS PENDING-ELIGIBILITY IS VERIFIED",.ERRCOUNT)
S DGENR("REASON")=$$CONVERT^DGENUPL1(SEG(5))
S DGENR("REMARKS")=$$CONVERT^DGENUPL1(SEG(6))
S DGENR("FACREC")=$$CONVERT^DGENUPL1(SEG(7),"INSTITUTION",.ERROR)
I ERROR D Q
.D ADDERROR^DGENUPL(MSGID,$G(DGPAT("SSN")),"FACILITY RECEIVED "_SEG(7)_" NOT FOUND IN THE INSTITUTION FILE",.ERRCOUNT)
S DGPAT("PREFAC")=$$CONVERT^DGENUPL1(SEG(8),"INSTITUTION",.ERROR)
I ERROR D Q
.D ADDERROR^DGENUPL(MSGID,$G(DGPAT("SSN")),"PREFERRED FACILITY "_SEG(8)_" NOT FOUND IN THE INSTITUTION FILE",.ERRCOUNT)
;
S DGENR("PRIORITY")=$$CONVERT^DGENUPL1(SEG(9))
S DGENR("EFFDATE")=$$CONVERT^DGENUPL1(SEG(10),"DATE",.ERROR)
I ERROR D Q
.D ADDERROR^DGENUPL(MSGID,$G(DGPAT("SSN")),"BAD VALUE, ZEN SEGMENT, SEQ 10",.ERRCOUNT)
S DGENR("APP")=$$CONVERT^DGENUPL1(SEG(11),"DATE",.ERROR)
I ERROR D Q
.D ADDERROR^DGENUPL(MSGID,$G(DGPAT("SSN")),"BAD VALUE, ZEN SEGMENT, SEQ 11",.ERRCOUNT)
;
;!!!!!! take next line out when HEC begins transmitting application dt
I DGENR("APP")=""!(DGENR("APP")="@") S DGENR("APP")=DGENR("DATE")
I DGENR("APP")=""!(DGENR("APP")="@") S DGENR("APP")=DGENR("EFFDATE")
;
S DGENR("END")=$$CONVERT^DGENUPL1(SEG(12),"DATE",.ERROR)
I ERROR D Q
.D ADDERROR^DGENUPL(MSGID,$G(DGPAT("SSN")),"BAD VALUE, ZEN SEGMENT, SEQ 12",.ERRCOUNT)
;Phase II Parse out Sub-Group (SRS 6[B.4)
S DGENR("SUBGRP")=$$CONVERT^DGENUPL1(SEG(13))
S DGPAT("PFSRC")=$$CONVERT^DGENUPL1(SEG(14)) N PFSRC S PFSRC=DGPAT("PFSRC")
I PFSRC'="V"&(PFSRC'="E")&(PFSRC'="PA")&(PFSRC'="PI")&(PFSRC'="@")&(PFSRC'="") D ADDERROR^DGENUPL(MSGID,$G(DGPAT("SSN")),"BAD VALUE, ZEN SEGMENT, SEQ 14",.ERRCOUNT) Q
;
;want to ignore double quotes sent for enrollment fields
S SUB=""
F S SUB=$O(DGENR(SUB)) Q:SUB="" I DGENR(SUB)="@"!(DGENR(SUB)="""""") S DGENR(SUB)=""
;
Q
;
ZMT ;
I SEG(1)>1 D ADDERROR^DGENUPL(MSGID,$G(DGPAT("SSN")),"ZMT SEGMENT, SEQ 1, SHOULD SPECIFY MEANS TEST",.ERRCOUNT) S ERROR=1 Q
S DGELG("MTSTA")=$$CONVERT^DGENUPL1(SEG(3),"MT",.ERROR)
I ERROR D Q
.D ADDERROR^DGENUPL(MSGID,$G(DGPAT("SSN")),"BAD VALUE, ZMT SEGMENT, SEQ 3",.ERRCOUNT)
Q
;
ZCD ;
;Phase II for multiple ZCD's
I SEG(1)>1 G SKIP
S DGCDIS("BY")=$$CONVERT^DGENUPL1(SEG(3))
S DGCDIS("DATE")=$$CONVERT^DGENUPL1(SEG(5),"DATE",.ERROR)
I ERROR D Q
.D ADDERROR^DGENUPL(MSGID,$G(DGPAT("SSN")),"BAD VALUE, ZCD SEGMENT, SEQ 5",.ERRCOUNT)
S DGCDIS("FACDET")=$$CONVERT^DGENUPL1(SEG(4),"INSTITUTION",.ERROR)
I ERROR D Q
.D ADDERROR^DGENUPL(MSGID,$G(DGPAT("SSN")),"FACILITY "_SEG(4)_" MAKING CATASTROPHIC DISABILITY DETERMINATION NOT FOUND IN THE INSTITUTION FILE",.ERRCOUNT)
S DGCDIS("REVDTE")=$$CONVERT^DGENUPL1(SEG(2),"DATE",.ERROR)
I ERROR D Q
.D ADDERROR^DGENUPL(MSGID,$G(DGPAT("SSN")),"BAD VALUE, ZCD SEGMENT, SEQ 2",.ERRCOUNT)
S DGCDIS("METDET")=$$CONVERT^DGENUPL1($P(SEG(6),$E(HLECH)))
S DGCDIS("VCD")=$$CONVERT^DGENUPL1(SEG(12))
;SEQ 14 - DATE VETERAN REQUESTED CD EVALUATION
S DGCDIS("VETREQDT")=$$CONVERT^DGENUPL1(SEG(14),"DATE",.ERROR)
I ERROR D Q
.D ADDERROR^DGENUPL(MSGID,$G(DGPAT("SSN")),"BAD VALUE, ZCD SEGMENT, SEQ 14",.ERRCOUNT)
;SEQ 15 - DATE FACILITY INITIATED REVIEW
S DGCDIS("DTFACIRV")=$$CONVERT^DGENUPL1(SEG(15),"DATE",.ERROR)
I ERROR D Q
.D ADDERROR^DGENUPL(MSGID,$G(DGPAT("SSN")),"BAD VALUE, ZCD SEGMENT, SEQ 15",.ERRCOUNT)
;SEQ 16 - DATE VETERAN WAS NOTIFIED
S DGCDIS("DTVETNOT")=$$CONVERT^DGENUPL1(SEG(16),"DATE",.ERROR)
I ERROR D Q
.D ADDERROR^DGENUPL(MSGID,$G(DGPAT("SSN")),"BAD VALUE, ZCD SEGMENT, SEQ 16",.ERRCOUNT)
SKIP ;
;Phase II Parse out additional fields. CONVERT type of RSN converts the code to IEN for diagnosis,procedure and condition (HL7TORSN^DGENA5).
S DGCDIS("DIAG",SEG(1))=$$CONVERT^DGENUPL1(SEG(7),"CDRSN")
S DGCDIS("PROC",SEG(1))=$$CONVERT^DGENUPL1(SEG(8),"CDRSN")
S DGCDIS("EXT",SEG(1),1)=$$CONVERT^DGENUPL1($P(SEG(9),$E(HLECH)),"EXT")
S DGCDIS("COND",SEG(1))=$$CONVERT^DGENUPL1(SEG(10),"CDRSN")
S DGCDIS("SCORE",SEG(1))=$$CONVERT^DGENUPL1($P(SEG(11),$E(HLECH)))
S DGCDIS("PERM",SEG(1))=$$CONVERT^DGENUPL1($P(SEG(13),$E(HLECH)))
I DGCDIS("VCD")="Y",'DGCDIS("DIAG",SEG(1)),'DGCDIS("PROC",SEG(1)),'DGCDIS("COND",SEG(1)) D Q
.S ERROR=1 D ADDERROR^DGENUPL(MSGID,$G(DGPAT("SSN")),"NO VALID DIAGNOSIS,PROCEDURE, OR CONDITION IN THE ZCD SEGMENT",.ERRCOUNT)
Q
;
ZSP ;
S DGELG("SC")=$$CONVERT^DGENUPL1(SEG(2),"Y/N",.ERROR)
I ERROR D Q
.D ADDERROR^DGENUPL(MSGID,$G(DGPAT("SSN")),"BAD VALUE, ZSP SEGMENT, SEQ 2",.ERRCOUNT)
S DGELG("SCPER")=$$CONVERT^DGENUPL1(SEG(3))
S DGELG("POS")=$$CONVERT^DGENUPL1(SEG(4),"POS",.ERROR)
I ERROR D Q
.D ADDERROR^DGENUPL(MSGID,$G(DGPAT("SSN")),"BAD VALUE, ZSP SEGMENT, SEQ 4",.ERRCOUNT)
S DGELG("EFFDT")=$$CONVERT^DGENUPL1(SEG(11),"DATE",.ERROR)
I ERROR D Q
. D ADDERROR^DGENUPL(MSGID,$G(DGELG("EFFDT")),"BAD VALUE, ZSP SEGMENT, SEQ 11",.ERRCOUNT)
;if effective date is null, set update value to "@" (delete)
I DGELG("EFFDT")="" S DGELG("EFFDT")="@"
;
;added 8/3/98 to reduce #rejects
;if HEC sends SC=NO, SC% not sent, and site has value for SC% then delete it
I DGELG("SC")="N",DGELG("SCPER")="" S DGELG("SCPER")="@"
;
S DGELG("P&T")=$$CONVERT^DGENUPL1(SEG(6),"Y/N",.ERROR)
I ERROR D Q
.D ADDERROR^DGENUPL(MSGID,$G(DGPAT("SSN")),"BAD VALUE, ZSP SEGMENT, SEQ 6",.ERRCOUNT)
S DGELG("UNEMPLOY")=$$CONVERT^DGENUPL1(SEG(7),"Y/N",.ERROR)
I ERROR D Q
.D ADDERROR^DGENUPL(MSGID,$G(DGPAT("SSN")),"BAD VALUE, ZSP SEGMENT, SEQ 7",.ERRCOUNT)
S DGELG("SCAWDATE")=$$CONVERT^DGENUPL1(SEG(8),"DATE",.ERROR)
I ERROR D Q
.D ADDERROR^DGENUPL(MSGID,$G(DGPAT("SSN")),"BAD VALUE, ZSP SEGMENT, SEQ 8",.ERRCOUNT)
S DGELG("P&TDT")=$$CONVERT^DGENUPL1(SEG(10),"DATE",.ERROR)
I ERROR D
.D ADDERROR^DGENUPL(MSGID,$G(DGPAT("SSN")),"BAD VALUE, ZSP SEGMENT, SEQ 10 - P&T EFFECTIVE DATE",.ERRCOUNT)
Q
;
ZMH ;Purple Heart, OEFOIE, POW
D ZMH^DGENUPL3 ;Moved to DGENUPL3 - DG*5.3*653
Q
;
ZRD ;
N COUNT,DXCODE,NAME,COND
S DXCODE=$P(SEG(2),$E(HLECH))
I DXCODE="""""" S DXCODE=""
S NAME=$P(SEG(2),$E(HLECH),2)
Q:DXCODE="" ;segment does not contain a disability condition
;
S COUNT=1+(+$G(DGELG("RATEDIS")))
S (COND,DGELG("RATEDIS",COUNT,"RD"))=$$DCLOOKUP(DXCODE,NAME)
S DGELG("RATEDIS",COUNT,"PER")=$$CONVERT^DGENUPL1(SEG(3)),DGELG("RATEDIS")=COUNT
S DGELG("RATEDIS",COUNT,"RDEXT")=$$CONVERT^DGENUPL1(SEG(12))
S DGELG("RATEDIS",COUNT,"RDORIG")=$$CONVERT^DGENUPL1(SEG(13),"DATE",.ERROR)
I ERROR D Q
. D ADDERROR^DGENUPL(MSGID,$G(DGPAT("SSN")),"BAD VALUE, ZRD SEGMENT, S 13",.ERRCOUNT)
S DGELG("RATEDIS",COUNT,"RDCURR")=$$CONVERT^DGENUPL1(SEG(14),"DATE",.ERROR)
I ERROR D Q
. D ADDERROR^DGENUPL(MSGID,$G(DGPAT("SSN")),"BAD VALUE, ZRD SEGMENT, S 14",.ERRCOUNT)
I 'COND D Q
.D ADDERROR^DGENUPL(MSGID,$G(DGPAT("SSN")),"BAD VALUE, ZRD SEGMENT, SEQ 2 - DISABILTY CONDITION LOOKUP FAILED",.ERRCOUNT)
.S ERROR=1
Q
OBX ;
D OBX^DGENUPLA ;code for OBX segment moved to DGENUPLA
Q
;
;*********** end of segment parsers ****
;
DCLOOKUP(DGCODE,DGNAME) ;
; Description: Returns the ien of a Disability Condition (file #31) based on the DGCODE and DGNAME
;
;Input:
; DGCODE - DX Code of the Disability Condition
; DGNAME - name of the Disability Condition
;Output:
; Function Value: ien of the entry found, or 0 otherwise
;
Q:(DGCODE="") 0
N NODE,IEN,FOUND
S (FOUND,IEN)=0
F S IEN=$O(^DIC(31,"C",DGCODE,IEN)) Q:'IEN D Q:FOUND
.S NODE=$G(^DIC(31,IEN,0))
.I DGNAME=$P(NODE,"^"),DGCODE=$P(NODE,"^",3) S FOUND=1
I 'FOUND S IEN=$O(^DIC(31,"C",DGCODE,0))
Q +IEN
;
REGCHECK(DFN) ;
; Description: passes patient through the registration consistency checker
;Input -
; DFN - is a pointer to the Patient File
;
N DGCD,DGCHK,DGDAY,DGEDCN,DGER,DGLST,DGNCK,DGRPCOLD,DGSC,DGTYPE,DGVT,VA,X
;
S DGEDCN=0
D ^DGRPC
Q
PEND(DFN,DGSTAT) ;
N DGARR,DGEC,DGERR,DGX
I $P($G(^DPT(DFN,.361)),U)'="V" Q 0
I $G(DGSTAT)="@" Q 0
I $G(DGSTAT)']"" Q 0
S DGSTAT="^"_DGSTAT_"^"
Q:"^15^17^"'[DGSTAT 0
D GETS^DIQ(2,DFN_",",".301;.302;.361;.36295","IE","DGARR","DGERR")
I $D(DGERR) Q 0
S DGEC=$G(DGARR(2,DFN_",",.361,"I"))
I $G(DGEC)']"" Q 0
S DGEC=$P($G(^DIC(8,DGEC,0)),U,9)
I $G(DGEC)']"" Q 0
I DGEC=5 Q 1
I DGEC=3 D Q DGX
. S DGX=1
. I $G(DGARR(2,DFN_",",.301,"I"))'="Y" S DGX=0 Q
. I +$G(DGARR(2,DFN_",",.302,"I"))>0 S DGX=0 Q
. I +$G(DGARR(2,DFN_",",.36295,"I"))>0 S DGX=0 Q
Q 0
DGENUPL2 ;ALB/CJM,RTK,TMK,ISA/KWP/RMM/CKN,EG,ERC,PWC - PROCESS INCOMING (Z11 EVENT TYPE) HL7 MESSAGES ; 2/14/11 2:45pm
+1 ;;5.3;PIMS;**147,222,232,310,314,367,397,677,631,675,672,673,716,653,688,1015,1016**;JUN 30, 2012;Build 20
+2 ;
+3 ;**************************************************************
+4 ;The following procedures parse particular segment types.
+5 ;Input:SEG(),MSGID
+6 ;Output:DGPAT(),DGELG(),DGENR(),DGCDIS(),DGNTR(),DGOEIF(),ERROR
+7 ;**************************************************************
+8 ;
PID ;
+1 SET DGPAT("SSN")=SEG(19)
+2 QUIT
+3 ;
ZPD ;
+1 ;code removed due to size of DGENUPLA - DG*5.3*688
DO ZPD^DGENUPLA
+2 QUIT
+3 ;
ZIE ;
+1 SET DGPAT("INELDATE")=$$CONVERT^DGENUPL1(SEG(2),"DATE",.ERROR)
+2 IF ERROR
Begin DoDot:1
+3 DO ADDERROR^DGENUPL(MSGID,$GET(DGPAT("SSN")),"BAD VALUE, ZIE SEGMENT, SEQ 2",.ERRCOUNT)
End DoDot:1
QUIT
+4 SET DGPAT("INELREA")=$$CONVERT^DGENUPL1(SEG(3))
+5 SET DGPAT("INELDEC")=$$CONVERT^DGENUPL1(SEG(4))
+6 QUIT
+7 ;
ZIO ;New segment - DG*5.3*653
+1 ;Code for ZIO has moved to DGENUPLA
DO ZIO^DGENUPLA
+2 QUIT
+3 ;
ZEL(COUNT) ;
+1 ;code for ZEL segment has moved to DGENUPLA
DO ZEL^DGENUPLA(COUNT)
+2 QUIT
+3 ;
ZEN ;
+1 NEW SUB
+2 SET DGENR("DATE")=$$CONVERT^DGENUPL1(SEG(2),"DATE",.ERROR)
+3 IF ERROR
Begin DoDot:1
+4 DO ADDERROR^DGENUPL(MSGID,$GET(DGPAT("SSN")),"BAD VALUE, ZEN SEGMENT, SEQ 2",.ERRCOUNT)
End DoDot:1
QUIT
+5 SET DGENR("SOURCE")=$$CONVERT^DGENUPL1(SEG(3))
+6 SET DGENR("STATUS")=$$CONVERT^DGENUPL1(SEG(4))
+7 SET ERROR=$$PEND(DFN,DGENR("STATUS"))
+8 IF ERROR
Begin DoDot:1
+9 DO ADDERROR^DGENUPL(MSGID,$GET(DGPAT("SSN")),"ENROLLMENT STATUS PENDING-ELIGIBILITY IS VERIFIED",.ERRCOUNT)
End DoDot:1
QUIT
+10 SET DGENR("REASON")=$$CONVERT^DGENUPL1(SEG(5))
+11 SET DGENR("REMARKS")=$$CONVERT^DGENUPL1(SEG(6))
+12 SET DGENR("FACREC")=$$CONVERT^DGENUPL1(SEG(7),"INSTITUTION",.ERROR)
+13 IF ERROR
Begin DoDot:1
+14 DO ADDERROR^DGENUPL(MSGID,$GET(DGPAT("SSN")),"FACILITY RECEIVED "_SEG(7)_" NOT FOUND IN THE INSTITUTION FILE",.ERRCOUNT)
End DoDot:1
QUIT
+15 SET DGPAT("PREFAC")=$$CONVERT^DGENUPL1(SEG(8),"INSTITUTION",.ERROR)
+16 IF ERROR
Begin DoDot:1
+17 DO ADDERROR^DGENUPL(MSGID,$GET(DGPAT("SSN")),"PREFERRED FACILITY "_SEG(8)_" NOT FOUND IN THE INSTITUTION FILE",.ERRCOUNT)
End DoDot:1
QUIT
+18 ;
+19 SET DGENR("PRIORITY")=$$CONVERT^DGENUPL1(SEG(9))
+20 SET DGENR("EFFDATE")=$$CONVERT^DGENUPL1(SEG(10),"DATE",.ERROR)
+21 IF ERROR
Begin DoDot:1
+22 DO ADDERROR^DGENUPL(MSGID,$GET(DGPAT("SSN")),"BAD VALUE, ZEN SEGMENT, SEQ 10",.ERRCOUNT)
End DoDot:1
QUIT
+23 SET DGENR("APP")=$$CONVERT^DGENUPL1(SEG(11),"DATE",.ERROR)
+24 IF ERROR
Begin DoDot:1
+25 DO ADDERROR^DGENUPL(MSGID,$GET(DGPAT("SSN")),"BAD VALUE, ZEN SEGMENT, SEQ 11",.ERRCOUNT)
End DoDot:1
QUIT
+26 ;
+27 ;!!!!!! take next line out when HEC begins transmitting application dt
+28 IF DGENR("APP")=""!(DGENR("APP")="@")
SET DGENR("APP")=DGENR("DATE")
+29 IF DGENR("APP")=""!(DGENR("APP")="@")
SET DGENR("APP")=DGENR("EFFDATE")
+30 ;
+31 SET DGENR("END")=$$CONVERT^DGENUPL1(SEG(12),"DATE",.ERROR)
+32 IF ERROR
Begin DoDot:1
+33 DO ADDERROR^DGENUPL(MSGID,$GET(DGPAT("SSN")),"BAD VALUE, ZEN SEGMENT, SEQ 12",.ERRCOUNT)
End DoDot:1
QUIT
+34 ;Phase II Parse out Sub-Group (SRS 6[B.4)
+35 SET DGENR("SUBGRP")=$$CONVERT^DGENUPL1(SEG(13))
+36 SET DGPAT("PFSRC")=$$CONVERT^DGENUPL1(SEG(14))
NEW PFSRC
SET PFSRC=DGPAT("PFSRC")
+37 IF PFSRC'="V"&(PFSRC'="E")&(PFSRC'="PA")&(PFSRC'="PI")&(PFSRC'="@")&(PFSRC'="")
DO ADDERROR^DGENUPL(MSGID,$GET(DGPAT("SSN")),"BAD VALUE, ZEN SEGMENT, SEQ 14",.ERRCOUNT)
QUIT
+38 ;
+39 ;want to ignore double quotes sent for enrollment fields
+40 SET SUB=""
+41 FOR
SET SUB=$ORDER(DGENR(SUB))
IF SUB=""
QUIT
IF DGENR(SUB)="@"!(DGENR(SUB)="""""")
SET DGENR(SUB)=""
+42 ;
+43 QUIT
+44 ;
ZMT ;
+1 IF SEG(1)>1
DO ADDERROR^DGENUPL(MSGID,$GET(DGPAT("SSN")),"ZMT SEGMENT, SEQ 1, SHOULD SPECIFY MEANS TEST",.ERRCOUNT)
SET ERROR=1
QUIT
+2 SET DGELG("MTSTA")=$$CONVERT^DGENUPL1(SEG(3),"MT",.ERROR)
+3 IF ERROR
Begin DoDot:1
+4 DO ADDERROR^DGENUPL(MSGID,$GET(DGPAT("SSN")),"BAD VALUE, ZMT SEGMENT, SEQ 3",.ERRCOUNT)
End DoDot:1
QUIT
+5 QUIT
+6 ;
ZCD ;
+1 ;Phase II for multiple ZCD's
+2 IF SEG(1)>1
GOTO SKIP
+3 SET DGCDIS("BY")=$$CONVERT^DGENUPL1(SEG(3))
+4 SET DGCDIS("DATE")=$$CONVERT^DGENUPL1(SEG(5),"DATE",.ERROR)
+5 IF ERROR
Begin DoDot:1
+6 DO ADDERROR^DGENUPL(MSGID,$GET(DGPAT("SSN")),"BAD VALUE, ZCD SEGMENT, SEQ 5",.ERRCOUNT)
End DoDot:1
QUIT
+7 SET DGCDIS("FACDET")=$$CONVERT^DGENUPL1(SEG(4),"INSTITUTION",.ERROR)
+8 IF ERROR
Begin DoDot:1
+9 DO ADDERROR^DGENUPL(MSGID,$GET(DGPAT("SSN")),"FACILITY "_SEG(4)_" MAKING CATASTROPHIC DISABILITY DETERMINATION NOT FOUND IN THE INSTITUTION FILE",.ERRCOUNT)
End DoDot:1
QUIT
+10 SET DGCDIS("REVDTE")=$$CONVERT^DGENUPL1(SEG(2),"DATE",.ERROR)
+11 IF ERROR
Begin DoDot:1
+12 DO ADDERROR^DGENUPL(MSGID,$GET(DGPAT("SSN")),"BAD VALUE, ZCD SEGMENT, SEQ 2",.ERRCOUNT)
End DoDot:1
QUIT
+13 SET DGCDIS("METDET")=$$CONVERT^DGENUPL1($PIECE(SEG(6),$EXTRACT(HLECH)))
+14 SET DGCDIS("VCD")=$$CONVERT^DGENUPL1(SEG(12))
+15 ;SEQ 14 - DATE VETERAN REQUESTED CD EVALUATION
+16 SET DGCDIS("VETREQDT")=$$CONVERT^DGENUPL1(SEG(14),"DATE",.ERROR)
+17 IF ERROR
Begin DoDot:1
+18 DO ADDERROR^DGENUPL(MSGID,$GET(DGPAT("SSN")),"BAD VALUE, ZCD SEGMENT, SEQ 14",.ERRCOUNT)
End DoDot:1
QUIT
+19 ;SEQ 15 - DATE FACILITY INITIATED REVIEW
+20 SET DGCDIS("DTFACIRV")=$$CONVERT^DGENUPL1(SEG(15),"DATE",.ERROR)
+21 IF ERROR
Begin DoDot:1
+22 DO ADDERROR^DGENUPL(MSGID,$GET(DGPAT("SSN")),"BAD VALUE, ZCD SEGMENT, SEQ 15",.ERRCOUNT)
End DoDot:1
QUIT
+23 ;SEQ 16 - DATE VETERAN WAS NOTIFIED
+24 SET DGCDIS("DTVETNOT")=$$CONVERT^DGENUPL1(SEG(16),"DATE",.ERROR)
+25 IF ERROR
Begin DoDot:1
+26 DO ADDERROR^DGENUPL(MSGID,$GET(DGPAT("SSN")),"BAD VALUE, ZCD SEGMENT, SEQ 16",.ERRCOUNT)
End DoDot:1
QUIT
SKIP ;
+1 ;Phase II Parse out additional fields. CONVERT type of RSN converts the code to IEN for diagnosis,procedure and condition (HL7TORSN^DGENA5).
+2 SET DGCDIS("DIAG",SEG(1))=$$CONVERT^DGENUPL1(SEG(7),"CDRSN")
+3 SET DGCDIS("PROC",SEG(1))=$$CONVERT^DGENUPL1(SEG(8),"CDRSN")
+4 SET DGCDIS("EXT",SEG(1),1)=$$CONVERT^DGENUPL1($PIECE(SEG(9),$EXTRACT(HLECH)),"EXT")
+5 SET DGCDIS("COND",SEG(1))=$$CONVERT^DGENUPL1(SEG(10),"CDRSN")
+6 SET DGCDIS("SCORE",SEG(1))=$$CONVERT^DGENUPL1($PIECE(SEG(11),$EXTRACT(HLECH)))
+7 SET DGCDIS("PERM",SEG(1))=$$CONVERT^DGENUPL1($PIECE(SEG(13),$EXTRACT(HLECH)))
+8 IF DGCDIS("VCD")="Y"
IF 'DGCDIS("DIAG",SEG(1))
IF 'DGCDIS("PROC",SEG(1))
IF 'DGCDIS("COND",SEG(1))
Begin DoDot:1
+9 SET ERROR=1
DO ADDERROR^DGENUPL(MSGID,$GET(DGPAT("SSN")),"NO VALID DIAGNOSIS,PROCEDURE, OR CONDITION IN THE ZCD SEGMENT",.ERRCOUNT)
End DoDot:1
QUIT
+10 QUIT
+11 ;
ZSP ;
+1 SET DGELG("SC")=$$CONVERT^DGENUPL1(SEG(2),"Y/N",.ERROR)
+2 IF ERROR
Begin DoDot:1
+3 DO ADDERROR^DGENUPL(MSGID,$GET(DGPAT("SSN")),"BAD VALUE, ZSP SEGMENT, SEQ 2",.ERRCOUNT)
End DoDot:1
QUIT
+4 SET DGELG("SCPER")=$$CONVERT^DGENUPL1(SEG(3))
+5 SET DGELG("POS")=$$CONVERT^DGENUPL1(SEG(4),"POS",.ERROR)
+6 IF ERROR
Begin DoDot:1
+7 DO ADDERROR^DGENUPL(MSGID,$GET(DGPAT("SSN")),"BAD VALUE, ZSP SEGMENT, SEQ 4",.ERRCOUNT)
End DoDot:1
QUIT
+8 SET DGELG("EFFDT")=$$CONVERT^DGENUPL1(SEG(11),"DATE",.ERROR)
+9 IF ERROR
Begin DoDot:1
+10 DO ADDERROR^DGENUPL(MSGID,$GET(DGELG("EFFDT")),"BAD VALUE, ZSP SEGMENT, SEQ 11",.ERRCOUNT)
End DoDot:1
QUIT
+11 ;if effective date is null, set update value to "@" (delete)
+12 IF DGELG("EFFDT")=""
SET DGELG("EFFDT")="@"
+13 ;
+14 ;added 8/3/98 to reduce #rejects
+15 ;if HEC sends SC=NO, SC% not sent, and site has value for SC% then delete it
+16 IF DGELG("SC")="N"
IF DGELG("SCPER")=""
SET DGELG("SCPER")="@"
+17 ;
+18 SET DGELG("P&T")=$$CONVERT^DGENUPL1(SEG(6),"Y/N",.ERROR)
+19 IF ERROR
Begin DoDot:1
+20 DO ADDERROR^DGENUPL(MSGID,$GET(DGPAT("SSN")),"BAD VALUE, ZSP SEGMENT, SEQ 6",.ERRCOUNT)
End DoDot:1
QUIT
+21 SET DGELG("UNEMPLOY")=$$CONVERT^DGENUPL1(SEG(7),"Y/N",.ERROR)
+22 IF ERROR
Begin DoDot:1
+23 DO ADDERROR^DGENUPL(MSGID,$GET(DGPAT("SSN")),"BAD VALUE, ZSP SEGMENT, SEQ 7",.ERRCOUNT)
End DoDot:1
QUIT
+24 SET DGELG("SCAWDATE")=$$CONVERT^DGENUPL1(SEG(8),"DATE",.ERROR)
+25 IF ERROR
Begin DoDot:1
+26 DO ADDERROR^DGENUPL(MSGID,$GET(DGPAT("SSN")),"BAD VALUE, ZSP SEGMENT, SEQ 8",.ERRCOUNT)
End DoDot:1
QUIT
+27 SET DGELG("P&TDT")=$$CONVERT^DGENUPL1(SEG(10),"DATE",.ERROR)
+28 IF ERROR
Begin DoDot:1
+29 DO ADDERROR^DGENUPL(MSGID,$GET(DGPAT("SSN")),"BAD VALUE, ZSP SEGMENT, SEQ 10 - P&T EFFECTIVE DATE",.ERRCOUNT)
End DoDot:1
+30 QUIT
+31 ;
ZMH ;Purple Heart, OEFOIE, POW
+1 ;Moved to DGENUPL3 - DG*5.3*653
DO ZMH^DGENUPL3
+2 QUIT
+3 ;
ZRD ;
+1 NEW COUNT,DXCODE,NAME,COND
+2 SET DXCODE=$PIECE(SEG(2),$EXTRACT(HLECH))
+3 IF DXCODE=""""""
SET DXCODE=""
+4 SET NAME=$PIECE(SEG(2),$EXTRACT(HLECH),2)
+5 ;segment does not contain a disability condition
IF DXCODE=""
QUIT
+6 ;
+7 SET COUNT=1+(+$GET(DGELG("RATEDIS")))
+8 SET (COND,DGELG("RATEDIS",COUNT,"RD"))=$$DCLOOKUP(DXCODE,NAME)
+9 SET DGELG("RATEDIS",COUNT,"PER")=$$CONVERT^DGENUPL1(SEG(3))
SET DGELG("RATEDIS")=COUNT
+10 SET DGELG("RATEDIS",COUNT,"RDEXT")=$$CONVERT^DGENUPL1(SEG(12))
+11 SET DGELG("RATEDIS",COUNT,"RDORIG")=$$CONVERT^DGENUPL1(SEG(13),"DATE",.ERROR)
+12 IF ERROR
Begin DoDot:1
+13 DO ADDERROR^DGENUPL(MSGID,$GET(DGPAT("SSN")),"BAD VALUE, ZRD SEGMENT, S 13",.ERRCOUNT)
End DoDot:1
QUIT
+14 SET DGELG("RATEDIS",COUNT,"RDCURR")=$$CONVERT^DGENUPL1(SEG(14),"DATE",.ERROR)
+15 IF ERROR
Begin DoDot:1
+16 DO ADDERROR^DGENUPL(MSGID,$GET(DGPAT("SSN")),"BAD VALUE, ZRD SEGMENT, S 14",.ERRCOUNT)
End DoDot:1
QUIT
+17 IF 'COND
Begin DoDot:1
+18 DO ADDERROR^DGENUPL(MSGID,$GET(DGPAT("SSN")),"BAD VALUE, ZRD SEGMENT, SEQ 2 - DISABILTY CONDITION LOOKUP FAILED",.ERRCOUNT)
+19 SET ERROR=1
End DoDot:1
QUIT
+20 QUIT
OBX ;
+1 ;code for OBX segment moved to DGENUPLA
DO OBX^DGENUPLA
+2 QUIT
+3 ;
+4 ;*********** end of segment parsers ****
+5 ;
DCLOOKUP(DGCODE,DGNAME) ;
+1 ; Description: Returns the ien of a Disability Condition (file #31) based on the DGCODE and DGNAME
+2 ;
+3 ;Input:
+4 ; DGCODE - DX Code of the Disability Condition
+5 ; DGNAME - name of the Disability Condition
+6 ;Output:
+7 ; Function Value: ien of the entry found, or 0 otherwise
+8 ;
+9 IF (DGCODE="")
QUIT 0
+10 NEW NODE,IEN,FOUND
+11 SET (FOUND,IEN)=0
+12 FOR
SET IEN=$ORDER(^DIC(31,"C",DGCODE,IEN))
IF 'IEN
QUIT
Begin DoDot:1
+13 SET NODE=$GET(^DIC(31,IEN,0))
+14 IF DGNAME=$PIECE(NODE,"^")
IF DGCODE=$PIECE(NODE,"^",3)
SET FOUND=1
End DoDot:1
IF FOUND
QUIT
+15 IF 'FOUND
SET IEN=$ORDER(^DIC(31,"C",DGCODE,0))
+16 QUIT +IEN
+17 ;
REGCHECK(DFN) ;
+1 ; Description: passes patient through the registration consistency checker
+2 ;Input -
+3 ; DFN - is a pointer to the Patient File
+4 ;
+5 NEW DGCD,DGCHK,DGDAY,DGEDCN,DGER,DGLST,DGNCK,DGRPCOLD,DGSC,DGTYPE,DGVT,VA,X
+6 ;
+7 SET DGEDCN=0
+8 DO ^DGRPC
+9 QUIT
PEND(DFN,DGSTAT) ;
+1 NEW DGARR,DGEC,DGERR,DGX
+2 IF $PIECE($GET(^DPT(DFN,.361)),U)'="V"
QUIT 0
+3 IF $GET(DGSTAT)="@"
QUIT 0
+4 IF $GET(DGSTAT)']""
QUIT 0
+5 SET DGSTAT="^"_DGSTAT_"^"
+6 IF "^15^17^"'[DGSTAT
QUIT 0
+7 DO GETS^DIQ(2,DFN_",",".301;.302;.361;.36295","IE","DGARR","DGERR")
+8 IF $DATA(DGERR)
QUIT 0
+9 SET DGEC=$GET(DGARR(2,DFN_",",.361,"I"))
+10 IF $GET(DGEC)']""
QUIT 0
+11 SET DGEC=$PIECE($GET(^DIC(8,DGEC,0)),U,9)
+12 IF $GET(DGEC)']""
QUIT 0
+13 IF DGEC=5
QUIT 1
+14 IF DGEC=3
Begin DoDot:1
+15 SET DGX=1
+16 IF $GET(DGARR(2,DFN_",",.301,"I"))'="Y"
SET DGX=0
QUIT
+17 IF +$GET(DGARR(2,DFN_",",.302,"I"))>0
SET DGX=0
QUIT
+18 IF +$GET(DGARR(2,DFN_",",.36295,"I"))>0
SET DGX=0
QUIT
End DoDot:1
QUIT DGX
+19 QUIT 0