Search in sources :

Example 66 with CanonicalType

use of org.hl7.fhir.r5.model.CanonicalType in project cqf-ruler by DBCG.

the class ExpressionEvaluation method cleanReferences.

private List<CanonicalType> cleanReferences(List<CanonicalType> references) {
    List<CanonicalType> cleanRefs = new ArrayList<>();
    List<CanonicalType> noDupes = new ArrayList<>();
    for (CanonicalType reference : references) {
        boolean dup = false;
        for (CanonicalType ref : noDupes) {
            if (ref.equalsDeep(reference)) {
                dup = true;
            }
        }
        if (!dup) {
            noDupes.add(reference);
        }
    }
    for (CanonicalType reference : noDupes) {
        cleanRefs.add(new CanonicalType(reference.getValue().replace("#", "")));
    }
    return cleanRefs;
}
Also used : ArrayList(java.util.ArrayList) CanonicalType(org.hl7.fhir.r4.model.CanonicalType)

Example 67 with CanonicalType

use of org.hl7.fhir.r5.model.CanonicalType in project cqf-ruler by DBCG.

the class CanonicalsTest method partialCanonicalType.

@Test
public void partialCanonicalType() {
    CanonicalType testUrl = new CanonicalType("http://fhir.acme.com/Questionnaire/example");
    assertEquals("http://fhir.acme.com/Questionnaire/example", Canonicals.getUrl(testUrl));
    assertEquals("Questionnaire", Canonicals.getResourceType(testUrl));
    assertEquals("example", Canonicals.getIdPart(testUrl));
    assertNull(Canonicals.getVersion(testUrl));
    assertNull(Canonicals.getFragment(testUrl));
}
Also used : CanonicalType(org.hl7.fhir.r4.model.CanonicalType) Test(org.junit.jupiter.api.Test)

Example 68 with CanonicalType

use of org.hl7.fhir.r5.model.CanonicalType in project cqf-ruler by DBCG.

the class CanonicalsTest method fullCanonicalType.

@Test
public void fullCanonicalType() {
    CanonicalType testUrl = new CanonicalType("http://fhir.acme.com/Questionnaire/example|1.0#vs1");
    assertEquals("http://fhir.acme.com/Questionnaire/example", Canonicals.getUrl(testUrl));
    assertEquals("example", Canonicals.getIdPart(testUrl));
    assertEquals("1.0", Canonicals.getVersion(testUrl));
    assertEquals("vs1", Canonicals.getFragment(testUrl));
}
Also used : CanonicalType(org.hl7.fhir.r4.model.CanonicalType) Test(org.junit.jupiter.api.Test)

Example 69 with CanonicalType

use of org.hl7.fhir.r5.model.CanonicalType in project Gravity-SDOH-Exchange-RI by FHIR.

the class PatientTaskService method addQuestionnairesToTaskBundle.

