use of org.openmrs.module.fhir2.model.FhirConceptSource in project openmrs-module-fhir2 by openmrs.
the class ConceptTranslatorImplTest method shouldTranslateCIELCodeableConceptToConcept.
@Test
public void shouldTranslateCIELCodeableConceptToConcept() {
CodeableConcept codeableConcept = new CodeableConcept();
Coding cielCoding = codeableConcept.addCoding();
cielCoding.setSystem(FhirTestConstants.CIEL_SYSTEM_URN);
cielCoding.setCode("1650");
Concept concept = new Concept();
ConceptMap conceptMap = new ConceptMap();
ConceptReferenceTerm conceptReferenceTerm = new ConceptReferenceTerm();
ConceptSource ciel = new ConceptSource();
ciel.setName("CIEL");
conceptReferenceTerm.setConceptSource(ciel);
conceptReferenceTerm.setCode("1650");
conceptMap.setConceptReferenceTerm(conceptReferenceTerm);
ConceptMapType conceptMapType = new ConceptMapType();
conceptMap.setConceptMapType(conceptMapType);
concept.addConceptMapping(conceptMap);
when(conceptService.getConceptBySourceNameAndCode("CIEL", "1650")).thenReturn(Optional.of(concept));
FhirConceptSource fhirCielSource = new FhirConceptSource();
fhirCielSource.setConceptSource(ciel);
fhirCielSource.setUrl(FhirTestConstants.CIEL_SYSTEM_URN);
when(conceptSourceService.getFhirConceptSourceByUrl(FhirTestConstants.CIEL_SYSTEM_URN)).thenReturn(Optional.of(fhirCielSource));
Concept result = conceptTranslator.toOpenmrsType(codeableConcept);
assertThat(result, notNullValue());
assertThat(result.getConceptMappings(), notNullValue());
assertThat(result.getConceptMappings(), not(empty()));
assertThat(result.getConceptMappings(), hasItem(hasProperty("conceptReferenceTerm", hasProperty("code", equalTo("1650")))));
}
use of org.openmrs.module.fhir2.model.FhirConceptSource in project openmrs-module-fhir2 by openmrs.
the class FhirConceptSourceServiceImplTest method getFhirConceptSourceByConceptSourceName_shouldReturnConceptSourceForName.
@Test
public void getFhirConceptSourceByConceptSourceName_shouldReturnConceptSourceForName() {
FhirConceptSource source = new FhirConceptSource();
when(dao.getFhirConceptSourceByConceptSourceName("LOINC")).thenReturn(Optional.of(source));
Optional<FhirConceptSource> result = fhirConceptSourceService.getFhirConceptSourceByConceptSourceName("LOINC");
assertThat(result.isPresent(), is(true));
assertThat(result.get(), equalTo(source));
}
use of org.openmrs.module.fhir2.model.FhirConceptSource in project openmrs-module-fhir2 by openmrs.
the class FhirConceptSourceServiceImplTest method getFhirConceptSources_shouldReturnFhirConceptSources.
@Test
public void getFhirConceptSources_shouldReturnFhirConceptSources() {
Collection<FhirConceptSource> sources = Lists.newArrayList(new FhirConceptSource(), new FhirConceptSource());
when(dao.getFhirConceptSources()).thenReturn(sources);
Collection<FhirConceptSource> result = fhirConceptSourceService.getFhirConceptSources();
assertThat(result, notNullValue());
assertThat(result, not(empty()));
}
use of org.openmrs.module.fhir2.model.FhirConceptSource in project openmrs-module-fhir2 by openmrs.
the class ConceptTranslatorImplTest method shouldOnlyAddCodesThatAreMappedSAME_AS.
@Test
public void shouldOnlyAddCodesThatAreMappedSAME_AS() {
Collection<ConceptMap> conceptMaps = new ArrayList<>();
ConceptMap conceptMap1 = mock(ConceptMap.class);
conceptMaps.add(conceptMap1);
ConceptMap conceptMap2 = mock(ConceptMap.class);
conceptMaps.add(conceptMap2);
ConceptMapType conceptMapType1 = mock(ConceptMapType.class);
conceptMap1.setConceptMapType(conceptMapType1);
ConceptMapType conceptMapType2 = mock(ConceptMapType.class);
conceptMap2.setConceptMapType(conceptMapType2);
ConceptReferenceTerm conceptReferenceTerm = mock(ConceptReferenceTerm.class);
ConceptSource conceptSource1 = mock(ConceptSource.class);
when(concept.getConceptMappings()).thenReturn(conceptMaps);
when(conceptMap1.getConceptReferenceTerm()).thenReturn(conceptReferenceTerm);
when(conceptReferenceTerm.getConceptSource()).thenReturn(conceptSource1);
when(conceptReferenceTerm.getCode()).thenReturn("1650");
when(conceptSource1.getName()).thenReturn("CIEL");
when(conceptMap1.getConceptMapType()).thenReturn(conceptMapType1);
when(conceptMapType1.getName()).thenReturn("SAME-AS");
when(conceptMap2.getConceptMapType()).thenReturn(conceptMapType2);
when(conceptMapType2.getName()).thenReturn("NARROWER-THAN");
FhirConceptSource ciel = new FhirConceptSource();
ConceptSource cielConceptSource = new ConceptSource();
cielConceptSource.setName("CIEL");
ciel.setConceptSource(cielConceptSource);
ciel.setUrl(FhirTestConstants.CIEL_SYSTEM_URN);
when(conceptSourceService.getFhirConceptSourceByConceptSourceName("CIEL")).thenReturn(Optional.of(ciel));
CodeableConcept result = conceptTranslator.toFhirResource(concept);
assertThat(result, notNullValue());
assertThat(result.getCoding(), not(empty()));
// one SAME-AS, one UUID
assertThat(result.getCoding(), hasSize(2));
assertThat(result.getCoding(), hasItem(hasProperty("system", equalTo(FhirTestConstants.CIEL_SYSTEM_URN))));
assertThat(result.getCoding(), hasItem(hasProperty("code", equalTo("1650"))));
assertThat(result.getCoding(), hasItem(hasProperty("display", equalTo(CONCEPT_NAME))));
}
Aggregations