DGROHLU3 ;DJH/AMA - ROM HL7 BUILD MSA/ERR SEGMENTS ; 02 Jul 2003 5:02 PM
;;5.3;Registration;**533,1015**;Aug 13, 1993;Build 21
;
Q
;
MSA(DGACK,DGID,DGERR,DGFLD,DGHL) ;MSA Segment API
;This function wraps the data retrieval and segment creation APIs and
;returns a formatted MSA segment.
; Called from BLDORF^DGROHLQ and BLDACK^DGROHLU4
;
; Input:
; DGACK - (required) MSA segment Acknowledgment code
; DGID - (required) Message Control ID
; DGERR - (optional) Error condition
; DGFLD - (optional) List of comma-separated fields (sequence #'s)
; to include. Defaults to all required fields (1,2).
; DGHL - (required) HL7 environment array
;
; Output:
; Function Value - MSA segment on success, "" on failure
;
N DGMSA
N DGVAL
;
S DGMSA=""
I $G(DGACK)]"",+$G(DGID) D
. S DGERR=$G(DGERR)
. S DGFLD=$$CKSTR^DGROHLUT("1,2",DGFLD) ;validate field string
. I DGERR]"" S DGFLD=DGFLD_",6"
. S DGFLD=","_DGFLD_","
. I $$MSAVAL(DGFLD,DGACK,DGID,"","","",DGERR,.DGVAL) D
. . S DGMSA=$$BLDSEG^DGROHLUT("MSA",.DGVAL,.DGHL)
Q DGMSA
;
MSAVAL(DGFLD,DGACK,DGID,DGTEXT,DGESN,DGDAT,DGERR,DGVAL) ;build MSA value array
;
; Input:
; DGFLD - (required) fields string
; DGACK - (required) MSA segment Acknowledgment code
; DGID - (required) Message Control ID
; DGTEXT - (optional) Text message
; DGESN - (optional) Expected sequence number
; DGDAT - (optional) Delayed acknowledgment type
; DGERR - (optional) Error condition
;
; Output:
; Function Value - 1 on sucess, 0 on failure
; DGVAL - MSA field array [SUB1:field, SUB2:repetition,
; SUB3:component, SUB4:sub-component]
;
N DGRSLT ;function value
N DGACKS ;array of valid ACK codes
N DGCOD ;ACK code string
N DGERRSTR ;Error condition string
N DGTBL ;VA086 Error code array
;
S DGRSLT=0
I $G(DGFLD)]"",$G(DGACK)]"",+$G(DGID) D
. F DGCOD="AA","AE","AR","CA","CE","CR" S DGACKS(DGCOD)=""
. ;
. ; seq 1 Acknowledgment Code
. I DGFLD[",1," D
. . S DGVAL(1)=$S($D(DGACKS(DGACK)):DGACK,1:"")
. Q:(DGVAL(1)="") ;required field
. ;
. ; seq 2 Message Control ID
. I DGFLD[",2," D
. . S DGVAL(2)=DGID
. Q:(DGVAL(2)="") ;required field
. ;
. ; seq 3 Text Message
. I DGFLD[",3," D
. . S DGVAL(3)=$G(DGTEXT)
. ;
. ; seq 4 Expected Sequence Number
. I DGFLD[",4," D
. . S DGVAL(4)=$G(DGESN)
. ;
. ; seq 5 Delayed Acknowledgment Type
. I DGFLD[",5," D
. . S DGDAT=$G(DGDAT)
. . S DGVAL(5)=$S(DGDAT="D":DGDAT,DGDAT="F":DGDAT,1:"")
. ;
. ; seq 6 Error Condition
. I DGFLD[",6," D
. . D BLDVA086(.DGTBL)
. . I $G(DGERR)]"",$D(DGTBL(DGERR))#2 D
. . . S DGVAL(6,1,1)=DGERR
. . . S DGVAL(6,1,2)=DGTBL(DGERR)
. . . S DGVAL(6,1,3)="VA086"
. S DGRSLT=1
I 'DGRSLT K DGVAL
Q DGRSLT
;
ERR(DGSEG,DGSEQ,DGPOS,DGCOD,DGFLD,DGHL) ;ERR segment API
;Called from BLDERR^DGROHLU4
; Input:
; DGSEG - (required) Segment ID
; DGSEQ - (required) Sequence
; DGPOS - (required) Field position
; DGCOD - (required) Error code from table VA086
; DGFLD - (optional) List of comma-separated fields (sequence #'s)
; to include. Defaults to all required fields (1).
; DGHL - (required) HL7 Environment array
;
; Output:
; Function value - ERR segment on success, "" on failure
;
N DGERR
N DGVAL
N DGFLD
;
S DGERR=""
I $G(DGSEG)]"",+$G(DGSEQ),+$G(DGPOS),$G(DGCOD)]"",$G(DGHL("ECH"))]"" D
. S DGFLD=$$CKSTR^DGROHLUT("1",DGFLD) ;validate field string
. S DGFLD=","_DGFLD_","
. I $$ERRVAL(DGFLD,DGSEG,DGSEQ,DGPOS,DGCOD,.DGVAL) D
. . S DGERR=$$BLDSEG^DGROHLUT("ERR",.DGVAL,.DGHL)
Q DGERR
;
ERRVAL(DGFLD,DGSEG,DGSEQ,DGPOS,DGCOD,DGVAL) ;build ERR value array
;
; Input:
; DGFLD - (required) Field string
; DGSEG - (required) Segment ID
; DGSEQ - (required) Sequence
; DGPOS - (required) Field position
; DGCOD - (required) Error code from table VA086
;
; Output:
; Function value - 1 on success, 0 on failure
; DGVAL - ERR field array [SUB1:field, SUB2:repetition,
; SUB3:component, SUB4:sub-component]
N DGRSLT
N DGTBL
;
S DGRSLT=0
I $G(DGFLD)]"",$G(DGSEG)]"",+$G(DGSEQ),+$G(DGPOS),$G(DGCOD)]"" D
. I DGFLD[",1," D
. . D BLDVA086(.DGTBL)
. . I $D(DGTBL(DGCOD))#2 D
. . . S DGVAL(1,1,1)=DGSEG
. . . S DGVAL(1,1,2)=DGSEQ
. . . S DGVAL(1,1,3)=DGPOS
. . . S DGVAL(1,1,4,1)=DGCOD
. . . S DGVAL(1,1,4,2)=DGTBL(DGCOD)
. . . S DGVAL(1,1,4,3)="VA086"
. S DGRSLT=1
Q DGRSLT
;
BLDVA086(DGTBL) ;build error code/text array for table VA086
;
; Input:
; none
;
; Output:
; DGTBL - error code array subscripted by code containing error text
;
N DGI
N DGLINE
N DGCOD
N DGTXT
N DGDESC
;
F DGI=1:1 S DGLINE=$T(ERRTBL+DGI) Q:DGLINE="" D
. S DGCOD=$P(DGLINE,";",3)
. S DGTXT=$P(DGLINE,";",4)
. S DGDESC=$P(DGLINE,";",5)
. S DGTBL(DGCOD)=DGTXT
. S DGTBL(DGCOD,"DESC")=DGDESC
Q
;
ERRTBL ;VA086 Error Code Table;error code;error text
;;FE;Filer Error;An error occurred at the remote site when attempting to add or update an assignment.
;;IF;Invalid Patient Record Flag;The transmitted Patient Record Flag is not defined at the remote site.
;;IID;Invalid Observation ID;The transmitted observation ID is not "N"arrative, "S"tatus or "C"omment.
;;IOR;Invalid Originating Site;The originating site of the transmission is not defined at the remote site.
;;IOW;Invalid Owner Site;The transmitted owning site is not defined at the remote site.
;;NM;No Match;No patient was found that correlates to the transmitted ICN, DOB and SSN.
;;UU;Unauthorized Update;The originating site of the transmission is not defined as the owning site of the assignment or an invalid action was transmitted (i.e. Reactivate an already active assignment).
DGROHLU3 ;DJH/AMA - ROM HL7 BUILD MSA/ERR SEGMENTS ; 02 Jul 2003 5:02 PM
+1 ;;5.3;Registration;**533,1015**;Aug 13, 1993;Build 21
+2 ;
+3 QUIT
+4 ;
MSA(DGACK,DGID,DGERR,DGFLD,DGHL) ;MSA Segment API
+1 ;This function wraps the data retrieval and segment creation APIs and
+2 ;returns a formatted MSA segment.
+3 ; Called from BLDORF^DGROHLQ and BLDACK^DGROHLU4
+4 ;
+5 ; Input:
+6 ; DGACK - (required) MSA segment Acknowledgment code
+7 ; DGID - (required) Message Control ID
+8 ; DGERR - (optional) Error condition
+9 ; DGFLD - (optional) List of comma-separated fields (sequence #'s)
+10 ; to include. Defaults to all required fields (1,2).
+11 ; DGHL - (required) HL7 environment array
+12 ;
+13 ; Output:
+14 ; Function Value - MSA segment on success, "" on failure
+15 ;
+16 NEW DGMSA
+17 NEW DGVAL
+18 ;
+19 SET DGMSA=""
+20 IF $GET(DGACK)]""
IF +$GET(DGID)
Begin DoDot:1
+21 SET DGERR=$GET(DGERR)
+22 ;validate field string
SET DGFLD=$$CKSTR^DGROHLUT("1,2",DGFLD)
+23 IF DGERR]""
SET DGFLD=DGFLD_",6"
+24 SET DGFLD=","_DGFLD_","
+25 IF $$MSAVAL(DGFLD,DGACK,DGID,"","","",DGERR,.DGVAL)
Begin DoDot:2
+26 SET DGMSA=$$BLDSEG^DGROHLUT("MSA",.DGVAL,.DGHL)
End DoDot:2
End DoDot:1
+27 QUIT DGMSA
+28 ;
MSAVAL(DGFLD,DGACK,DGID,DGTEXT,DGESN,DGDAT,DGERR,DGVAL) ;build MSA value array
+1 ;
+2 ; Input:
+3 ; DGFLD - (required) fields string
+4 ; DGACK - (required) MSA segment Acknowledgment code
+5 ; DGID - (required) Message Control ID
+6 ; DGTEXT - (optional) Text message
+7 ; DGESN - (optional) Expected sequence number
+8 ; DGDAT - (optional) Delayed acknowledgment type
+9 ; DGERR - (optional) Error condition
+10 ;
+11 ; Output:
+12 ; Function Value - 1 on sucess, 0 on failure
+13 ; DGVAL - MSA field array [SUB1:field, SUB2:repetition,
+14 ; SUB3:component, SUB4:sub-component]
+15 ;
+16 ;function value
NEW DGRSLT
+17 ;array of valid ACK codes
NEW DGACKS
+18 ;ACK code string
NEW DGCOD
+19 ;Error condition string
NEW DGERRSTR
+20 ;VA086 Error code array
NEW DGTBL
+21 ;
+22 SET DGRSLT=0
+23 IF $GET(DGFLD)]""
IF $GET(DGACK)]""
IF +$GET(DGID)
Begin DoDot:1
+24 FOR DGCOD="AA","AE","AR","CA","CE","CR"
SET DGACKS(DGCOD)=""
+25 ;
+26 ; seq 1 Acknowledgment Code
+27 IF DGFLD[",1,"
Begin DoDot:2
+28 SET DGVAL(1)=$SELECT($DATA(DGACKS(DGACK)):DGACK,1:"")
End DoDot:2
+29 ;required field
IF (DGVAL(1)="")
QUIT
+30 ;
+31 ; seq 2 Message Control ID
+32 IF DGFLD[",2,"
Begin DoDot:2
+33 SET DGVAL(2)=DGID
End DoDot:2
+34 ;required field
IF (DGVAL(2)="")
QUIT
+35 ;
+36 ; seq 3 Text Message
+37 IF DGFLD[",3,"
Begin DoDot:2
+38 SET DGVAL(3)=$GET(DGTEXT)
End DoDot:2
+39 ;
+40 ; seq 4 Expected Sequence Number
+41 IF DGFLD[",4,"
Begin DoDot:2
+42 SET DGVAL(4)=$GET(DGESN)
End DoDot:2
+43 ;
+44 ; seq 5 Delayed Acknowledgment Type
+45 IF DGFLD[",5,"
Begin DoDot:2
+46 SET DGDAT=$GET(DGDAT)
+47 SET DGVAL(5)=$SELECT(DGDAT="D":DGDAT,DGDAT="F":DGDAT,1:"")
End DoDot:2
+48 ;
+49 ; seq 6 Error Condition
+50 IF DGFLD[",6,"
Begin DoDot:2
+51 DO BLDVA086(.DGTBL)
+52 IF $GET(DGERR)]""
IF $DATA(DGTBL(DGERR))#2
Begin DoDot:3
+53 SET DGVAL(6,1,1)=DGERR
+54 SET DGVAL(6,1,2)=DGTBL(DGERR)
+55 SET DGVAL(6,1,3)="VA086"
End DoDot:3
End DoDot:2
+56 SET DGRSLT=1
End DoDot:1
+57 IF 'DGRSLT
KILL DGVAL
+58 QUIT DGRSLT
+59 ;
ERR(DGSEG,DGSEQ,DGPOS,DGCOD,DGFLD,DGHL) ;ERR segment API
+1 ;Called from BLDERR^DGROHLU4
+2 ; Input:
+3 ; DGSEG - (required) Segment ID
+4 ; DGSEQ - (required) Sequence
+5 ; DGPOS - (required) Field position
+6 ; DGCOD - (required) Error code from table VA086
+7 ; DGFLD - (optional) List of comma-separated fields (sequence #'s)
+8 ; to include. Defaults to all required fields (1).
+9 ; DGHL - (required) HL7 Environment array
+10 ;
+11 ; Output:
+12 ; Function value - ERR segment on success, "" on failure
+13 ;
+14 NEW DGERR
+15 NEW DGVAL
+16 NEW DGFLD
+17 ;
+18 SET DGERR=""
+19 IF $GET(DGSEG)]""
IF +$GET(DGSEQ)
IF +$GET(DGPOS)
IF $GET(DGCOD)]""
IF $GET(DGHL("ECH"))]""
Begin DoDot:1
+20 ;validate field string
SET DGFLD=$$CKSTR^DGROHLUT("1",DGFLD)
+21 SET DGFLD=","_DGFLD_","
+22 IF $$ERRVAL(DGFLD,DGSEG,DGSEQ,DGPOS,DGCOD,.DGVAL)
Begin DoDot:2
+23 SET DGERR=$$BLDSEG^DGROHLUT("ERR",.DGVAL,.DGHL)
End DoDot:2
End DoDot:1
+24 QUIT DGERR
+25 ;
ERRVAL(DGFLD,DGSEG,DGSEQ,DGPOS,DGCOD,DGVAL) ;build ERR value array
+1 ;
+2 ; Input:
+3 ; DGFLD - (required) Field string
+4 ; DGSEG - (required) Segment ID
+5 ; DGSEQ - (required) Sequence
+6 ; DGPOS - (required) Field position
+7 ; DGCOD - (required) Error code from table VA086
+8 ;
+9 ; Output:
+10 ; Function value - 1 on success, 0 on failure
+11 ; DGVAL - ERR field array [SUB1:field, SUB2:repetition,
+12 ; SUB3:component, SUB4:sub-component]
+13 NEW DGRSLT
+14 NEW DGTBL
+15 ;
+16 SET DGRSLT=0
+17 IF $GET(DGFLD)]""
IF $GET(DGSEG)]""
IF +$GET(DGSEQ)
IF +$GET(DGPOS)
IF $GET(DGCOD)]""
Begin DoDot:1
+18 IF DGFLD[",1,"
Begin DoDot:2
+19 DO BLDVA086(.DGTBL)
+20 IF $DATA(DGTBL(DGCOD))#2
Begin DoDot:3
+21 SET DGVAL(1,1,1)=DGSEG
+22 SET DGVAL(1,1,2)=DGSEQ
+23 SET DGVAL(1,1,3)=DGPOS
+24 SET DGVAL(1,1,4,1)=DGCOD
+25 SET DGVAL(1,1,4,2)=DGTBL(DGCOD)
+26 SET DGVAL(1,1,4,3)="VA086"
End DoDot:3
End DoDot:2
+27 SET DGRSLT=1
End DoDot:1
+28 QUIT DGRSLT
+29 ;
BLDVA086(DGTBL) ;build error code/text array for table VA086
+1 ;
+2 ; Input:
+3 ; none
+4 ;
+5 ; Output:
+6 ; DGTBL - error code array subscripted by code containing error text
+7 ;
+8 NEW DGI
+9 NEW DGLINE
+10 NEW DGCOD
+11 NEW DGTXT
+12 NEW DGDESC
+13 ;
+14 FOR DGI=1:1
SET DGLINE=$TEXT(ERRTBL+DGI)
IF DGLINE=""
QUIT
Begin DoDot:1
+15 SET DGCOD=$PIECE(DGLINE,";",3)
+16 SET DGTXT=$PIECE(DGLINE,";",4)
+17 SET DGDESC=$PIECE(DGLINE,";",5)
+18 SET DGTBL(DGCOD)=DGTXT
+19 SET DGTBL(DGCOD,"DESC")=DGDESC
End DoDot:1
+20 QUIT
+21 ;
ERRTBL ;VA086 Error Code Table;error code;error text
+1 ;;FE;Filer Error;An error occurred at the remote site when attempting to add or update an assignment.
+2 ;;IF;Invalid Patient Record Flag;The transmitted Patient Record Flag is not defined at the remote site.
+3 ;;IID;Invalid Observation ID;The transmitted observation ID is not "N"arrative, "S"tatus or "C"omment.
+4 ;;IOR;Invalid Originating Site;The originating site of the transmission is not defined at the remote site.
+5 ;;IOW;Invalid Owner Site;The transmitted owning site is not defined at the remote site.
+6 ;;NM;No Match;No patient was found that correlates to the transmitted ICN, DOB and SSN.
+7 ;;UU;Unauthorized Update;The originating site of the transmission is not defined as the owning site of the assignment or an invalid action was transmitted (i.e. Reactivate an already active assignment).