1
|
#ifndef DBACCESS_H
|
2
|
#define DBACCESS_H
|
3
|
|
4
|
#include <QObject>
|
5
|
#include <QSqlDatabase>
|
6
|
#include <QSqlQuery>
|
7
|
#include <QList>
|
8
|
|
9
|
#define ALL_OK 0
|
10
|
#define REC_EXISTS 1
|
11
|
#define OTHER_ERR 2
|
12
|
|
13
|
class QSqlQueryModel;
|
14
|
|
15
|
//! Třída pro přímou práci s databází
|
16
|
/*!
|
17
|
Třída slouží pro zápis, nebo čtení dat pacientů, indikací a výsledků
|
18
|
*/
|
19
|
|
20
|
class dbAccess : public QObject
|
21
|
{
|
22
|
Q_OBJECT
|
23
|
public:
|
24
|
//! Konstruktor.
|
25
|
/*!
|
26
|
V kostruktoru je vytvořen hlavní objekt, který bude použit pro přístup k databázi postgres
|
27
|
*/
|
28
|
explicit dbAccess(QObject *parent = nullptr);
|
29
|
//! Destruktor.
|
30
|
/*!
|
31
|
Slouží pro uzavření databázového spojení
|
32
|
*/
|
33
|
~dbAccess();
|
34
|
bool connect(QString server, QString userName, QString password, int port, QString dbName);
|
35
|
void getPatientsQueryModel(QSqlQueryModel *m);
|
36
|
void getIndicationsQueryModel(QSqlQueryModel *m);
|
37
|
void getResultsQueryModel(QSqlQueryModel *m, int p_id, int ind_id);
|
38
|
int addNewPatient(QString name, QString surname, QDate birthdate, QString idNo, QString indNo);
|
39
|
int addNewIndication(QString name, QString description, QString curveName, int time);
|
40
|
int getPatientId(QString pid);
|
41
|
int getIndicationId(QString name);
|
42
|
bool getIndicationInfo(int indId, int *pTime, QString *cName);
|
43
|
bool getAllIndicationsName(QList<int> *allIndIds, QStringList *allNames);
|
44
|
bool getAllPatientsName(QList<int> *allPIds, QStringList *allNames);
|
45
|
bool setActualIndication(int p_id, int ind_id);
|
46
|
bool addResult(int p_id, int ind_id, int series, QList<int> quality);
|
47
|
int getLastSeriesNo(int p_id);
|
48
|
int getLastSeriesResultNo(int p_id, int series);
|
49
|
bool getResultsNumber(int p_id, int ind_id, int *results_count);
|
50
|
bool getNextResult(int *cycles, QString *quality);
|
51
|
bool getSeriesResultAvg(int p_id, int series, QList<int> *avg);
|
52
|
|
53
|
signals:
|
54
|
|
55
|
public slots:
|
56
|
|
57
|
private:
|
58
|
//! Privátní proměnná - DB spojení
|
59
|
/*!
|
60
|
Proměnná je použita pro spojení s databází
|
61
|
*/
|
62
|
QSqlDatabase *db;
|
63
|
//! Privátní proměnná - výsledek dotazu
|
64
|
/*!
|
65
|
Proměnná je použita pro sdílení výsledku dotazu mezi funkcemi
|
66
|
*/
|
67
|
QSqlQuery *result_query;
|
68
|
};
|
69
|
|
70
|
#endif // DBACCESS_H
|