Charles Tritt / Mbed 2 deprecated PatientStructure

Dependencies:   mbed

Fork of test_patient_structure by MSOE EE2905

Committer:
CSTritt
Date:
Thu Nov 02 21:22:34 2017 +0000
Revision:
1:060801821b1c
Parent:
0:c435f76658b2
Initial version. Based on demo program by Dr. Sheila Ross.

Who changed what in which revision?

UserRevisionLine numberNew contents of line
CSTritt 1:060801821b1c 1 /*
CSTritt 1:060801821b1c 2 Project: PatientStructure (based on very similar example by Dr. Ross.)
CSTritt 1:060801821b1c 3 File: main.cpp (file v. 1.0)
CSTritt 1:060801821b1c 4 Modified by by: Dr. C. S. Tritt
CSTritt 1:060801821b1c 5 Last revision on: 11/2/17 (Project v. 1.0)
CSTritt 1:060801821b1c 6
CSTritt 1:060801821b1c 7 Simulates a patient database. See comments in patients.cpp regarding purpose
CSTritt 1:060801821b1c 8 use of each function. This function just populates the database and initates
CSTritt 1:060801821b1c 9 update of one record.
CSTritt 1:060801821b1c 10
CSTritt 1:060801821b1c 11 This program is for demonstration only. Input is not validated and array
CSTritt 1:060801821b1c 12 limits are not checked. This is bad programming practice, but okay for "toy"
CSTritt 1:060801821b1c 13 programs like this.
CSTritt 1:060801821b1c 14 */
CSTritt 1:060801821b1c 15
rossatmsoe 0:c435f76658b2 16 #include "mbed.h"
rossatmsoe 0:c435f76658b2 17 #include "patients.h"
rossatmsoe 0:c435f76658b2 18
CSTritt 1:060801821b1c 19 // Some functions use the serial monitor so define it here. Declare as extern
CSTritt 1:060801821b1c 20 // in header file.
CSTritt 1:060801821b1c 21 Serial pc(USBTX,USBRX);
CSTritt 1:060801821b1c 22
rossatmsoe 0:c435f76658b2 23 //Pretend we have a pulse oximeter attached to A0 which provides the SpO2
rossatmsoe 0:c435f76658b2 24 //as a fraction.
rossatmsoe 0:c435f76658b2 25 AnalogIn pulse_oximeter(A0);
rossatmsoe 0:c435f76658b2 26
rossatmsoe 0:c435f76658b2 27 int main()
rossatmsoe 0:c435f76658b2 28 {
CSTritt 1:060801821b1c 29 pc.printf("\nWelcome to PatientStructure Example.\n");
CSTritt 1:060801821b1c 30 pc.printf("Turn local echo on!\n");
CSTritt 1:060801821b1c 31 // Create an array of patient_record structures to form the patient
CSTritt 1:060801821b1c 32 // database.
CSTritt 1:060801821b1c 33 pc.printf("About to create and populate database...\n");
rossatmsoe 0:c435f76658b2 34 struct patient_record all_patients[MAX_PATIENTS];
rossatmsoe 0:c435f76658b2 35 // Keep track of the number of patients.
rossatmsoe 0:c435f76658b2 36 int enrollment=0;
rossatmsoe 0:c435f76658b2 37
rossatmsoe 0:c435f76658b2 38 //Add patient info.
rossatmsoe 0:c435f76658b2 39 newPatient(&(all_patients[enrollment]),"George","Washington");
rossatmsoe 0:c435f76658b2 40 enrollment++;
rossatmsoe 0:c435f76658b2 41
rossatmsoe 0:c435f76658b2 42 newPatient(&(all_patients[enrollment]),"John","Adams");
rossatmsoe 0:c435f76658b2 43 enrollment++;
rossatmsoe 0:c435f76658b2 44
rossatmsoe 0:c435f76658b2 45 newPatient(&(all_patients[enrollment]),"Thomas","Jefferson");
CSTritt 1:060801821b1c 46 enrollment++; // Enrollment incr. an extra time. Its the # of pateints.
rossatmsoe 0:c435f76658b2 47
CSTritt 1:060801821b1c 48 //Look up a patient -- this one is not in our database.
CSTritt 1:060801821b1c 49 pc.printf("About to lookup non-existent patient...\n");
CSTritt 1:060801821b1c 50 int X = lookup_patient_name(all_patients, "Abraham", "Lincoln");
CSTritt 1:060801821b1c 51 pc.printf("Abraham Lincoln is patient %d\n", X);
rossatmsoe 0:c435f76658b2 52
rossatmsoe 0:c435f76658b2 53 //Look up a patient.
CSTritt 1:060801821b1c 54 pc.printf("About to lookup valid patient...\n");
CSTritt 1:060801821b1c 55 int Y = lookup_patient_name(all_patients, "Thomas", "Jefferson");
CSTritt 1:060801821b1c 56 pc.printf("Thomas Jefferson is patient %d\n", Y);
rossatmsoe 0:c435f76658b2 57
rossatmsoe 0:c435f76658b2 58 //Enter patient's vitals.
CSTritt 1:060801821b1c 59 pc.printf("About to interactively update patient data...\n");
CSTritt 1:060801821b1c 60 pc.printf("There are %d patients in the database. Be careful!\n",
CSTritt 1:060801821b1c 61 enrollment);
rossatmsoe 0:c435f76658b2 62 recordBPinteractive(all_patients, pulse_oximeter);
CSTritt 1:060801821b1c 63
CSTritt 1:060801821b1c 64 pc.printf("Done. I sleep now...\n");
CSTritt 1:060801821b1c 65 while(true) wait(3600); // Loop here forever, waiting an hour at a time.
rossatmsoe 0:c435f76658b2 66 }