Versions Compared

Key

  • This line was added.
  • This line was removed.
  • Formatting was changed.

...

  • Filtering is based on "Anding" i.e if any one assigned filter returns false then form does not appear on the patient dashboard.
  • Current Role Filter uses role inheritance behavior in filtering a form. We can switch between use/do not use role inheritance by setting "Use Role Inheritance Comparison" Global Property value to yes/no.
  • All filters should have a single string parameter constructor which takes filter properties as input. This constructor can be used to initialize filter properties.
    Example:
    Code Block
    package org.openmrs.module.formfilter.impl;
    
    import java.lang.reflect.Field;
    
    import org.apache.commons.logging.Log;
    import org.apache.commons.logging.LogFactory;
    import org.openmrs.Patient;
    import org.openmrs.User;
    import org.openmrs.module.formfilter.FormFilterHandler;
    
    /**
     * This class will provide patient age based form filter.
     */
    public class AgeFormFilter implements FormFilterHandler {
    
    	protected Log log = LogFactory.getLog(getClass());
    
    	/**
    	 * Default Constructor
    	 */
    	public AgeFormFilter()
    	{
    
    	}
    
    	/**
    	 * Constructor sets class field values.
    	 * @param properties ,string property from FormFilterProperty class in key=value based format
    	 * Example: minimumAge=value&maximumAge=value
    	 */
    	public AgeFormFilter(String properties){
    		for (String string : properties.split("&")) {
    	        String str[]=string.split("=");
    	        try {
    	            Field field=this.getClass().getDeclaredField(str[0]);
    	            field.set(this, (Object)Integer.parseInt(str[1]));
                }catch (Exception e) {
                	log.info(e);
                }
    		}
    
    	}
    
    	private int minimumAge;
    
    	private int maximumAge;
    
    
    	/**
    	 * @return minimumAge
    	 */
        public int getMinimumAge() {
        	return minimumAge;
        }
    
        /**
    	 * Sets maximumAge
    	 *
    	 * @param maximumAge
    	 */
        public void setMinimumAge(int minimumAge) {
        	this.minimumAge = minimumAge;
        }
    
    
        /**
    	 * @return maximumAge
    	 */
        public int getMaximumAge() {
        	return maximumAge;
        }
    
    	/**
    	 * Sets maximumAge
    	 *
    	 * @param maximumAge
    	 */
        public void setMaximumAge(int maximumAge) {
        	this.maximumAge = maximumAge;
        }
    
        /**
         * @see org.openmrs.module.formfilter.FormFilterHandler#shouldDisplayForm(org.openmrs.Patient, org.openmrs.User)
         * @return True , if patient age lies between minimumAge and maximumAge.
         * @return False, if patient age does not between minimumAge and maximumAge.
         */
        @Override
        public boolean shouldDisplayForm(Patient p, User u) {
    	    // TODO Auto-generated method stub
    
    	    if((p.getAge()>=minimumAge) && (p.getAge()<=maximumAge))
    	    {
    	    	return true;
    	    }
    	    return false;
        }
    
    }
    

...

5)Role Form Filter
Form is shown if the user has specific rolehas any mentioned role.
Parameter: a) Role
Example:
Image Removed Image Added

Form is shown if user has "System Developer" or "Provider" role.
6)Privilege Form Filter
Form is shown if the user has specific mentioned privilege.
Parameter: a)Privilege
Example:
Image Removed Image Added

Form is shown if user has "Form Entry"Add Cohorts" or "Add Forms" privilege.