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

INHUTC51.m

Go to the documentation of this file.
  1. INHUTC51 ;KN,bar; 18 Jun 99 14:44; Interface Message/Error Search
  1. ;;3.01;BHL IHS Interfaces with GIS;;JUL 01, 2001
  1. ;COPYRIGHT 1991-2000 SAIC
  1. ;;COPYRIGHT 1997 SAIC
  1. ;
  1. ; Interface Message/Error Search Part II (INHUTC5)
  1. ; This sub-module contains functions FIND, MSGTEST, and ERRTEST.
  1. Q
  1. ;
  1. MSGTEST(INFND,INMIEN,INSRCH) ; Add matching message to array
  1. ;
  1. ; Description: Used to test a transaction in ^INTHU to
  1. ; values passed in INSRCH parameter.
  1. ; Parameters:
  1. ; INFND = Flag indicates status of the test (returned)
  1. ; 1 = match found
  1. ; 0 = no match
  1. ; INMIEN = IEN into ^INTHU
  1. ; INSRCH = The array contains search criteria
  1. ;
  1. N INMSG0,INMAXSZ,INFLAGZ
  1. S INFND=0,INMSG0=$G(^INTHU(INMIEN,0))
  1. ; Test single and multiple values of the Original Transaction type
  1. I $D(INSRCH("INORIG")) Q:$P(INMSG0,U,11)'=INSRCH("INORIG")
  1. I $D(INSRCH("MULTIORIG")) S INQ=0 D Q:'INQ
  1. .S X=0 F S X=$O(INSRCH("MULTIORIG",X)) Q:'X I $P(INMSG0,U,11)=X S INQ=1 Q
  1. ; Test single and multiple values of the Destination
  1. I $D(INSRCH("INDEST")) Q:$P(INMSG0,U,2)'=INSRCH("INDEST")
  1. I $D(INSRCH("MULTIDEST")) S INQ=0 D Q:'INQ
  1. .S X=0 F S X=$O(INSRCH("MULTIDEST",X)) Q:'X I $P(INMSG0,U,2)=X S INQ=1 Q
  1. ; Test single and multiple values of the Status
  1. I $D(INSRCH("INSTAT")) Q:$P(INMSG0,U,3)'=INSRCH("INSTAT")
  1. I $D(INSRCH("MULTISTAT")) S INQ=0 D Q:'INQ
  1. .S X="" F S X=$O(INSRCH("MULTISTAT",X)) Q:'$L(X) I $P(INMSG0,U,3)=X S INQ=1 Q
  1. ; Test single and multiple values of the Division
  1. I $D(INSRCH("INDIV")) Q:$P(INMSG0,U,21)'=INSRCH("INDIV")
  1. I $D(INSRCH("MULTIDIV")) S INQ=0 D Q:'INQ
  1. .S X=0 F S X=$O(INSRCH("MULTIDIV",X)) Q:'X I $P(INMSG0,U,21)=X S INQ=1 Q
  1. ; Test single value of the message ID, Source, User, Patient and Message Text
  1. I $D(INSRCH("INID")) Q:$P(INMSG0,U,5)'=INSRCH("INID")
  1. I $D(INSRCH("INDIR")) Q:$P(INMSG0,U,10)'=INSRCH("INDIR")
  1. I $D(INSRCH("INSOURCE")) Q:$E($P(INMSG0,U,8),1,$L(INSRCH("INSOURCE")))'=INSRCH("INSOURCE")
  1. I $D(INSRCH("INUSER")) Q:$P(INMSG0,U,15)'=INSRCH("INUSER")
  1. I $D(INSRCH("INPAT")) Q:'$$INMSPAT^INHMS1(INMIEN,INSRCH("INPAT"))
  1. I $D(INSRCH("INTEXT"))>9 Q:'$$INMSRCH^INHMS1(.INSRCH,INMIEN,INSRCH("INTYPE"))
  1. S INFND=1
  1. Q
  1. ;
  1. ERRTEST(INFND,INEIEN,INSRCH) ; Test for error matching criteria
  1. ;
  1. ; Description: The function ERRTEST is used to test the error record
  1. ; in ^INTHER (which pointed by INEIEN) for error to
  1. ; values passed in INSRCH parameter.
  1. ; Parameters:
  1. ; INFND = Flag indicates status of the test (returned)
  1. ; 1 = match found
  1. ; 0 = no match
  1. ; INEIEN = IEN into ^INTHER
  1. ; INSRCH = The array contains search criteria
  1. ;
  1. N INERR0,INMSG0,INMAXSZ,INMIEN
  1. S INFND=0,INERR0=$G(^INTHER(INEIEN,0))
  1. S INMIEN=$P(INERR0,U,4),INMSG0=$G(^INTHU(+INMIEN,0))
  1. Q:'INMIEN&$D(INSRCH("MESSAGEREQ"))
  1. ; Checking the Interface Error File
  1. ; Test single and multiple values of the Original Transaction type
  1. I $D(INSRCH("INORIG")) I $P(INERR0,U,2)'=INSRCH("INORIG"),($P(INMSG0,U,11)'=INSRCH("INORIG")) Q
  1. I $D(INSRCH("MULTIORIG")) S INQ=0 D Q:'INQ
  1. . S X=0 F S X=$O(INSRCH("MULTIORIG",X)) Q:'X I ($P(INERR0,U,2)=X)!($P(INMSG0,U,11)=X) S INQ=1 Q
  1. ; Test single and multiple values of the Destination
  1. I $D(INSRCH("INDEST")) I $P(INERR0,U,9)'=INSRCH("INDEST"),($P(INMSG0,U,2)'=INSRCH("INDEST")) Q
  1. I $D(INSRCH("MULTIDEST")) S INQ=0 D Q:'INQ
  1. . S X=0 F S X=$O(INSRCH("MULTIDEST",X)) Q:'X I ($P(INERR0,U,9)=X)!($P(INMSG0,U,2)=X) S INQ=1 Q
  1. ; Test single and multiple values of the Status
  1. I $D(INSRCH("INSTAT")) Q:$P(INMSG0,U,3)'=INSRCH("INSTAT")
  1. I $D(INSRCH("MULTISTAT")) S INQ=0 D Q:'INQ
  1. . S X="" F S X=$O(INSRCH("MULTISTAT",X)) Q:'$L(X) I ($P(INMSG0,U,3)=X) S INQ=1 Q
  1. ; Test single and multiple values of the Division
  1. I $D(INSRCH("INDIV")) Q:$P(INMSG0,U,21)'=INSRCH("INDIV")
  1. I $D(INSRCH("MULTIDIV")) S INQ=0 D Q:'INQ
  1. . S X=0 F S X=$O(INSRCH("MULTIDIV",X)) Q:'X I ($P(INMSG0,U,21)=X) S INQ=1 Q
  1. ; Test value of the Error Location, Error Resolution Status and Error Text to search
  1. I $D(INSRCH("INERLOC")) Q:$P(INERR0,U,5)'=INSRCH("INERLOC")
  1. I $D(INSRCH("INERSTAT")) Q:$P(INERR0,U,10)'=INSRCH("INERSTAT")
  1. I $D(INSRCH("INTEXT"))>9 Q:'$$INERSRCH^INHERR1(.INSRCH,INEIEN,INSRCH("INTYPE"))
  1. ; Checking the Interface Message file
  1. ; Test value of the Message Start Date and Message End Date
  1. I $D(INSRCH("INMSGSTART")) Q:($P(INMSG0,U)<INSRCH("INMSGSTART"))
  1. I $D(INSRCH("INMSGEND")) Q:($P(INMSG0,U)>INSRCH("INMSGEND"))
  1. ; Test value of the Message ID, Direction, User, Source and Patient
  1. I $D(INSRCH("INID")) Q:$P(INMSG0,U,5)'=INSRCH("INID")
  1. I $D(INSRCH("INDIR")) Q:$P(INMSG0,U,10)'=INSRCH("INDIR")
  1. I $D(INSRCH("INSOURCE")) Q:$E($P(INMSG0,U,8),1,$L(INSRCH("INSOURCE")))'=INSRCH("INSOURCE")
  1. I $D(INSRCH("INUSER")) Q:($P(INMSG0,U,15)'=INSRCH("INUSER"))&($P(INERR0,U,8)'=INSRCH("INUSER"))
  1. I $D(INSRCH("INPAT")) Q:'INMIEN Q:'$$INMSPAT^INHMS1(INMIEN,INSRCH("INPAT"))
  1. S INFND=1
  1. Q
  1. ;
  1. MSGSTD(INIEN) ; return the message standard for a given entry in the UIF
  1. ;
  1. ; INIEN = IEN into ^INTHU
  1. ;
  1. N INMSG0,INORIGTT,INREP,INSCR
  1. S INIEN=$G(INIEN) Q:'INIEN ""
  1. S INMSG0=$G(^INTHU(INIEN,0)) Q:'$L(INMSG0) ""
  1. ; if incoming message, the parent message field points to the
  1. ; outgoing message
  1. I $P(INMSG0,U,10)="I" D Q:'$L(INMSG0)!('INIEN) ""
  1. . S INIEN=$P(INMSG0,U,7) Q:'INIEN
  1. . S INMSG0=$G(^INTHU(INIEN,0))
  1. S INORIGTT=$P(INMSG0,U,11) Q:'INORIGTT ""
  1. S INSCR=$P($G(^INRHT(INORIGTT,0)),U,3) I 'INSCR D Q:'INSCR ""
  1. . ; Special processing for replicated messages, if no script pointer
  1. . S INREP=$O(^INRHR("B",INORIGTT,"")) Q:'INREP
  1. . S INORIGTT=$P($G(^INRHR(INREP,0)),U,2) Q:'INORIGTT
  1. . S INSCR=$P($G(^INRHT(INORIGTT,0)),U,3)
  1. Q $P($G(^INRHS(INSCR,0)),U,7)
  1. ;
  1. INNCPAT(INIEN,INPAT,INPATNA) ; Test msg. for a NCPDP patient match
  1. ;
  1. ; MODULE NAME: INNCPAT (Interface Message PATIENT Search for NCPDP msg)
  1. ; DESCRIPTION: Search ^INTHU( INIEN ) Pharm. claim message for matching
  1. ; values to the string: INPAT. Using CHCS patient IEN for
  1. ; outbound messages, and Pharmacy Prescription Number.
  1. ; RETURN = PASS/FAIL (1/0) and patient found set in INPATNAM
  1. ; PARAMETERS:
  1. ; INIEN = The IEN of the message in the ^INTHU message file
  1. ; INPAT = The patients internal IEN from the ^DPT file
  1. ; INPATNA = The patient name found in the message ("" if none)
  1. ;
  1. S INIEN=$G(INIEN),INPAT=+$G(INPAT),INPATNAM=$G(INPATNA)
  1. Q:'INIEN 0
  1. N INBLDCT,INBLDTXT,INRET,INRXNUM
  1. ; Pharmacy claim message is in line 3
  1. S INBLDTXT="",INBLDCT=2 D GETLINE^INHOU(INIEN,.INBLDCT,.INBLDTXT)
  1. Q:'$D(INBLDTXT) 0
  1. ; prescription number is the first field and is 7 bytes
  1. S INRXNUM=+$E(INBLDTXT,1,7),INRET=$$NCMATCH(INPAT,INRXNUM),INPATNAM=$P(INRET,U,2)
  1. Q INRET
  1. ;
  1. NCMATCH(INPAT,INRXNUM) ; For a given RX number find a patient match
  1. ;
  1. ; Input: INPAT (req) = IEN for the Patient
  1. ; INRXNUM (req) = Prescription number from the NCPDP message
  1. ; Output: 1_"^"_Patient IEN, if match found
  1. ; 0, otherwise
  1. ;
  1. N INC0,INCPT,INCOLLEC,INDPT
  1. S INPAT=$G(INPAT) Q:'INPAT 0
  1. S INCOLLEC=$O(^PSM(8216,"B",INRXNUM,0)) Q:'INCOLLEC 0
  1. S INC0=$G(^PSM(8216,INCOLLEC,0)) Q:'$L(INC0) 0
  1. S INCPT=$P(INC0,U,5) S:INCPT INDPT=$P($G(^DPT(INCPT,0)),U)
  1. Q:INPAT=INCPT 1_"^"_INDPT
  1. Q 0