/* * Copyright (c) 1995, 1996 Gunther Schadow. All rights reserved. * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation; either version 2 of the License, or * (at your option) any later version. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * * You should have received a copy of the GNU General Public License * along with this program; if not, write to the Free Software * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. */ #include "carevue.h" #include "cvgateway.h" #include "NMDmsg.h" #include "ACKmsg.h" #include #include #include /* Process NMD messages: If message goes to us, i.e. if RecApp == App * is true (App is my application tag) then return ACKmsg. Otherwise * simply forward the message to carevue. */ HL7Message *network_data(HL7Message &msg) { NMDmsg &request = (NMDmsg &)msg; if(request.MesHea.RecApp == App) { ACKmsg &ack = *new ACKmsg; // MSA segment ack.MesAck.Ack = AckCode::AppAcc; ack.MesAck.MesConTrolId = msg.MesHea.MesConTrolId; ack.MesAck.TextMes = "message accepted"; // ERR segment might contain warnings even for an acceptable message ack.Error = parseErrorSegment; // MSH segment ack.MesHea.SenApp = "HL7TEST"; ack.MesHea.RecApp = msg.MesHea.SenApp; ack.MesHea.RecFac = msg.MesHea.SenFac; stamp(ack.MesHea.DateTimeOfMes); strstream s; s.form("RES%05u",(u_int)getpid()); s << '\0'; ack.MesHea.MesConTrolId = s.str(); s.freeze(0); ack.MesHea.ProId = ProIdCode::Pro; ack.MesHea.VerId = VerIdCode::_2_2val; ack.commit(); return &ack; } else { // since NSCseg is the only allowed segment and since the // network status change type is not standardized, simply // unset any segment except -- of course -- MSHseg request.GRPgroup.unset(); return forward_message(request); } }