DGENUPL1 ;ALB/CJM,ISA/KWP,CKN,LBD - PROCESS INCOMING (Z11 EVENT TYPE) HL7 MESSAGES ; 6/17/09 10:07am
;;5.3;PIMS;**147,222,232,314,397,379,407,363,673,653,688,1015,1016**;JUN 30, 2012;Build 20
;
PARSE(MSGIEN,MSGID,CURLINE,ERRCOUNT,DGPAT,DGELG,DGENR,DGCDIS,DGOEIF,DGSEC,DGNTR,DGMST,DGNMSE) ;
;
;Description: This function parses the HL7 segments. It creates arrays
;defined by the PATIENT, ENROLLMENT, ELIGIBILY, CATASTROPHIC DISABILITY,
;OEF/OIF CONFLICT objects.
;Field values are put in DHCP format and the validity at the
;field level is tested. Fields to be deleted are set to "@".
;
;Input:
; MSGIEN - the ien of the HL7 message in the HL7 MESSAGE TEXT file (772)
; MSGID -message control id of HL7 msg in the MSH segment
; CURLINE - the subscript of the PID segment of the current message (pass by reference)
; ERRCOUNT - is a count of the number of messages in the batch that can not be processed (pass by ref)
;
;Output:
; Function Value: Returns 1 on success, 0 on failure.
; CURLINE - upon leaving the procedure this parameter should be set to the end of the current message.
; ERRCOUNT - set to count of messages that were not processed due to errors encountered. (pass by ref)
; DGPAT - array defined by the PATIENT object. (pass by ref)
; DGENR - array defined by the PATIENT ENROLLMENT object. (pass by ref)
; DGELG - array defined by the PATIENT ELIGIBILITY object. (pass by ref)
; DGCDIS - array defined by the CATASTROPHIC DISABILITY object. (pass by ref)
; DGSEC - array defined by the PATIENT SECURITY object. (pass by ref)
; DGOEIF - array defined by the OEF/OIF CONFLICT object. (pass by ref)
; DGNTR - array defined for NTR data.
; DGMST - array defined for MST data.
; DGNMSE - array define for MILITARY SERVICE EPISODE data (pass by ref)
N SEG,ERROR,COUNT,QFLG,NFLG
;
K DGEN,DGPAT,DGELG,DGCDIS,DGNTR,DGMST
;
S ERROR=0,NFLG=1
F SEG="PID","ZPD","ZIE","ZIO","ZEL" D Q:ERROR
.D:NFLG NXTSEG^DGENUPL(MSGIEN,.CURLINE,.SEG)
.I SEG="ZIO",SEG("TYPE")'="ZIO" S NFLG=0 Q
.I SEG("TYPE")=SEG D Q
..D:(SEG'="ZEL") @SEG^DGENUPL2
..D:(SEG="ZEL") ZEL^DGENUPL2(1)
..S NFLG=1
.D ADDERROR^DGENUPL(MSGID,$G(DGPAT("SSN")),SEG_" SEGMENT MISSING OR OUT OF ORDER",.ERRCOUNT)
.S ERROR=1
.;
.;possible that in a bad message we are now past the end
.S CURLINE=CURLINE-1
;
I 'ERROR F COUNT=2:1 D NXTSEG^DGENUPL(MSGIEN,CURLINE,.SEG) Q:(SEG("TYPE")'="ZEL") D Q:ERROR
.S CURLINE=CURLINE+1
.D ZEL^DGENUPL2(COUNT)
;Phase II Add the capability to accept more than 1 ZCD
I 'ERROR F SEG="ZEN","ZMT","ZCD" D Q:ERROR
.D NXTSEG^DGENUPL(MSGIEN,.CURLINE,.SEG)
.I SEG("TYPE")=SEG D
..D @SEG^DGENUPL2
.E D
..D ADDERROR^DGENUPL(MSGID,$G(DGPAT("SSN")),SEG_" SEGMENT MISSING OR OUTOF ORDER",.ERRCOUNT)
..S ERROR=1
..;
..;possible that in a bad message we are now past the end
..S CURLINE=CURLINE-1
;
I 'ERROR F COUNT=2:1 D NXTSEG^DGENUPL(MSGIEN,CURLINE,.SEG) Q:(SEG("TYPE")'="ZCD") D Q:ERROR
.S CURLINE=CURLINE+1
.D ZCD^DGENUPL2
;
; Purple Heart/OEF-OIF Addition of optional ZMH segment
; Modified handling of ZSP and ZRD to accomodate ZMH
;
I 'ERROR D Q:ERROR $S(ERROR:0,1:1)
.D NXTSEG^DGENUPL(MSGIEN,.CURLINE,.SEG)
.I SEG("TYPE")="ZSP" D ZSP^DGENUPL2 Q
.D ADDERROR^DGENUPL(MSGID,$G(DGPAT("SSN")),SEG_" SEGMENT MISSING OR OUT OF ORDER",.ERRCOUNT)
.S ERROR=1
.;possible that in a bad message we are now past the end
.S CURLINE=CURLINE-1
;
;Modified following code to receive multiple ZMH segment for
;Military service information - DG*5.3*653
I 'ERROR D Q:ERROR $S(ERROR:0,1:1)
.D NXTSEG^DGENUPL(MSGIEN,.CURLINE,.SEG)
.S QFLG=0 F D Q:QFLG
. . I SEG("TYPE")'="ZMH" S QFLG=1 Q
. . D ZMH^DGENUPL2,NXTSEG^DGENUPL(MSGIEN,.CURLINE,.SEG)
.I SEG("TYPE")="ZRD" D ZRD^DGENUPL2 Q
.D ADDERROR^DGENUPL(MSGID,$G(DGPAT("SSN")),SEG_" SEGMENT MISSING OR OUT OF ORDER",.ERRCOUNT)
.S ERROR=1
.;possible that in a bad message we are now past the end
.S CURLINE=CURLINE-1
;
I 'ERROR F COUNT=2:1 D NXTSEG^DGENUPL(MSGIEN,CURLINE,.SEG) Q:(SEG("TYPE")'="ZRD") D Q:ERROR
.S CURLINE=CURLINE+1
.D ZRD^DGENUPL2
;
I 'ERROR F D Q:(ERROR!(SEG("TYPE")'="OBX"))
.;possible if OBX segment not present that we are now past the end
.I SEG("TYPE")'="OBX" S CURLINE=CURLINE-1 Q
.D OBX^DGENUPL2
.S CURLINE=CURLINE+1
.D NXTSEG^DGENUPL(MSGIEN,CURLINE,.SEG)
;
Q $S(ERROR:0,1:1)
;
CONVERT(VAL,DATATYPE,ERROR) ;
;Description: Converts the value found in the HL7 segment to DHCP format
;
;Input:
; VAL - value parsed from the HL7 segment
; DATATYPE: indicates the type of conversion necessary
; "DATE" - needs to be converted to FM format
; "TS" - time stamp, needs to be converted to FM format
; "Y/N" - 0->"N",1->"Y"
; "1/0" - "Y"->1,"N"->0
; "INSTITUTION" - needs to convert the station number with suffix to a point to the INSTITUTION file
; "ELIGIBILITY" - VAL is a pointer to the national eligibility code file (#8.1), needs to be converted to a local eligibility code (file #8)
;
; "MT" - VAL is a Means Test Status code, it needs to be converted
; to a pointer to the Means Test Status file
; Phase II convert code to RSN IEN for DGCDIS object
; "CDRSN" data type converts the codes diagnosis,procedure,condition to RSN IEN. (HL7TORSN^DGENA5)
; "EXT" convert from code to abbreviation
; "POS" convert from Period of Service code to a point to Period of Service file
; "AGENCY" convert Agency/Allied Country code from file 35
;OUTPUT:
; Function Value - the result of the conversion
; ERROR - set to 1 if an error is detected, 0 otherwise (optional,pass by ref)
;
S ERROR=0
D
.I VAL="" Q
.I VAL="""""" S VAL="@" Q
.I $G(DATATYPE)="EXT" D Q
..S VAL=$$HLTOLIMB^DGENA5(VAL)
.I $G(DATATYPE)="CDRSN" D Q
..S VAL=$$HL7TORSN^DGENA5(VAL)
.I ($G(DATATYPE)="MT") D Q
..S VAL=$O(^DG(408.32,"AC",1,VAL,0))
..I 'VAL S ERROR=1
.I ($G(DATATYPE)="DATE") D Q
..I $L(VAL)'=8 S ERROR=1 Q
..S VAL=$$FMDATE^HLFNC(VAL)
..I ((VAL'=+VAL)!($L($P(VAL,"."))<7)) S ERROR=1
.I ($G(DATATYPE)="TS") D Q
..I $L(VAL)<8 S ERROR=1 Q
..S VAL=$$FMDATE^HLFNC(VAL)
..I ((VAL'=+VAL)!($L($P(VAL,"."))<7)) S ERROR=1
.I ($G(DATATYPE)="Y/N") D Q
..I VAL=0 S VAL="N" Q
..I VAL=1 S VAL="Y" Q
..S ERROR=1
.I ($G(DATATYPE)="1/0") D Q
..I VAL="N" S VAL=0 Q
..I VAL="Y" S VAL=1 Q
..S ERROR=1
.I ($G(DATATYPE)="ELIGIBILITY") D Q
..S VAL=$$MAP(VAL)
..I 'VAL S ERROR=1
.I ($G(DATATYPE)="INSTITUTION") D Q
..N OLDVAL
..S OLDVAL=VAL
..S VAL=$O(^DIC(4,"D",OLDVAL,0))
..I 'VAL S VAL=$O(^DIC(4,"D",(+OLDVAL),0))
..I 'VAL S ERROR=1
.I ($G(DATATYPE)="POS") D Q
..N OLDVAL
..S OLDVAL=VAL
..S VAL=$O(^DIC(21,"D",OLDVAL,0))
..I 'VAL S ERROR=1
.I ($G(DATATYPE)="AGENCY") D Q
..N OLDVAL
..S OLDVAL=VAL
..S VAL=$O(^DIC(35,"C",OLDVAL,0))
..I 'VAL S ERROR=1
Q VAL
;
MAP(VALUE) ;
;Description: Tries to map an eligibility code from file #8.1 (the national MAS ELIGIBILITY CODE file) to file #8 (the local ELIGIBILITY CODE file)
;
;Input: VALUE - ien of an entry in file #8.1
;
;Output: Function value - NULL if mapping is not found, otherwise returns an ien of entry in file #8
;
N ECODE,NODE,COUNT,NAME
;try to choose a code from file 8 to use that is appropriate
S (COUNT,ECODE)=0
;
F S ECODE=$O(^DIC(8,"D",VALUE,ECODE)) Q:'ECODE D
.S NODE=$G(^DIC(8,ECODE,0))
.;put code on list if active
.I (NODE'=""),'$P(NODE,"^",7) S ECODE(ECODE)=$P(NODE,"^"),COUNT=COUNT+1
;
;only one match found, so use it
Q:COUNT=1 $O(ECODE(0))
;
;no match found
Q:'COUNT ""
;
;multiple matches found, try to match by name
I COUNT>1 D
.S ECODE=0
.S NAME=$P($G(^DIC(8.1,VALUE,0)),"^")
.F S ECODE=$O(ECODE(ECODE)) Q:'ECODE Q:ECODE(ECODE)=NAME
Q ECODE
;
ACCEPT(MSGID) ;
;Description: Writes an ack (AA) to a global to be transmitted later.
;
;Inputs:
; MSGID -message control id of HL7 msg in the MSH segment
;
;Outputs: none
;
K HL,HLMID,HLMTIEN,HLDT,HLDT1
D INIT^HLFNC2(HLEID,.HL)
D CREATE^HLTF(.HLMID,.HLMTIEN,.HLDT,.HLDT1)
S HLEVN=1
S MID=HLMID_"-"_HLEVN
D MSH^HLFNC2(.HL,MID,.HLRES)
S ^TMP("HLS",$J,1)=HLRES
;
;it seems HLFS sometimes disappears upon reaching this point
I $G(HLFS)="" S HLFS="^"
;
S ^TMP("HLS",$J,2)="MSA"_HLFS_"AA"_HLFS_MSGID
Q
;
MVERRORS ;
;Error messages were being deleted from ^TMP("HLS",$J by another package
;during the upload. To fix this, errors are written to another
;subscript, then moved when the error list is complete.
;
M ^TMP("HLS",$J)=^TMP("IVM","HLS",$J)
K ^TMP("IVM","HLS",$J)
Q
DGENUPL1 ;ALB/CJM,ISA/KWP,CKN,LBD - PROCESS INCOMING (Z11 EVENT TYPE) HL7 MESSAGES ; 6/17/09 10:07am
+1 ;;5.3;PIMS;**147,222,232,314,397,379,407,363,673,653,688,1015,1016**;JUN 30, 2012;Build 20
+2 ;
PARSE(MSGIEN,MSGID,CURLINE,ERRCOUNT,DGPAT,DGELG,DGENR,DGCDIS,DGOEIF,DGSEC,DGNTR,DGMST,DGNMSE) ;
+1 ;
+2 ;Description: This function parses the HL7 segments. It creates arrays
+3 ;defined by the PATIENT, ENROLLMENT, ELIGIBILY, CATASTROPHIC DISABILITY,
+4 ;OEF/OIF CONFLICT objects.
+5 ;Field values are put in DHCP format and the validity at the
+6 ;field level is tested. Fields to be deleted are set to "@".
+7 ;
+8 ;Input:
+9 ; MSGIEN - the ien of the HL7 message in the HL7 MESSAGE TEXT file (772)
+10 ; MSGID -message control id of HL7 msg in the MSH segment
+11 ; CURLINE - the subscript of the PID segment of the current message (pass by reference)
+12 ; ERRCOUNT - is a count of the number of messages in the batch that can not be processed (pass by ref)
+13 ;
+14 ;Output:
+15 ; Function Value: Returns 1 on success, 0 on failure.
+16 ; CURLINE - upon leaving the procedure this parameter should be set to the end of the current message.
+17 ; ERRCOUNT - set to count of messages that were not processed due to errors encountered. (pass by ref)
+18 ; DGPAT - array defined by the PATIENT object. (pass by ref)
+19 ; DGENR - array defined by the PATIENT ENROLLMENT object. (pass by ref)
+20 ; DGELG - array defined by the PATIENT ELIGIBILITY object. (pass by ref)
+21 ; DGCDIS - array defined by the CATASTROPHIC DISABILITY object. (pass by ref)
+22 ; DGSEC - array defined by the PATIENT SECURITY object. (pass by ref)
+23 ; DGOEIF - array defined by the OEF/OIF CONFLICT object. (pass by ref)
+24 ; DGNTR - array defined for NTR data.
+25 ; DGMST - array defined for MST data.
+26 ; DGNMSE - array define for MILITARY SERVICE EPISODE data (pass by ref)
+27 NEW SEG,ERROR,COUNT,QFLG,NFLG
+28 ;
+29 KILL DGEN,DGPAT,DGELG,DGCDIS,DGNTR,DGMST
+30 ;
+31 SET ERROR=0
SET NFLG=1
+32 FOR SEG="PID","ZPD","ZIE","ZIO","ZEL"
Begin DoDot:1
+33 IF NFLG
DO NXTSEG^DGENUPL(MSGIEN,.CURLINE,.SEG)
+34 IF SEG="ZIO"
IF SEG("TYPE")'="ZIO"
SET NFLG=0
QUIT
+35 IF SEG("TYPE")=SEG
Begin DoDot:2
+36 IF (SEG'="ZEL")
DO @SEG^DGENUPL2
+37 IF (SEG="ZEL")
DO ZEL^DGENUPL2(1)
+38 SET NFLG=1
End DoDot:2
QUIT
+39 DO ADDERROR^DGENUPL(MSGID,$GET(DGPAT("SSN")),SEG_" SEGMENT MISSING OR OUT OF ORDER",.ERRCOUNT)
+40 SET ERROR=1
+41 ;
+42 ;possible that in a bad message we are now past the end
+43 SET CURLINE=CURLINE-1
End DoDot:1
IF ERROR
QUIT
+44 ;
+45 IF 'ERROR
FOR COUNT=2:1
DO NXTSEG^DGENUPL(MSGIEN,CURLINE,.SEG)
IF (SEG("TYPE")'="ZEL")
QUIT
Begin DoDot:1
+46 SET CURLINE=CURLINE+1
+47 DO ZEL^DGENUPL2(COUNT)
End DoDot:1
IF ERROR
QUIT
+48 ;Phase II Add the capability to accept more than 1 ZCD
+49 IF 'ERROR
FOR SEG="ZEN","ZMT","ZCD"
Begin DoDot:1
+50 DO NXTSEG^DGENUPL(MSGIEN,.CURLINE,.SEG)
+51 IF SEG("TYPE")=SEG
Begin DoDot:2
+52 DO @SEG^DGENUPL2
End DoDot:2
+53 IF '$TEST
Begin DoDot:2
+54 DO ADDERROR^DGENUPL(MSGID,$GET(DGPAT("SSN")),SEG_" SEGMENT MISSING OR OUTOF ORDER",.ERRCOUNT)
+55 SET ERROR=1
+56 ;
+57 ;possible that in a bad message we are now past the end
+58 SET CURLINE=CURLINE-1
End DoDot:2
End DoDot:1
IF ERROR
QUIT
+59 ;
+60 IF 'ERROR
FOR COUNT=2:1
DO NXTSEG^DGENUPL(MSGIEN,CURLINE,.SEG)
IF (SEG("TYPE")'="ZCD")
QUIT
Begin DoDot:1
+61 SET CURLINE=CURLINE+1
+62 DO ZCD^DGENUPL2
End DoDot:1
IF ERROR
QUIT
+63 ;
+64 ; Purple Heart/OEF-OIF Addition of optional ZMH segment
+65 ; Modified handling of ZSP and ZRD to accomodate ZMH
+66 ;
+67 IF 'ERROR
Begin DoDot:1
+68 DO NXTSEG^DGENUPL(MSGIEN,.CURLINE,.SEG)
+69 IF SEG("TYPE")="ZSP"
DO ZSP^DGENUPL2
QUIT
+70 DO ADDERROR^DGENUPL(MSGID,$GET(DGPAT("SSN")),SEG_" SEGMENT MISSING OR OUT OF ORDER",.ERRCOUNT)
+71 SET ERROR=1
+72 ;possible that in a bad message we are now past the end
+73 SET CURLINE=CURLINE-1
End DoDot:1
IF ERROR
QUIT $SELECT(ERROR:0,1:1)
+74 ;
+75 ;Modified following code to receive multiple ZMH segment for
+76 ;Military service information - DG*5.3*653
+77 IF 'ERROR
Begin DoDot:1
+78 DO NXTSEG^DGENUPL(MSGIEN,.CURLINE,.SEG)
+79 SET QFLG=0
FOR
Begin DoDot:2
+80 IF SEG("TYPE")'="ZMH"
SET QFLG=1
QUIT
+81 DO ZMH^DGENUPL2
DO NXTSEG^DGENUPL(MSGIEN,.CURLINE,.SEG)
End DoDot:2
IF QFLG
QUIT
+82 IF SEG("TYPE")="ZRD"
DO ZRD^DGENUPL2
QUIT
+83 DO ADDERROR^DGENUPL(MSGID,$GET(DGPAT("SSN")),SEG_" SEGMENT MISSING OR OUT OF ORDER",.ERRCOUNT)
+84 SET ERROR=1
+85 ;possible that in a bad message we are now past the end
+86 SET CURLINE=CURLINE-1
End DoDot:1
IF ERROR
QUIT $SELECT(ERROR:0,1:1)
+87 ;
+88 IF 'ERROR
FOR COUNT=2:1
DO NXTSEG^DGENUPL(MSGIEN,CURLINE,.SEG)
IF (SEG("TYPE")'="ZRD")
QUIT
Begin DoDot:1
+89 SET CURLINE=CURLINE+1
+90 DO ZRD^DGENUPL2
End DoDot:1
IF ERROR
QUIT
+91 ;
+92 IF 'ERROR
FOR
Begin DoDot:1
+93 ;possible if OBX segment not present that we are now past the end
+94 IF SEG("TYPE")'="OBX"
SET CURLINE=CURLINE-1
QUIT
+95 DO OBX^DGENUPL2
+96 SET CURLINE=CURLINE+1
+97 DO NXTSEG^DGENUPL(MSGIEN,CURLINE,.SEG)
End DoDot:1
IF (ERROR!(SEG("TYPE")'="OBX"))
QUIT
+98 ;
+99 QUIT $SELECT(ERROR:0,1:1)
+100 ;
CONVERT(VAL,DATATYPE,ERROR) ;
+1 ;Description: Converts the value found in the HL7 segment to DHCP format
+2 ;
+3 ;Input:
+4 ; VAL - value parsed from the HL7 segment
+5 ; DATATYPE: indicates the type of conversion necessary
+6 ; "DATE" - needs to be converted to FM format
+7 ; "TS" - time stamp, needs to be converted to FM format
+8 ; "Y/N" - 0->"N",1->"Y"
+9 ; "1/0" - "Y"->1,"N"->0
+10 ; "INSTITUTION" - needs to convert the station number with suffix to a point to the INSTITUTION file
+11 ; "ELIGIBILITY" - VAL is a pointer to the national eligibility code file (#8.1), needs to be converted to a local eligibility code (file #8)
+12 ;
+13 ; "MT" - VAL is a Means Test Status code, it needs to be converted
+14 ; to a pointer to the Means Test Status file
+15 ; Phase II convert code to RSN IEN for DGCDIS object
+16 ; "CDRSN" data type converts the codes diagnosis,procedure,condition to RSN IEN. (HL7TORSN^DGENA5)
+17 ; "EXT" convert from code to abbreviation
+18 ; "POS" convert from Period of Service code to a point to Period of Service file
+19 ; "AGENCY" convert Agency/Allied Country code from file 35
+20 ;OUTPUT:
+21 ; Function Value - the result of the conversion
+22 ; ERROR - set to 1 if an error is detected, 0 otherwise (optional,pass by ref)
+23 ;
+24 SET ERROR=0
+25 Begin DoDot:1
+26 IF VAL=""
QUIT
+27 IF VAL=""""""
SET VAL="@"
QUIT
+28 IF $GET(DATATYPE)="EXT"
Begin DoDot:2
+29 SET VAL=$$HLTOLIMB^DGENA5(VAL)
End DoDot:2
QUIT
+30 IF $GET(DATATYPE)="CDRSN"
Begin DoDot:2
+31 SET VAL=$$HL7TORSN^DGENA5(VAL)
End DoDot:2
QUIT
+32 IF ($GET(DATATYPE)="MT")
Begin DoDot:2
+33 SET VAL=$ORDER(^DG(408.32,"AC",1,VAL,0))
+34 IF 'VAL
SET ERROR=1
End DoDot:2
QUIT
+35 IF ($GET(DATATYPE)="DATE")
Begin DoDot:2
+36 IF $LENGTH(VAL)'=8
SET ERROR=1
QUIT
+37 SET VAL=$$FMDATE^HLFNC(VAL)
+38 IF ((VAL'=+VAL)!($LENGTH($PIECE(VAL,"."))<7))
SET ERROR=1
End DoDot:2
QUIT
+39 IF ($GET(DATATYPE)="TS")
Begin DoDot:2
+40 IF $LENGTH(VAL)<8
SET ERROR=1
QUIT
+41 SET VAL=$$FMDATE^HLFNC(VAL)
+42 IF ((VAL'=+VAL)!($LENGTH($PIECE(VAL,"."))<7))
SET ERROR=1
End DoDot:2
QUIT
+43 IF ($GET(DATATYPE)="Y/N")
Begin DoDot:2
+44 IF VAL=0
SET VAL="N"
QUIT
+45 IF VAL=1
SET VAL="Y"
QUIT
+46 SET ERROR=1
End DoDot:2
QUIT
+47 IF ($GET(DATATYPE)="1/0")
Begin DoDot:2
+48 IF VAL="N"
SET VAL=0
QUIT
+49 IF VAL="Y"
SET VAL=1
QUIT
+50 SET ERROR=1
End DoDot:2
QUIT
+51 IF ($GET(DATATYPE)="ELIGIBILITY")
Begin DoDot:2
+52 SET VAL=$$MAP(VAL)
+53 IF 'VAL
SET ERROR=1
End DoDot:2
QUIT
+54 IF ($GET(DATATYPE)="INSTITUTION")
Begin DoDot:2
+55 NEW OLDVAL
+56 SET OLDVAL=VAL
+57 SET VAL=$ORDER(^DIC(4,"D",OLDVAL,0))
+58 IF 'VAL
SET VAL=$ORDER(^DIC(4,"D",(+OLDVAL),0))
+59 IF 'VAL
SET ERROR=1
End DoDot:2
QUIT
+60 IF ($GET(DATATYPE)="POS")
Begin DoDot:2
+61 NEW OLDVAL
+62 SET OLDVAL=VAL
+63 SET VAL=$ORDER(^DIC(21,"D",OLDVAL,0))
+64 IF 'VAL
SET ERROR=1
End DoDot:2
QUIT
+65 IF ($GET(DATATYPE)="AGENCY")
Begin DoDot:2
+66 NEW OLDVAL
+67 SET OLDVAL=VAL
+68 SET VAL=$ORDER(^DIC(35,"C",OLDVAL,0))
+69 IF 'VAL
SET ERROR=1
End DoDot:2
QUIT
End DoDot:1
+70 QUIT VAL
+71 ;
MAP(VALUE) ;
+1 ;Description: Tries to map an eligibility code from file #8.1 (the national MAS ELIGIBILITY CODE file) to file #8 (the local ELIGIBILITY CODE file)
+2 ;
+3 ;Input: VALUE - ien of an entry in file #8.1
+4 ;
+5 ;Output: Function value - NULL if mapping is not found, otherwise returns an ien of entry in file #8
+6 ;
+7 NEW ECODE,NODE,COUNT,NAME
+8 ;try to choose a code from file 8 to use that is appropriate
+9 SET (COUNT,ECODE)=0
+10 ;
+11 FOR
SET ECODE=$ORDER(^DIC(8,"D",VALUE,ECODE))
IF 'ECODE
QUIT
Begin DoDot:1
+12 SET NODE=$GET(^DIC(8,ECODE,0))
+13 ;put code on list if active
+14 IF (NODE'="")
IF '$PIECE(NODE,"^",7)
SET ECODE(ECODE)=$PIECE(NODE,"^")
SET COUNT=COUNT+1
End DoDot:1
+15 ;
+16 ;only one match found, so use it
+17 IF COUNT=1
QUIT $ORDER(ECODE(0))
+18 ;
+19 ;no match found
+20 IF 'COUNT
QUIT ""
+21 ;
+22 ;multiple matches found, try to match by name
+23 IF COUNT>1
Begin DoDot:1
+24 SET ECODE=0
+25 SET NAME=$PIECE($GET(^DIC(8.1,VALUE,0)),"^")
+26 FOR
SET ECODE=$ORDER(ECODE(ECODE))
IF 'ECODE
QUIT
IF ECODE(ECODE)=NAME
QUIT
End DoDot:1
+27 QUIT ECODE
+28 ;
ACCEPT(MSGID) ;
+1 ;Description: Writes an ack (AA) to a global to be transmitted later.
+2 ;
+3 ;Inputs:
+4 ; MSGID -message control id of HL7 msg in the MSH segment
+5 ;
+6 ;Outputs: none
+7 ;
+8 KILL HL,HLMID,HLMTIEN,HLDT,HLDT1
+9 DO INIT^HLFNC2(HLEID,.HL)
+10 DO CREATE^HLTF(.HLMID,.HLMTIEN,.HLDT,.HLDT1)
+11 SET HLEVN=1
+12 SET MID=HLMID_"-"_HLEVN
+13 DO MSH^HLFNC2(.HL,MID,.HLRES)
+14 SET ^TMP("HLS",$JOB,1)=HLRES
+15 ;
+16 ;it seems HLFS sometimes disappears upon reaching this point
+17 IF $GET(HLFS)=""
SET HLFS="^"
+18 ;
+19 SET ^TMP("HLS",$JOB,2)="MSA"_HLFS_"AA"_HLFS_MSGID
+20 QUIT
+21 ;
MVERRORS ;
+1 ;Error messages were being deleted from ^TMP("HLS",$J by another package
+2 ;during the upload. To fix this, errors are written to another
+3 ;subscript, then moved when the error list is complete.
+4 ;
+5 MERGE ^TMP("HLS",$JOB)=^TMP("IVM","HLS",$JOB)
+6 KILL ^TMP("IVM","HLS",$JOB)
+7 QUIT