Hospital - svetlilaloli/EntityFramework-SoftUni GitHub Wiki

Practice: Code-First

1. Hospital Database

You went to your GP for your annual checkup and you told him that you’ve started work as a Junior Database App Developer. It turned out he was looking for someone to make an app, which he could use to manage and store data about his patients.

Your task is to design a database using the Code-First approach. The GP needs to keep information about his patients. Each patient has a first name, last name, address, email, information on whether he/ she has medical insurance or not and should keep a history of all his/ her visitations, diagnoses, and prescribed medicaments. Each visitation has a date and comments. Each diagnosis has a name and comments for it. Each medicament has a name. Validate all data before inserting it into the database.

Constraints: Your namespaces should be:

  • P01_HospitalDatabase – for your Startup class, if you have one
  • P01_HospitalDatabase.Data – for your DbContext
  • P01_HospitalDatabase.Data.Models – for your models

Your classes should be:

  • HospitalContext – your DbContext
  • Patient:
    • PatientId
    • FirstName (up to 50 characters, unicode)
    • LastName (up to 50 characters, unicode)
    • Address (up to 250 characters, unicode)
    • Email (up to 80 characters, not unicode)
    • HasInsurance
  • Visitation:
    • VisitationId
    • Date
    • Comments (up to 250 characters, unicode)
    • Patient
  • Diagnose:
    • DiagnoseId
    • Name (up to 50 characters, unicode)
    • Comments (up to 250 characters, unicode)
    • Patient
  • Medicament:
    • MedicamentId
    • Name (up to 50 characters, unicode)
  • PatientMedicament – mapping class between Patients and Medicaments

The collections of mapping classes (ICollection) must be named Prescriptions!

Don’t use a version of Entity Framework Core above 3.1.3!

Bonus Task

Make a console-based user interface, so the doctor can easily use the database.

2. Hospital Database Modification

Your GP bragged around in the hospital about the cool software you made for him. Now the hospital administration wants to modify your program so they can use it too. They want to store information about the doctors (name and specialty). Each doctor can perform many visitations. Make the necessary changes in the database to satisfy the new needs of the hospital administration.

Constraints: Keep the namespaces from the previous task and only add the class Doctor and change the class Visitation accordingly. The doctor’s name and specialty should be up to 100 characters long, Unicode.

Bonus Task

Make an authentication system for doctors. Each doctor should be able to log in with his email and password. Choose what information each doctor should have access to and hide the rest.