Question: Dear all. Is there a way to avoid OpenMRS to allowing Male patients to be enrolled in PTV programs and adult patients to be enrolled to a CCR program?
Step-by-step instructions for others to reproduce the problem
Scenario 1: Create a New Male patient with 22 years-> search for the patient-> On patient dashboard look for programs session-> Click on add program -> on program name select PTV-> Chose any completion date and Location-> Click on enrrol button. (The system enrolles the patient)
Scenario 2: Search for the the same Male patient-> On patient dashboard look for programs session-> Click on add program -> on program name select CCR-> Chose any completion date and Location-> Click on enrrol button. (The system enrolles the patient)
Platform: We are using OpenMRS v1.11.5 as a retrospective system
Having user defined validations for program enrollment is not currently implemented. It therefore requires creating a ticket.
Thank you for your response.
Did you take a look at the link i gave above?
Yes @dkayiwa. I did create the issue successfully.
@dkayiwa What would be the best way to implement this validation in a custom module? Should I override
Our practice has been creating validator classes which get called automatically when saving the validated objects. Here is a list of such validators: https://github.com/openmrs/openmrs-core/tree/master/api/src/main/java/org/openmrs/validator
I’m having a problem with the validator implemented.
When I call endpoint
/programenrollment with a payload that should not pass validation, the message from error response is actually the key from the messages bundle:
"message": "Invalid Submission",
Any idea what might be wrong?
Can i look at your validator implementation?
And where are those message codes defined or expanded?
Did you intentionally decide not to prefix them with your moduleid?
I did not know it was necessary
@dkayiwa thanks the messages are expanded now, just missing i18n.
We are setting the locale through
/session endpoint, but they are always in english.
Nevermind it was missing in config.xml, thank you for your help.