Menu

(Solved) : Patient Public Class Patient Int Pid Int Age Int Gender Double Height Double Weight Public Q29984814 . . .

You are required to write a java program that read the data file medicalRecords.txt that represent a set of medical readings. Your program should use the UML shown below. Description pf each class and interface are detailed below Patient Mapping Comparable Laboratory MedicalMapper

Patient :

——————–
public class Patient {

   int pid;
   int age;
   int gender;
   double height;
   double weight;
public Patient(){}
  
   public Patient (int pid,int age,int gender,doubleheight,double weight){
      
       pid = this.pid;
       age = this.age;
       gender = this.gender;
       height = this.height;
       weight = this.weight;
   }
  
   public double getBMI(){
       returnweight/Math.pow((height*0.1),2);
      
      
   }
  
}

======================================================================================================================

Mapping :

——————–

public interface Mapping {

   public abstract double mapBMI ();
   public abstract int mapBloodPressure ();
   public abstract int mapFBS (double fbs);
   public abstract int mapCholestrol (double chol);
   public abstract int mapHDL (double hdl);
   public abstract int mapLDL (double ldl);
   public abstract int getTG (double tg);
   public abstract int mapHB1AC (double hba1c);
  
  
}

===========================================================================================================

Laboratory:

———————–

public abstract class Laboratory extends Patient implements Mapping{

int sbp;
int dbp;
double fbs;
double chol;
double hdl;
double ldl;
double tg;
double hba1c;
public Laboratory(){}

public Laboratory (int pid,int age,int gender,doubleheight,double weight,
   int sbp, int dbp, double fbs, double chol, double hdl,double ldl,double tg, double hba1c   ){
  
   super(pid, age,gender,weight,height);
  

this.sbp =sbp;;
this.dbp=dbp;
this.fbs=fbs;
this.chol=chol;
this.hdl=hdl;
this.ldl=ldl;
this.tg=tg;
this.hba1c=hba1c;
}
  
  
  
}

=============================================================================================================

MedicalMapper:

—————————–

public class MedicalMapper extends Laboratory {
  
   int pid;
   int age;
   int gender;
   double weight;
   double height;
   int sbp;
   int dbp;
   double fbs;
   double chol;
   double ldl;
   double hdl;
   double tg;
   double hba1c;
  

   public MedicalMapper( int pid, int age, int gender,double weight, double height, int sbp, int dbp, double fbs,
           double chol,double ldl, double hdl, double tg, double hba1c) {
       super( pid, age,gender,height,weight, sbp, dbp, fbs, chol, hdl, ldl,tg, hba1c);
      
       this.pid=pid;
      
       this.age=age;
       this.gender=gender;
       this.weight=weight;
       this.height=height;
       this.sbp=sbp;
       this.dbp=dbp;
       this.fbs=fbs;
       this.chol=chol;
       this.ldl=ldl;
       this.hdl=hdl;
       this.tg=tg;
       this.hba1c=hba1c;
      
   }
public char convertGender(int gender){
       this.gender=gender;
       if ( gender == 1){
          
           return’M’;
       }
       else {
           return’F’;
       }
          
   }

public double mapBMI(){
  
   if (getBMI()>=0 &&getBMI()<18.0){return0.0;}
   else if (getBMI() <25.0) { return 1.0; }
   else if (getBMI()<30.0){ return 2.0;}
   else {return 3.0;}

}
public int mapBloodPressure(){
  
if (sbp<130 &&dbp<80)   { return 1;}
else if (sbp<=130&& dbp==80){return 2;}
else if (sbp>130&& dbp<100){return 3;}
else if (sbp>150&& dbp>100){return 4;}
else {return 5;}
  
  
}
public int mapFBS(double fbs){
   this.fbs=fbs;
   if(fbs >=70&& fbs<=110){return 1;}
   else if(fbs<141){return 2;}
   else if(fbs<201){return 3;}
   else if(fbs<301){return 4;}
   else {return 5;}
  
  
}
  
public int mapCholestrol (double chol){
   this.chol=chol;
  
   if (chol>=50&&chol<150){return 1;}
   else if (chol <185){return 2;}
   else if (chol <200){return 3;}
   else if (chol <250){return 4;}
   else {return 5;}
  
  
  
  
}

public int mapHDL(double hdl){
   this.hdl=hdl;
   if (hdl<40){return 5;}
   else if (hdl<60){return 4;}
   else if (hdl<75){return 3;}
   else if (hdl<100){return 2;}
   else { return 1;}
  
  
}

public int mapLDL(double ldl){
   this.ldl=ldl;
  
   if (ldl<100){return 1;}
   else if (ldl<130){return 2;}
   else if (ldl<160){return 3;}
   else if (ldl<190){return 4;}
   else {return 5;}
  
      
}
public int getTG(double tg){
   this.tg=tg;
  
   if (tg<150){return 1;}
   else if (tg<180){return 2;}
   else if (tg<200){return 3;}
   else if (tg<500){return 4;}
   else {return 5;}
  
}
public int mapHB1AC(double hba1c){
   this.hba1c=hba1c;
   if(hba1c>=4&& hba1c<=6){return 1;}
   else if (hba1c<=7){return 2;}
   else if (hba1c<=8){return 3;}
   else if (hba1c<=9){return 4;}
   else {return 5;}
  
  
}

public int getTotal(){
return   pid+age+gender;
  
  
}
  
}

