/***************************************************************************
 *   Copyright (C) 2009 by Docteur Pierre-Marie Desombre.   *
 *   pm.desombre@medsyn.fr  *
 *                                                                         *
 *   This program is free software; you can redistribute it and/or modify  *
 *   it under the terms of the GNU Library General Public License as       *
 *   published by the Free Software Foundation; either version 3 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 Library General Public     *
 *   License along with this program; if not, write to the                 *
 *   Free Software Foundation, Inc.,                                       *
 *   59 Temple Place - Suite 330, Boston, MA  02111-1307, USA.             *
 ***************************************************************************/

#ifndef RECETTEDIALOG_H
#define RECETTEDIALOG_H

#include <QtCore>
#include <QtGui>
#include <QtSql>

#include "ui_recettedialog.h"
#include "modifierrecette.h"
#include "../parametrages/parametrages.h"

class QDialog;
class modifierrecette;


class recettedialog : public QWidget, public Ui::RecetteDialog
{
Q_OBJECT
public:
  recettedialog();
  ~recettedialog();
  //QSqlDatabase m_db1;
  QSqlDatabase m_accountancyDb;
  QSqlQueryModel *m_model;
  QSqlTableModel *m_tableModel;
  QSortFilterProxyModel *m_proxymodel;
  QStringList m_usernames;
  QStringList m_textes;
  QStringList m_listelogin;
  QStringList m_reglesListe;
  QStringList m_pourcentsListe;

  double m_sommeentree;
  double m_facteurpourcent;//facteur du pourcentage du
  int    m_nbredos;
  int    m_idusr;
  int    m_id;
  int    m_ida;
  int    m_iplusmoins;//fonctionplus et fonctionmoins
  int    m_tempsFermeture;
  QString m_ouinon;//choix de l'ouverture du widget dans comptabilite.ini, par exemple choixouvert=non
  QString m_texte;
  QString m_entreelibre;
  QString m_str;
  QString m_nomprenom;
  QString m_dateOfBirth;
  QString m_guid;
  QString m_date;
  QString m_acteCcam;
  QString m_acteautre;
  //QString m_guid;
  QString m_loginpref;
  QString m_login;
  QString m_praticien;
  QString m_executedquery;
  QString enregistrement(QSqlQuery &);
  QStringList m_listAdress;
  QString m_dataLibreOne;
  QString m_dataLibreTwo;
  QMenu  *m_menu;
  QAction *m_remontrerActeCourant;
protected :
  double eachActRegistering(QString & /*act*/);
  void message_libre();
  void mousePressEvent(QMouseEvent *);
  QString     adapteCheminWindows(QString & );
  void newTextOnButtons(QString &);
  QList<double> variousSums(QString & /*strActs*/);
  void controlOfQueries(QString & /*executedQueryResult*/);
  QString priceValueOfCcamAct(QString & /*ccamAct*/);
  QString correctNameOfAct(QString & /*Act*/);
  QString correctValueOfAct(QString & /*value*/);
  QString findIdPayeur();
  QString findIdSite();
  QStringList findPatientNameGuidForIndependantProgram();

  QMultiMap <int,QString> m_mapIdActesNGAP,
                          m_mapNameActesNGAP,
                          m_mapDescrActesNGAP,
                          m_maptypeActesNGAP,
                          m_mapPriceActesNGAP,
                          m_mapPartPriceActesNGAP;
  QMultiMap <int,QString> m_mapIdThesaurus,
                          m_mapSequenceThesaurus,
                          m_mapTypeThesaurus;
  QMultiMap <int,QString> m_mapIdForfaits,
                          m_mapForfaitsForfaits,
                          m_mapValueForfaits,
                          m_mapTypeForfaits;
  QMultiMap <int,QString> m_mapTypeIK,
                          m_mapValueIK,
                          m_mapAbattementIK,
                          m_mapIndemnitesIK;
  QMap <QString,double> m_mapCcamActs;
  QMap <QString,QString>m_mapRules;

signals:
  //void pressed();
  //void activated();

protected slots:
  void prefActRegistering();
  void actsRegistering();
  void fermer();
  void fermer2();
  void modifierrecettes();
  void on_lineEdit_textChanged();
  void textenonchange();
  void textechange(const QString&);
 /* void parametragesites();
  void parametragepayeurs();
  void testerbasecompta();
  void renseignerbaseactesdispo();
  void renseignerpourcentages();*/
  void fonctionplus();
  void fonctionmoins();
  void ccam_process();
 // void rafraichiractesdepenses();
  void saveInThesaurus();
  void changebouton(int);
  void changebouton_7(int);
  void changeButtonHighlighted_7(int);
  void changeButtonHighlighted(int);
  void changebouton2(const QString &);
  void clearAll();
 // void utilisateurdialog();
  void ccamIsFinished();
  void automatismeOuvert();
  void setWhatsThisMode();
  void changeToolTip(const QString &);
  void rafraichirComboBox_3();
  void rafraichirComboBox_5();
 // void mailing();
  void BoutonActeCourant();
  void redHelp();
  void parametrer();
  void enregistreSeance();
  void chooseNGAP(const QString &);
  void chooseForfaits(const QString &);
  void chooseIK(int);
  void chooseCCAM(const QString &);
  void clearLabel_7Text();
  void combo_5_toolTip(const QString&);
  void showErrors();
  void putDown(int);

  private :
    QString m_programName; // nom du programme appelant
    QString m_nomRecupere; // patient name
    QString m_prenomRecupere;//patient surname
    QString m_guidEntre;    // uid patient history file
    QString m_tarif;        // price
    QString m_codeTarif;    // price code
    QString m_user;         //user from calling program
    QHash<QString,QString> m_hashCompte;//hash comptes_bancaires
    QString m_valueForfaits;//valeur forfait choisi
    QString m_forfaitsForfaits;//dénomination forfait choisi
    double m_solde_initial;
    QString m_idHono;
    QString m_actesSeance;
    double m_especeSeance;
    double m_chequeSeance;
    double m_carteBleueSeance;
    double m_virementSeance;
    double m_dafSeance;
    double m_autreSeance;
    double m_duSeance;
    QString m_actesToolTip;
    QMap<QString,QString> m_mapRegleAssociation;
};

#endif
