Academic Integrity: tutoring, explanations, and feedback — we don’t complete graded work or submit on a student’s behalf.

ER diagram A database for Doctors Office. Tracking the patients and doctor data.

ID: 3857205 • Letter: E

Question

ER diagram

A database for Doctors Office. Tracking the patients and doctor data. Normalize the database up to the 3rd normal form.

Business Rules

– One patient can see many doctors in the same office on the same day.

One doctor can also see many patients.

On the same day.

If one doctor see’s the same patient multiple times in one day, then it’s only recorded once in the database.

For each patient, we are recording primary and secondary phone numbers.

A doctor can also be a patient. A doctor cannot be his/her own patient.

Each patient can be given many prescriptions(medicine). Each patient can be given many tests (medical test).

A patient cannot be given a new prescription, test without first visiting the doctor.

Some of the attributes being recorded are DoctorOffice

Patient Id

Name

Patient Address (ex of address 1234, street, city, state, Zip)

Patient primary phone number

Patient secondary number

Patient date of birth

Doctor Name

Visit date

Doctor phone number

Doctor Specialty

Prescription 1,

Prescription 2 ..

Prescription 10

Test 1,

Test 2 ..

Test 10

Doctor note

Explanation / Answer

public class demo {

public static void main (String args[])

{
Hospital h1= new Hospital("Appollo");
int choice=0;
Doctor o = new Doctor("Rai","Surgeon");
Doctor o1 = new Doctor("James","Opthalmologist");
Doctor o2 = new Doctor("Steve","ENT");
System.out.println("Press 1 to add doctor Press 2 to show doctors. Press 3 to add patient 4 Assign doctor to patients 5 Doctor and their patients ");
Scanner cin = new Scanner (System.in);
choice = cin.nextInt();
switch (choice)
{
case 1: h1.addDoctor(o);
h1.addDoctor(o1);
h1.addDoctor(o2);
// break;
case 2: { System.out.println(h1.showDoctors());

}
case 3: { Patient p = new Patient ("Steven ",21,"Male","eye");
Patient p1 = new Patient ("Michael ",12,"Male","heart patient");
Patient p2 = new Patient ("Sara ",23,"Female","earnose");
Patient p3 = new Patient ("Amy ",31,"Female","earnose");
Patient p5 = new Patient ("Rocky ",18,"Male","eye");
Patient p4= new Patient ("Jessy ",15,"Male","heart patient");
h1.addPatient(p);
h1.addPatient(p1);
h1.addPatient(p2);
h1.addPatient(p3);
h1.addPatient(p4);
h1.addPatient(p5);
System.out.println(h1.showPatients());
}   
case 4: {
h1.assignDoctor();
}

case 5: {
System.out.println(" "+ ""+o2.getDoctorName()+""+o2.getDoctorPatientList());
}
}
}}
Hospital

public class Hospital {

List <Doctor> doctorList = new ArrayList<Doctor>();
List <Patient> patientList = new ArrayList<Patient>();
String hospitalName;
void addDoctor(Doctor o)
{
doctorList.add(o);

}
void addPatient(Patient o)
{
patientList.add(o);
}
Hospital(String name)
{
this.hospitalName=name;
}

public List<Doctor> showDoctors()
{
return doctorList;
}
public List<Patient> showPatients()
{
return patientList;
}

public void assignDoctor()
{
for (Patient x: patientList)
{ for (Doctor y: doctorList)
{ if (x.getDisease().equals("eye"))
{
if (y.getDoctorspeciality().equals("Opthalmologist"))
{
y.addPatientsToDoctor(x);
}
}
if (x.getDisease().equals("heart patient"))
{
if (y.getDoctorspeciality().equals("Surgeon"))
{
y.addPatientsToDoctor(x);
}
}

if (x.getDisease().equals("earnose"))
{
if (y.getDoctorspeciality().equals("ENT"))
{
y.addPatientsToDoctor(x);
}
}

}
}

}


}
Doctor

public class Doctor {

private String doctorName;
private String doctorSpeciality;
String doctorStatus;
List<Patient> doctorPatientList= new ArrayList<Patient>();
Doctor(String c, String cc)
{
this.doctorName=c;
this.doctorSpeciality=cc;

}
public String getDoctorName()
{
return doctorName;
}

public List<Patient> getDoctorPatientList()
{   
return doctorPatientList;
}

public void addPatientsToDoctor(Patient o)
{
doctorPatientList.add(o);
}

String getDoctorspeciality()
{
return doctorSpeciality;
}
public String toString()
{
return (doctorName+""+doctorSpeciality);
}

}
Patient
public class Patient {
private String patientName;
private Patient primary phone number;
private Patient secondary number;
private Patient date of birth;
private Doctor Name;
private Visprivateit date;
private Doctor phone number;
private Doctor Specialty;
private Prescription 1;
private Prescription 2 ;
private Test 1;
private Test 2;
private Doctor note;
Patient (String patientName, int patientAge,String patientGender, String disease)
{
  
this.patientName= primary phone numberpatientName;
this.patientprimary phone number=Patient primary phone number;
this.patientPatie secondary = secondary number;
this.patient date of birth =Patient date of birth;
this.patient Doctor Name=Doctor Name;
this.patient Visprivateit date= Visprivateit date;
this.patient Doctor phone number=Doctor phone number;
this.patient Doctor Specialty=Doctor Specialty;
this.patient Prescription 1=Prescription 1;
this.patientPrescription2=Prescription 2;
this.patient Prescription 10=Prescription 10;
this.Test1=Test 1;
this.Test2=Test 2 ;
this.patientTest 10
this.Doctor Note=Doctor note;this.patientGender= primary phone number;
this.patientAge=patientAge;
this.disease=disease;
}   

public String getDisease()
{return disease;}

public String toString()
{
return (patientName+""Patient primary phone number+" "+Patient secondary number+" "+Patient date of birth+" "+ Doctor Name+" "+ Visprivateit date+" "+Doctor phone number+" "+Doctor Specialty+" "+ Prescription 1,+" "+Prescription 2 ..+" "+ Prescription 10+" "+ Test 1,+" "+ Test 2 ..+" "+ Test 10+" "+ Doctor note);
}
}