-
Notifications
You must be signed in to change notification settings - Fork 137
Java attributes and methods
Rashmika_Harshamal edited this page Jul 20, 2026
·
27 revisions
Java attributes and methods are essential parts of HMIS development.
Attributes store information such as:
- Patient name
- Patient code
- Bill total
- Created date
- Department
- Investigation
- Report status
- Retired status
Methods are used to:
- Read attribute values
- Change attribute values
- Validate data
- Calculate totals
- Process reports
- Search database records
- Clear filters
- Format information for display
A simple HMIS-style example is:
private String patientCode;
private double total;
private boolean retired;
public String getPatientCode() { return patientCode; }
public void setPatientCode(String patientCode) { this.patientCode = patientCode; }
public double calculateNetTotal(double discount) { return total - discount; }
In this example:
- patientCode, total, and retired are attributes.
- getPatientCode(), setPatientCode(), and calculateNetTotal() are methods.
An attribute stores data inside a Java component. Attributes are also called:
- Fields
- Member variables
- Instance variables
- Properties, especially when accessed through getters and setters
General syntax : accessModifier dataType attributeName;
private String patientName;
- private is the access modifier.
- String is the data type.
- patientName is the attribute name.
Exmples
- private Long id;
- private String patientCode;
- private Date createdAt;
- private Department department;
- private Investigation investigation;
- private boolean retired;
- private List results;