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

INHVAMR.m

Go to the documentation of this file.
  1. INHVAMR ;JSH; 27 May 94 09:34; VA gateway/MDIS Receiver
  1. ;;3.01;BHL IHS Interfaces with GIS;;JUL 01, 2001
  1. ;COPYRIGHT 1991-2000 SAIC
  1. ;
  1. RECEIVE ;Receiver
  1. ;INPUT:
  1. ; INBPN - background process ien
  1. ;
  1. S SYSTEM="VA" ;magic
  1. LOOP ;Restart at top of queue
  1. Q:'$D(^INRHB("RUN",INBPN)) S IN=0,^INRHB("RUN",INBPN)=$H
  1. LP1 ;Look for a message using the APS cross reference
  1. L -^INVAMI(IN) Q:'$D(^INRHB("RUN",INBPN)) S ^INRHB("RUN",INBPN)=$H
  1. S IN=$O(^INVAMI("APS",0,IN)) G:'IN WAIT
  1. ;Lock the entry
  1. L +^INVAMI(IN):0 E G LP1
  1. G:'$D(^INVAMI(IN,0)) LP1 G:$P(^INVAMI(IN,0),U,4) LP1
  1. S ING="INDATA" K INDATA
  1. S (%,%1)=0 F Q:%="" S %=$O(^INVAMI(IN,1,%)) Q:'% S %1=%1+1,INDATA(%1)=^(%,0) D:INDATA(%1)'[$C(13) I INDATA(%1)[$C(13) S INDATA(%1)=$TR(INDATA(%1),$C(13))
  1. . S %2=0 F S %=$O(^INVAMI(IN,1,%)) Q:'% S %2=%2+1,INDATA(%1,%2)=^(%,0) I INDATA(%1,%2)[$C(13) S INDATA(%1,%2)=$TR(INDATA(%1,%2),$C(13)) Q
  1. I '$D(INDATA(2)) D ENR^INHE(INBPN,"Message format error in MDIS message #"_IN) G MP
  1. I $E(INDATA(2),1,3)="MSA" S DEST="INCOMING ACK",ACK=0 G STORE
  1. ;Not currently accepting anything except ack messages
  1. D ENR^INHE(INBPN,"Invalid MDIS message type received entry #"_IN) G MP
  1. ;
  1. S X=$P(INDATA(2),U,1,2) I $E(X,1,3)'="EVN" D ENR^INHE(INBPN,"MDIS message entry #"_IN_" does not have the EVN segment in the correct location.") G MP
  1. NOCON S XX=^INVAMI(IN,0)
  1. ;,A=$P(XX,U,4),A=A+1,$P(^(0),U,4)=A
  1. ;I A>5 D ENR^INHE(INBPN,"Too many attempts for entry #"_IN) G MP
  1. S DEST=$P($T(@$P(X,U,2)),";",3),ACK=1
  1. I DEST="" D ENR^INHE(INBPN,"No known destination for event type "_$P(X,U,2)_" in MDIS message entry #"_IN) G MP
  1. ;
  1. STORE ;store in UIF
  1. S MESSID=$P(INDATA(1),U,10) I MESSID="" D ENR^INHE(INBPN,"MDIS message entry #"_IN_" does not have a message ID") G MP
  1. S MESSID="MDIS-"_MESSID
  1. ;Call the input driver
  1. S X=$$NEW^INHD(MESSID,DEST,"MDIS","INDATA",ACK,"I")
  1. ;If the input driver returns a -1 then the transaction was rejected
  1. I X<0 D ENR^INHE(INBPN,"MDIS message entry #"_IN_" was rejected by GIS") G MP
  1. ;
  1. DEL ;Delete entry
  1. S DIK="^INVAMI(",DA=IN D ^DIK
  1. ;unlock and return to loop
  1. L -^INVAMI(IN) G LP1
  1. ;
  1. MP ;Mark as processed
  1. S DIE="^INVAMI(",DA=IN,DR=".04///1" D ^DIE
  1. ;unlock and return to loop
  1. L -^INVAMI(IN) G LP1
  1. ;
  1. WAIT ;Wait for new messages to appear in the queue
  1. H 15 G LOOP
  1. ;
  1. ;
  1. DEST ;The following tags are used to determine destination
  1. ;