Create a simple application for the hospital patient queue system. The application will be used by the Hospital receptionist. Since this is still a prototype, the UI is still using the console on terminal view. The command is also pretty simple, for incoming patients, the receptionist just needs to type IN <MRNumber> <Gender>
. The <MRNumber>
format will be prefixed with MR
and followed with a 4-digit number, for example: MR2023
, and <Gender>
will be 1-character F
for female and M
for male. For instance when a female patient with MRNumber MR2015 comes, the receptionist will type: IN MR2015 M
. <MRNumber>
should be unique per patient. The queue using FIFO ordering by default. When the counselling room is free, the receptionist will dispatch the patient with command: OUT
. Occasionally the receptionist needs to change the ordering system into round-robin Gender, to dispatch consecutive patients with different gender with FIFO if available. To change the ordering system the receptionist must type ROUNDROBIN
and to change back into default by typing: DEFAULT
. You may add another command as needed, and you can print out some information after the receptionist enters a command. And to quit the application, the receptionist will type: EXIT
.
Result of this script:
$ go run app.go
Enter command: IN MR0001 M
Patient MR0001 added to the queue.
[{MR0001 M}]
Enter command: IN MR0002 M
Patient MR0002 added to the queue.
[{MR0001 M} {MR0002 M}]
Enter command: IN MR0003 M
Patient MR0003 added to the queue.
[{MR0001 M} {MR0002 M} {MR0003 M}]
Enter command: IN MR0004 F
Patient MR0004 added to the queue.
[{MR0001 M} {MR0002 M} {MR0003 M} {MR0004 F}]
Enter command: IN MR0005 F
Patient MR0005 added to the queue.
[{MR0001 M} {MR0002 M} {MR0003 M} {MR0004 F} {MR0005 F}]
Enter command: ROUNDROBIN
Queue ordering changed to Round Robin Gender.
[{MR0001 M} {MR0004 F} {MR0002 M} {MR0005 F} {MR0003 M}]
Enter command: DEFAULT
Queue ordering changed to Default (FIFO).
[{MR0001 M} {MR0004 F} {MR0002 M} {MR0005 F} {MR0003 M}]
Enter command: EXIT
Exiting the application. Goodbye!