0

I am making software for patients record keeping in a clinic . I have written a peewee model for setting up tables to store record of each patient visit and patient contact and a relative table that store name of parent or husband (in case female patient is married)

import peewee
from app.datastore.core import db as _db


class Patient(peewee.Model):
    """ Patinets table """

    name = peewee.CharField(max_length=90)
    townCity = peewee.CharField(max_length=200)
    contactnumber = peewee.CharField(max_length=20)
    age = peewee.IntegerField(default=0)
    gender = peewee.CharField(max_length=9)
    email = peewee.CharField(max_length=1024, null=True)
    postalAddress = peewee.TextField() 

    def __repr__(self):
        return "<Patient Id: {}>".format(self.id)

    class Meta:
        database = _db

class Relative(peewee.Model):
    """ Visit attendence """

    patient = peewee.ForeignKeyField(Patient,
        related_name="patient")
    relation = peewee.CharField(max_length=10)
    relativeName = peewee.CharField(max_length=90)

    class Meta:
        database = _db

# the below table continues to increment on each visit of new or old patient by frontdesk.

class PatientAttendOnVisit(peewee.Model):
    """ Attendence or visit record """
    patient = peewee.ForeignKeyField(Patient, 
        related_name="patient")
    dateTimeofvisit = peewee.DateTimeField()
    attendtype = peewee.CharField(max_length=12) # walkin or appointment
    department = peewee.CharField(max_length=9) # medicine or dental

    class Meta:
        database = _db

# the below table continues to increment on each patient visit by doctor

class PatientCheckup(peewee.Model):
    """ 
    Patient Checkup table stores what patient reports on each visit 
    to doctor like symptoms, diagnosis and presciption
    """
    patient = peewee.ForeignKeyField(Patient, 
        related_name="patient")
    chiefcomplaint = peewee.TextField()
    symptoms = peewee.TextField()
    diagnosis = peewee.TextField()
    treatment = peewee.TextField()
    presciption = peewee.TextField()
    dateTimeofvisit = peewee.ForeignKeyField(PatientAttendOnVisit)

    class Meta:
        database = _db

enter image description here

I am very new to database driven application with no knowledge of db design please help me design the best database and schema ?

2
  • 1
    Hi Ciasto. It will be easier for us to help you by drawing the relationships in an ERD instead of dumping code. Dec 30, 2018 at 0:09
  • @RandolphWest I have added ERD.. Dec 30, 2018 at 4:35

0

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.

Browse other questions tagged or ask your own question.