Package Databases
Class MedicalRecordDatabase
java.lang.Object
Common.Database
Databases.MedicalRecordDatabase
The
MedicalRecordDatabase
class manages a collection of medical records.
It extends Database
and provides methods for creating, searching,
removing, and printing medical records.-
Field Summary
Fields inherited from class Common.Database
csvPath, headerFormat, records
-
Constructor Summary
ConstructorsConstructorDescriptionConstructs aMedicalRecordDatabase
with a default CSV path.MedicalRecordDatabase
(String csvpath) Constructs aMedicalRecordDatabase
with a specified CSV path. -
Method Summary
Modifier and TypeMethodDescriptioncreateDatabaseItem
(String[] values) Creates a newMedicalRecord
instance from an array of values.void
Prints all items in the medical records database.boolean
removeItem
(String userid) Removes a medical record by its unique identifier (ID).searchItem
(String id) Searches for a medical record by its unique identifier (ID).Methods inherited from class Common.Database
addItem, extractFromCSV, getRecords, printItems, setcsvPath, setHeaderFormat, storeToCSV
-
Constructor Details
-
MedicalRecordDatabase
public MedicalRecordDatabase()Constructs aMedicalRecordDatabase
with a default CSV path. -
MedicalRecordDatabase
Constructs aMedicalRecordDatabase
with a specified CSV path.- Parameters:
csvpath
- the path to the CSV file containing medical records
-
-
Method Details
-
createDatabaseItem
Creates a newMedicalRecord
instance from an array of values.- Specified by:
createDatabaseItem
in classDatabase
- Parameters:
values
- an array of strings containing medical record data- Returns:
- a new
MedicalRecord
object
-
searchItem
Searches for a medical record by its unique identifier (ID).- Specified by:
searchItem
in classDatabase
- Parameters:
id
- the unique identifier of the medical record to search for- Returns:
- the found
MedicalRecord
object; null if not found
-
removeItem
Removes a medical record by its unique identifier (ID).- Specified by:
removeItem
in classDatabase
- Parameters:
userid
- the unique identifier of the medical record to remove- Returns:
- true if the record was successfully removed; false otherwise
-
printItems
public void printItems()Prints all items in the medical records database.- Specified by:
printItems
in classDatabase
-