/** * $Id: ehrclient.h 2 2009-10-31 02:48:23Z l0728348 $ * * Copyright 2009 * * @author Manuel Mausz (0728348) * @brief implements the main routines of the console application */ #ifndef EHRCLIENT_H #define EHRCLIENT_H #include #include #include #include #include #include "ehr.h" #include "security.h" /** * implements the main routines of the console application */ class EhrClient : virtual public Ice::Application { public: /** * @brief exception thrown by EhrClient */ class runtime_error : public std::runtime_error { public: /** * @brief Default exception ctor * @param what message to pass along */ runtime_error(const std::string& what) : std::runtime_error(what) {} }; /** * @brief main routine * gets called by Ice after internal setup * @param argc argc from main * @param argv argv from main */ virtual int run(int argc, char *argv[]); /** * @brief retrieves and returns documentlist from server * @return list of documents */ Ehr::DocumentList getDocumentList(); /** * @brief search for documents using parameters * @param hasFrom set true to consider from parameter * @param from value for from parameter * @param hasTill set true to consider till parameter * @param till value for till parameter * @param doctype document type to search for * @param docid document id to search for * @return list of documents * @throw Ehr::EhrException */ Ehr::DocumentList searchDocument(const bool hasFrom = false, const long from = 0, const bool hasTill = false, const long till = 0, const Ehr::DocumentType doctype = Ehr::DOCANY, const long docid = 0); /** * @brief overloaded method for searching for documents * @param from value for from parameter * @param till value for till parameter * @return list of documents * @throw Ehr::EhrException */ Ehr::DocumentList searchDocument(const long from, const long till) { return searchDocument(true, from, true, till); } /** * @brief overloaded method for searching for documents * @param doctype document type to search for * @return list of documents * @throw Ehr::EhrException */ Ehr::DocumentList searchDocument(const Ehr::DocumentType doctype) { return searchDocument(false, 0, false, 0, doctype); } /** * @brief overloaded method for searching for documents * @param docid document id to search for * @return list of documents * @throw Ehr::EhrException */ Ehr::DocumentList searchDocument(const long docid) { return searchDocument(false, 0, false, 0, Ehr::DOCANY, docid); } /** * @brief list all document on server on console output */ void listDocuments(); /** * @brief retrieves document with documentid, generates a pdf document * and stores it as output on disc * @param docid document id * @param output filename to store the pdf document * @throw EhrClient::runtime_error */ void saveDocument(const long docid, const std::string& output); /** * @brief get current time in milliseconds * @return current time in milliseconds */ long getTime(); /** * @brief generate date string * @param msecs time in milliseconds since 01.01.1900 00:00 * @return string containing the date. syntax: dd.mm.yyyy */ std::string getDate(long msecs); /** * @brief generate date string * @param date date in Ehr::Date format * @return string containing the date. syntax: dd.mm.yyyy */ std::string getDate(const Ehr::Date& date); /** * @brief convert ice request to bytestream * @param request ice request to convert * @return converted bytestream containing the request */ std::vector convertToByteStream(const Ice::ObjectPtr& request); /** * @brief split commonname (syntax user @ domain) of certificate * into user and domain * @param cert certificate which contains the commonname * @return pair of user and domain * @throw EhrClient::runtime_error */ std::pair splitCN(const std::string& cert); private: Ehr::ProviderPrx m_provider; Security *m_security; std::string m_ownercert; std::string m_requestorcert; }; #endif /* vim: set et sw=2 ts=2: */