Commit 5a89af6f by Andrew Dahl

Initial Commit

This was written long ago and we apparently never
used version control because we're idiots
parents
This diff is collapsed. Click to expand it.
[Buildset]
BuildItems=@Variant(\x00\x00\x00\t\x00\x00\x00\x00\x01\x00\x00\x00\x0b\x00\x00\x00\x00\x01\x00\x00\x00\x08\x00B\x00A\x00C\x00H)
<?xml version="1.0" encoding="UTF-8"?>
<projectDescription>
<name>BACH</name>
<comment></comment>
<projects>
</projects>
<buildSpec>
<buildCommand>
<name>org.eclipse.cdt.managedbuilder.core.genmakebuilder</name>
<triggers>clean,full,incremental,</triggers>
<arguments>
<dictionary>
<key>?name?</key>
<value></value>
</dictionary>
<dictionary>
<key>org.eclipse.cdt.make.core.append_environment</key>
<value>true</value>
</dictionary>
<dictionary>
<key>org.eclipse.cdt.make.core.autoBuildTarget</key>
<value>all</value>
</dictionary>
<dictionary>
<key>org.eclipse.cdt.make.core.buildArguments</key>
<value></value>
</dictionary>
<dictionary>
<key>org.eclipse.cdt.make.core.buildCommand</key>
<value>make</value>
</dictionary>
<dictionary>
<key>org.eclipse.cdt.make.core.cleanBuildTarget</key>
<value>clean</value>
</dictionary>
<dictionary>
<key>org.eclipse.cdt.make.core.contents</key>
<value>org.eclipse.cdt.make.core.activeConfigSettings</value>
</dictionary>
<dictionary>
<key>org.eclipse.cdt.make.core.enableAutoBuild</key>
<value>false</value>
</dictionary>
<dictionary>
<key>org.eclipse.cdt.make.core.enableCleanBuild</key>
<value>true</value>
</dictionary>
<dictionary>
<key>org.eclipse.cdt.make.core.enableFullBuild</key>
<value>true</value>
</dictionary>
<dictionary>
<key>org.eclipse.cdt.make.core.fullBuildTarget</key>
<value>all</value>
</dictionary>
<dictionary>
<key>org.eclipse.cdt.make.core.stopOnError</key>
<value>true</value>
</dictionary>
<dictionary>
<key>org.eclipse.cdt.make.core.useDefaultBuildCmd</key>
<value>true</value>
</dictionary>
</arguments>
</buildCommand>
<buildCommand>
<name>org.eclipse.cdt.managedbuilder.core.ScannerConfigBuilder</name>
<triggers>full,incremental,</triggers>
<arguments>
</arguments>
</buildCommand>
</buildSpec>
<natures>
<nature>org.eclipse.cdt.core.cnature</nature>
<nature>org.eclipse.cdt.core.ccnature</nature>
<nature>org.eclipse.cdt.managedbuilder.core.managedBuildNature</nature>
<nature>org.eclipse.cdt.managedbuilder.core.ScannerConfigNature</nature>
</natures>
</projectDescription>
[Project]
Manager=KDevGenericManager
Name=BACH
# File: Makefile
CC=g++
CFLAGS=-c -Wall
LDFLAGS=-lsqlite3 -lform -lmenu -lpanel -lncurses
# Directories
SRCDIR=src
LIBDIR=lib
# Source
SRC=$(LIBDIR)/Name.cpp $(LIBDIR)/MedStaff.cpp $(LIBDIR)/Address.cpp $(LIBDIR)/Query.cpp $(LIBDIR)/StderrLog.cpp $(LIBDIR)/Database.cpp $(LIBDIR)/ApplicationMenu.cpp $(LIBDIR)/Patient.cpp $(LIBDIR)/Parent.cpp $(SRCDIR)/main.cpp
OBJ=$(SRC:.cpp=.o)
EXEC=bach
$(EXEC): $(OBJ)
$(CC) $(LDFLAGS) $(SRC) -o $@
.cpp.o:
$(CC) $(CFLAGS) $< -o $@
clean:
rm -rf $(EXEC) $(OBJ) core.*
cleanall: clean
rm -rf $(LIBDIR)/*.cpp~ $(SRCDIR)/*.cpp~
Quick Bits:
Authors: Andrew Dahl & Samuel Sussman
This application uses curses/ncurses and sqlite, thus you will need both dev packages to compile.
Enjoy!
(Note: This was tested and works on a machine running Fedora 13)
File added
#include <string>
#ifndef __ADDRESS_H__
#define __ADDRESS_H__
/** \brief Address class, defines an address for the BACH system */
class Address
{
public:
/**
* \brief Address Constructor
* @param line1 Address line 1
* @param line2 Address line 2
* @param city City of the Address
* @param state State of the Address
* @param postal Postal code of the Address
* @param country Country of the Address
*/
Address(std::string line1,std::string line2, std::string city, std::string state, std::string postal, std::string country);
/**
* \brief Empty Address
*/
Address();
/**
* \brief returns the 1st address line
* @return 1st address line
*/
std::string GetLine1();
/**
* \brief sets address line 1
* @param l1 address line 1
*/
void SetLine1(std::string l1);
/**
* \brief returns the 2st address line
* @return 2st address line
*/
std::string GetLine2();
/**
* \brief sets address line 2
* @param l2 address line 2
*/
void SetLine2(std::string l2);
/**
* \brief returns the city
* @return the city
*/
std::string GetCity();
/**
* \brief sets the city
* @param city address city
*/
void SetCity(std::string city);
/**
* \brief returns the state
* @return the state
*/
std::string GetState();
/**
* \brief sets the state
* @param state address state
*/
void SetState(std::string state);
/**
* \brief returns the postal code
* @return the postal code
*/
std::string GetZip();
/**
* \brief sets the postal code
* @param zip the address postal code
*/
void SetZip(std::string zip);
/**
* \brief returns the country
* @return the country
*/
std::string GetCountry();
/**
* \brief sets the country
* @param country the address country
*/
void SetCountry(std::string country);
/**
* \brief return a the entire address in the form below:
* line1
* [line2]
* city, state postalCode
* @return the address in the above form
*/
std::string GetAddressString();
private:
std::string addressLine1;
std::string addressLine2;
std::string city;
std::string state;
std::string postalCode;
std::string country;
};
#endif /* __ADDRESS_H__ */
/*
* ApplicationMenu.h
*
*/
#include <ncurses.h>
#include <curses.h>
#include <menu.h>
#include <form.h>
#include <stdlib.h>
#include <string>
#include <map>
#include <vector>
#include <string.h>
#include "MedStaff.h"
#include <stdlib.h>
#include "Parent.h"
#include "Patient.h"
#include "Address.h"
using std::string;
using std::map;
using std::vector;
#ifndef APPLICATIONMENU_H_
#define APPLICATIONMENU_H_
struct window_info{
int origin_x, origin_y;
int width, height;
};
class ApplicationMenu {
public:
ApplicationMenu();
void Run();
private:
map<int,map<int, string> > sections;
void SelectedSection(int first, int second);
window_info getWindowInfo(WINDOW* win);
int GetChoiceWithOptions(const int choice,
const string& message,
int xloc,
int yloc,
bool border,
string mark);
int GetChoiceWithOptions(const vector<string>& choices,
const string& message,
int xloc,
int yloc,
bool border,
string mark);
bool GetYesNo(const string& message);
string Dialog(const string& title, const string& default_text, int width, int height);
string DialogCentered(const string& title, const string& default_text);
};
#endif /* APPLICATIONMENU_H_ */
/*
** Database.h
**
** Published / author: 2005-08-12 / grymse@alhem.net
**/
/*
Copyright (C) 2001-2006 Anders Hedstrom
This program is made available under the terms of the GNU GPL.
If you would like to use this program in a closed-source application,
a separate license agreement is available. For information about
the closed-source license agreement for this program, please
visit http://www.alhem.net/sqlwrapped/license.html and/or
email license@alhem.net.
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., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
*/
#ifndef _DATABASE_H_SQLITE
#define _DATABASE_H_SQLITE
#ifdef _WIN32
#include <windows.h>
#else
#include <sqlite3.h>
#include <pthread.h>
#endif
#include <string>
#include <list>
#ifdef WIN32
typedef unsigned __int64 uint64_t;
typedef __int64 int64_t;
#else
#include <stdint.h>
#endif
#ifdef SQLITEW_NAMESPACE
namespace SQLITEW_NAMESPACE {
#endif
class IError;
class Query;
class Mutex;
/** Connection information and pool. */
class Database
{
public:
/** Mutex container class, used by Lock.
\ingroup threading */
class Mutex {
public:
Mutex();
~Mutex();
void Lock();
void Unlock();
private:
#ifdef _WIN32
HANDLE m_mutex;
#else
pthread_mutex_t m_mutex;
#endif
};
private:
/** Mutex helper class. */
class Lock {
public:
Lock(Mutex& mutex,bool use);
~Lock();
private:
Mutex& m_mutex;
bool m_b_use;
};
public:
/** Connection pool struct. */
struct OPENDB {
OPENDB() : busy(false) {}
sqlite3 *db;
bool busy;
};
typedef std::list<OPENDB *> opendb_v;
public:
/** Use file */
Database(const std::string& database,
IError * = NULL);
/** Use file + thread safe */
Database(Mutex& ,const std::string& database,
IError * = NULL);
virtual ~Database();
/** try to establish connection with given host */
bool Connected();
void RegErrHandler(IError *);
void error(Query&,const char *format, ...);
void error(Query&,const std::string& );
/** Request a database connection.
The "grabdb" method is used by the Query class, so that each object instance of Query gets a unique
database connection. I will reimplement your connection check logic in the Query class, as that's where
the database connection is really used.
It should be used something like this.
{
Query q(db);
if (!q.Connected())
return false;
q.execute("delete * from user"); // well maybe not
}
When the Query object is deleted, then "freedb" is called - the database connection stays open in the
m_opendbs vector. New Query objects can then reuse old connections.
*/
OPENDB *grabdb();
void freedb(OPENDB *odb);
/** Escape string - change all ' to ''. */
std::string safestr(const std::string& );
/** Make string xml safe. */
std::string xmlsafestr(const std::string& );
/** Convert string to 64-bit integer. */
int64_t a2bigint(const std::string& );
/** Convert string to unsigned 64-bit integer. */
uint64_t a2ubigint(const std::string& );
private:
Database(const Database& ) : m_mutex(m_mutex) {}
Database& operator=(const Database& ) { return *this; }
void error(const char *format, ...);
//
std::string database;
opendb_v m_opendbs;
IError *m_errhandler;
bool m_embedded;
Mutex& m_mutex;
bool m_b_use_mutex;
};
#ifdef SQLITEW_NAMESPACE
} // namespace SQLITEW_NAMESPACE {
#endif
#endif // _DATABASE_H
/*
** IError.h
**
** Published / author: 2004-06-11 / grymse@alhem.net
**/
/*
Copyright (C) 2004,2005,2006 Anders Hedstrom
This program is made available under the terms of the GNU GPL.
If you would like to use this program in a closed-source application,
a separate license agreement is available. For information about
the closed-source license agreement for this program, please
visit http://www.alhem.net/sqlwrapped/license.html and/or
email license@alhem.net.
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., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
*/
#ifndef _IERROR_H_SQLITE
#define _IERROR_H_SQLITE
#include <string>
#ifdef SQLITEW_NAMESPACE
namespace SQLITEW_NAMESPACE {
#endif
class Database;
class Query;
/** Log class interface. */
class IError
{
public:
virtual void error(Database&,const std::string&) = 0;
virtual void error(Database&,Query&,const std::string&) = 0;
};
#ifdef SQLITEW_NAMESPACE
} // namespace SQLITEW_NAMESPACE {
#endif
#endif // _IERROR_H
#include <string>
#include "Name.h"
#include <sstream>
using std::stringstream;
#ifndef __MEDSTAFF_H__
#define __MEDSTAFF_H__
/** \brief MedStaff class, defines a nurse or doctor for the BACH system */
class MedStaff
{
public:
MedStaff();
/**
* \brief MedStaff constructor
* @param name
* @param beeper number
*/
MedStaff(Name name, std::string beeper);
/**
* \brief returns name
* @return name
*/
Name GetName();
/**
* \brief set name
* @param name
*/
void SetName(Name name);
/**
* \brief returns the beeper number
* @return beeper number
*/
std::string GetBeeperNumber();
/**
* \brief sets beeper number
* @param beeper number
*/
void SetBeeperNumber(std::string beeper);
/**
* \brief return the staffID
* @return StaffID corrispinding to an entry in the db
*/
int GetStaffID();
/**
* \brief Inserts the object into the databse and returns the ID
* @return ID of inserted object
*/
int Insert();
/**
* \brief Updates the associated database entry
* @return success
*/
bool Update();
/**
* \brief Fills the current object with info from the db
* @param staff_id id to fill object with
* @return success
*/
bool Read(int staff_id);
private:
int staffID;
Name name;
std::string beeperNumber;
/**
* \brief Sets the staffID
* @param id to fill the object with
*/
void setStaffID(int id);
};
#endif /* __MEDSTAFF_H__ */
#include<string>
#ifndef __NAME_H__
#define __NAME_H__
/** \brief Name class, definition of a name for the BACH system */
class Name
{
public:
/**
* \brief Name constructor
* @param first name
* @param last name
* @param middle name
* @param suffix
*/
Name(std::string first ="", std::string last="", std::string middle="", std::string suffix="");
/**
* \brief return the first name
* @return first name
*/
std::string GetFirst();
/**
* \brief set the first name
* @param first name
*/
void SetFirst(std::string first);
/**
* \brief return the last name
* @return last name
*/
std::string GetLast();
/**
* \brief set the last name
* @param last name
*/
void SetLast(std::string last);
/**
* \brief return the middle name
* @return middle name
*/
std::string GetMiddle();
/**
* \brief set the middle name
* @param middle name
*/
void SetMiddle(std::string middle);
/**
* \brief return the suffix
* @return suffix
*/
std::string GetSuffix();
/**
* \brief set the suffix
* @param suffix
*/
void SetSuffix(std::string suffix);
/**
* \brief returns a string in the form [first] [middle] [last] [suffix]
* @return the string above
*/
std::string GetFullName();
/**
* \brief returns a string in the form [first] [last]
* @return the string above
*/
std::string GetFirstLast();
/**
* \brief returns a string in the form [last], [first] [middle]
* @return the string above
*/
std::string GetLastFirstMiddle();
private:
std::string firstName;
std::string middleName;
std::string lastName;
std::string suffix;
};
#endif /* __NAME_H__ */
#include"Name.h"
#include"Address.h"
#include<string>
#ifndef __PARENTGUARDIAN_H__
#define __PARENTGUARDIAN_H__
/** \brief Parent class, defines a parent for the the BACH system */
class Parent
{
public:
/**
* \brief Parent constructor
* @param name Parent name
* @param relationship Parent's relationship to the patient
* @param address Parents's home address
* @param alt_address other address
* @param primary_phone phone number
* @param alt_phone alternate phone number
*/
Parent(Name name, std::string relationship, Address address, Address alt_address, std::string primary_phone, std::string alt_phone);
/**
* \brief Empty Parent Constuctor
*/
Parent();
/**
* \brief returns a name
* @return The name of the parent
*/
Name GetName();
/**
* \brief Sets the name
* @param name The name of the parent
*/
void SetName(Name name);
/**
* \brief return the patient_relationship string
* @return the relationship string
*/
std::string GetRelationship();
/**
* \brief set the relationship string
* @param rel the rel string to be set
*/
void SetRelationship(std::string rel);
/**
* \brief get the address
* @return the address
*/
Address GetAddress();
/**
* \brief set the local address
* @param address the parent's local address
*/
void SetAddress(Address address);
/**
* \brief get the address
* @return the address
*/
Address GetLocalAddress();
/**
* \brief set the local address
* @param address the parent's local address
*/
void SetLocalAddress(Address address);
/**
* \brief get the primary phone
* @return the primary phone
*/
std::string GetPrimaryPhone();
/**
* \brief set the primary phone
* @param phone the primary phone
*/
void SetPrimaryPhone(std::string phone);