F:/18-Teaching/18-IOO-S1/5-Assignment/Part1/1-Handout/IOO-2018-Assignment-Handout.dvi 1 Assignment Objectives: The general aims of this assignment are: • To analyze a problem in an object-oriented...

wait for the price quote


F:/18-Teaching/18-IOO-S1/5-Assignment/Part1/1-Handout/IOO-2018-Assignment-Handout.dvi 1 Assignment Objectives: The general aims of this assignment are: • To analyze a problem in an object-oriented manner, and then design and implement an object-oriented solution that conforms to given specifications • To practise using inheritance in Java • To practise file input and output in Java • To make implementations more robust through mechanisms such as exception han- dling. Submission Details and Marking Scheme: Instructions on how to submit electronic copies of your source code files from your latcs8 account and a marking scheme overview are given at the end. If you have not been able to complete a program that compiles and executes containing all functionality, then you should submit a program that compiles and executes with as much functionality as you have completed. You may comment out code that does not compile. However, the commented out code will not be marked. Deployment Platform: While you are free to develop the code for this assignment on any operating system, your solution must run on the latcs8 system. We should be able to compile your classes with the simple command javac *.java, and execute your programs with a simple command, e.g. java PatientRecordSystemTester. 2 PART A Problem Description In this assignment, which consists of two parts, you will develop a prototype of a patient record system. The description below applies to both part 1 and part 2. The tasks required for part 1 will be described later in this handout. A medical clinic needs a system to keep information about their patients and medical observations about the patients. The concept of medical observation is explained below. • Each patient has a unique patient ID and a name. For each patient, various kinds of medical observations are recorded. • A medical observation can be measurement such as height, weight, blood pressure, etc. These measurements are referred to as “measurement observations”. • In addition, there are observations that are of non-quantitative nature, for example, the patient’s blood type. These observations are referred to as “category observa- tions”. • Each observation type has a name (e.g. “Height” , “Blood type”) and a unique code. • Each measurement observation type has a unit associated with it. Each unit is identified by a name. • Each category observation type has a number of valid categories associated with. Each category of a category observation type is specified by a name. The nurses and doctors who use the system should be able to: • Add a measurement observation type • Add a category observation type • Delete an observation type (which has no associated observations) • Add a patient • Add a measurement observation (for a patient) • Add a category observation (for a patient) • Modify the value for a measurement observation • Modify the category for a category observation • Delete an observation (of a patient) • Delete a patient (delete all the patient’s observation as well) • Retrieve details of an observation type (given its code) • Retrieve a patient record by the patient id (including the patient’s observations) In addition (though we will not be concerned with these for Part 1), the nurses and doctors should be able to • Save all the data • Load data from the file 3 Design Class Diagram A design has been made of the system, and is presented in the class diagram below. Note: The different shapes of the arrows denote different relationships. The empty triangular arrow denotes the ‘is-a’ relationship, as shown in lectures. The other type of arrow denotes the association relationship. For example, the arrow from Patient to Observation means that the two classes are associated with each other. Moreover, with the arrow going from Patient to Observation, it means that a Patient object has references to Observation objects associated with the Patient. A snapshot of the objects Note that each observation must be associated with an observation type. Thus, a snapshot of a patient’s data may look like what shown in the diagram below. 4 Task 1 – Implementing all the classes required to validate the design class diagram As the first step in the implementation process, it is desirable to validate the design class diagram. Toward this purpose, for Task 1, you are required to • Implement the classes in the design class diagram: Patient, ObservationType, MeasurementObservationType, CategoryObservationType, Observation, MeasurementObservation and CategoryObservation. Include all the necessary attributes and methods, which you need to identify • Implement a class, called PatientRecordSystem, that manages the data of the pa- tients and their records Operations required to be supported For the purpose of validating the design, the PatientRecordSystem class should provide the methods to perform the following operations: 1. Add a measurement observation type 2. Add a category observation type 3. Add a patient (enter details such as id, name) 4. Add a measurement observation (for a patient) 5. Add a category observation (for a patient) For testing purpose, as will be required for Task 2, the PatientRecordSystem should also have a toString method to display all the objects stored in the system. No Interactive Inputs The PatientRecordSystem class must be implemented in such a way that it can be tested by the program given in the Appendix without any changes. Thus, it should not take any interactive input. That is, it should not take any input by the user via the keyboard. Array Sizes Assume that we can have the maximum of 50 observation types, and the maximum of 100 patients. Functional Correctness Your classes are required to ensure that the following conditions are met: 1. No two observation types have the same code 2. No two patients have the same IDs 5 3. A patient can have at most one observation of a particular type 4. Observations and their associated observation types are compatible. For example, a category observation of a patient must be associated with a category observation type and the observation’s value must be one of the categories of that associated observation type When those conditions are violated, an exception of type Exception should be thrown. Task 2 – Testing the PatientRecordSystem class Test your PatientRecordSystem class with the test program provided in the appendix. Your classes should be implemented in such a way that the provided test program can be run without any changes. Try to make the output of the tests easy to read. Electronic Submission of Your Source Code • Submit – All the Java files that you have developed for Task 1 – A text file that contains all the test results for Task 2 • The code has to run under Unix on the latcs8 machine (which you normally log in through PuTTy). • You submit your files from your latcs8 account. • Submit each file separately using the submit command. For example, for the file called (say) Patient.java, use command: submit IOO Patient.java • After submitting the files, you can run the following command that lists the files submitted from your account: verify • You can submit the same filename as many times as you like before the assignment deadline; the previously submitted copy will be replaced by the latest one. How- ever, note carefully that any submissions after the deadline will make your whole assignment considered late. 6 Appendix – A Test Program As stated earlier, we should be able to run the test program below with your classes, without having to any changes to it. /* PatientRecordSystemTester.java */ import java.io.*; import java.util.*; public class PatientRecordSystemTester { public static void main(String [] args) throws Exception { testInit(); testAddObservationTypes(); testAddPatients(); testAddObservations(); } public static void testInit() { String test = "TEST: Create new patient record system and display it"; System.out.println(test); PatientRecordSystem prs = new PatientRecordSystem(); System.out.println(prs); } public static void testAddObservationTypes() throws Exception { PatientRecordSystem prs = new PatientRecordSystem(); // add a measurement observation type prs.addMeasurementObservationType("T100", "Blood Pressure", "psi"); System.out.println(prs); // add a measurement observation type with invalid code try { prs.addMeasurementObservationType("T100", "Height", "cm"); } catch(Exception e) { System.out.println(e.getMessage()); } finally { System.out.println(prs); } //add a category observation type String [] categories = {"Group A", "Group B1", "Group B2"}; prs.addCategoryObservationType("T200", "blood type", categories); System.out.println(prs); } 7 public static void testAddPatients() throws Exception { PatientRecordSystem prs = new PatientRecordSystem(); //add a new patient prs.addPatient("P100", "Smith"); System.out.println(prs); // add another patient prs.addPatient("P200", "Adams"); System.out.println(prs); // invalid request try { prs.addPatient("P200", "Blake"); } catch(Exception e) { System.out.println(e.getMessage()); } finally { System.out.println(prs); } } public static void testAddObservations() throws Exception { // Create PatientRecordSystem and add patients PatientRecordSystem prs = new PatientRecordSystem(); // add observation types prs.addMeasurementObservationType("T100", "Blood Pressure", "psi"); String [] categories = {"Group A", "Group B1", "Group B2"}; prs.addCategoryObservationType("T200", "blood type", categories); //add patients prs.addPatient("P100", "Smith"); prs.addPatient("P200", "Adams"); System.out.println(prs); // add a measurement observation to Smith’s records prs.addMeasurementObservation("P100", "T100", 120); System.out.println(prs); // add a category observation to Smith’s records prs.addCategoryObservation("P100", "T200", "Group A"); System.out.println(prs); // invalid request: patient already has
May 14, 2020
SOLUTION.PDF

Get Answer To This Question

Related Questions & Answers

More Questions »

Submit New Assignment

Copy and Paste Your Assignment Here