private void addQuestionnairesToTaskBundle(Bundle responseBundle) {
    // Extract all 'addresses' references as ids and search for corresponding Conditions, since they cannot be included.
    List<String> urls = FhirUtil.getFromBundle(responseBundle, Task.class, Bundle.SearchEntryMode.MATCH).stream().map(t -> t.getInput().stream().filter(i -> SDCTemporaryCode.QUESTIONNAIRE.getCode().equals(i.getType().getCodingFirstRep().getCode())).findAny().orElse(null)).filter(Objects::nonNull).filter(i -> i.getValue() instanceof CanonicalType).map(i -> ((CanonicalType) i.getValue()).getValue()).collect(Collectors.toList());
    Bundle questionnaires = ehrClient.search().forResource(Questionnaire.class).where(Questionnaire.URL.matches().values(urls)).returnBundle(Bundle.class).execute();
    FhirUtil.mergeBundles(ehrClient.getFhirContext(), responseBundle, questionnaires);
}
Also used : PatientSocialRiskTaskPrepareBundleFactory(org.hl7.gravity.refimpl.sdohexchange.fhir.factory.patienttask.PatientSocialRiskTaskPrepareBundleFactory) PatientTaskBundleToDtoConverter(org.hl7.gravity.refimpl.sdohexchange.dto.converter.PatientTaskBundleToDtoConverter) RequiredArgsConstructor(lombok.RequiredArgsConstructor) Autowired(org.springframework.beans.factory.annotation.Autowired) PatientTaskUpdateBundleFactory(org.hl7.gravity.refimpl.sdohexchange.fhir.factory.PatientTaskUpdateBundleFactory) PatientSocialRiskTaskBundleFactory(org.hl7.gravity.refimpl.sdohexchange.fhir.factory.patienttask.PatientSocialRiskTaskBundleFactory) Reference(org.hl7.fhir.r4.model.Reference) BaseResource(org.hl7.fhir.r4.model.BaseResource) SDCTemporaryCode(org.hl7.gravity.refimpl.sdohexchange.codes.SDCTemporaryCode) PatientTaskDto(org.hl7.gravity.refimpl.sdohexchange.dto.response.patienttask.PatientTaskDto) Task(org.hl7.fhir.r4.model.Task) UpdateTaskRequestDto(org.hl7.gravity.refimpl.sdohexchange.dto.request.UpdateTaskRequestDto) PatientTaskQueryFactory(org.hl7.gravity.refimpl.sdohexchange.fhir.query.PatientTaskQueryFactory) Lists(com.google.common.collect.Lists) PatientSocialRiskTaskPrepareBundleExtractor(org.hl7.gravity.refimpl.sdohexchange.fhir.extract.patienttask.PatientSocialRiskTaskPrepareBundleExtractor) Service(org.springframework.stereotype.Service) IGenericClient(ca.uhn.fhir.rest.client.api.IGenericClient) ResourceNotFoundException(ca.uhn.fhir.rest.server.exceptions.ResourceNotFoundException) PatientTaskBundleFactory(org.hl7.gravity.refimpl.sdohexchange.fhir.factory.patienttask.PatientTaskBundleFactory) PatientMakeContactTaskPrepareBundleFactory(org.hl7.gravity.refimpl.sdohexchange.fhir.factory.patienttask.PatientMakeContactTaskPrepareBundleFactory) UserDto(org.hl7.gravity.refimpl.sdohexchange.dto.response.UserDto) TokenClientParam(ca.uhn.fhir.rest.gclient.TokenClientParam) NewFeedbackTaskRequestDto(org.hl7.gravity.refimpl.sdohexchange.dto.request.patienttask.NewFeedbackTaskRequestDto) CanonicalType(org.hl7.fhir.r4.model.CanonicalType) NewSocialRiskTaskRequestDto(org.hl7.gravity.refimpl.sdohexchange.dto.request.patienttask.NewSocialRiskTaskRequestDto) PatientFeedbackTaskBundleFactory(org.hl7.gravity.refimpl.sdohexchange.fhir.factory.patienttask.PatientFeedbackTaskBundleFactory) Collectors(java.util.stream.Collectors) IdType(org.hl7.fhir.r4.model.IdType) PatientMakeContactTaskBundleFactory(org.hl7.gravity.refimpl.sdohexchange.fhir.factory.patienttask.PatientMakeContactTaskBundleFactory) Objects(java.util.Objects) NewMakeContactTaskRequestDto(org.hl7.gravity.refimpl.sdohexchange.dto.request.patienttask.NewMakeContactTaskRequestDto) NewPatientTaskRequestDto(org.hl7.gravity.refimpl.sdohexchange.dto.request.patienttask.NewPatientTaskRequestDto) QuestionnaireResponse(org.hl7.fhir.r4.model.QuestionnaireResponse) PatientFeedbackTaskPrepareBundleExtractor(org.hl7.gravity.refimpl.sdohexchange.fhir.extract.patienttask.PatientFeedbackTaskPrepareBundleExtractor) PatientFeedbackTaskPrepareBundleFactory(org.hl7.gravity.refimpl.sdohexchange.fhir.factory.patienttask.PatientFeedbackTaskPrepareBundleFactory) List(java.util.List) Coding(org.hl7.fhir.r4.model.Coding) PatientTaskBundleToItemDtoConverter(org.hl7.gravity.refimpl.sdohexchange.dto.converter.PatientTaskBundleToItemDtoConverter) SmartOnFhirContext(com.healthlx.smartonfhir.core.SmartOnFhirContext) Bundle(org.hl7.fhir.r4.model.Bundle) PatientTaskItemDto(org.hl7.gravity.refimpl.sdohexchange.dto.response.patienttask.PatientTaskItemDto) PatientMakeContactTaskPrepareBundleExtractor(org.hl7.gravity.refimpl.sdohexchange.fhir.extract.patienttask.PatientMakeContactTaskPrepareBundleExtractor) Questionnaire(org.hl7.fhir.r4.model.Questionnaire) FhirUtil(org.hl7.gravity.refimpl.sdohexchange.util.FhirUtil) Assert(org.springframework.util.Assert) Questionnaire(org.hl7.fhir.r4.model.Questionnaire) Bundle(org.hl7.fhir.r4.model.Bundle) CanonicalType(org.hl7.fhir.r4.model.CanonicalType)

