/** * 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; }
ConceptAnswer answer = iterator.next(); String conceptUuid = answer.getConcept().getUuid(); String drugUuid = (answer.getAnswerDrug() != null) ? answer.getAnswerDrug().getUuid() : null; if (answerUuids.contains(conceptUuid)) {
/** * @verifies return all drugs with a matching term code or drug name or concept name * @see ConceptService#getDrugs(String, java.util.Locale, boolean, boolean) */ @Test public void getDrugs_shouldReturnAllDrugsWithAMatchingTermCodeOrDrugNameOrConceptName() throws Exception { executeDataSet(DRUG_SEARCH_TEST_DATA); String[] expectedDrugUuids = { conceptService.getDrug(3).getUuid(), conceptService.getDrug(11).getUuid(), conceptService.getDrug(444).getUuid() }; SimpleObject results = deserialize(handle(newGetRequest(getURI(), new Parameter("s", "default"), new Parameter("q", "ZZZ"), new Parameter("exactLocale", "false"), new Parameter("includeAll", "true")))); Assert.assertEquals(3, Util.getResultsSize(results)); List<Object> resultList = Util.getResultsList(results); List<String> uuids = Arrays.asList(new String[] { PropertyUtils.getProperty(resultList.get(0), "uuid").toString(), PropertyUtils.getProperty(resultList.get(1), "uuid").toString(), PropertyUtils.getProperty(resultList.get(2), "uuid").toString() }); assertThat(uuids, hasItems(expectedDrugUuids)); } }
@Test public void shouldGetADrugByUuid() throws Exception { MockHttpServletRequest req = request(RequestMethod.GET, getURI() + "/" + getUuid()); SimpleObject result = deserialize(handle(req)); Drug drug = service.getDrugByUuid(getUuid()); Assert.assertNotNull(result); Assert.assertEquals(drug.getUuid(), PropertyUtils.getProperty(result, "uuid")); Assert.assertEquals(drug.getName(), PropertyUtils.getProperty(result, "name")); }
/** * @verifies get drugs linked to concepts with names that match the phrase * @see ConceptService#getDrugs(String, java.util.Locale, boolean, boolean) */ @Test public void getDrugs_shouldGetDrugsLinkedToConceptsWithNamesThatMatchThePhrase() throws Exception { SimpleObject results = deserialize(handle(newGetRequest(getURI(), new Parameter("s", "default"), new Parameter("q", "amiv")))); Assert.assertEquals(1, Util.getResultsSize(results)); Assert.assertEquals(conceptService.getDrug(2).getUuid(), PropertyUtils.getProperty(Util.getResultsList(results).get(0), "uuid")); }
@Test public void shouldPurgeADrug() throws Exception { Drug drug = service.getDrug(11); MockHttpServletRequest req = request(RequestMethod.DELETE, getURI() + "/" + drug.getUuid()); req.addParameter("purge", "true"); handle(req); Assert.assertNull(service.getDrug(11)); }
/** * @verifies get drugs that have mappings with reference term codes that match the phrase * @see ConceptService#getDrugs(String, java.util.Locale, boolean, boolean) */ @Test public void getDrugs_shouldGetDrugsThatHaveMappingsWithReferenceTermCodesThatMatchThePhrase() throws Exception { executeDataSet(DRUG_SEARCH_TEST_DATA); SimpleObject results = deserialize(handle(newGetRequest(getURI(), new Parameter("s", "default"), new Parameter("q", "XXXZZ"), new Parameter("exactLocale", "true"), new Parameter("includeAll", "true")))); Assert.assertEquals(1, Util.getResultsSize(results)); Assert.assertEquals(conceptService.getDrug(11).getUuid(), PropertyUtils.getProperty(Util.getResultsList(results).get(0), "uuid")); }
/** * @verifies get drugs linked to concepts with names that match the phrase and related locales * @see ConceptService#getDrugs(String, java.util.Locale, boolean, boolean) */ @Test public void getDrugs_shouldGetDrugsLinkedToConceptsWithNamesThatMatchThePhraseAndRelatedLocales() throws Exception { executeDataSet(DRUG_SEARCH_TEST_DATA); final String searchPhrase = "another"; //Should look only in the exact locale if exactLocale is set to true SimpleObject results = deserialize(handle(newGetRequest(getURI(), new Parameter("s", "default"), new Parameter("q", searchPhrase), new Parameter("locale", "fr_CA"), new Parameter("exactLocale", "true")))); Assert.assertEquals(0, Util.getResultsSize(results)); //Should look in broader locale if exactLocale is set to false results = deserialize(handle(newGetRequest(getURI(), new Parameter("s", "default"), new Parameter("q", searchPhrase), new Parameter("locale", "fr_CA")))); Assert.assertEquals(1, Util.getResultsSize(results)); Assert.assertEquals(conceptService.getDrug(3).getUuid(), PropertyUtils.getProperty(Util.getResultsList(results).get(0), "uuid")); }
@Test public void shouldRetireADrug() throws Exception { Drug drug = service.getDrugByUuid(getUuid()); Assert.assertFalse(drug.isRetired()); MockHttpServletRequest req = request(RequestMethod.DELETE, getURI() + "/" + drug.getUuid()); req.addParameter("!purge", ""); req.addParameter("reason", "random reason"); handle(req); Drug retiredDrug = service.getDrugByUuid(getUuid()); Assert.assertTrue(retiredDrug.isRetired()); Assert.assertEquals("random reason", retiredDrug.getRetireReason()); }
@Test public void getDrugsByMapping_shouldReturnADrugThatMatchesTheCodeAndSourceAndTheBestMapType() throws Exception { executeDataSet(DRUG_MAPPINGS); final String sourceUuid = conceptService.getConceptSource(1).getUuid(); String expectedDrugUuid = conceptService.getDrug(3).getUuid(); String mapTypeUuids = conceptService.getConceptMapType(3).getUuid(); SimpleObject results = deserialize(handle(newGetRequest(getURI(), new Parameter("s", "getDrugsByMapping"), new Parameter("code", "CD41003"), new Parameter("source", sourceUuid), new Parameter("preferredMapTypes", mapTypeUuids)))); assertEquals(0, Util.getResultsSize(results)); mapTypeUuids = conceptService.getConceptMapType(2).getUuid(); results = deserialize(handle(newGetRequest(getURI(), new Parameter("s", "getDrugsByMapping"), new Parameter("code", "CD41003"), new Parameter("source", sourceUuid), new Parameter("preferredMapTypes", mapTypeUuids)))); assertEquals(expectedDrugUuid, PropertyUtils.getProperty(Util.getResultsList(results).get(1), "uuid")); }
Assert.assertTrue(rep.keySet().contains("value")); rep = (SimpleObject) rep.get("value"); Assert.assertEquals("drug", drug.getUuid(), rep.get("uuid"));