/* * 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. */ /* * This is a HL7 server application that acts as a gateway for the * HP CareVue 9000 Klinical Information system. CareVue comes with * a limited (and somehow brain-dead) HL7 interface, that requires * us to transform messages, add a (non-standard) segment, remove * other (standard) segments, decompose some messages, change field * contents etc. * * The ANYmsg server facility of ProtoGen/HL7 allows you to build a * HL7 server applications very easily. The ANYmsg server waits for * a connection to be made on a TCP port and reads the HL7 request * message. After the connection and the message has passed the access * control check the ANYmsg server calls a server function if one was * registered for the request message/event type. A server function * takes a request message as it's argument and returns a pointer to * a result message. * * There is a little problem with contravariance, when up-casting an * abstract message reference (`class Message &') to a reference to a * concrete message (`class XYZmsg &'). However, since the server * functions are only called by ANYmsg the problem becomes less severe. * ANYmsg assures that a server function gets called only on the message * type that it has beed registered for. Thus the assumption can be * made that the request message is of the right type. Care has to be * taken only that server functions are registered to the right message * type. */ #include "cvgateway.h" #include "ANYmsg.h" #include "logfile.h" #ifdef DEBUG # ifdef LOGLEVEL # undef LOGLEVEL # endif # define LOGLEVEL L_JUNK #else # ifndef LOGLEVEL # define LOGLEVEL L_MESG # endif #endif const char *fsi_service = NULL; // argv[1] const char *fsi_host = NULL; // argv[2] const char *App = "CVGATEWAY"; const char *Fac = NULL; // argv[3] // const char *RecApp = NULL; // filled by server functions ("ADT" or "CLI") const char *RecFac = NULL; // argv[3] /* The main function is very simple and is made up of merely argument * processing, and initialization of the ANYmsg server. If the logger * is not initialized it writes to a default file. */ int main(int argc, char *argv[]) { const char *service; bool exactMatch = FALSE; // read arguments if(argc == 6 && strcmp(argv[1],"-x") == 0) { exactMatch = TRUE; service = argv[2]; fsi_service = argv[3]; fsi_host = argv[4]; Fac = RecFac = argv[5]; } else if(argc == 5) { service = argv[1]; fsi_service = argv[2]; fsi_host = argv[3]; Fac = RecFac = argv[4]; } else { cerr << "usage: " << argv[0] << " [-x] service fsi_service fsi_host facility" << endl; exit(1); } // initialize logger and log a message log_init(argv[0], "/tmp/cvgateway.log", (char *)Fac); log_level(LOGLEVEL); LOGINFO("%s %s server startup", App, Fac); // initialize the ANYmsg server ANYmsg any; // register our services any.register_service(UniMesIdCode::ADT_A01val, admit_patient); any.register_service(UniMesIdCode::ADT_A02val, transfer_patient); any.register_service(UniMesIdCode::ADT_A03val, discharge_patient); any.register_service(UniMesIdCode::ADT_A08val, update_pat_info); any.register_service(UniMesIdCode::ADT_A11val, cancel_admit); any.register_service(UniMesIdCode::ADT_A12val, cancel_transfer); any.register_service(UniMesIdCode::ADT_A13val, cancel_discharge); any.register_service(UniMesIdCode::ADT_A17val, swap_patients); any.register_service(UniMesIdCode::ORUval, report_results); any.register_service(UniMesIdCode::NMDval, network_data); // and begin serving any.serve(service, App, Fac, exactMatch); // this point is not normally reached, since the server runs until // it is terminated by a signal. return 0; }