Módulo de Administración
El módulo de administración es responsable de la gestión integral de información médica y departamental. El administrador puede realizar operaciones de creación, lectura, actualización y eliminación (CRUD) sobre los médicos, gestionar los departamentos del hospital y consultar información de los usuarios registrados en el sistema.
Pantalla Principal del Administrador
Estructura del Archivo de Encabezado
#pragma once
#include "screenBase.h"
#include "Label.h"
#include "Cbuttun.h"
class AdminMainScreen : public ScreenBase
{
public:
AdminMainScreen(int x = 0, int y = 0, int w = 0, int h = 0);
~AdminMainScreen();
int executeAction();
private:
Label* labelHeader;
CButton* btnDoctorMgmt;
CButton* btnUserMgmt;
CButton* btnDeptMgmt;
CButton* btnReturn;
};
Implementación
#include "AdminMainScreen.h"
AdminMainScreen::AdminMainScreen(int x, int y, int w, int h) : ScreenBase(x, y, w, h)
{
this->labelHeader = new Label(30, 8, 6, 3, "Sistema de Citas Médicas");
this->btnDoctorMgmt = new CButton(20, 12, 6, 3, "Gestión Médicos");
this->btnUserMgmt = new CButton(20, 16, 6, 3, "Gestión Usuarios");
this->btnDeptMgmt = new CButton(40, 12, 6, 3, "Gestión Departamentos");
this->btnReturn = new CButton(40, 16, 6, 3, "Regresar");
this->screenElements.push_back(this->labelHeader);
this->screenElements.push_back(this->btnDoctorMgmt);
this->screenElements.push_back(this->btnDeptMgmt);
this->screenElements.push_back(this->btnUserMgmt);
this->screenElements.push_back(this->btnReturn);
}
AdminMainScreen::~AdminMainScreen()
{
for (int i = 0; i < this->screenElements.size(); i++)
{
delete this->screenElements[i];
}
}
int AdminMainScreen::executeAction()
{
if (this->selectedIndex == 1)
{
return 5;
}
else if (this->selectedIndex == 2)
{
return 14;
}
else if (this->selectedIndex == 3)
{
// Acceso a gestión de usuarios
}
else if (this->selectedIndex == 4)
{
return 1;
}
return 0;
}
Gestión de Médicos
Archivo de Encabezado
#pragma once
#include "screenBase.h"
#include "Label.h"
#include "Cbuttun.h"
class DoctorManagementScreen : public ScreenBase
{
public:
DoctorManagementScreen(int x = 0, int y = 0, int w = 0, int h = 0);
~DoctorManagementScreen();
int executeAction();
private:
Label* labelHeader;
CButton* btnSearch;
CButton* btnAdd;
CButton* btnModify;
CButton* btnReturn;
};
Implementación
#include "DoctorManagementScreen.h"
DoctorManagementScreen::DoctorManagementScreen(int x, int y, int w, int h) : ScreenBase(x, y, w, h)
{
this->labelHeader = new Label(30, 8, 6, 3, "Gestión de Médicos");
this->btnSearch = new CButton(20, 12, 6, 3, "Buscar Médico");
this->btnAdd = new CButton(20, 16, 6, 3, "Agregar Médico");
this->btnModify = new CButton(40, 12, 8, 3, "Modificar Información");
this->btnReturn = new CButton(40, 16, 6, 3, "Regresar");
this->screenElements.push_back(this->labelHeader);
this->screenElements.push_back(this->btnSearch);
this->screenElements.push_back(this->btnAdd);
this->screenElements.push_back(this->btnModify);
this->screenElements.push_back(this->btnReturn);
}
DoctorManagementScreen::~DoctorManagementScreen()
{
for (int i = 0; i < screenElements.size(); i++)
{
delete screenElements[i];
}
}
int DoctorManagementScreen::executeAction()
{
if (this->selectedIndex == 1)
{
return 7;
}
else if (this->selectedIndex == 2)
{
return 6;
}
else if (this->selectedIndex == 3)
{
return 8;
}
else
{
return 4;
}
}
Búsqueda de Información de Médicos
Encabezado
#pragma once
#include "screenBase.h"
#include "Label.h"
#include "Cbuttun.h"
#include "CEdit.h"
class DoctorSearchScreen : public ScreenBase
{
public:
DoctorSearchScreen(int x = 0, int y = 0, int w = 0, int h = 0);
~DoctorSearchScreen();
int executeAction();
private:
Label* labelInstruction;
CButton* btnSearch;
CButton* btnReturn;
CButton* btnShowAll;
CEdit* editDoctorName;
};
Implementación
#define _CRT_SECURE_NO_WARNINGS
#include "DoctorSearchScreen.h"
#include "DatabaseConnector.h"
#include <iostream>
#include <iomanip>
using namespace std;
DoctorSearchScreen::DoctorSearchScreen(int x, int y, int w, int h) : ScreenBase(x, y, w, h)
{
this->labelInstruction = new Label(28, 8, 6, 3, "Ingrese nombre del médico");
this->btnSearch = new CButton(70, 7, 6, 3, "Buscar");
this->btnShowAll = new CButton(85, 7, 6, 3, "Mostrar Todos");
this->btnReturn = new CButton(23, 23, 6, 3, "Regresar");
this->editDoctorName = new CEdit(42, 8, 12, 3, "", 3, 10, 0);
this->screenElements.push_back(this->labelInstruction);
this->screenElements.push_back(this->editDoctorName);
this->screenElements.push_back(this->btnSearch);
this->screenElements.push_back(this->btnShowAll);
this->screenElements.push_back(this->btnReturn);
}
DoctorSearchScreen::~DoctorSearchScreen()
{
for (int i = 0; i < this->screenElements.size(); i++)
{
delete this->screenElements[i];
}
}
int DoctorSearchScreen::executeAction()
{
if (this->selectedIndex == 2)
{
ConsoleUtils::setCursorPosition(0, 29);
DatabaseConnector* db = DatabaseConnector::getInstance();
char query[256] = { 0 };
char** resultSet = nullptr;
int rowCount = 0, colCount = 0;
sprintf(query, "SELECT * FROM doctorInfo WHERE doctorname = '%s'",
this->editDoctorName->getText());
int result = db->executeQuery(query, resultSet, rowCount, colCount);
if (result == 0)
{
if (rowCount == 0)
{
ConsoleUtils::setCursorPosition(18, 15);
cout << "No se encontró información" << endl;
this->editDoctorName->clear();
return 7;
}
else
{
ConsoleUtils::setCursorPosition(18, 10);
for (int i = 0; i < rowCount + 1; i++)
{
for (int j = 0; j < colCount; j++)
{
ConsoleUtils::setCursorPosition(18 + j * 10, 10 + i * 2);
cout << "| " << setw(10) << left << resultSet[i * colCount + j] << " ";
}
cout << "|" << endl;
}
this->editDoctorName->clear();
return 7;
}
}
}
else if (this->selectedIndex == 3)
{
ConsoleUtils::setCursorPosition(0, 29);
DatabaseConnector* db = DatabaseConnector::getInstance();
char query[256] = { 0 };
char** resultSet = nullptr;
int rowCount = 0, colCount = 0;
sprintf(query, "SELECT * FROM doctorInfo");
int result = db->executeQuery(query, resultSet, rowCount, colCount);
if (result == 0)
{
if (rowCount == 0)
{
ConsoleUtils::setCursorPosition(18, 10);
cout << "No se encontró información" << endl;
this->editDoctorName->clear();
return 7;
}
else
{
ConsoleUtils::setCursorPosition(25, 10);
for (int i = 0; i < rowCount + 1; i++)
{
for (int j = 0; j < colCount; j++)
{
ConsoleUtils::setCursorPosition(25 + j * 10, 10 + i * 2);
cout << "| " << setw(10) << left << resultSet[i * colCount + j] << " ";
}
cout << "|" << endl;
}
this->editDoctorName->clear();
return 7;
}
}
}
else if (this->selectedIndex == 4)
{
this->editDoctorName->clear();
return 5;
}
return 0;
}
</iomanip></iostream>
Modificación de Información de Médicos
Encabezado
#pragma once
#include "screenBase.h"
#include "Label.h"
#include "Cbuttun.h"
#include "CEdit.h"
class DoctorModifyScreen : public ScreenBase
{
public:
DoctorModifyScreen(int x = 0, int y = 0, int w = 0, int h = 0);
~DoctorModifyScreen();
int executeAction();
private:
Label* labelHeader;
Label* labelDoctorName;
Label* labelCurrentDept;
Label* labelNewDept;
Label* labelCurrentTitle;
Label* labelNewTitle;
CEdit* editDoctorName;
CEdit* editCurrentDept;
CEdit* editNewDept;
CEdit* editCurrentTitle;
CEdit* editNewTitle;
CButton* btnConfirm;
CButton* btnReturn;
};
Implementación
#define _CRT_SECURE_NO_WARNINGS
#include "DoctorModifyScreen.h"
#include "DatabaseConnector.h"
#include <iostream>
#include <string>
using namespace std;
DoctorModifyScreen::DoctorModifyScreen(int x, int y, int w, int h) : ScreenBase(x, y, w, h)
{
this->labelHeader = new Label(35, 6, 6, 3, "Modificar Información del Médico");
this->labelDoctorName = new Label(19, 8, 6, 3, "Nombre del Médico:");
this->labelCurrentDept = new Label(19, 12, 6, 3, "Departamento Actual:");
this->labelNewDept = new Label(40, 12, 6, 3, "Nuevo Departamento:");
this->labelCurrentTitle = new Label(19, 16, 6, 3, "Título Actual:");
this->labelNewTitle = new Label(40, 16, 6, 3, "Nuevo Título:");
this->editDoctorName = new CEdit(30, 8, 6, 3, "", 3, 15, 0);
this->editCurrentDept = new CEdit(30, 12, 6, 3, "", 3, 15, 0);
this->editNewDept = new CEdit(50, 12, 6, 3, "", 3, 15, 0);
this->editCurrentTitle = new CEdit(30, 16, 6, 3, "", 3, 15, 0);
this->editNewTitle = new CEdit(50, 16, 6, 3, "", 3, 15, 0);
this->btnConfirm = new CButton(20, 20, 6, 3, "Confirmar");
this->btnReturn = new CButton(40, 20, 6, 3, "Regresar");
this->screenElements.push_back(this->labelHeader);
this->screenElements.push_back(this->labelDoctorName);
this->screenElements.push_back(this->labelCurrentDept);
this->screenElements.push_back(this->labelNewDept);
this->screenElements.push_back(this->labelCurrentTitle);
this->screenElements.push_back(this->labelNewTitle);
this->screenElements.push_back(this->editDoctorName);
this->screenElements.push_back(this->editCurrentDept);
this->screenElements.push_back(this->editNewDept);
this->screenElements.push_back(this->editCurrentTitle);
this->screenElements.push_back(this->editNewTitle);
this->screenElements.push_back(this->btnConfirm);
this->screenElements.push_back(this->btnReturn);
}
DoctorModifyScreen::~DoctorModifyScreen()
{
for (int i = 0; i < this->screenElements.size(); i++)
{
delete this->screenElements[i];
}
}
int DoctorModifyScreen::executeAction()
{
if (this->selectedIndex == 11)
{
ConsoleUtils::setCursorPosition(0, 29);
DatabaseConnector* db = DatabaseConnector::getInstance();
char query[256] = { 0 };
char** resultSet = nullptr;
int rowCount = 0, colCount = 0;
sprintf(query, "UPDATE doctorInfo SET department = '%s', level = '%s' WHERE doctorname = '%s'",
this->editNewDept->getText(),
this->editNewTitle->getText(),
this->editDoctorName->getText());
int result = db->executeQuery(query, resultSet, rowCount, colCount);
if (result == 0)
{
cout << "Modificación exitosa" << endl;
}
else
{
cout << "Error en la modificación" << endl;
}
this->editDoctorName->clear();
this->editCurrentDept->clear();
this->editNewDept->clear();
this->editCurrentTitle->clear();
this->editNewTitle->clear();
return 8;
}
else if (this->selectedIndex == 12)
{
this->editDoctorName->clear();
this->editCurrentDept->clear();
this->editNewDept->clear();
this->editCurrentTitle->clear();
this->editNewTitle->clear();
return 5;
}
return 0;
}
</string></iostream>
Agregar Nuevo Médico
Encabezado
#pragma once
#include "screenBase.h"
#include "Cbuttun.h"
#include "CEdit.h"
#include "Label.h"
#include "CtrlBase.h"
class DoctorAddScreen : public ScreenBase
{
public:
DoctorAddScreen(int x = 0, int y = 0, int w = 0, int h = 0);
~DoctorAddScreen();
int executeAction();
private:
Label* labelHeader;
Label* labelDoctorName;
Label* labelDepartment;
Label* labelTitle;
CEdit* editDoctorName;
CEdit* editDepartment;
CEdit* editTitle;
CButton* btnConfirm;
CButton* btnReturn;
};
Implementación
#define _CRT_SECURE_NO_WARNINGS
#include "DoctorAddScreen.h"
#include "DatabaseConnector.h"
#include <iostream>
using namespace std;
DoctorAddScreen::DoctorAddScreen(int x, int y, int w, int h) : ScreenBase(x, y, w, h)
{
this->labelHeader = new Label(30, 8, 6, 3, "Agregar Información del Médico");
this->labelDoctorName = new Label(19, 12, 6, 3, "Nombre del Médico");
this->labelDepartment = new Label(19, 16, 6, 3, "Departamento");
this->labelTitle = new Label(19, 20, 6, 3, "Título Profesional");
this->editDoctorName = new CEdit(35, 12, 10, 3, "", 3, 10, 0);
this->editDepartment = new CEdit(35, 16, 10, 3, "", 3, 10, 0);
this->editTitle = new CEdit(35, 20, 10, 3, "", 3, 10, 0);
this->btnConfirm = new CButton(19, 23, 10, 3, "Confirmar");
this->btnReturn = new CButton(40, 23, 10, 3, "Regresar");
this->screenElements.push_back(this->labelHeader);
this->screenElements.push_back(this->labelDoctorName);
this->screenElements.push_back(this->labelDepartment);
this->screenElements.push_back(this->labelTitle);
this->screenElements.push_back(this->editDoctorName);
this->screenElements.push_back(this->editDepartment);
this->screenElements.push_back(this->editTitle);
this->screenElements.push_back(this->btnConfirm);
this->screenElements.push_back(this->btnReturn);
}
DoctorAddScreen::~DoctorAddScreen()
{
for (int i = 0; i < this->screenElements.size(); i++)
{
delete this->screenElements[i];
}
}
int DoctorAddScreen::executeAction()
{
if (this->selectedIndex == 7)
{
this->editDoctorName->getText();
this->editDepartment->getText();
this->editTitle->getText();
if (strlen(this->editDoctorName->getText()) == 0 ||
strlen(this->editDepartment->getText()) == 0 ||
strlen(this->editTitle->getText()) == 0)
{
ConsoleUtils::setCursorPosition(0, 29);
cout << "Los campos no pueden estar vacíos" << endl;
return 6;
}
else
{
DatabaseConnector* db = DatabaseConnector::getInstance();
char query[256] = { 0 };
char** resultSet = nullptr;
int rowCount = 0, colCount = 0;
sprintf(query, "SELECT doctorname FROM doctorInfo WHERE doctorname='%s'",
this->editDoctorName->getText());
int result = db->executeQuery(query, resultSet, rowCount, colCount);
if (result == 0)
{
if (rowCount == 0)
{
char insertQuery[256] = { 0 };
sprintf(insertQuery, "INSERT INTO doctorInfo(doctorname, passwd, department, level, role) VALUES('%s', '123456','%s', '%s', 2)",
this->editDoctorName->getText(),
this->editDepartment->getText(),
this->editTitle->getText());
db->executeQuery(insertQuery, resultSet, rowCount, colCount);
this->editDoctorName->clear();
this->editDepartment->clear();
this->editTitle->clear();
return 6;
}
else
{
ConsoleUtils::setCursorPosition(0, 29);
cout << "El médico ya existe en el sistema" << endl;
this->editDoctorName->clear();
this->editDepartment->clear();
this->editTitle->clear();
return 6;
}
}
}
}
else if (this->selectedIndex == 8)
{
this->editDoctorName->clear();
this->editDepartment->clear();
this->editTitle->clear();
return 5;
}
return 0;
}
</iostream>
Gestión de Departamentos
Encabezado
#pragma once
#include "screenBase.h"
#include "Label.h"
#include "Cbuttun.h"
class DepartmentManagementScreen : public ScreenBase
{
public:
DepartmentManagementScreen(int x = 0, int y = 0, int w = 0, int h = 0);
~DepartmentManagementScreen();
int executeAction();
private:
Label* labelHeader;
CButton* btnAdd;
CButton* btnSearch;
CButton* btnModify;
CButton* btnReturn;
};
Implementación
#include "DepartmentManagementScreen.h"
DepartmentManagementScreen::DepartmentManagementScreen(int x, int y, int w, int h) : ScreenBase(x, y, w, h)
{
this->labelHeader = new Label(30, 8, 6, 3, "Gestión de Departamentos");
this->btnAdd = new CButton(20, 12, 6, 3, "Agregar Depto");
this->btnSearch = new CButton(20, 16, 6, 3, "Buscar Depto");
this->btnModify = new CButton(40, 12, 6, 3, "Modificar Depto");
this->btnReturn = new CButton(40, 16, 6, 3, "Regresar");
this->screenElements.push_back(this->labelHeader);
this->screenElements.push_back(this->btnAdd);
this->screenElements.push_back(this->btnModify);
this->screenElements.push_back(this->btnSearch);
this->screenElements.push_back(this->btnReturn);
}
DepartmentManagementScreen::~DepartmentManagementScreen()
{
for (int i = 0; i < this->screenElements.size(); i++)
{
delete this->screenElements[i];
}
}
int DepartmentManagementScreen::executeAction()
{
if (this->selectedIndex == 1)
{
return 15;
}
else if (this->selectedIndex == 2)
{
return 16;
}
else if (this->selectedIndex == 3)
{
return 17;
}
else if (this->selectedIndex == 4)
{
return 4;
}
return 0;
}
Agregar Depatramento
Encabezado
#pragma once
#include "screenBase.h"
#include "Label.h"
#include "Cbuttun.h"
#include "CEdit.h"
class AddDepartmentScreen : public ScreenBase
{
public:
AddDepartmentScreen(int x = 0, int y = 0, int w = 0, int h = 0);
~AddDepartmentScreen();
int executeAction();
private:
Label* labelHeader;
Label* labelDeptName;
Label* labelLocation;
CEdit* editDeptName;
CEdit* editLocation;
CButton* btnConfirm;
CButton* btnReturn;
};
Implementación
#define _CRT_SECURE_NO_WARNINGS
#include "AddDepartmentScreen.h"
#include "DatabaseConnector.h"
AddDepartmentScreen::AddDepartmentScreen(int x, int y, int w, int h) : ScreenBase(x, y, w, h)
{
this->labelHeader = new Label(30, 8, 6, 3, "Agregar Departamento");
this->labelDeptName = new Label(19, 12, 6, 3, "Nombre del Departamento");
this->labelLocation = new Label(19, 16, 6, 3, "Ubicación");
this->editDeptName = new CEdit(35, 12, 10, 3, "", 3, 10, 0);
this->editLocation = new CEdit(35, 16, 10, 3, "", 3, 10, 0);
this->btnConfirm = new CButton(19, 23, 10, 3, "Confirmar");
this->btnReturn = new CButton(40, 23, 10, 3, "Regresar");
this->screenElements.push_back(labelHeader);
this->screenElements.push_back(labelDeptName);
this->screenElements.push_back(labelLocation);
this->screenElements.push_back(editDeptName);
this->screenElements.push_back(editLocation);
this->screenElements.push_back(btnConfirm);
this->screenElements.push_back(btnReturn);
}
AddDepartmentScreen::~AddDepartmentScreen()
{
for (int i = 0; i < screenElements.size(); i++)
{
delete screenElements[i];
}
}
int AddDepartmentScreen::executeAction()
{
if (this->selectedIndex == 5)
{
this->editDeptName->getText();
this->editLocation->getText();
if (strlen(this->editDeptName->getText()) == 0 ||
strlen(this->editLocation->getText()) == 0)
{
ConsoleUtils::setCursorPosition(0, 29);
cout << "Los campos no pueden estar vacíos" << endl;
return 15;
}
else
{
DatabaseConnector* db = DatabaseConnector::getInstance();
char query[256] = { 0 };
char** resultSet = nullptr;
int rowCount = 0, colCount = 0;
sprintf(query, "SELECT department FROM departmentInfo WHERE department = '%s'",
this->editDeptName->getText());
int result = db->executeQuery(query, resultSet, rowCount, colCount);
if (result == 0)
{
if (rowCount == 0)
{
char insertQuery[256] = { 0 };
sprintf(insertQuery, "INSERT INTO departmentInfo(department, address) VALUES('%s','%s')",
this->editDeptName->getText(),
this->editLocation->getText());
db->executeQuery(insertQuery, resultSet, rowCount, colCount);
this->editDeptName->clear();
this->editLocation->clear();
return 15;
}
else
{
ConsoleUtils::setCursorPosition(0, 29);
cout << "El departamento ya existe en el sistema" << endl;
this->editDeptName->clear();
this->editLocation->clear();
return 15;
}
}
}
}
else if (this->selectedIndex == 6)
{
this->editDeptName->clear();
this->editLocation->clear();
return 14;
}
return 0;
}
Buscar Departamento
Encabezado
#pragma once
#include "screenBase.h"
#include "Label.h"
#include "Cbuttun.h"
class DepartmentSearchScreen : public ScreenBase
{
public:
DepartmentSearchScreen(int x = 0, int y = 0, int w = 0, int h = 0);
~DepartmentSearchScreen();
int executeAction();
private:
Label* titleLabel;
CButton* btnReturn;
CButton* btnSearch;
};
Implementación
#define _CRT_SECURE_NO_WARNINGS
#include "DepartmentSearchScreen.h"
#include <iomanip>
#include "DatabaseConnector.h"
DepartmentSearchScreen::DepartmentSearchScreen(int x, int y, int w, int h) : ScreenBase(x, y, w, h)
{
this->titleLabel = new Label(35, 6, 6, 3, "Buscar Departamento");
this->btnReturn = new CButton(42, 22, 6, 3, "Regresar");
this->btnSearch = new CButton(22, 22, 6, 3, "Buscar");
this->screenElements.push_back(this->titleLabel);
this->screenElements.push_back(this->btnSearch);
this->screenElements.push_back(this->btnReturn);
}
DepartmentSearchScreen::~DepartmentSearchScreen()
{
for (int i = 0; i < this->screenElements.size(); i++)
{
delete this->screenElements[i];
}
}
int DepartmentSearchScreen::executeAction()
{
if (this->selectedIndex == 1)
{
ConsoleUtils::setCursorPosition(0, 29);
DatabaseConnector* db = DatabaseConnector::getInstance();
char query[256] = { 0 };
char** resultSet = nullptr;
int rowCount = 0, colCount = 0;
sprintf(query, "SELECT * FROM departmentInfo");
int result = db->executeQuery(query, resultSet, rowCount, colCount);
if (result == 0)
{
if (rowCount == 0)
{
ConsoleUtils::setCursorPosition(18, 15);
cout << "No se encontró información" << endl;
return 10;
}
else
{
ConsoleUtils::setCursorPosition(18, 8);
for (int i = 0; i < rowCount + 1; i++)
{
for (int j = 0; j < colCount; j++)
{
ConsoleUtils::setCursorPosition(18 + j * 10, 8 + i * 2);
cout << "|" << setw(12) << left << resultSet[i * colCount + j] << " ";
}
cout << "|" << endl;
}
return 11;
}
}
}
else if (this->selectedIndex == 2)
{
return 14;
}
return 0;
}
</iomanip>