/** * The contents of this file are subject to the OpenMRS Public License * Version 1.0 (the "License"); you may not use this file except in * compliance with the License. You may obtain a copy of the License at * http://license.openmrs.org * * Software distributed under the License is distributed on an "AS IS" * basis, WITHOUT WARRANTY OF ANY KIND, either express or implied. See the * License for the specific language governing rights and limitations * under the License. * * Copyright (C) OpenMRS, LLC. All Rights Reserved. */ package org.openmrs.module.reporting.logic; import java.util.Map; import java.util.Set; import org.openmrs.Patient; import org.openmrs.logic.LogicContext; import org.openmrs.logic.LogicException; import org.openmrs.logic.Rule; import org.openmrs.logic.result.Result; import org.openmrs.logic.result.Result.Datatype; import org.openmrs.logic.rule.RuleParameterInfo; /** * Mock implementation of Logic Service to get around issues using the actual Logic Service implementations */ public class GenderRule implements Rule { /** * @see Rule#eval(LogicContext, Patient, Map) */ public Result eval(LogicContext context, Integer patientId, Map<String, Object> parameters) throws LogicException { Patient patient = context.getPatient(patientId); return new Result(patient.getGender()); } /** * @see org.openmrs.logic.Rule#getParameterList() */ public Set<RuleParameterInfo> getParameterList() { return null; } /** * @see org.openmrs.logic.Rule#getDependencies() */ public String[] getDependencies() { return null; } /** * @see org.openmrs.logic.Rule#getTTL() */ public int getTTL() { return 60 * 60 * 24; // 1 day } /** * @see org.openmrs.logic.Rule#getDefaultDatatype() */ public Datatype getDefaultDatatype() { return Datatype.TEXT; } }