This configuration allows users to show or hide sections in registration create new patient page based on conditions. For this a specific file named "attributesConditions.js" must be defined.
This file "attributesConditions.js" should be located in "/var/www/bahmni_config/openmrs/apps/registration/" directory.
For example: If age is less than 18, only then show the "Guardian Details" section.
"patientInformation": { "patientContact": { "title": "Patient Contact", "translationKey": "Patient Contact", "attributes": [ "phoneNumber1", "phoneNumber2", "emailAddress", ] }, "guardian": { "title": "Guardian Details", "translationKey": "Guardian Details", "attributes": [ "guardianNameEnglish", "guardianGender", "guardianDob", "guardianAge", "guardianNationality" ] }, } |
Here, 'patientContact' and 'guardian' are the sections. Below is the javascript that is needed to show the guardian section if patient's age is less than 18.
var showOrHideGuardianSection = function (patient) { var returnValues = { show: [], hide: [] }; if (patient["age"].years < 18) { returnValues.show.push("guardian") } else { returnValues.hide.push("guardian") } return returnValues }; Bahmni.Registration.AttributesConditions.rules = { 'age': function (patient) { return showOrHideGuardianSection(patient); }, 'birthdate': function (patient) { return showOrHideGuardianSection(patient); }, 'isGuardianRequired': function(patient) { var returnValues = { show: [], hide: [] }; if (patient["isGuardianRequired"]) { returnValues.show.push("guardian"); } else { returnValues.hide.push("guardian"); } return returnValues; } }; |