How to generate random Patient ID numbers?

4 visualizaciones (últimos 30 días)
Emily Czopek
Emily Czopek el 13 de Sept. de 2022
Comentada: Emily Czopek el 13 de Sept. de 2022
Hello, I'm trying to create a GUI for a patient intake form in the research lab I work in. I need to be able to assign the patient a random number ID to refer to them by for patient confidentiality. I'm trying to use App Designer for this (I've inserted my code below, excluding what app designer does for you). I've only just started so I don't have all the info they need to put in added yet, but I keep getting an error of "Error using save 'app.PatientID' is not a valid variable name.". I would want to be able to save that patient info into another file with that patient ID as the file name. Any help with that would be appreciated! Please let me know if what I said doesn't make sense.
classdef Patient_Intake_Form < matlab.apps.AppBase
% Properties that correspond to app components
properties (Access = public)
UIFigure matlab.ui.Figure
PatientIntakeFormLabel matlab.ui.control.Label
FirstNameEditFieldLabel matlab.ui.control.Label
FirstNameEditField matlab.ui.control.EditField
LastNameEditFieldLabel matlab.ui.control.Label
LastNameEditField matlab.ui.control.EditField
WeightlbsEditFieldLabel matlab.ui.control.Label
WeightlbsEditField matlab.ui.control.NumericEditField
DOBDatePickerLabel matlab.ui.control.Label
DOBDatePicker matlab.ui.control.DatePicker
SaveButton matlab.ui.control.Button
HeightinEditFieldLabel matlab.ui.control.Label
HeightinEditField matlab.ui.control.NumericEditField
PatientIDDonotfillinEditFieldLabel matlab.ui.control.Label
PatientIDDonotfillinEditField matlab.ui.control.NumericEditField
end
properties (Access = private)
PatientID
FirstName
LastName
Weight
Height
DOB
% Description
end
% Callbacks that handle component events
methods (Access = private)
% Button pushed function: SaveButton
function SaveButtonPushed(app, event)
save('PatientID.mat','app.PatientID','app.FirstName','app.LastName','app.Weight','app.Height','app.DOB')
publish('PatientID.mat')
end
% Value changed function: FirstNameEditField
function FirstNameEditFieldValueChanged(app, event)
app.FirstName = app.FirstNameEditField.Value;
end
% Value changed function: LastNameEditField
function LastNameEditFieldValueChanged(app, event)
app.LastName = app.LastNameEditField.Value;
end
% Value changed function: WeightlbsEditField
function WeightlbsEditFieldValueChanged(app, event)
app.Weight = app.WeightlbsEditField.Value;
end
% Value changed function: HeightinEditField
function HeightinEditFieldValueChanged(app, event)
app.Height = app.HeightinEditField.Value;
end
% Value changed function: DOBDatePicker
function DOBDatePickerValueChanged(app, event)
app.DOB = app.DOBDatePicker.Value;
end
% Value changed function: PatientIDDonotfillinEditField
function PatientIDDonotfillinEditFieldValueChanged(app, event)
rng('shuffle');
app.PatientIDDonotfillinEditField.Value = rand(1);
app.PatientID = app.PatientIDDonotfillinEditField.Value;
end
end

Respuesta aceptada

Rik
Rik el 13 de Sept. de 2022
The save function has two modes: saving variables and saving a struct.
The easiest way to solve this error is to store the data in separate variables and save those.
Like this:
PatientID=app.PatientID;
save('PatientID.mat','PatientID')

Más respuestas (0)

Categorías

Más información sobre Develop Apps Using App Designer en Help Center y File Exchange.

Productos


Versión

R2019a

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by