public static boolean isConceptInList(Concept concept, List<Concept> list) { boolean ret = false; if (concept != null && list != null) { for (Concept c : list) { if (c.equals(concept)) { ret = true; break; } } } return ret; }
/** * Gets the reaction with a given concept * * @param concept the concept * @return the reaction if any exists */ public AllergyReaction getReaction(Concept concept) { for (AllergyReaction reaction : reactions) { if (reaction.getReaction().equals(concept)) { return reaction; } } return null; }
/** * Returns a {@link ProgramWorkflowState} whose Concept matches the passed concept * * @param concept the Concept to match * @return Returns a {@link ProgramWorkflowState} whose {@link Concept} matches the passed * <code>concept</code> */ public ProgramWorkflowState getState(Concept concept) { for (ProgramWorkflowState s : getStates()) { if (s.getConcept().equals(concept)) { return s; } } return null; }
/** * @see java.lang.Object#equals(java.lang.Object) */ @Override public boolean equals(Object obj) { if (this == obj) { return true; } if (!(obj instanceof ConceptSearchResult)) { return false; } ConceptSearchResult other = (ConceptSearchResult) obj; if (getConcept() == null) { return false; } return getConcept().equals(other.getConcept()); }
/** * Checks if this allergen is the same as the given one * * @param allergen the given allergen to test with * * @should return true for same coded allergen * @should return false for different coded allergen * @should return true for same non coded allergen * @should return false for different non coded allergen * * @return true if the same, else false */ public boolean isSameAllergen(Allergen allergen) { if (isCoded()) { return allergen.getCodedAllergen() != null && codedAllergen.equals(allergen.getCodedAllergen()); } else { return nonCodedAllergen != null && allergen.getNonCodedAllergen() != null && nonCodedAllergen .equalsIgnoreCase(allergen.getNonCodedAllergen()); } } }
return (valueBoolean.equals(r.valueBoolean)); case CODED: return (valueCoded.equals(r.valueCoded)); case DATETIME: return (valueDatetime.equals(r.valueDatetime));
return false; if (this.condition.getCoded() != null && !this.condition.getCoded().equals(condition.getCondition().getCoded())) { return false;
continue; if (candidateName.getConcept().equals(name.getConcept())) { continue;
/** * Coerces a value to a Boolean representation * * @return Boolean representation of the obs value * @should return true for value_numeric concepts if value is 1 * @should return false for value_numeric concepts if value is 0 * @should return null for value_numeric concepts if value is neither 1 nor 0 */ public Boolean getValueAsBoolean() { if (getValueCoded() != null) { if (getValueCoded().equals(Context.getConceptService().getTrueConcept())) { return Boolean.TRUE; } else if (getValueCoded().equals(Context.getConceptService().getFalseConcept())) { return Boolean.FALSE; } } else if (getValueNumeric() != null) { if (getValueNumeric() == 1) { return Boolean.TRUE; } else if (getValueNumeric() == 0) { return Boolean.FALSE; } } //returning null is preferred to defaulting to false to support validation of user input is from a form return null; }
/** * @see BaseOpenmrsObject#equals(Object) */ @Test public void equals_shouldReturnTrueIfGivenObjectIsInstanceOfSuperOrExtendingClass() { Concept concept = new Concept(5); Concept numeric = new ConceptNumeric(); numeric.setUuid(concept.getUuid()); Assert.assertTrue(numeric.equals(concept)); Assert.assertTrue(concept.equals(numeric)); }
/** * @see ConceptService#convertBooleanConceptToCoded(Concept) */ @Test public void changeConceptFromBooleanToCoded_shouldExplicitlyAddTrueConceptAsAValue_CodedAnswer() { Concept concept = conceptService.getConcept(18); Collection<ConceptAnswer> answers = concept.getAnswers(false); boolean trueConceptFound = false; for (ConceptAnswer conceptAnswer : answers) { if (conceptAnswer.getAnswerConcept().equals(conceptService.getTrueConcept())) { trueConceptFound = true; } } Assert.assertEquals(false, trueConceptFound); conceptService.convertBooleanConceptToCoded(concept); answers = concept.getAnswers(false); for (ConceptAnswer conceptAnswer : answers) { if (conceptAnswer.getAnswerConcept().equals(conceptService.getTrueConcept())) { trueConceptFound = true; } } Assert.assertEquals(true, trueConceptFound); }
/** * @see ConceptService#convertBooleanConceptToCoded(Concept) */ @Test public void changeConceptFromBooleanToCoded_shouldExplicitlyAddFalseConceptAsAValue_CodedAnswer() { Concept concept = conceptService.getConcept(18); Collection<ConceptAnswer> answers = concept.getAnswers(false); boolean falseConceptFound = false; //initially the concept shouldn't present for (ConceptAnswer conceptAnswer : answers) { if (conceptAnswer.getAnswerConcept().equals(conceptService.getFalseConcept())) { falseConceptFound = true; } } Assert.assertEquals(false, falseConceptFound); conceptService.convertBooleanConceptToCoded(concept); answers = concept.getAnswers(false); for (ConceptAnswer conceptAnswer : answers) { if (conceptAnswer.getAnswerConcept().equals(conceptService.getFalseConcept())) { falseConceptFound = true; } } Assert.assertEquals(true, falseConceptFound); }
/** * @see BaseOpenmrsObject#equals(Object) */ @Test public void equals_shouldReturnFalseIfGivenObjIsNotInstanceOfSuperOrExtendingClass() { Encounter encounter = new Encounter(); Concept concept = new Concept(5); concept.setUuid(encounter.getUuid()); Assert.assertFalse(encounter.equals(concept)); Assert.assertFalse(concept.equals(encounter)); }
/** * @see ConceptService@getTrueConcept() */ @Test public void getTrueConcept_shouldReturnProperTrueConcept() { Concept trueConceptLoadedManually = Context.getConceptService().getConcept( Context.getAdministrationService().getGlobalProperty(OpenmrsConstants.GLOBAL_PROPERTY_TRUE_CONCEPT)); Concept trueConceptLoadedByServiceMethod = Context.getConceptService().getTrueConcept(); Assert.assertTrue(trueConceptLoadedManually.equals(trueConceptLoadedByServiceMethod)); }
/** * @see ConceptService@getFalseConcept() */ @Test public void getFalseConcept_shouldReturnProperFalseConcept() { Concept falseConceptLoadedManually = Context.getConceptService().getConcept( Context.getAdministrationService().getGlobalProperty(OpenmrsConstants.GLOBAL_PROPERTY_FALSE_CONCEPT)); Concept falseConceptLoadedByServiceMethod = Context.getConceptService().getFalseConcept(); Assert.assertTrue(falseConceptLoadedManually.equals(falseConceptLoadedByServiceMethod)); }
/** * @see OrderService#saveOrder(org.openmrs.Order, OrderContext) */ @Test public void saveOrder_shouldFailIfConceptInPreviousOrderDoesNotMatchThatOfTheRevisedOrder() { Order previousOrder = orderService.getOrder(7); Order order = previousOrder.cloneForRevision(); order.setDateActivated(new Date()); order.setOrderer(providerService.getProvider(1)); order.setEncounter(encounterService.getEncounter(6)); Concept newConcept = conceptService.getConcept(5089); assertFalse(previousOrder.getConcept().equals(newConcept)); order.setConcept(newConcept); expectedException.expect(EditedOrderDoesNotMatchPreviousException.class); expectedException.expectMessage("The orderable of the previous order and the new one order don't match"); orderService.saveOrder(order, null); }
} else if (activeOrder.getConcept().equals(order.getConcept())) { if (orderToBeDiscontinued == null) { orderToBeDiscontinued = activeOrder;
/** * @see OrderService#saveOrder(org.openmrs.Order, OrderContext) */ @Test public void saveOrder_shouldFailIfConceptInPreviousOrderDoesNotMatchThisConcept() { Order previousOrder = orderService.getOrder(7); assertTrue(OrderUtilTest.isActiveOrder(previousOrder, null)); Order order = previousOrder.cloneForDiscontinuing(); order.setDateActivated(new Date()); order.setOrderReasonNonCoded("Discontinue this"); order.setEncounter(encounterService.getEncounter(6)); order.setOrderer(providerService.getProvider(1)); Concept newConcept = conceptService.getConcept(5089); assertFalse(previousOrder.getConcept().equals(newConcept)); order.setConcept(newConcept); expectedException.expect(EditedOrderDoesNotMatchPreviousException.class); expectedException.expectMessage("The orderable of the previous order and the new one order don't match"); orderService.saveOrder(order, null); }
&& !order.getDrug().getConcept().equals(order.getConcept())) { errors.rejectValue("drug", "error.general"); errors.rejectValue("concept", "error.concept");
assertTrue(field1.getConcept().equals(concept2)); assertTrue(field1.getName().equals(name2)); assertTrue(field1.getDescription().equals(descript2));