/** * @since 1.5 * @see org.openmrs.OpenmrsObject#getId() */ @Override public Integer getId() { return getDrugId(); }
/** * Turn the given drug into a string acceptable for hl7 and forms * * @param drug Drug to convert to a string * @return String representation of the given drug */ public static String drugToString(Drug drug) { return drug.getDrugId() + "^" + drug.getName() + "^" + HL7Constants.HL7_LOCAL_DRUG; } }
/** * @see ConceptService#getDrugs(String, java.util.Locale, boolean, boolean) */ @Test public void getDrugs_shouldGetDrugsLinkedToConceptsWithNamesThatMatchThePhrase() { final Integer expectedDrugId = 2; List<Drug> drugs = conceptService.getDrugs("stav", null, false, false); assertEquals(1, drugs.size()); assertEquals(expectedDrugId, drugs.get(0).getDrugId()); //should match anywhere in the concept name drugs = conceptService.getDrugs("lamiv", null, false, false); assertEquals(1, drugs.size()); assertEquals(expectedDrugId, drugs.get(0).getDrugId()); }
/** * @see ConceptService#getDrugs(String, java.util.Locale, boolean, boolean) */ @Test public void getDrugs_shouldIncludeRetiredDrugsIfIncludeRetiredIsSetToTrue() { //Should be case insensitive final String searchPhrase = "Nyq"; List<Drug> drugs = conceptService.getDrugs(searchPhrase, null, false, false); assertEquals(0, drugs.size()); drugs = conceptService.getDrugs(searchPhrase, null, false, true); assertEquals(1, drugs.size()); assertEquals(11, drugs.get(0).getDrugId().intValue()); }
answerDeleted = false; } else if ((drugId != null && answerDrug != null) && drugId.equals(origConceptAnswer.getAnswerDrug().getDrugId())) { answerDeleted = false; if (drugId == null && answerDrug == null) { newAnswerConcept = false; } else if ((drugId != null && answerDrug != null) && drugId.equals(answerDrug.getDrugId())) { newAnswerConcept = false;
/** * @see ConceptService#getDrugs(String, java.util.Locale, boolean, boolean) */ @Test public void getDrugs_shouldGetDrugsLinkedToConceptsWithNamesThatMatchThePhraseAndLocale() { executeDataSet("org/openmrs/api/include/ConceptServiceTest-drugSearch.xml"); final String searchPhrase = "some"; List<Drug> drugs = conceptService.getDrugs(searchPhrase, Locale.FRENCH, true, false); assertEquals(0, drugs.size()); drugs = conceptService.getDrugs(searchPhrase, Locale.CANADA_FRENCH, true, false); assertEquals(1, drugs.size()); assertEquals(3, drugs.get(0).getDrugId().intValue()); }
/** * @see ConceptService#getDrugByUuid(String) */ @Test public void getDrugByUuid_shouldFindObjectGivenValidUuid() { String uuid = "3cfcf118-931c-46f7-8ff6-7b876f0d4202"; Drug drug = Context.getConceptService().getDrugByUuid(uuid); Assert.assertEquals(2, (int) drug.getDrugId()); }
/** * Ensures that unique drugs are returned in situations where more than one searched fields * match e.g drug name and linked concept name match the search phrase * * @see ConceptService#getDrugs(String, java.util.Locale, boolean, boolean) */ @Test public void getDrugs_shouldReturnUniqueDrugs() { //sanity check that drug.name and drug.concept.name will both match the search phrase Drug drug = conceptService.getDrug("ASPIRIN"); assertEquals(drug.getName().toLowerCase(), drug.getConcept().getName().getName().toLowerCase()); List<Drug> drugs = conceptService.getDrugs("Asp", null, false, false); assertEquals(1, drugs.size()); assertEquals(3, drugs.get(0).getDrugId().intValue()); }
/** * @see ConceptService#getDrugByMapping(String, org.openmrs.ConceptSource, java.util.Collection */ @Test public void getDrugByMapping_shouldReturnADrugThatMatchesTheCodeAndSourceAndTheBestMapType() { executeDataSet(GET_DRUG_MAPPINGS); final Integer expectedDrugId = 2; final ConceptSource source = conceptService.getConceptSource(2); final ConceptMapType mapTypeWithMatch = conceptService.getConceptMapType(1); final ConceptMapType mapTypeWithNoMatch = conceptService.getConceptMapType(2); List<ConceptMapType> conceptMapTypeList = new ArrayList<>(); conceptMapTypeList.add(mapTypeWithMatch); conceptMapTypeList.add(mapTypeWithNoMatch); Drug drug = conceptService.getDrugByMapping("WGT234", source, conceptMapTypeList); assertEquals(expectedDrugId, drug.getDrugId()); //Lets switch the order is the map types in the list to make sure that //if there is no match on the first map type, the logic matches on the second //sanity check that actually there will be no match on the first map type in the list conceptMapTypeList.clear(); conceptMapTypeList.add(mapTypeWithNoMatch); assertNull(conceptService.getDrugByMapping("WGT234", source, conceptMapTypeList)); conceptMapTypeList.add(mapTypeWithMatch); drug = conceptService.getDrugByMapping("WGT234", source, conceptMapTypeList); assertEquals(expectedDrugId, drug.getDrugId()); }
/** * @see ConceptService#getDrugByMapping(String, org.openmrs.ConceptSource, java.util.Collection */ @Test public void getDrugByMapping_shouldReturnADrugThatMatchesTheCodeAndSource() { executeDataSet(GET_DRUG_MAPPINGS); final Integer expectedDrugId = 2; Drug drug = conceptService.getDrugByMapping("WGT234", conceptService.getConceptSource(2), null); assertEquals(expectedDrugId, drug.getDrugId()); }
/** * This method exists because of the stupid bug where Concept.equals(Concept) doesn't always work. * TODO: Fix the bug where Concept.equals(Concept) doesn't always work */ private boolean equalDrug(Drug c1, Drug c2) { return OpenmrsUtil.nullSafeEquals(c1 == null ? null : c1.getDrugId(), c2 == null ? null : c2.getDrugId()); }
/** * Finds a drug in a set of drugs by id or uuid; excludes voided DrugOrders from consideration * * */ private static DrugOrder drugIdFoundInDrugSet(DrugSuggestion ds, List<Order> dors){ for (Order or : dors){ if (or instanceof DrugOrder){ DrugOrder dor = (DrugOrder) or; if (dor.getDrug() != null && !dor.isVoided() && (dor.getDrug().getDrugId().toString().equals(ds.getDrugId()) || dor.getDrug().getUuid().toString().equals(ds.getDrugId()))) return dor; } } return null; }
/** * Finds a drug in a set of drugs by id or uuid; excludes voided DrugOrders from consideration * * */ private static DrugOrder drugIdFoundInDrugSet(DrugSuggestion ds, List<Order> dors){ for (Order or : dors){ if (or instanceof DrugOrder){ DrugOrder dor = (DrugOrder) or; if (dor.getDrug() != null && !dor.isVoided() && (dor.getDrug().getDrugId().toString().equals(ds.getDrugId()) || dor.getDrug().getUuid().toString().equals(ds.getDrugId()))) return dor; } } return null; }
displayText = drugLabels.get(drugListIndexPos); options.add(new Option(displayText, drug.getDrugId().toString(), false)); if (drugsUsedAsKey == null) { drugsUsedAsKey = new ArrayList<Drug>(); CheckboxWidget cb = new CheckboxWidget(); cb.setLabel(displayText); cb.setValue(drugsUsedAsKey.get(0).getDrugId().toString()); drugWidget = cb; } else {
widget.setInitialValue(new Option(existingObs.getValueDrug().getName(), existingObs.getValueDrug().getDrugId().toString(), true));