Class DoctorMenu

java.lang.Object
cz.cuni.kubinja.hospitalsystem.UI.DoctorMenu
All Implemented Interfaces:
Page, PersonnelMenu

public class DoctorMenu extends Object implements PersonnelMenu
Menu page containing options connected with doctors.
  • Field Summary

    Fields
    Modifier and Type
    Field
    Description
    protected Hospital
    Connection to the hospital system
    protected static final String
    Sequence that forcefully stop entering data
    protected List<cz.cuni.kubinja.hospitalsystem.UI.MenuEntry>
    Options of the menu page
    protected Scanner
    Scanner pointing to the input data
    protected UIState
    State in which menu page is
  • Constructor Summary

    Constructors
    Constructor
    Description
    DoctorMenu(Hospital api, Scanner scanner)
    Creates doctor menu page.
  • Method Summary

    Modifier and Type
    Method
    Description
    void
    add()
    Processes input data and calls for creating of new doctor in hospital system.
    protected void
    addOption(String text, Runnable action)
    Adds new option into the menu.
    void
    all()
    Prints data about every doctor in hospital system.
    void
    Clears console with appropriate command based on OS
    boolean
    Checks whether the user wants to create new object.
    void
    Defines which options should menu provide and how will be mapped options to the functions.
    void
    Processes scanner input for identification number and afterward deletes doctor with this id.
    void
    Processes input data and edits doctor with the provided ID.
    protected void
    end()
    Sets state of the menu to the end.
    void
    Processes scanner input for identification number and afterward prints data about this doctor.
    boolean
    getBool(String question)
    Processes input from scanner and returns value after processing first line that contains some text that can be converted to bool value.
    getDate(String question)
    Processes input and extracts first line containing valid date (int format YYYY-MM-DD)
    getDate(String question, LocalDate defaultValue)
    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.
    Processes input and extracts valid information into doctors details data wrapper.
    int
    getInteger(String question)
    Processes input and extracts first valid integer.
    int
    getOption(int range)
    Processes input and returns extracted option.
    Processes input and extracts valid information into patient details data wrapper.
    Processes input and extracts valid information into patient details data wrapper.
    Processes input and extracts valid information into Person data wrapper.
    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.
    getString(String question)
    Processes input and extracts first not empty line.
    getString(String question, String defaultValue)
    Processes input and extracts first not empty line.
    void
    Prints text and wait for the confirmation action from the user.
    void
    Shows menu options in terminal.
    void
    Processes the user option based on page menu.
    boolean
    Processes packet status and prints the resolved status.
    boolean
    Processes packet status and prints the status if the API request was not successful.
    void
    Show waiting text and prompts user into pressing any key.

    Methods inherited from class Object

    clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
  • Field Details

    • api

      protected Hospital api
      Connection to the hospital system
    • scanner

      protected Scanner scanner
      Scanner pointing to the input data
    • options

      protected List<cz.cuni.kubinja.hospitalsystem.UI.MenuEntry> options
      Options of the menu page
    • state

      protected UIState state
      State in which menu page is
    • exitSequence

      protected static final String exitSequence
      Sequence that forcefully stop entering data
      See Also:
  • Constructor Details

    • DoctorMenu

      public DoctorMenu(Hospital api, Scanner scanner)
      Creates doctor menu page.
      Parameters:
      api - HospitalAPI giving the menu options how to interact with hospital system.
      scanner - Scanner pointing to the input data.
  • Method Details

    • defineMenu

      public void defineMenu()
      Description copied from interface: Page
      Defines which options should menu provide and how will be mapped options to the functions.
      Specified by:
      defineMenu in interface Page
    • add

      public void add()
      Processes input data and calls for creating of new doctor in hospital system.
      Specified by:
      add in interface PersonnelMenu
    • edit

      public void edit()
      Processes input data and edits doctor with the provided ID.
      Specified by:
      edit in interface PersonnelMenu
    • delete

      public void delete()
      Processes scanner input for identification number and afterward deletes doctor with this id.
      Specified by:
      delete in interface PersonnelMenu
    • findById

      public void findById()
      Processes scanner input for identification number and afterward prints data about this doctor.
      Specified by:
      findById in interface PersonnelMenu
    • all

      public void all()
      Prints data about every doctor in hospital system.
      Specified by:
      all in interface PersonnelMenu
    • printMenu

      public void printMenu()
      Description copied from interface: Page
      Shows menu options in terminal.
      Specified by:
      printMenu in interface Page
    • processMenu

      public void processMenu()
      Description copied from interface: Page
      Processes the user option based on page menu.
      Specified by:
      processMenu in interface Page
    • addOption

      protected void addOption(String text, Runnable action)
      Adds new option into the menu.
      Parameters:
      text - Text of the option.
      action - Action that will be called every time the option is selected.
    • 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

      public PersonData getPersonData(Person person)
      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

      public PersonData getPersonData()
      Processes input and extracts valid information into Person data wrapper.
      Returns:
      Person data wrapper containing data for person creation.
    • getPatientDetails

      public PatientsDetails getPatientDetails(Patient patient)
      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

      public PatientsDetails getPatientDetails()
      Processes input and extracts valid information into patient details data wrapper.
      Returns:
      Patient details data wrapper.
    • getDoctorDetails

      public DoctorDetails getDoctorDetails(Doctor doctor)
      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

      public DoctorDetails getDoctorDetails()
      Processes input and extracts valid information into doctors details data wrapper.
      Returns:
      Doctor details data wrapper.
    • getQuestion

      public String getQuestion(String question)
      Returns question, where the default value is not present.
      Parameters:
      question - Text of the question.
      Returns:
      question, where the default value is not present.
    • getQuestion

      public String getQuestion(String question, String defaultValue)
      Returns question, where will be displayed default value.
      Parameters:
      question - Text of the question.
      defaultValue - Default value for the question.
      Returns:
      Question, where will be displayed default value.
    • clearConsole

      public void clearConsole()
      Clears console with appropriate command based on OS
    • getInteger

      public int getInteger(String question)
      Processes input and extracts first valid integer.
      Parameters:
      question - Question with which will be user prompted.
      Returns:
      Valid integer.
    • getString

      public String getString(String question, String defaultValue)
      Processes input and extracts first not empty line.
      Parameters:
      question - Question with which will be user prompted.
      defaultValue - Default value that will be suggested to the user.
      Returns:
      Not empty string.
    • getString

      public String getString(String question)
      Processes input and extracts first not empty line.
      Parameters:
      question - Question with which will be user prompted.
      Returns:
      First not empty line.
    • getDate

      public LocalDate getDate(String question, LocalDate defaultValue)
      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

      public LocalDate getDate(String question)
      Processes input and extracts first line containing valid date (int format YYYY-MM-DD)
      Parameters:
      question - Question with which will be user prompted.
      Returns:
      LocalDate object containing valid date.
    • getDateTime

      public LocalDateTime getDateTime(String question)
      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

      public boolean createNew(String what)
      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

      public boolean getBool(String question)
      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

      public void printAndWait(String text)
      Prints text and wait for the confirmation action from the user.
      Parameters:
      text - Text that will be displayed.
    • processPacketStatus

      public boolean processPacketStatus(GeneralPacket packet)
      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

      public boolean processPacketStatusInSilence(GeneralPacket packet)
      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.