Question: Overview: The final project for this course is a summary and reflections report documenting the decision making and results of your tests for the Medical

Overview: The final project for this course is a summary and reflections report documenting the decision making and results of your tests for the Medical Application. You will submit the software tests that you develop in this milestone, which will inform your final project. Refer to the Final Project Code zip file and the Final Project Test Plan document to complete this assignment.

In Module Three, you completed a tutorial that demonstrated two possible approaches to software testing. For your milestone, you can use either of these approaches, but be sure to consider the best practices you have learned as well as the requirements in the test plan.

Prompt: Your code should meet each of the following criteria:

Technically Sound

Your code should be syntactically accurate. This is a measure of the style and syntax of your program code. This will include factors such as the following:

o Statement choice (e.g., for vs. while, nested vs cascaded if-else, appropriate use of Boolean operators, fields vs. variables)

o Appropriate use of techniques to enhance reusability and maintainability of code (e.g., class constants, private helper methods, proper access modifiers)

Your code should be logical. This is a measure of how well your program satisfies the requirements of the assignment. This may include the following:

o Checking that your code meets the specifications in the assignment (e.g., specific class names and method signatures)

o Running your code against the JUnit reference tests Executing your program manually and checking that it performs all required operations correctly (if not fully tested by the JUnit reference tests)

o Inspecting your source code for bugs not uncovered by other testing methods

o Ensuring proper methods are used, including appropriate tags (e.g., @param, @return, @before)

Efficient

Your code should be concise. This is a measure of how thoroughly you have tested your own code. This will include the following factors:

o Code does not perform unnecessary work (no extraneous fields/variables/code, data type selection, etc.)

o Code is tested thoroughly (all code is exercised, likely sources of errors are probed, boundary cases are tested, etc.)

Your code should be modular. This is a measure of how you organized your tests (e.g., grouping tests into test suites) for each of the features. This will include the following:

o Tests are organized to maximize testing for each of the features identified in the requirement document.

o The purpose of each test is readily identifiable based upon the test method name and/or added comments.

o Each test includes appropriate assertions with helpful failure messages.

Additionally, your tests overall should be effective. This means that they must accurately identify at least five bugs in the application and indicate the nature of each of the identified bugs.

Final Project Test Plan

I. Feature Requirements: This test plan will document unit testing requirements for accepting the medical record system (MRS). The MRS will have the following features that must be tested to ensure the quality of the product:

a. Doctor Information Feature Requirement: The system shall allow the user to log in and add a doctor to the list of doctors. Doctors names do not have to be unique, but doctors IDs should be unique.

b. Medical Records Feature Requirement: The system shall allow the user to add a medical record to a patient. i. Add a patient. ii. Add a medical record with treatments, medications, and allergies. o When you create a medical record, it is necessary to create a patient history, which will contain 1 to many treatments, 1 to many medications, and 1 to many allergies. Medications cannot be assigned to a patient history unless there has been a treatment first.

c. Allergy Find Feature Requirement: The system shall allow the user to search for allergies and print all patients with allergies.

II. Roles: The software developer will perform unit tests.

III. Testing levels

a. Unit testing

IV. Testing artifacts: The deliverable for this project will be a zip file containing all the JUnit tests.

package medical.com.medicalApplication.model;

/**

* This class represent the Allergy model in the application

*

*/

public class Allergey {

private String name;

public Allergey(String name) {

this.name = name;

}

public String getName() {

return name;

}

public void setName(String name) {

this.name = name;

}

@Override

public String toString() {

return "Allergy " + name;

}

}

package medical.com.medicalApplication.model;

/**

*

* This class represents the Doctor data model in the system

*

*/

public class Doctor {

private String name;

private String id;

public Doctor(String name, String id) {

super();

this.name = name;

this.id = id;

}

public String getName() {

return name;

}

public void setName(String name) {

this.name = name;

}

public String getId() {

return id;

}

public void setId(String id) {

this.id = id;

}

@Override

public String toString() {

return "Doctor Name:"+ name + " ID: "+id;

}

}

package medical.com.medicalApplication.model;

/**

*

* This class represents the employee model in the system

*

*/

public class Employee {

private String name;

private String id;

private String password;

public Employee(String name, String id) {

super();

this.name = name;

this.id = id;

this.password = "Open";

}

public String getName() {

return name;

}

public String getId() {

return id;

}

public String getPassword() {

return password;

}

}

package medical.com.medicalApplication.model;

/**

*

*

* This class represents a medical record model in the system

*

*/

