@@ -0,0 +1,3555 @@
+package org.phenotips.data.internal;%0A%0Aimport org.phenotips.Constants;%0Aimport org.phenotips.data.Patient;%0A%0Aimport org.xwiki.container.Container;%0Aimport org.xwiki.container.Request;%0Aimport org.xwiki.observation.AbstractEventListener;%0Aimport org.xwiki.observation.ObservationManager;%0Aimport org.xwiki.observation.event.Event;%0A%0Aimport java.util.List;%0A%0Aimport javax.inject.Inject;%0A%0Aimport org.apache.commons.lang3.StringUtils;%0A%0Aimport com.xpn.xwiki.doc.XWikiDocument;%0Aimport com.xpn.xwiki.objects.BaseObject;%0A%0A/**%0A * Some method implementations that can be used by objects that update patient data.%0A *%0A * @version $Id$%0A */%0Apublic abstract class AbstractPatientDataUpdater extends AbstractEventListener%0A%7B%0A    /** Needed for getting access to the request. */%0A    @Inject%0A    private Container container;%0A%0A    /**%0A     * @param name the listener's name. It's a free form text identifying this listener instance in a unique manner.%0A     *            This name is used for some operations in %7B@link ObservationManager%7D.%0A     * @param events the list of events this listener is configured to receive. This listener will be automatically%0A     *            registered with this list of events against the %7B@link ObservationManager%7D. When an event occurs, for%0A     *            each matching event in this list, the %7B@link #onEvent(Event, Object, Object)%7D method will be called.%0A     */%0A    public AbstractPatientDataUpdater(String name, List%3C? extends Event%3E events)%0A    %7B%0A        super(name, events);%0A    %7D%0A%0A    /**%0A     * @param name the listener's name. It's a free form text identifying this listener instance in a unique manner.%0A     *            This name is used for some operations in %7B@link ObservationManager%7D.%0A     * @param events the list of events this listener is configured to receive. This listener will be automatically%0A     *            registered with this list of events against the %7B@link ObservationManager%7D. When an event occurs, for%0A     *            each matching event in this list, the %7B@link #onEvent(Event, Object, Object)%7D method will be called.%0A     */%0A    public AbstractPatientDataUpdater(String name, Event... events)%0A    %7B%0A        super(name, events);%0A    %7D%0A%0A    /**%0A     * Read a property from the request.%0A     *%0A     * @param propertyName the name of the property as it would appear in the class, for example%0A     *            %7B@code age_of_onset_years%7D%0A     * @param objectNumber the object's number%0A     * @return the value sent in the request, or false if not set%0A     */%0A    protected boolean getParameter(String propertyName, int objectNumber)%0A    %7B%0A        String parameterName = Constants.CODE_SPACE + %22.PatientClass_%22 + objectNumber + %22_%22 + propertyName;%0A        Request request = this.container.getRequest();%0A        if (request == null) %7B%0A            return false;%0A        %7D%0A        String value = (String) request.getProperty(parameterName);%0A        if (!StringUtils.isNumeric(value)) %7B%0A            return false;%0A        %7D%0A        return (Integer.valueOf(value) == 1);%0A    %7D%0A%0A    /**%0A     * Returns a patient record base object.%0A     *%0A     * @param source the event source i.e. the object for which the event was triggered.%0A     * @return a patient record object%0A     */%0A    protected BaseObject getPatientRecord(Object source)%0A    %7B%0A        if (source instanceof XWikiDocument) %7B%0A            XWikiDocument doc = (XWikiDocument) source;%0A            BaseObject patientRecordObj = doc.getXObject(Patient.CLASS_REFERENCE);%0A            return patientRecordObj;%0A        %7D else %7B%0A            return null;%0A        %7D%0A    %7D%0A%0A%7D%0A

Add 'Allergies- environmental, food, medication' Created AbstractPatientDataUpdater with implementation of two methods that are used in multiple PatientXUpdater-s.