Class PatientMenu
java.lang.Object
cz.cuni.kubinja.hospitalsystem.UI.PatientMenu
- All Implemented Interfaces:
Page, PersonnelMenu
Menu page containing options connected with patients.
-
Field Summary
FieldsModifier and TypeFieldDescriptionprotected HospitalConnection to the hospital systemprotected static final StringSequence that forcefully stop entering dataprotected List<cz.cuni.kubinja.hospitalsystem.UI.MenuEntry> Options of the menu pageprotected ScannerScanner pointing to the input dataprotected UIStateState in which menu page is -
Constructor Summary
ConstructorsConstructorDescriptionPatientMenu(Hospital api, Scanner scanner) Creates patient menu page.PatientMenu(Hospital api, Scanner scanner, boolean dummy) Creates dummy patient menu page. -
Method Summary
Modifier and TypeMethodDescriptionvoidadd()Processes input data and calls for creating of new patient in hospital system.protected voidAdds new option into the menu.voidall()Prints all patients in the hospital system.voidClears console with appropriate command based on OSbooleanChecks whether the user wants to create new object.voidDefines which options should menu provide and how will be mapped options to the functions.voiddelete()Delete patient based on provided ID.voidedit()Processes input about patient and updates data for the patient with the provided id.protected voidend()Sets state of the menu to the end.voidfindById()Prints information about patient with provided ID.booleanProcesses input from scanner and returns value after processing first line that contains some text that can be converted to bool value.Processes input and extracts first line containing valid date (int format YYYY-MM-DD)Processes input and extracts first line containing valid date (in format YYYY-MM-DD)getDateTime(String question) Processes input and extracts first line containing valid date and time.Processes input and extracts valid information into doctors details data wrapper.getDoctorDetails(Doctor doctor) Processes input and extracts valid information into doctors details data wrapper.intgetInteger(String question) Processes input and extracts first valid integer.intgetOption(int range) Processes input and returns extracted option.Processes input and extracts valid information into patient details data wrapper.getPatientDetails(Patient patient) Processes input and extracts valid information into patient details data wrapper.Processes input and extracts valid information into Person data wrapper.getPersonData(Person person) Processes input and extracts valid information into Person data wrapper.getQuestion(String question) Returns question, where the default value is not present.getQuestion(String question, String defaultValue) Returns question, where will be displayed default value.Processes input and extracts first not empty line.Processes input and extracts first not empty line.voidprintAndWait(String text) Prints text and wait for the confirmation action from the user.voidShows menu options in terminal.voidProcesses the user option based on page menu.booleanprocessPacketStatus(GeneralPacket packet) Processes packet status and prints the resolved status.booleanProcesses packet status and prints the status if the API request was not successful.voidShow waiting text and prompts user into pressing any key.
-
Field Details
-
api
Connection to the hospital system -
scanner
Scanner pointing to the input data -
options
Options of the menu page -
state
State in which menu page is -
exitSequence
-
-
Constructor Details
-
PatientMenu
-
PatientMenu
Creates dummy patient menu page.This way how to create menu is only used for testing, because we want to have option how to call directly menu options and not only via prepared input data.
- Parameters:
api- Hospital gives menu options how to interact with hospital system.scanner- Scanner pointing to the input data.dummy- Decides whether the menu page will be dummy (do not show menu, but only processes direct method calls)
-
-
Method Details
-
defineMenu
public void defineMenu()Description copied from interface:PageDefines which options should menu provide and how will be mapped options to the functions.- Specified by:
defineMenuin interfacePage
-
add
public void add()Processes input data and calls for creating of new patient in hospital system.- Specified by:
addin interfacePersonnelMenu
-
edit
public void edit()Processes input about patient and updates data for the patient with the provided id.- Specified by:
editin interfacePersonnelMenu
-
delete
public void delete()Delete patient based on provided ID.- Specified by:
deletein interfacePersonnelMenu
-
findById
public void findById()Prints information about patient with provided ID.ID is provided via input data in class scanner.
- Specified by:
findByIdin interfacePersonnelMenu
-
all
public void all()Prints all patients in the hospital system.- Specified by:
allin interfacePersonnelMenu
-
printMenu
-
processMenu
public void processMenu()Description copied from interface:PageProcesses the user option based on page menu.- Specified by:
processMenuin interfacePage
-
addOption
-
end
protected void end()Sets state of the menu to the end. -
getOption
public int getOption(int range) Processes input and returns extracted option.- Parameters:
range- Upper bound for not zero positive range of options, thus (0, range]- Returns:
- First valid option in the input stream.
-
getPersonData
Processes input and extracts valid information into Person data wrapper.- Parameters:
person- Person whose data will be user as the default values.- Returns:
- Wrapper containing data for Person creating (without id)
-
getPersonData
Processes input and extracts valid information into Person data wrapper.- Returns:
- Person data wrapper containing data for person creation.
-
getPatientDetails
Processes input and extracts valid information into patient details data wrapper.- Parameters:
patient- Patient object that will be used as default values.- Returns:
- Patient details data wrapper.
-
getPatientDetails
Processes input and extracts valid information into patient details data wrapper.- Returns:
- Patient details data wrapper.
-
getDoctorDetails
Processes input and extracts valid information into doctors details data wrapper.- Parameters:
doctor- Doctor object that will be used as default values.- Returns:
- Doctors details data wrapper.
-
getDoctorDetails
Processes input and extracts valid information into doctors details data wrapper.- Returns:
- Doctor details data wrapper.
-
getQuestion
-
getQuestion
-
clearConsole
public void clearConsole()Clears console with appropriate command based on OS -
getInteger
Processes input and extracts first valid integer.- Parameters:
question- Question with which will be user prompted.- Returns:
- Valid integer.
-
getString
-
getString
-
getDate
Processes input and extracts first line containing valid date (in format YYYY-MM-DD)- Parameters:
question- Question with which will be user prompted.defaultValue- Default value that will be suggested to the user.- Returns:
- LocalDate object containing valid date.
-
getDate
-
getDateTime
Processes input and extracts first line containing valid date and time.(in format YYYY-MM-DDTHH:MM or YYYY-MM-DD HH:MM)
- Parameters:
question- Question with which will be user prompted.- Returns:
- LocalDateTime object containing valid date and time.
-
createNew
Checks whether the user wants to create new object.- Parameters:
what- The object in question.- Returns:
- Whether the user wants to create new object.
-
getBool
Processes input from scanner and returns value after processing first line that contains some text that can be converted to bool value.- Parameters:
question- Question with which will be user prompted.- Returns:
- Value after processing first line that contains some text that can be converted to bool value.
-
waitForEnter
public void waitForEnter()Show waiting text and prompts user into pressing any key. -
printAndWait
Prints text and wait for the confirmation action from the user.- Parameters:
text- Text that will be displayed.
-
processPacketStatus
Processes packet status and prints the resolved status.- Parameters:
packet- Packet that will be processed.- Returns:
- Whether the packet came from successful API request.
-
processPacketStatusInSilence
Processes packet status and prints the status if the API request was not successful.- Parameters:
packet- Packet that will be processed.- Returns:
- Whether the packet came from successful API request.
-