public class MedicalRecord {

private Patient patient;

private PatientHistory history;

public MedicalRecord(Patient patient) {

super();

this.patient = patient;

this.history = new PatientHistory();

}

public Patient getPatient() {

return patient;

}

public PatientHistory getHistory() {

return history;

}

}

package medical.com.medicalApplication.model;

/**

*

* This class represents the mediation model in the system

*

*/

public class Medication {

private String name;

private String startDate;

private String endDate;

private String dose;

public Medication(String name, String startDate, String endDate, String dose) {

super();

this.name = name;

this.startDate = startDate;

this.endDate = endDate;

this.dose = dose;

}

public String getName() {

return name;

}

public void setName(String name) {

this.name = name;

}

public String getStartDate() {

return startDate;

}

public void setStartDate(String startDate) {

this.startDate = startDate;

}

public String getEndDate() {

return endDate;

}

public void setEndDate(String endDate) {

this.endDate = endDate;

}

public String getDose() {

return dose;

}

public void setDose(String dose) {

this.dose = dose;

}

@Override

public String toString() {

return "Medication:"+name + " Start Date: " + startDate + " End Date: "+endDate+ " Dose: "+dose;

}

}

package medical.com.medicalApplication.model;

/**

*

* This class represents a patient model in the system

*

*/

public class Patient {

private String name;

private String id;

public Patient(String name, String id) {

super();

this.name = name;

this.id = id;

}

public String getName() {

return name;

}

public void setName(String name) {

this.name = name;

}

public String getId() {

return id;

}

public void setId(String id) {

this.id = id;

}

@Override

public String toString() {

return "Patient Name: "+name+ " ID: "+id;

}

}

package medical.com.medicalApplication.model;

import java.util.ArrayList;

import java.util.List;

/**

*

* This class represents a patient history model in the system

*

*/

public class PatientHistory {

private List treatments;

private List medications;

private List allergy;

public PatientHistory() {

this.treatments = new ArrayList();

this.medications = new ArrayList();

this.allergy = new ArrayList();

}

public void addTreatment(Treatment treatment) {

treatments.add(treatment);

}

public void addAllergy(Allergey allegry) {

allergy.add(allegry);

}

public void addMedication(Medication medication) {

if(treatments != null){

medications.add(medication);

}

}

public List getAlergies() {

return allergy;

}

public List getAllTreatments() {

return treatments;

}

public List getAllMedications() {

return medications;

}

}

package medical.com.medicalApplication.model;

/**

*

* This class represents a treatment model in the system.

*

*/

public class Treatment {

private String treatmentDate;

private String diagnose;

private String description;

public Treatment(String treatmentDate, String diagnose, String description) {

super();

this.treatmentDate = treatmentDate;

this.diagnose = diagnose;

this.description = description;

}

public String getTreatmentDate() {

return treatmentDate;

}

public void setTreatmentDate(String treatmentDate) {

this.treatmentDate = treatmentDate;

}

public String getDiagnose() {

return diagnose;

}

public void setDiagnose(String diagnose) {

this.diagnose = diagnose;

}

public String getDescription() {

return description;

}

public void setDescription(String description) {

this.description = description;

}

@Override

public String toString() {

return "Treatment: "+ " Date: "+ treatmentDate+ " Diagnose: " + diagnose;

}

}

package medical.com.medicalApplication;

import java.util.Arrays;

import java.util.List;

import java.util.Scanner;

import medical.com.medicalApplication.model.Employee;

import medical.com.medicalApplication.prompts.MedicalRecordPrompt;

import medical.com.medicalApplication.services.DoctorService;

import medical.com.medicalApplication.services.MedicalRescordService;

import medical.com.medicalApplication.util.MenuUtil;

import medical.com.medicalApplication.util.Pair;

//Add duplicate doctors

//Adding medical records

//Find Allergies per patient

