Search in sources :

Example 1 with FHIRException

use of org.hl7.fhir.exceptions.FHIRException in project gpconnect-demonstrator by nhsconnect.

the class PatientResourceProvider method patientDetailsToRegisterPatientResourceConverter.

// a cut-down Patient
private Patient patientDetailsToRegisterPatientResourceConverter(PatientDetails patientDetails) throws FHIRException {
    Patient patient = patientDetailsToMinimalPatient(patientDetails);
    HumanName name = getPatientNameFromPatientDetails(patientDetails);
    patient.addName(name);
    patient = setStaticPatientData(patient);
    return patient;
}
Also used : HumanName(org.hl7.fhir.dstu3.model.HumanName) Patient(org.hl7.fhir.dstu3.model.Patient)

Example 2 with FHIRException

use of org.hl7.fhir.exceptions.FHIRException in project bunsen by cerner.

the class FhirEncodersTest method annotation.

@Test
public void annotation() throws FHIRException {
    Annotation original = medRequest.getNoteFirstRep();
    Annotation decoded = decodedMedRequest.getNoteFirstRep();
    Assert.assertEquals(original.getText(), medDataset.select(functions.expr("note[0].text")).head().get(0));
    Assert.assertEquals(original.getText(), decoded.getText());
    Assert.assertEquals(original.getAuthorReference().getReference(), decoded.getAuthorReference().getReference());
}
Also used : Annotation(org.hl7.fhir.dstu3.model.Annotation) Test(org.junit.Test)

Example 3 with FHIRException

use of org.hl7.fhir.exceptions.FHIRException in project bunsen by cerner.

the class ConceptMapsTest method testAppendMappings.

@Test
public void testAppendMappings() throws FHIRException {
    ConceptMaps original = ConceptMaps.getEmpty(spark).withConceptMaps(conceptMap("urn:cerner:map:testmap", "1"), conceptMap("urn:cerner:map:othermap", "1"));
    ConceptMaps maps = original.withConceptMaps(conceptMap("urn:cerner:map:newmap", "1"));
    // The original should be unchanged.
    Assert.assertEquals(2, original.getMappings().count());
    Assert.assertEquals(3, maps.getMappings().count());
    ConceptMap firstMap = maps.getConceptMap("urn:cerner:map:testmap", "1");
    checkMap(firstMap, "urn:cerner:map:testmap", "1");
    ConceptMap secondMap = maps.getConceptMap("urn:cerner:map:othermap", "1");
    checkMap(secondMap, "urn:cerner:map:othermap", "1");
    ConceptMap newMap = maps.getConceptMap("urn:cerner:map:newmap", "1");
    checkMap(newMap, "urn:cerner:map:newmap", "1");
}
Also used : ConceptMap(org.hl7.fhir.dstu3.model.ConceptMap) Test(org.junit.Test)

Example 4 with FHIRException

use of org.hl7.fhir.exceptions.FHIRException in project bunsen by cerner.

the class ConceptMapsTest method testCreateSimpleMappings.

@Test
public void testCreateSimpleMappings() throws FHIRException {
    ConceptMaps maps = ConceptMaps.getEmpty(spark).withConceptMaps(conceptMap("urn:cerner:map:testmap", "1"), conceptMap("urn:cerner:map:othermap", "1"));
    Dataset<Mapping> mappings = maps.getMappings();
    Assert.assertEquals(2, mappings.count());
    ConceptMap firstMap = maps.getConceptMap("urn:cerner:map:testmap", "1");
    checkMap(firstMap, "urn:cerner:map:testmap", "1");
    ConceptMap secondMap = maps.getConceptMap("urn:cerner:map:othermap", "1");
    checkMap(secondMap, "urn:cerner:map:othermap", "1");
}
Also used : ConceptMap(org.hl7.fhir.dstu3.model.ConceptMap) Test(org.junit.Test)

Example 5 with FHIRException

use of org.hl7.fhir.exceptions.FHIRException in project bunsen by cerner.

the class ConceptMaps method expandMappingsIterator.

private static Iterator<Mapping> expandMappingsIterator(ConceptMap map) {
    List<Mapping> mappings = new ArrayList<>();
    for (ConceptMapGroupComponent group : map.getGroup()) {
        for (SourceElementComponent element : group.getElement()) {
            for (TargetElementComponent target : element.getTarget()) {
                Mapping mapping = new Mapping();
                mapping.setConceptMapUri(map.getUrl());
                mapping.setConceptMapVersion(map.getVersion());
                try {
                    String sourceValue = map.getSource() instanceof UriType ? map.getSourceUriType().getValue() : map.getSourceReference().getReference();
                    mapping.setSourceValueSet(sourceValue);
                    String targetValue = map.getTarget() instanceof UriType ? map.getTargetUriType().getValue() : map.getTargetReference().getReference();
                    mapping.setTargetValueSet(targetValue);
                } catch (FHIRException fhirException) {
                    // an exception.
                    throw new RuntimeException(fhirException);
                }
                mapping.setSourceSystem(group.getSource());
                mapping.setSourceValue(element.getCode());
                mapping.setTargetSystem(group.getTarget());
                mapping.setTargetValue(target.getCode());
                if (target.getEquivalence() != null) {
                    mapping.setEquivalence(target.getEquivalence().toCode());
                }
                mappings.add(mapping);
            }
        }
    }
    return mappings.iterator();
}
Also used : ArrayList(java.util.ArrayList) TargetElementComponent(org.hl7.fhir.dstu3.model.ConceptMap.TargetElementComponent) FHIRException(org.hl7.fhir.exceptions.FHIRException) ConceptMapGroupComponent(org.hl7.fhir.dstu3.model.ConceptMap.ConceptMapGroupComponent) SourceElementComponent(org.hl7.fhir.dstu3.model.ConceptMap.SourceElementComponent) UriType(org.hl7.fhir.dstu3.model.UriType)

Aggregations

FHIRException (org.hl7.fhir.exceptions.FHIRException)8 UnprocessableEntityException (ca.uhn.fhir.rest.server.exceptions.UnprocessableEntityException)6 Test (org.junit.Test)4 ArrayList (java.util.ArrayList)3 ConceptMap (org.hl7.fhir.dstu3.model.ConceptMap)3 Date (java.util.Date)2 Patient (org.hl7.fhir.dstu3.model.Patient)2 PopulateMedicationBundle (uk.gov.hscic.medications.PopulateMedicationBundle)2 PatientDetails (uk.gov.hscic.model.patient.PatientDetails)2 ForbiddenOperationException (ca.uhn.fhir.rest.server.exceptions.ForbiddenOperationException)1 InvalidRequestException (ca.uhn.fhir.rest.server.exceptions.InvalidRequestException)1 ResourceNotFoundException (ca.uhn.fhir.rest.server.exceptions.ResourceNotFoundException)1 UnclassifiedServerFailureException (ca.uhn.fhir.rest.server.exceptions.UnclassifiedServerFailureException)1 AllergyIntolerance (org.hl7.fhir.dstu3.model.AllergyIntolerance)1 Annotation (org.hl7.fhir.dstu3.model.Annotation)1 CodeableConcept (org.hl7.fhir.dstu3.model.CodeableConcept)1 Coding (org.hl7.fhir.dstu3.model.Coding)1 ConceptMapGroupComponent (org.hl7.fhir.dstu3.model.ConceptMap.ConceptMapGroupComponent)1 SourceElementComponent (org.hl7.fhir.dstu3.model.ConceptMap.SourceElementComponent)1 TargetElementComponent (org.hl7.fhir.dstu3.model.ConceptMap.TargetElementComponent)1