Home   Package List   Routine Alphabetical List   Global Alphabetical List   FileMan Files List   FileMan Sub-Files List   Package Component Lists   Package-Namespace Mapping  
Routine: INHUSEN5

INHUSEN5.m

Go to the documentation of this file.
  1. INHUSEN5 ; DGH ; 27 Jul 1999 11:06:07; MEDE/NCPDP processing functions
  1. ;;3.01;BHL IHS Interfaces with GIS;;JUL 01, 2001
  1. ;COPYRIGHT 1991-2000 SAIC
  1. ;CHCS TOOLS_460; GEN 5; 21-MAY-1997
  1. ;COPYRIGHT 1994 SAIC
  1. ;
  1. ;This contains the MEDE implementation of NCPDP validation software.
  1. ;
  1. Q
  1. INNC(ING,INSEQ,INXDST,INERR) ;Primary entry point for MEDE/NCPDP messages.
  1. ;Called from IN^INHUSEN
  1. ;INPUT:
  1. ; ING (req) = message array
  1. ; INSEQ (PBR) = variable in which to return MEDE sequence number
  1. ; INXDST = EXecutable code to identify the destination of messages.
  1. ; INERR (PBR) = variable to return error array if message is in error
  1. ; INDSTR = state variable, destination ien of transceiver
  1. ;RETURNS
  1. ; 0 = no errors--transceier will QKILL and set message to "complete"
  1. ; 1 = PDTS error--transceiver should resend message
  1. ; 2 = communication error--transceiver should reroute message
  1. ; 3 = error in outgoing MEDE ENP header--QKILL and log error
  1. ; 4 = ENP error (incoming)--log error but take no other action.
  1. ; 5 = Error in incoming such as no sequence # x-ref
  1. ; 6 = Dummy message is ok
  1. ; 7 = Dummy message is not ok
  1. N INMEDE,INVL,PARUIF,INMSG,MESS
  1. ;Verify MEDE ENP header--get sequence number & type. Quit if error
  1. S INVL=$$VERIF(ING,.INMEDE,.INTYP,.INSEQ,.INERR) Q:INVL INVL
  1. ;
  1. ;--Determine the GIS destination from MEDE transaction type
  1. D Q:INVL INVL
  1. .;Tranceiver must pass Dest. Deter. routine, INXDST, execute it.
  1. .X INXDST
  1. .;Dest Det. code must return INDSTP
  1. .I '$G(INDSTP) S INVL=3,MSG="Message "_INSEQ_" has no destination" M MSG=@ING D ERRADD^INHUSEN3(.INERR,.MSG) Q
  1. .;pointer needed for most functions, NAME needed for NEW^INHD.
  1. .S:'$D(INDST) INDST=$P(^INRHD(INDSTP,0),U)
  1. ;
  1. ;Identify parent (original outgoing message) for this response.
  1. S PARUIF=$O(^INTHU("ASEQ",INDSTR,INSEQ,""))
  1. I 'PARUIF S MSG="Message "_INSEQ_" has no ASEQ cross reference",INVL=5 D ERRADD^INHUSEN3(.INERR,.MSG)
  1. ;
  1. ;Set variables needed for STORE and store the message
  1. S (ORIGID,MESSID)=INSEQ,INMSH=INMEDE
  1. D STORE^INHUSEN4
  1. I INMSG>0,PARUIF D
  1. .;Update parent pointer in incoming message.
  1. .S:$D(^INTHU(INMSG)) $P(^INTHU(INMSG,0),U,7)=PARUIF
  1. .;Update "application ack" pointer in parent message
  1. .S $P(^INTHU(PARUIF,0),U,6)=INMSG
  1. .S MESS(1)="Response received"
  1. .D ULOG^INHU(PARUIF,"A",.MESS)
  1. Q $S(INVL:INVL,1:0)
  1. ;
  1. VERIF(INGBL,INMEDE,INTYP,INSEQ,INERR) ;Check for error status and extract MEDE data
  1. ;INPUT
  1. ;--INGBL = global being checked, can be ^INTHU
  1. ;--------If numeric, assumed to be IEN for ^INTHU
  1. ;--------If non-numeric, assumed to be global reference
  1. ;--INMEDE = variable for MEDE segment (Pass by reference)
  1. ;--INTYP = Message type in format (PBR)
  1. ;--INSEQ = sequence number (PBR)
  1. ;--INERR = error message array (PBR)
  1. ;RETURN
  1. ;-error codes 0-4 as desribed in INNC tag
  1. N LCT,MSG,ERR,INDMISID,INSITE,INSE,INNCP,INNC3
  1. ;--First segment is MEDE header.
  1. I +INGBL S LCT=0 D GETLINE^INHOU(INGBL,.LCT,.INMEDE)
  1. I 'INGBL S INMEDE=$G(@INGBL@(1))
  1. ;--Get type = "CR", "HB" or "ER" and sequence number
  1. S INTYP=$E(INMEDE,3,4),INSEQ=$E(INMEDE,5,12),INSITE=$E(INMEDE,17,20)
  1. ;If either of these are missing, this is a fatal ENP error
  1. I ",CR,DR,HR,ER,SE,"'[(","_INTYP_",") S MSG="Message from receiver "_$P(^INTHPC(INBPN,0),U)_" does not have a valid type" M MSG=@INGBL D ERRADD^INHUSEN3(.INERR,.MSG) Q 4
  1. ;If sequence number = DUMMYTRX, this is a response to a dummy/heartbeat
  1. I INSEQ="DUMMYTRX" D Q INVL
  1. .;INTYP="DR" means the dummy was good. Otherwise build error array
  1. .I INTYP="DR" S INVL=6 Q
  1. .S MSG="Error in 'dummy' message from receiver "_$P(^INTHPC(INBPN,0),U)
  1. .M MSG=@INGBL D ERRADD^INHUSEN3(.INERR,.MSG) S INVL=7
  1. ;INSEQ must be numeric except for DUMMYTRX.
  1. I INSEQ'?.N S MSG="Sequence number contains non-numberic characters" M MSG=@INGBL D ERRADD^INHUSEN3(.INERR,.MSG) Q 4
  1. S INSEQ=+INSEQ
  1. I 'INSEQ S MSG="Message does not have a valid sequence number" M MSG=@INGBL D ERRADD^INHUSEN3(.INERR,.MSG) Q 4
  1. ;INTYP="ER" is reserved for ENP header problem. Log and quit.
  1. I INTYP="ER" D Q 3
  1. .S MSG="ENP header error in message with sequence number "_INSEQ M MSG=@INGBL
  1. .D ERRADD^INHUSEN3(.INERR,.MSG)
  1. ;--Check destination=DMIS ID from MEDICAL TREATMENT FACILITY file
  1. ;Following code is CHCS specific. Will require equivalent IHS function
  1. ;S OUT=1 I $$SC^INHUTIL1 D Q:OUT 4
  1. ;.S INDMISID=$$DMISID^DAHPNU
  1. ;.I INDMISID'=INSITE S MSG="Message destination of "_INSITE_" does not match "_INDMISID M MSG=@INGBL D ERRADD^INHUSEN3(.INERR,.MSG) S OUT=1
  1. ;If INTYP="CR", message contains a valid response, no need to continue
  1. Q:INTYP="CR" 0
  1. ;If INTYP="SE", a switch/communication error has occured.
  1. I INTYP="SE" D Q INVL
  1. . ;Switch error will start immediately in second segment.
  1. . I INGBL D GETLINE^INHOU(INGBL,.LCT,.INNCP)
  1. . I 'INGBL S INNCP=$G(@INGBL@(2))
  1. . ;Trim leading and trailing blanks
  1. . S INSE=$$LBTB^UTIL(INNCP)
  1. . I '$L(INSE) S MSG="Error field of message "_$G(INSEQ)_" is blank" M MSG=@INGBL D ERRADD^INHUSEN3(.INERR,.MSG) S INVL=2 Q
  1. . ;convert to upper case and match known error messages
  1. . S INSE=$$CASECONV^UTIL(INSE,"U"),INVL=0
  1. . F I=1:1 S ERR=$T(ERRORS+I) Q:ERR'[";;"!INVL I INSE[$P(ERR,";;",2) S INVL=$P(ERR,";;",3) M MSG=@INGBL D ERRADD^INHUSEN3(.INERR,.MSG)
  1. . ;If no match on error message, default to INVL=4
  1. . Q:INVL
  1. . S INVL=4,MSG="Message contains no known error code" M MSG=@INGBL
  1. . D ERRADD^INHUSEN3(.INERR,.MSG)
  1. ;-If heartbeat, it is unexpected. Log it.
  1. D ERRADD^INHUSEN3(.INERR,"Heart beat received "_INMEDE) S INVL=4
  1. Q INVL
  1. ;
  1. ERRORS ;Tags containing all known MEDE error messages
  1. ;;TSHARED UNAVAILABLE;;2;;
  1. ;;SWITCH UNAVAILABLE;;2;;MEDE may use this instead of TSHARED
  1. ;;TSHARED NOT RESPONDING;;1;;
  1. ;;PDTS NOT RESPONDING;;1;;
  1. ;;PDTS UNAVAILABLE;;2;;May indicate need to switch processor?
  1. ;;WRONG VERSION;;3;;
  1. ;;INVALID ENP TYPE;;3;;
  1. ;;NON ALPHANUMERIC;;3;;
  1. ;;INCORRECT VALUE IN SOURCE;;3;;
  1. ;;DATA LENGTH;;3;;
  1. ;;MISSING ENP;;3;;
  1. ;