IBCIUT3 ;DSI/ESG - TCP/IP UTILITIES FOR CLAIMSMANAGER INTERFACE ;4-JAN-2001 ;;2.0;INTEGRATED BILLING;**161,226**;21-MAR-94 ;;Per VHA Directive 10-93-142, this routine should not be modified. ; ; Can't call from the top Q ; READ(Z,PROBLEM,IBCISOCK) ; ClaimsManager read message/close port/unlock port utility ; ; A utility to read the ACK/NAK, read the ClaimsManager response, ; write the ACK, close the port, and unlock the port. ; ; Data will get returned in the Z array and if there's a problem ; of any kind, it will get returned in variable PROBLEM which is just ; a number. ; ; IBCISOCK is the current tcp/ip port number that is being passed in ; here so this port can be unlocked after reading is complete. ; NEW ACK,CH,CHAR,CNT,DATA,ERRLN,ERRTXT,INGTO,J,K,MAXSIZE,MINSTORE,NAK NEW POP,RESP,SEGMENT,SEGNUM,SEQ,SGT,SGTNUM,STOP,STORERR,SUB2,Z0 NEW $ESTACK,$ETRAP S $ETRAP="D ERRTRP^IBCIUT3" ; ib*226 TJH/EG ; ; Initialize variables ; INGTO - Ingenix ClaimsManager read time-out ; MINSTORE - minimum local symbol table size ; ACK/NAK - Ingenix ClaimsManager positive/negative acknowledgement ; STORERR - local storage error flag ; PROBLEM - parameter which stores the problem# ; S INGTO=300,MINSTORE=11000,ACK=$C(1,6,3),NAK=$C(15),STORERR=0,PROBLEM=0 KILL Z,^TMP($J,"CMRESP2") ; ; Read #1 ; Quit if we encounter a time-out, an ascii-3, or storage problems S RESP(1)="" F CNT=1:1:100 R CH#1:INGTO S RESP(1)=RESP(1)_CH Q:'$T Q:$A(CH)=3 Q:$S3 S STOP=1 Q .. S SEGMENT=$P(SGT,U,SGTNUM),SEGNUM=1,Z(SEGMENT,SEGNUM)="" .. I SEGMENT="RL" S SEQ=1,Z(SEGMENT,SEGNUM,SEQ)="" .. Q . ; another segment of the same type coming up. This is the segment repetition character. Just increment the segment number and keep the segment type the same. . I CHAR=$C(29) D Q .. S SEGNUM=SEGNUM+1,Z(SEGMENT,SEGNUM)="" .. I SEGMENT="RL" S SEQ=1,Z(SEGMENT,SEGNUM,SEQ)="" .. Q . ; If we're processing the route or the header segments, then just add the character and quit. No maxstring problems with these segments. . I SEGMENT'="RL" S Z(SEGMENT,SEGNUM)=Z(SEGMENT,SEGNUM)_CHAR Q . ; At this point, we're processing a Result Line segment. . ; Here is the field delimiter character. Increment the SEQuence id# and initialize the array entry and quit. . I CHAR=$C(30) S SEQ=SEQ+1,Z(SEGMENT,SEGNUM,SEQ)="" Q . ; If the sequence number is 1-3, then we don't have a problem with maxstring errors so go ahead and add the character and quit. . I SEQ<4 S Z(SEGMENT,SEGNUM,SEQ)=Z(SEGMENT,SEGNUM,SEQ)_CHAR Q . ; Now we know we're processing the 2000 character EditDescription field in the Result Line segment. If we're OK length-wise or the character isn't a space or a hyphen or a comma, then just add it like normal and quit. . I $L(Z(SEGMENT,SEGNUM,SEQ))= to the max size & the character is a space/hyphen/comma so it's a perfect time to split the text onto a new node. Add this character to the current string, increment the SEQ by .01 and init and quit. . S Z(SEGMENT,SEGNUM,SEQ)=Z(SEGMENT,SEGNUM,SEQ)_CHAR,SEQ=SEQ+.01,Z(SEGMENT,SEGNUM,SEQ)="" Q . Q ; ; Do some more processing to the Result Line segment data and ; clean it up a bit. ; S SEGMENT="RL",SEGNUM="" F S SEGNUM=$O(Z(SEGMENT,SEGNUM)) Q:SEGNUM="" D . S DATA=$G(Z(SEGMENT,SEGNUM,1)) . S Z(SEGMENT,SEGNUM,0)=$$TRIM($E(DATA,1,25))_U_$$TRIM($E(DATA,26,45))_U_$$TRIM($E(DATA,46,50))_U_$$TRIM($E(DATA,131))_U_$$TRIM($E(DATA,132,141))_U_$$TRIM(Z(SEGMENT,SEGNUM,2)) . S Z0=Z(SEGMENT,SEGNUM,0) . ; . ; now loop thru the SEQ #4 data (EditDescription) and build . ; the "E" area of the array. This replaces the 4* nodes so we . ; can kill this area as we go. . S SEQ=3 . F S SEQ=$O(Z(SEGMENT,SEGNUM,SEQ)) Q:$E(SEQ)'=4 D .. S ERRTXT=Z(SEGMENT,SEGNUM,SEQ) .. S ERRTXT=$TR(ERRTXT,$C(10)) .. KILL Z(SEGMENT,SEGNUM,SEQ) .. I $TR(ERRTXT," ")="" Q .. S (ERRLN,Z(SEGMENT,SEGNUM,"E",0))=$G(Z(SEGMENT,SEGNUM,"E",0))+1 .. S Z(SEGMENT,SEGNUM,"E",ERRLN)=ERRTXT .. Q . ; . ; Now append the AutoFix data if it exists . I $P(Z0,U,4)="Y",$P(Z0,U,6)'="" D AUTOFIX . Q ; READX ; KILL ^TMP($J,"CMRESP2") Q ; ; For speed reasons, code taken from TRIM^XLFSTR TRIM(X,SIDE,CHAR) ;Trim chars from left/right of string NEW LEFT,RIGHT I X="" Q X S SIDE=$G(SIDE,"LR"),CHAR=$G(CHAR," "),LEFT=1,RIGHT=$L(X) I X=CHAR Q "" I SIDE["R" F RIGHT=$L(X):-1:1 Q:$E(X,RIGHT)'=CHAR I SIDE["L" F LEFT=1:1:$L(X) Q:$E(X,LEFT)'=CHAR Q $E(X,LEFT,RIGHT) ; ; AUTOFIX ; Append the AutoFix data to the rest of the error message NEW AFMSG,AFT,AFW,AFV,AF,AFLN ; first two autofix lines here S (ERRLN,Z(SEGMENT,SEGNUM,"E",0))=$G(Z(SEGMENT,SEGNUM,"E",0))+1 S Z(SEGMENT,SEGNUM,"E",ERRLN)=" " ; blank line here S (ERRLN,Z(SEGMENT,SEGNUM,"E",0))=$G(Z(SEGMENT,SEGNUM,"E",0))+1 S Z(SEGMENT,SEGNUM,"E",ERRLN)="*** ClaimsManager AutoFix Indicated ***" ; construct the actual message S AFMSG="A possible fix for Line Item "_$P(Z0,U,1)_" is to " S AFT=$E($P(Z0,U,5),1,3),AFW=$E($P(Z0,U,5),4,99),AFV=$P(Z0,U,6) S AFMSG=AFMSG_$S(AFT="ADD":"add",AFT="DEL":"delete",AFT="CHG":"change",1:$P(Z0,U,5))_" the " S AFMSG=AFMSG_$S(AFW="PROC":"procedure code",AFW="MOD":"modifier",1:$P(Z0,U,5))_" " I AFT="CHG" S AFMSG=AFMSG_"to be "_AFV_" instead." E S AFMSG=AFMSG_AFV_"." ; ; call an IB utility to parse AFMSG into lines of acceptable length D FSTRNG(AFMSG,MAXSIZE,.AF) ; ; put the data into the Z array F AFLN=1:1:AF D . S (ERRLN,Z(SEGMENT,SEGNUM,"E",0))=$G(Z(SEGMENT,SEGNUM,"E",0))+1 . S Z(SEGMENT,SEGNUM,"E",ERRLN)=AF(AFLN) . Q AFX ; Q ; FSTRNG(STR,WD,ARRAY) ; please see IBJU1 for documentation NEW %,DIW,DIWI,DIWT,DIWTC,DIWX,DN,I,Z D FSTRNG^IBJU1(STR,WD,.ARRAY) Q ; ERRTRP ; Error trap processing ; ib*226 TJH/EG S Z(1,1)=$$EC^%ZOSV ; mumps error location and description S Z="A SYSTEM ERROR HAS BEEN DETECTED AT THE FOLLOWING LOCATION" S PROBLEM=7 D CLOSE^%ZISTCP ; close the tcp/ip port L -^IBCITCP(IBCISOCK) ; unlock the current port K ^TMP($J,"CMRESP2") ; kill scratch global D ^%ZTER ; record the error in the trap G UNWIND^%ZTER ; unwind stack levels ;