use of org.hl7.gravity.refimpl.sdohexchange.sdohmappings.System in project summary-care-record-api by NHSDigital.
the class ObservationMapper method mapFinding.
private static Finding mapFinding(Observation observation, Bundle bundle) {
var finding = new Finding();
finding.setIdRoot(observation.getIdentifierFirstRep().getValue());
finding.setCodeCode(observation.getCode().getCodingFirstRep().getCode());
finding.setCodeDisplayName(observation.getCode().getCodingFirstRep().getDisplay());
finding.setStatusCodeCode(mapStatus(observation.getStatus()));
if (observation.getEffective() instanceof DateTimeType) {
finding.setEffectiveTimeCenter(formatDateToHl7(observation.getEffectiveDateTimeType()));
} else if (observation.getEffective() instanceof Period) {
var period = observation.getEffectivePeriod();
if (period.hasStart()) {
finding.setEffectiveTimeLow(formatDateToHl7(period.getStartElement()));
}
if (period.hasEnd()) {
finding.setEffectiveTimeHigh(formatDateToHl7(period.getEndElement()));
}
} else {
throw new FhirValidationException("Observation.effective must be of type DateTimeType or Period");
}
var encounterReference = observation.getEncounter().getReference();
if (StringUtils.isNotBlank(encounterReference)) {
var encounter = getResourceByReference(bundle, encounterReference, Encounter.class).orElseThrow(() -> new FhirValidationException(String.format("Bundle is Missing Encounter %s that is linked to Condition %s", observation.getEncounter().getReference(), observation.getId())));
for (var encounterParticipant : encounter.getParticipant()) {
Coding coding = encounterParticipant.getTypeFirstRep().getCodingFirstRep();
if (!PARTICIPATION_TYPE_SYSTEM.equals(coding.getSystem())) {
throw new FhirValidationException("Unsupported encounter participant system: " + coding.getSystem());
}
var code = coding.getCode();
if ("AUT".equals(code)) {
var author = mapAuthor1(bundle, encounterParticipant);
finding.setAuthor(author);
} else if ("INF".equals(code)) {
var informant = mapInformant(bundle, encounterParticipant);
finding.setInformant(informant);
} else if ("PRF".equals(code)) {
var performer = mapPerformer(bundle, encounterParticipant);
finding.setPerformer(performer);
} else {
throw new FhirValidationException(String.format("Invalid encounter %s participant code %s", encounter.getId(), code));
}
}
}
return finding;
}
use of org.hl7.gravity.refimpl.sdohexchange.sdohmappings.System in project openmrs-module-fhir2 by openmrs.
the class ServiceRequestSearchQueryTest method searchForServiceRequests_shouldSupportMappedAndUnmappedConcepts.
@Test
public void searchForServiceRequests_shouldSupportMappedAndUnmappedConcepts() {
TokenAndListParam code = new TokenAndListParam().addAnd(new TokenParam().setSystem(FhirTestConstants.LOINC_SYSTEM_URL).setValue(TEST_ORDER_LOINC_CODE)).addAnd(new TokenParam().setValue(TEST_ORDER_CONCEPT_ID));
SearchParameterMap theParams = new SearchParameterMap().addParameter(FhirConstants.CODED_SEARCH_HANDLER, code);
IBundleProvider results = search(theParams);
assertThat(results, notNullValue());
assertThat(results.size(), equalTo(4));
List<ServiceRequest> resultList = get(results);
assertThat(resultList, not(empty()));
assertThat(resultList, hasSize(equalTo(4)));
assertThat(resultList, everyItem(allOf(hasProperty("code", hasProperty("coding", hasItem(allOf(hasProperty("code", equalTo(TEST_ORDER_LOINC_CODE)), hasProperty("system", equalTo(FhirTestConstants.LOINC_SYSTEM_URL)))))), hasProperty("code", hasProperty("coding", hasItem(hasProperty("code", equalTo(TEST_ORDER_CONCEPT_UUID))))))));
}
use of org.hl7.gravity.refimpl.sdohexchange.sdohmappings.System in project openmrs-module-fhir2 by openmrs.
the class ServiceRequestSearchQueryTest method searchForServiceRequests_shouldReturnFromMultipleConceptMappings.
@Test
public void searchForServiceRequests_shouldReturnFromMultipleConceptMappings() {
TokenAndListParam code = new TokenAndListParam().addAnd(new TokenParam().setSystem(FhirTestConstants.LOINC_SYSTEM_URL).setValue(TEST_ORDER_LOINC_CODE), new TokenParam().setSystem(FhirTestConstants.CIEL_SYSTEM_URN).setValue(TEST_ORDER_CIEL_CODE));
SearchParameterMap theParams = new SearchParameterMap().addParameter(FhirConstants.CODED_SEARCH_HANDLER, code);
IBundleProvider results = search(theParams);
assertThat(results, notNullValue());
assertThat(results.size(), equalTo(4));
List<ServiceRequest> resultList = get(results);
assertThat(resultList, not(empty()));
assertThat(resultList, hasSize(equalTo(4)));
assertThat(resultList, everyItem(anyOf(hasProperty("code", hasProperty("coding", hasItem(allOf(hasProperty("code", equalTo(TEST_ORDER_LOINC_CODE)), hasProperty("system", equalTo(FhirTestConstants.LOINC_SYSTEM_URL)))))), hasProperty("code", hasProperty("coding", hasItem(allOf(hasProperty("code", equalTo(TEST_ORDER_CIEL_CODE)), hasProperty("system", equalTo(FhirTestConstants.CIEL_SYSTEM_URN)))))))));
}
use of org.hl7.gravity.refimpl.sdohexchange.sdohmappings.System in project openmrs-module-fhir2 by openmrs.
the class ConceptTranslatorImplTest method shouldTranslateCIELMappingForCIELMappedConcept.
@Test
public void shouldTranslateCIELMappingForCIELMappedConcept() {
Collection<ConceptMap> conceptMaps = new ArrayList<>();
ConceptMap conceptMap = mock(ConceptMap.class);
conceptMaps.add(conceptMap);
ConceptReferenceTerm conceptReferenceTerm = mock(ConceptReferenceTerm.class);
ConceptSource conceptSource = mock(ConceptSource.class);
ConceptMapType conceptMapType = mock(ConceptMapType.class);
when(conceptMap.getConceptMapType()).thenReturn(conceptMapType);
when(conceptMapType.getName()).thenReturn("SAME-AS");
when(conceptMap.getConceptReferenceTerm()).thenReturn(conceptReferenceTerm);
when(conceptReferenceTerm.getConceptSource()).thenReturn(conceptSource);
when(conceptReferenceTerm.getCode()).thenReturn("1650");
when(conceptSource.getName()).thenReturn("CIEL");
when(concept.getConceptMappings()).thenReturn(conceptMaps);
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()));
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))));
}
use of org.hl7.gravity.refimpl.sdohexchange.sdohmappings.System in project openmrs-module-fhir2 by openmrs.
the class ConceptTranslatorImplTest method shouldTranslateLOINCMappingForLOINCMappedConcept.
@Test
public void shouldTranslateLOINCMappingForLOINCMappedConcept() {
Collection<ConceptMap> conceptMaps = new ArrayList<>();
ConceptMap conceptMap = mock(ConceptMap.class);
conceptMaps.add(conceptMap);
ConceptReferenceTerm conceptReferenceTerm = mock(ConceptReferenceTerm.class);
ConceptSource conceptSource = mock(ConceptSource.class);
ConceptMapType conceptMapType = mock(ConceptMapType.class);
when(conceptMap.getConceptMapType()).thenReturn(conceptMapType);
when(conceptMapType.getName()).thenReturn("SAME-AS");
when(conceptMap.getConceptReferenceTerm()).thenReturn(conceptReferenceTerm);
when(conceptReferenceTerm.getConceptSource()).thenReturn(conceptSource);
when(conceptReferenceTerm.getCode()).thenReturn("1000-1");
when(conceptSource.getName()).thenReturn("LOINC");
when(concept.getConceptMappings()).thenReturn(conceptMaps);
FhirConceptSource loinc = new FhirConceptSource();
ConceptSource loincConceptSource = new ConceptSource();
loincConceptSource.setName("LOINC");
loinc.setConceptSource(loincConceptSource);
loinc.setUrl(FhirTestConstants.LOINC_SYSTEM_URL);
when(conceptSourceService.getFhirConceptSourceByConceptSourceName("LOINC")).thenReturn(Optional.of(loinc));
CodeableConcept result = conceptTranslator.toFhirResource(concept);
assertThat(result, notNullValue());
assertThat(result.getCoding(), not(empty()));
assertThat(result.getCoding(), hasItem(hasProperty("system", equalTo(FhirTestConstants.LOINC_SYSTEM_URL))));
assertThat(result.getCoding(), hasItem(hasProperty("code", equalTo("1000-1"))));
assertThat(result.getCoding(), hasItem(hasProperty("display", equalTo(CONCEPT_NAME))));
}
Aggregations