Example 70 with CanonicalType

use of org.hl7.fhir.r5.model.CanonicalType in project Gravity-SDOH-Exchange-RI by FHIR.

the class ConvertService method convert.

public Map<String, Object> convert(JSONObject questionnaireResponse) throws IOException {
    QuestionnaireResponse qs = (QuestionnaireResponse) fhirContext.newJsonParser().parseResource(questionnaireResponse.toString());
    if (qs.getQuestionnaire() == null) {
        throw new IllegalStateException(String.format("QuestionnaireResponse '%s' does not contain a link to a Questionnaire.", qs.getIdElement().getIdPart()));
    }
    Optional<Questionnaire> foundQuestionnaire = questionnaireRepository.findByCanonnicalUri(qs.getQuestionnaire());
    if (!foundQuestionnaire.isPresent()) {
        throw new ResourceNotFoundException(String.format("Questionnaire was not found by URL '%s'.", qs.getQuestionnaire()));
    }
    Questionnaire questionnaire = foundQuestionnaire.get();
    String mapUri = ((CanonicalType) questionnaire.getExtensionByUrl(MAP_EXTENSION).getValue()).getValueAsString();
    boolean mapExists = validationEngine.getContext().listTransforms().stream().anyMatch(map -> map.getUrl().equals(mapUri));
    if (!mapExists) {
        loadMapIg(mapUri);
    }
    return new ObjectMapper().readValue(convertToBundle(questionnaireResponse, mapUri), Map.class);
}
Also used : Questionnaire(org.hl7.fhir.r4.model.Questionnaire) ResourceNotFoundException(ca.uhn.fhir.rest.server.exceptions.ResourceNotFoundException) QuestionnaireResponse(org.hl7.fhir.r4.model.QuestionnaireResponse) CanonicalType(org.hl7.fhir.r4.model.CanonicalType) ObjectMapper(com.fasterxml.jackson.databind.ObjectMapper)

Aggregations

CanonicalType (org.hl7.fhir.r4.model.CanonicalType)45 CanonicalType (org.hl7.fhir.r5.model.CanonicalType)37 ArrayList (java.util.ArrayList)27 CanonicalType (org.hl7.fhir.r4b.model.CanonicalType)19 TypeRefComponent (org.hl7.fhir.r5.model.ElementDefinition.TypeRefComponent)14 StructureDefinition (org.hl7.fhir.r5.model.StructureDefinition)13 CommaSeparatedStringBuilder (org.hl7.fhir.utilities.CommaSeparatedStringBuilder)12 Test (org.junit.jupiter.api.Test)12 List (java.util.List)10 FHIRException (org.hl7.fhir.exceptions.FHIRException)9 ElementDefinition (org.hl7.fhir.r5.model.ElementDefinition)9 HashMap (java.util.HashMap)7 HashSet (java.util.HashSet)7 Extension (org.hl7.fhir.r4.model.Extension)7 Library (org.hl7.fhir.r4.model.Library)7 StringType (org.hl7.fhir.r4.model.StringType)6 XhtmlNode (org.hl7.fhir.utilities.xhtml.XhtmlNode)6 FHIRFormatError (org.hl7.fhir.exceptions.FHIRFormatError)5 Bundle (org.hl7.fhir.r4.model.Bundle)5 IdType (org.hl7.fhir.r4.model.IdType)5