==================================================================================================

*** (here I could not compelte it)Testclass:

——————–

import java.io.*;
import java.util.Scanner;
public class TestClass {

   public static void main(String[] args) throwsFileNotFoundException {
      
       //Files
       java.io.File medicalRecords = newjava.io.File(“src/medicalRecords.txt”);
       java.io.FileconvertedMedicalRecords = newjava.io.File(“src/convertedMedicalRecords.txt”);
       java.io.File binaryMedicalRecords =new java.io.File(“src/convertedMedicalRecords.dat”);
      
       //File Reader Objects
       Scanner medicalRecordsInput = newScanner(medicalRecords);
      
       //File Writer Objects
       java.io.PrintWritermedicalRecordsOutput = newjava.io.PrintWriter(convertedMedicalRecords);
       DataOutputStream dos = newDataOutputStream(newFileOutputStream(“src/convertedMedicalRecords.dat”));
      
      
       //Write to File Objects
      while(medicalRecordsInput.hasNext()){
          
          int pid =medicalRecordsInput.nextInt();
          int age =medicalRecordsInput.nextInt();
          int gender =medicalRecordsInput.nextInt();
          double weight =medicalRecordsInput.nextDouble();
          double height =medicalRecordsInput.nextDouble();
      
          int sbp =medicalRecordsInput.nextInt();
          int dbp =medicalRecordsInput.nextInt();
          double fbs =medicalRecordsInput.nextDouble();
          double chol =medicalRecordsInput.nextDouble();
          double ldl =medicalRecordsInput.nextDouble();
          double hdl =medicalRecordsInput.nextDouble();
          double tg =medicalRecordsInput.nextDouble();
          double hba1c =medicalRecordsInput.nextDouble();
      
          MedicalMapper m = newMedicalMapper(pid, age, gender, weight, height,
                 sbp, dbp, fbs, chol, hdl, ldl, tg,hba1c);
      
      
         medicalRecordsOutput.println(m.toString());
       try {
          
          
          dos.writeUTF(m.toString());
       } catch (IOException e) {
          e.printStackTrace();
       }
             
             
      
       }
      
      
       medicalRecordsOutput.close();
       medicalRecordsInput.close();
     
   }
   // Reading the outuput
  
}

==============================================================

medicalRecords.txt

—————————-