public class App {

private static List mainMenu = Arrays.asList("", "Main Menu", "Please select from the following options",

"1 Print Patient List", "2 Print Doctor List", "3 Add a Doctor", "4 Add a Patient", "5 Medical Records",

"6 Search for Allergies", "0 to Exit");

public static void main(String[] args) {

//Created for testing purposes password is "Open"

Employee employee = new Employee("Mike", "1111");

//Read console input

Scanner scanner = new Scanner(System.in);

scanner.useDelimiter(System.getProperty("line.separator"));

int passwordAttepts = 3;

String password = null;

boolean loginSuccess = false;

//Login

while (passwordAttepts > 0 && !loginSuccess) {

System.out.println("Login Enter Password");

password = scanner.next();

loginSuccess = employee.getPassword().equals(password);

passwordAttepts--;

}

if (loginSuccess) {

MedicalRecordPrompt medicalRecordPrompt = new MedicalRecordPrompt();

int input = -1;

System.out.println("Welcome to Mercy Hospitol System");

while (input != 0) {

mainMenu.stream().forEach(System.out::println);

input = scanner.nextInt();

switch (input) {

case 1:

MedicalRescordService.getReference().getAllPatients().forEach(System.out::println);

break;

case 2:

DoctorService.getReference().getAllDoctors().forEach(System.out::println);

break;

case 3:

addPerson(true, scanner);

break;

case 4:

addPerson(false, scanner);

break;

case 5:

medicalRecordPrompt.mainPrompt(scanner);

break;

case 6:

medicalRecordPrompt.findAllPatientsWithAllergy(scanner).forEach(System.out::println);

break;

case 0:

System.out.println("Good bye!");

break;

default:

break;

}

}

scanner.close();

}else{

System.out.println("Invalid Password after 3 tries");

}

}

private static void addPerson(boolean addDoctor, Scanner scanner) {

int input = -1;

String person = addDoctor ? "Doctor" : "Patient";

while (input != 0) {

Pair response = MenuUtil.createTwoItemMenu(scanner, "Enter Name:", "Enter ID:");

boolean personAdded = false;

if (addDoctor) {

personAdded = DoctorService.getReference().addDoctor(response.getOne(), response.getTwo());

} else {

personAdded = MedicalRescordService.getReference().addPatient(response.getOne(), response.getTwo());

}

if (personAdded) {

System.out.println(person + " " + response.getOne() + " was succesfully added ");

} else {

System.out.println(person + " " + response.getOne() + " Could not be added ");

}

System.out.println(

"Would you like to add another " + person + "? 1 for Yes 0 To return to the Main Menu");

input = scanner.nextInt();

}

}

}

package medical.com.medicalApplication.prompts;

import java.util.Arrays;

import java.util.List;

import java.util.Scanner;

import medical.com.medicalApplication.model.Allergey;

import medical.com.medicalApplication.model.MedicalRecord;

import medical.com.medicalApplication.model.Medication;

import medical.com.medicalApplication.model.Patient;

import medical.com.medicalApplication.model.Treatment;

import medical.com.medicalApplication.services.MedicalRescordService;

/**

*

* This class creates the prompts for the medical application

*

*/

public class MedicalRecordPrompt {

private static List prompt = Arrays.asList("","Medical Record Menu", "1 Add a Treatment", "2 Add a Medication",

"3 Print Patient's Treatments", "4 Print Patient's Medications", "5 Add Allergy", "6 Print Allergies", "0 Main Menu");

public void mainPrompt(Scanner scanner) {

int input = -1;

System.out.println("Enter Patient ID:");

String patientId = scanner.next();

Patient patient = MedicalRescordService.getReference().getPatient(patientId);

if (patient != null) {

while (input != 0) {

System.out.println("Patient: " + patient.getName());

prompt.stream().forEach(System.out::println);

input = scanner.nextInt();

switch (input) {

case 1:

addTreatment(scanner, patient.getId());

break;

case 2:

addMedication(scanner, patient.getId());

break;

case 3:

MedicalRescordService.getReference().getMedicalRecord(patientId).getHistory().getAllTreatments()

.forEach(System.out::println);

break;

case 4:

MedicalRescordService.getReference().getMedicalRecord(patientId).getHistory().getAllMedications()

.forEach(System.out::println);

break;

case 5:

addAllergy(scanner, patient.getId());

break;

case 6:

MedicalRescordService.getReference().getMedicalRecord(patientId).getHistory().getAlergies()

.forEach(System.out::println);

break;

case 0:

break;

default:

break;

}

}

} else {

System.out.println("Patient with that ID could not be found");

}

}

private void addAllergy(Scanner scanner, String patientId) {

int input = -1;

while (input != 0) {

System.out.println("Enter Allergy:");

String allergyName = scanner.next();

Allergey allergy = new Allergey(allergyName);

MedicalRecord medicalRecord = MedicalRescordService.getReference().getMedicalRecord(patientId);

if (medicalRecord != null) {

medicalRecord.getHistory().addAllergy(allergy);

} else {

System.err.println("Error! Medical Record is null");

}

System.out.println(

"Would you like to add another Allergy? 1 for Yes 0 To return to the Medical Record Menu");

input = scanner.nextInt();

}

}

public void addTreatment(Scanner scanner, String patientId) {

int input = -1;

while (input != 0) {

System.out.println("Enter the treatment date:");

String treatmentDate = scanner.next();

System.out.println("Enter diagnose:");

String diagnose = scanner.next();

System.out.println("Enter description:");

String description = scanner.next();

Treatment treatment = new Treatment(treatmentDate, diagnose, description);

MedicalRecord medicalRecord = MedicalRescordService.getReference().getMedicalRecord(patientId);

if (medicalRecord != null) {

medicalRecord.getHistory().addTreatment(treatment);

} else {

System.err.println("Error! Medical Record is null");

}

System.out.println(

"Would you like to add another Treatment? 1 for Yes 0 To return to the Medical Record Menu");

input = scanner.nextInt();

}

}

public List findAllPatientsWithAllergy(Scanner scanner){

System.out.println("Enter Allergy:");

String allergy = scanner.next();

return MedicalRescordService.getReference().getPatientsWithAllergies(allergy);

}

public void addMedication(Scanner scanner, String patientId) {

int input = -1;

while (input != 0) {

System.out.println("Enter medication name:");

String name = scanner.next();

System.out.println("Enter startDate:");

String startDate = scanner.next();

System.out.println("Enter endDate:");

String endDate = scanner.next();

System.out.println("Enter dose:");

String dose = scanner.next();

Medication medication = new Medication(name, startDate, endDate, dose);

MedicalRecord medicalRecord = MedicalRescordService.getReference().getMedicalRecord(patientId);

if (medicalRecord != null) {

medicalRecord.getHistory().addMedication(medication);

} else {

System.err.println("Error! Medical Record is null");

}

System.out.println(

"Would you like to add another Medication? 1 for Yes 0 To return to the Medical Record Menu");

input = scanner.nextInt();

}

}

}

