Change new patient view in openmrs
A very specific question!
To change the New Patient view in OpenMRS, you'll need to modify the patient registration
module. Here's a step-by-step guide:
Prerequisites:
- You have a basic understanding of OpenMRS and its architecture.
- You have a development environment set up with OpenMRS (e.g., Eclipse, IntelliJ IDEA, or Visual Studio Code).
- You have the OpenMRS source code checked out from the OpenMRS GitHub repository.
Step 1: Identify the relevant files
The New Patient view is defined in the patient registration
module, specifically in the PatientRegistrationModule
class. You'll need to modify the getNewPatientView()
method to change the view.
Look for the following files:
PatientRegistrationModule.java
(in theorg.openmrs.module.patientregistration
package)PatientRegistrationForm.java
(in theorg.openmrs.module.patientregistration.form
package)
Step 2: Modify the getNewPatientView()
method
In the PatientRegistrationModule
class, find the getNewPatientView()
method and modify it to return a new instance of your custom view. You can create a new class that extends PatientRegistrationForm
and override the getForm()
method to return your custom form.
For example, let's say you want to add a new field to the New Patient view. You can create a new class MyNewPatientForm
that extends PatientRegistrationForm
:
public class MyNewPatientForm extends PatientRegistrationForm {
@Override
public Form getForm() {
Form form = super.getForm();
form.addFormField("newField", "New Field", "text");
return form;
}
}
Then, in the getNewPatientView()
method, return an instance of your custom form:
public PatientRegistrationView getNewPatientView() {
return new MyNewPatientForm();
}
Step 3: Update the PatientRegistrationModule
class
After modifying the getNewPatientView()
method, update the PatientRegistrationModule
class to use your custom view.
Step 4: Rebuild and redeploy the module
Rebuild the patient registration
module by running the following command in your terminal:
mvn clean package
Then, redeploy the module to your OpenMRS instance:
mvn deploy
Step 5: Verify the changes
Log in to your OpenMRS instance and navigate to the New Patient view. You should see your custom changes reflected in the form.
Remember to test your changes thoroughly to ensure they don't break any existing functionality.
That's it! You've successfully modified the New Patient view in OpenMRS.