1002 53 1 82 169 120 80 237.6 239.0 177.6 42.5 885.8 7.41004 53 1 83.7 169 110 70 160.2 173.4 115.8 44.0 73.5 8.21006 48 1 81.1 158 130 70 102.6 173.4 100.4 61.8 73.5 5.21008 55 1 83.5 174 120 85 192.6 170.7 112.0 40.9 86.7 10.91010 55 1 83.4 174 130 90 172.8 154.1 100.4 37.1 108.8 9.61012 43 1 69.6 169 110 80 129.6 182.2 112.0 34.0 195.6 8.91014 35 2 91 154 130 90 203.4 215.4 115.8 66.4 169.9 9.81016 36 2 85 154 110 70 180 184.9 100.4 55.2 148.7 9.61018 43 2 60.3 157 130 80 199.8 268.3 200.8 49.4 100.9 10.71020 56 1 64.7 170 130 80 252 108.5 61.8 31.7 77.9 10.21022 38 1 77.7 178 130 70 118.8 165.3 96.5 32.0 188.5 8.91024 39 1 77.9 178 150 80 108 127.4 73.4 26.6 138.1 9.21026 78 2 60 166 150 80 154.8 145.9 104.2 35.5 129.2 71028 61 2 61.4 148 130 70 154.8 193.4 104.2 54.4 173.5 61030 62 2 62 148 110 80 144 205.8 115.8 55.2 423.9 7.11032 55 1 84 156 110 70 57.6 209.3 146.7 34.4 133.6 6.31034 56 1 84 156 130 80 270 262.5 196.9 45.9 102.7 10.41036 67 1 85 160 120 70 115.2 187.6 112.0 73.0 114.2 7.91038 56 2 60 146 120 80 135 214.3 112.0 74.9 143.4 8.21040 61 1 66 169 130 80 138.6 154.1 96.5 39.4 89.4 7.51042 58 2 45.5 153 110 70 234 264.9 181.5 52.1 149.6 9.61044 59 2 46.4 153 130 80 340.2 189.2 92.7 50.2 230.1 91046 60 1 70 161 130 80 126 198.1 131.3 45.2 112.4 5.71048 63 1 61.2 154 110 70 126 227.8 154.4 46.7 139.8 61050 37 1 64 176 110 70 198 212.4 131.3 37.1 223.0 10.21052 44 2 66 145 110 70 174.6 159.1 88.8 44.8 123.9 8.21054 45 2 66 145 110 80 108 173.7 115.8 37.1 105.3 6.91056 36 1 95 160 140 80 136.8 223.2 150.6 38.6 81.4 8.21058 37 1 95 160 140 80 136.8 203.9 150.6 38.6 81.4 8.21060 73 1 70.3 155 130 70 133.2 130.1 69.5 34.4 134.5 7.71062 74 1 69.5 155 110 70 142.2 146.7 81.1 36.7 143.4 6.81064 52 1 60 152 130 80 235.8 135.9 84.9 26.3 115.0 9.131066 53 1 63.5 152 110 70 106.2 138.6 81.1 30.9 135.4 7.41068 57 2 60.9 166 140 90 176.4 255.2 154.4 55.6 227.4 91070 59 2 59.6 166 130 80 196.2 286.5 189.2 59.5 183.2 8.91072 69 1 59 153 150 90 129.6 204.6 139.0 44.8 105.3 10.21074 64 1 68.8 154 130 70 216 181.5 119.7 50.2 60.2 11.31076 65 1 68.6 154 110 70 163.8 192.7 127.4 42.1 108.0 8.31078 53 1 93 179 140 90 165.6 179.2 104.2 36.7 185.8 7.71080 78 2 55 131 110 70 264.6 166.4 115.8 34.4 69.9 6.51082 50 2 65.5 148 150 90 178.2 205.4 135.1 13.1 198.2 8.81084 50 2 63.9 148 110 70 162 243.2 173.7 32.4 398.2 111086 31 1 83 176 120 70 156.6 187.3 119.7 45.6 117.7 4.61088 43 2 71.5 159 130 80 205.2 247.5 162.2 63.3 113.3 8.41090 43 2 68.3 159 110 70 228.6 208.5 115.8 58.7 145.1 9.21092 43 2 68.5 159 110 70 214.2 185.3 104.2 59.8 108.0 9.21094 69 2 71.7 151 110 70 297 213.5 139.0 40.9 175.2 141096 70 2 71.2 151 130 80 271.8 243.2 166.0 44.0 173.5 9.41098 66 1 54 157 140 90 198 189.2 112.0 54.8 121.2 6.61100 66 1 70.6 157 170 100 97.2 189.2 112.0 54.8 115.0 6.21102 66 1 69.4 157 150 80 88.2 196.9 115.8 58.3 112.4 6.31104 63 2 71.7 156 110 70 297 213.5 139.0 40.9 173.5 141106 63 1 62 156 120 80 178.2 186.1 112.0 35.1 256.6 5.91108 88 1 89.8 165 120 70 149.4 170.3 77.2 45.6 230.1 9.31110 88 1 92.9 165 110 70 131.4 147.9 85.3 34.0 168.1 7.21112 88 1 97.2 165 130 80 108 173.7 73.4 33.6 334.5 7.11114 58 2 72 170 120 80 126 178.0 84.9 36.7 285.8 6.71116 58 2 72.6 170 140 70 140.4 132.0 50.2 30.5 261.1 6.71118 53 2 62.3 155 140 80 102.6 205.0 119.7 41.3 214.2 5.71120 53 2 61.7 155 120 70 162 212.0 127.4 51.7 155.8 8.31122 41 2 64.7 148 110 70 270 201.9 131.3 54.8 83.2 10.61124 50 2 81.7 153 110 70 244.8 178.4 115.8 42.1 108.8 11.31126 53 2 67.8 149 110 70 144 216.2 127.4 57.9 44.2 5.31128 55 1 64.8 153 110 70 140.4 192.3 115.8 46.7 142.5 6.41130 55 1 64 153 130 80 142.2 196.5 123.6 43.6 146.0 6.11132 73 1 48.2 160 110 70 144 215.8 150.6 59.5 134.5 6.81134 63 1 68 171 110 70 192.6 239.4 177.6 34.7 123.9 12.11136 63 1 65.9 171 120 80 212.4 223.9 154.4 35.1 178.8 10.91138 58 1 94 166 110 70 185.4 134.0 69.5 33.6 163.7 71140 58 1 90.8 166 120 80 156.6 120.5 57.9 25.1 192.0 6.31142 58 1 91 166 110 70 153 131.3 65.6 30.1 175.2 6.31144 83 1 73 160 120 80 176.4 181.5 127.4 39.0 68.1 6.91146 33 2 51.6 153 110 70 171 154.4 52.1 61.8 70.8 101148 33 2 53 153 120 80 169.2 162.2 92.7 52.1 100.0 8.61150 63 1 98.8 159 130 90 124.2 156.0 73.4 36.7 231.0 6.11152 63 1 96.9 159 140 90 153 169.9 84.9 33.2 259.3 5.71154 57 2 83.2 143 150 90 135 197.3 139.0 54.1 141.6 6.41156 57 2 79.5 143 140 80 140.4 209.7 104.2 76.8 142.5 5.61158 49 1 74.5 166 130 90 115.56 247.9 177.6 53.7 75.2 6.51160 63 2 66.5 164 170 90 149.4 162.2 81.1 81.1 194.7 6.21162 63 2 65.8 164 130 70 201.6 216.2 108.1 40.2 334.5 8.51164 55 2 35.5 137 130 80 156.6 208.5 129.7 52.5 117.7 6.91166 55 2 35.3 137 110 60 147.6 191.1 108.1 63.7 89.4 7.51168 63 2 53 150 110 70 120.6 93.1 42.5 57.1 66.4 8.51170 43 2 46 157 130 80 280.8 234.0 135.1 69.5 132.7 6.41172 43 2 46.6 157 110 70 133.2 204.6 139.0 30.1 185.8 7.51174 43 1 69.9 169 110 80 129.6 182.2 112.0 34.0 195.6 8.9

==========================================================

I did all the classes except the testClass I dontknow how to make the output look like the required….. PLEASE HELPME

You are required to write a java program that read the data file medicalRecords.txt that represent a set of medical readings. Your program should use the UML shown below. Description pf each class and interface are detailed below Patient Mapping Comparable Laboratory MedicalMapper Show transcribed image text

Expert Answer


Answer to Patient Public Class Patient Int Pid Int Age Int Gender Double Height Double Weight Public Q29984814 . . .

OR