package medical.com.medicalApplication.services;

import java.util.ArrayList;

import java.util.Collections;

import java.util.List;

import medical.com.medicalApplication.model.MedicalRecord;

import medical.com.medicalApplication.model.Patient;

/**

*

* This class uses a singleton pattern to mock a service instead of using dependency injection

*

* In addition, it stores data in memory only using Lists

*

*/

public class MedicalRescordService {

private static MedicalRescordService reference = new MedicalRescordService();

private List patients;

private List medicalRecords;

public static MedicalRescordService getReference() {

return reference;

}

MedicalRescordService() {

this.patients = new ArrayList();

this.medicalRecords = new ArrayList();

}

public boolean addPatient(String name, String id) {

boolean patientAdded = !patients.stream()

.anyMatch(patient -> patient.getId().equals(id));

if (patientAdded) {

Patient newPatient = new Patient(name, id);

patients.add(newPatient);

medicalRecords.add(new MedicalRecord(newPatient));

}

return patientAdded;

}

public MedicalRecord getMedicalRecord(String patientId) {

return medicalRecords.stream()

.filter(medicalRecord -> medicalRecord.getPatient().getId().equals(patientId)).findFirst().get();

}

public Patient getPatient(String patientId) {

return patients.stream().filter(person -> person.getId().equals(patientId))

.findFirst().get();

}

public List getAllPatients() {

return patients;

}

public List getPatientsWithAllergies(String allergyName){

for(Patient patient : getAllPatients()){

if(getMedicalRecord(patient.getId()).getHistory().getAlergies().stream().filter(allergy -> allergy.getName().equals(allergyName)).findFirst().get() != null){

return Collections.singletonList(patient);

}

}

return Collections.emptyList();

}

}

package medical.com.medicalApplication.services;

import java.util.ArrayList;

import java.util.List;

import medical.com.medicalApplication.model.Doctor;

/**

*

* This class uses a singleton pattern to mock a service instead of using dependency injection

*

* In addition, it stores data in memory only using Lists

*

*/

public class DoctorService {

private static DoctorService reference = new DoctorService();

private static List doctors;

DoctorService(){

doctors = new ArrayList();

}

public static DoctorService getReference(){

return reference;

}

public List getAllDoctors(){

return doctors;

}

public boolean addDoctor(String name, String id){

String tempId = new String(id);

boolean createDoctor = !doctors.stream().anyMatch(doctor -> doctor.getId() == tempId);

if (createDoctor) {

doctors.add(new Doctor(name, id));

}

return createDoctor;

}

}

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!