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

PRCVRE1.m

Go to the documentation of this file.
  1. PRCVRE1 ;WOIFO/VC-Transmit HL7 message to IFCAP for requisition received from DynaMed ; 11/3/04 3:13pm ; 5/6/05 3:43pm
  1. ;;5.1;IFCAP;**81,119**;Oct 20, 2000;Build 8
  1. ;Per VHA Directive 2004-038, this routine should not be modified
  1. ;
  1. ;An exemption from the 245 character length standard for a variable
  1. ; has been requested from the SACC for reading HL7 segments into
  1. ; a single variable. The limit is request to be 1K and if longer
  1. ; than that the system will exit with an Application ACK reject.
  1. ; Submitted 4/14/05.
  1. ;
  1. ;This routine processes messages from DynaMed to IFCAP to build a RIL
  1. ;
  1. ;HL("MID") - Message Control ID
  1. ;HL7DT - Today's date in HL7 format
  1. ;PRCDT - Date value
  1. ;ORC Segment will repeat for each item
  1. ; PRCORD - Order control should be NW for new order - ORC-1
  1. ; PRCFCP - Fund control Point - ORC-3
  1. ; PRCDATE - Date and time item entered - ORC-9
  1. ; PRCEMP - Enter by - ORC-10 DUZ^Lname^Fname^Approving Authority
  1. ; PRCCC - Cost Center - ORC-17
  1. ; PRCSITE - Site Code should be 516 - ORC-21
  1. ;RQD Segment will repeat for each item
  1. ; PRCCTR - Item counter - RQD-1
  1. ; PRCDOC - DynaMed Document number - unique per item - RQD-2
  1. ; PRCITM - Item number $p1 of RQD-3
  1. ; PRCQTY - Item quantity - RQD-5
  1. ; PRCNEED - Date Needed - RQD-10
  1. ;RQ1 Segment one segment for each RQD segment
  1. ; PRCCOST - Estimated Unit Cost - RQ1-1
  1. ; PRCBOC - BOC Number - RQ1-3
  1. ; PRCVND - Vendor number - pointer to file 440 - RQ1-4
  1. ; PRCNIF - National Item File number - RQ1-5
  1. ;PRCTYP - Repetitive Item List type - default to blank
  1. ;Message builds an ^XTMP to pass data to IFCAP RIL build routine.
  1. ; The first node is "PRCVRE*"+the Message Control ID. The next nodes
  1. ; are 0,1, and 2. The 0 node is the standard ^XTMP structure plus
  1. ; $H. The $H is used to measure transmission timing. The 1 node holds
  1. ; header data common to all detail items being transmitted. The 2
  1. ; node holds detail information about each item ordered in a counter
  1. ; sub-node.
  1. ; Under the 1 and 2 nodes are "ERR" subnodes that hold error
  1. ; information about each item. There can be multiple errors
  1. ; associated with each item, therefore there are multiple sub-nodes
  1. ; possible under each "ERR" node.
  1. ;Counters
  1. ; PRCCNT, ACKCNT,PRCCC1,PRCFCP1,X,X1,X2,X8,X9,I,II,LL,ERRCNT
  1. ;ERRCOD - Error code from IFCAP
  1. ;ERRDAT - Error data from IFCAP
  1. ;ERRSTR - Error text from IFCAP
  1. ;ERRSUB - A substring of ERRSTR
  1. ;ERRS - Error substring from IFCAP
  1. ;SEVER - Error severity value - W or E
  1. ;TOT,TOTERR,TOTGOOD,TOTREC - Counters of errors returned to DM
  1. ;FLDNO - Field identified in an error message
  1. ;ERRVAL - ERROR FLAG
  1. ;ERRARY - Message Error array sent to Prosthetics
  1. ;ERRLOC - Location of error sent in ACK
  1. ;PRCCS, PRCFS, PRCRS - Field delimiters
  1. ;PRCNODE - Message segment identifier
  1. ;Temporary Globals
  1. ; ^TMP("PRCVRIL",$J,"ACK") - Acknowledgement is ok
  1. ; ^TMP("PRCVRIL",$J,"NAK") - Acknowledgement is not ok
  1. ; ^TMP("HLA",$J) - Message array sent to DynaMed
  1. ; ^XTMP("PRCVRE*"_Message Control ID,) - Data sent to IFCAP
  1. ;Temporary variables
  1. ; TMP,MSGFLG,X, X1
  1. ;PRCHD - Array to hold map between HL7 and XTMP for Header info
  1. ;PRCDET - Array to hold map between HL7 and XTMP for Detail info
  1. ;PRCVERR - Array to hold error messages for MailMan
  1. ;PRCSUB - XTMP first node
  1. ;PRCSUB2 - Second $p of PRCSUB equal to Message Control ID
  1. ;PRCVRES - Return variable from GENACK - Note:this doesn't work.
  1. ;PRCVINDX - Index number into XTMP to keep track of number of items
  1. ;
  1. Q
  1. ;
  1. BEGIN N PRCORD,DYNADATE,PRCDATE,PRCEMP,PRCSITE
  1. N PRCDOC,PRCITM,PRCQTY,PRCFCP,PRCCC
  1. N PRCCOST,PRCVND,PRCBOC,PRCNEED,PRCNIF
  1. N PRCSUB,PRCSUB2,PRCDT,PRCVINDX
  1. N ERRARY,PRCCS,PRCFS,PRCRS,PRCNODE,PRCNODE2
  1. N ACKCNT,NODE1,NODE2,PRCCTR,PRCCNT,PRCI,PRCJ,MID
  1. N X,X1,X2,X8,X9,XX,TMP,PRCCC1,PRCFCP1,LENVAL
  1. ; Fields used in PRCVREA are NEWed and KILLed here
  1. N MSG,MSGFLG,DOCID,ERRCNT,ERRCOD,ERRDAT,ERRS,ERRSTR,ERRSUB,FLDNO
  1. N I,IL,ERRTXT,I,II,III,J,SEVER,TOT,TOTERR,TOTGOOD,TOTREC
  1. N PRCDET,PRCHD,PRCVERR,MYRESULT,ERRLOC,PRCVRES
  1. D:'$D(U) DT^DICRW
  1. S PRCDT=$$NOW^XLFDT
  1. S HL7DT=$$FMTHL7^XLFDT(PRCDT),PRCDT=HL7DT
  1. S PRCSUB="PRCVRE*"_HL("MID") K ^XTMP(PRCSUB)
  1. D BUILD
  1. S PRCCNT=0
  1. S PRCFS=$G(HL("FS")),PRCCS=$E($G(HL("ECH"))),PRCRS=$E($G(HL("ECH")),2)
  1. D START
  1. D CLEANUP
  1. Q
  1. ;
  1. START ;This will read the incoming message from DynaMed and build ^TMP
  1. ;
  1. SETACK ; Set up information for the ACK or NAK
  1. ;
  1. K ^TMP("PRCVRIL",$J)
  1. S ^TMP("PRCVRIL",$J,"ACK",1)="MSA"_PRCFS_"AA"_PRCFS_HL("MID")
  1. S ^TMP("PRCVRIL",$J,"NAK",1)="MSA"_PRCFS_"AE"_PRCFS_HL("MID")
  1. S ^TMP("PRCVRIL",$J,"NAK",2)="ERR"_PRCFS
  1. S ACKCNT=2
  1. ;
  1. ;If this is not the right message quit
  1. ;
  1. I HL("MTN")'="OMN" D Q
  1. .S $P(^TMP("PRCVRIL",$J,"NAK",ACKCNT),PRCFS,2)="Wrong Message Type: "_HL("MTN")
  1. .D NAKIT^PRCVREA
  1. I HL("ETN")'="O07" D Q
  1. .S $P(^TMP("PRCVRIL",$J,"NAK",ACKCNT),PRCFS,2)="Wrong Event Type: "_HL("ETN")
  1. .D NAKIT^PRCVREA
  1. ;
  1. S ERRARY(1)="OK"
  1. ;
  1. ;Read the message and build the ^TMP global
  1. ;
  1. K ^TMP("PRCVRE",$J)
  1. S PRCI=""
  1. F PRCI=1:1 X HLNEXT Q:HLQUIT'>0 D
  1. .S ^TMP("PRCVRE",$J,PRCSUB,PRCI)=HLNODE,PRCJ=0
  1. .F S PRCJ=$O(HLNODE(PRCJ)) Q:'PRCJ S ^TMP("PRCVRE",$J,PRCSUB,PRCI,PRCJ)=HLNODE(PRCJ)
  1. .I $E(HLNODE,1,3)="ORC" D
  1. ..S PRCFCP=$P(HLNODE,PRCFS,4),PRCCC=$P(HLNODE,PRCFS,18)
  1. ..S TMP($J,PRCFCP,PRCCC)=""
  1. ;
  1. ;Validate that there is only one FCP and CC
  1. S PRCFCP="",PRCFCP1=""
  1. ; Prevent PRCCC1 undefined PRC*5.1*119
  1. S PRCCC1=""
  1. F X8=1:1 S PRCFCP=$O(TMP($J,PRCFCP)) Q:PRCFCP="" D
  1. .S PRCFCP1=X8
  1. .S PRCCC=""
  1. .F X9=1:1 S PRCCC=$O(TMP($J,PRCFCP,PRCCC)) Q:PRCCC="" D
  1. ..S PRCCC1=X9
  1. I (PRCFCP1>1)!(PRCCC1>1) D Q
  1. .S $P(^TMP("PRCVRIL",$J,"NAK",2),PRCFS,2)="Message contains multiple FCP's or CC's: "_HL("ETN") D NAKIT^PRCVREA
  1. ;
  1. PARSIT ;Read the ^TMP global and build the ^XTMP global to pass to IFCAP
  1. ;
  1. S PRCI=0,PRCJ=0,LENVAL="OK"
  1. F S PRCI=$O(^TMP("PRCVRE",$J,PRCSUB,PRCI)) Q:PRCI="" Q:LENVAL="NOTOK" D
  1. .S NODE1=$G(^TMP("PRCVRE",$J,PRCSUB,PRCI)) Q:NODE1=""
  1. .F PRCJ=1:1 D Q:$G(^TMP("PRCVRE",$J,PRCSUB,PRCI,PRCJ))=""
  1. ..S NODE2=$G(^TMP("PRCVRE",$J,PRCSUB,PRCI,PRCJ))
  1. ..I $L(NODE1)+$L(NODE2)>1024 S LENVAL="NOTOK" Q
  1. ..S NODE1=NODE1_NODE2
  1. .Q:LENVAL="NOTOK"
  1. .S PRCNODE=$E(NODE1,1,3)
  1. .;
  1. .; IF MSH segment ignore the record
  1. .;
  1. .I PRCNODE="MSH" Q
  1. .S PRCNODE2=$E(NODE1,5,$L(NODE1))
  1. .;
  1. .; If ORC segment process the record
  1. .;
  1. .I PRCNODE="ORC" D Q
  1. ..I $D(^XTMP(PRCSUB,1))'=0 Q
  1. ..S PRCORD=$P(PRCNODE2,PRCFS,1),DYNADATE=$P(PRCNODE2,PRCFS,9),PRCEMP=$P($P(PRCNODE2,PRCFS,10),PRCCS,1,3),PRCSITE=$P(PRCNODE2,PRCFS,21)
  1. ..S PRCFCP=$P(PRCNODE2,PRCFS,3),PRCCC=$P(PRCNODE2,PRCFS,17)
  1. ..S PRCDATE=$$HL7TFM^XLFDT(DYNADATE)
  1. ..S $P(^XTMP(PRCSUB,1),U,1)=0
  1. ..S $P(^XTMP(PRCSUB,1),U,4)=PRCORD,$P(^XTMP(PRCSUB,1),U,5)=PRCSITE
  1. ..S $P(^XTMP(PRCSUB,1),U,6)=PRCDATE,$P(^XTMP(PRCSUB,1),U,7)=PRCEMP
  1. .;
  1. .; If RQD segment process the record
  1. .;
  1. .I PRCNODE="RQD" D Q
  1. ..S PRCCTR=$P(PRCNODE2,PRCFS,1)
  1. ..S PRCDOC=$P(PRCNODE2,PRCFS,2),PRCITM=$P(PRCNODE2,PRCFS,3)
  1. ..S PRCQTY=$P(PRCNODE2,PRCFS,5),DYNADATE=$P(PRCNODE2,PRCFS,10)
  1. ..S PRCNEED=$$HL7TFM^XLFDT(DYNADATE)
  1. .;
  1. .;If RQ1 segment process the record and build the XTMP global record
  1. .;
  1. .I PRCNODE="RQ1" D Q
  1. ..S PRCCOST=$P(PRCNODE2,PRCFS,1),PRCBOC=$P(PRCNODE2,PRCFS,3),PRCVND=$P(PRCNODE2,PRCFS,4),PRCNIF=$P(PRCNODE2,PRCFS,5)
  1. ..;
  1. ..; Now build the XTMP record
  1. ..;
  1. ..S PRCVINDX=$P($G(^XTMP(PRCSUB,1)),U,1)
  1. ..I PRCCTR>PRCVINDX S $P(^XTMP(PRCSUB,1),U,1)=PRCCTR
  1. ..S $P(^XTMP(PRCSUB,1),U,2)=PRCFCP
  1. ..S $P(^XTMP(PRCSUB,1),U,3)=PRCCC
  1. ..S ^XTMP(PRCSUB,2,PRCCTR)=PRCITM_U_PRCQTY_U_PRCVND_U_PRCCOST_U_PRCNEED_U_PRCDOC_U_PRCNIF_U_PRCBOC
  1. ;
  1. I LENVAL="NOTOK" D Q
  1. .S $P(^TMP("PRCVRIL",$J,"NAK",2),PRCFS,2)="HL7 Segment length greater than 1K"
  1. .D NAKIT^PRCVREA
  1. .K ^XTMP(PRCSUB)
  1. D CALLIT^PRCVREA
  1. Q
  1. ;
  1. BUILD ;Build the ^XTMP global zero node record.
  1. ;
  1. S XX=$$HTFM^XLFDT($H,1)
  1. S X1=$$FMADD^XLFDT(XX,5)
  1. S ^XTMP(PRCSUB,0)=X1_U_XX_"^Transmit message to IFCAP to build the RIL"_U_$H
  1. Q
  1. ;
  1. CLEANUP ;This area will kill all temporary globals and variables
  1. ;
  1. K ^TMP("PRCVRE",$J),TMP($J)
  1. K ^TMP("HLA",$J)
  1. K ^TMP("PRCVRIL",$J)
  1. K PRCCTR,PRCCNT,PRCORD,DYNADATE,PRCDATE,PRCEMP,PRCSITE,PRCDOC
  1. K PRCITM,PRCQTY,PRCFCP,PRCCC,PRCNIF,PRCBOC
  1. K PRCCOST,PRCVND,PRCSUB,PRCSUB2,PRCDT,PRCNEED
  1. K PRCFS,PRCCS,PRCRS,PRCVINDX
  1. K ERRARY
  1. K PRCFS,PRCRS,PRCNODE,PRCNODE2,PRCI,PRCJ
  1. K ACKCNT,NODE1,NODE2,LENVAL
  1. K X,X1,X2,X8,X9,XX,TMP,PRCCC1,PRCFCP1
  1. ;Fields killed here are used in PRCVREA
  1. K MID,MSG,MSGFLG,MYRESULT,PRCDET,PRCHD,ERRLOC,ERRSUB
  1. K DOCID,ERRCNT,ERRCOD,ERRDAT,ERRS,ERRSTR,I,II,III,IL,J,ERRTXT,SEVER
  1. K TOT,TOTERR,TOTGOOD,TOTREC,FLDNO,PRCVERR,PRCVRES
  1. Q