Charles Tritt / Mbed 2 deprecated PatientStructure

Dependencies:   mbed

Fork of test_patient_structure by MSOE EE2905

Committer:
rossatmsoe
Date:
Thu Nov 02 18:31:39 2017 +0000
Revision:
0:c435f76658b2
Child:
1:060801821b1c
Demonstration of the use of structures in C.  Inspiration to learn object-oriented programming for a more elegant solution.

Who changed what in which revision?

UserRevisionLine numberNew contents of line
rossatmsoe 0:c435f76658b2 1 #include "mbed.h"
rossatmsoe 0:c435f76658b2 2 #include "patients.h"
rossatmsoe 0:c435f76658b2 3
rossatmsoe 0:c435f76658b2 4 //Pretend we have a pulse oximeter attached to A0 which provides the SpO2
rossatmsoe 0:c435f76658b2 5 //as a fraction.
rossatmsoe 0:c435f76658b2 6 AnalogIn pulse_oximeter(A0);
rossatmsoe 0:c435f76658b2 7
rossatmsoe 0:c435f76658b2 8 int main()
rossatmsoe 0:c435f76658b2 9 {
rossatmsoe 0:c435f76658b2 10 // Create an array of patient_record structures to form the patient database.
rossatmsoe 0:c435f76658b2 11 struct patient_record all_patients[MAX_PATIENTS];
rossatmsoe 0:c435f76658b2 12 // Keep track of the number of patients.
rossatmsoe 0:c435f76658b2 13 int enrollment=0;
rossatmsoe 0:c435f76658b2 14
rossatmsoe 0:c435f76658b2 15 //Add patient info.
rossatmsoe 0:c435f76658b2 16 newPatient(&(all_patients[enrollment]),"George","Washington");
rossatmsoe 0:c435f76658b2 17 enrollment++;
rossatmsoe 0:c435f76658b2 18
rossatmsoe 0:c435f76658b2 19 newPatient(&(all_patients[enrollment]),"John","Adams");
rossatmsoe 0:c435f76658b2 20 enrollment++;
rossatmsoe 0:c435f76658b2 21
rossatmsoe 0:c435f76658b2 22 newPatient(&(all_patients[enrollment]),"Thomas","Jefferson");
rossatmsoe 0:c435f76658b2 23 enrollment++;
rossatmsoe 0:c435f76658b2 24
rossatmsoe 0:c435f76658b2 25 //Look up a patient--this one is not in our database.
rossatmsoe 0:c435f76658b2 26 int X=lookup_patient_name(all_patients,"Abraham","Lincoln");
rossatmsoe 0:c435f76658b2 27 pc.printf("Abraham Lincoln is patient %d\n",X);
rossatmsoe 0:c435f76658b2 28
rossatmsoe 0:c435f76658b2 29 //Look up a patient.
rossatmsoe 0:c435f76658b2 30 int Y=lookup_patient_name(all_patients,"Thomas","Jefferson");
rossatmsoe 0:c435f76658b2 31 pc.printf("Thomas Jefferson is patient %d\n",Y);
rossatmsoe 0:c435f76658b2 32
rossatmsoe 0:c435f76658b2 33 //Enter patient's vitals.
rossatmsoe 0:c435f76658b2 34 recordBPinteractive(all_patients, pulse_oximeter);
rossatmsoe 0:c435f76658b2 35
rossatmsoe 0:c435f76658b2 36 while(1);
rossatmsoe 0:c435f76658b2 37
rossatmsoe 0:c435f76658b2 38
rossatmsoe 0:c435f76658b2 39 }