Search in sources :

Example 56 with Coverage

use of org.hl7.fhir.r4.model.Coverage in project org.hl7.fhir.core by hapifhir.

the class RdfParser method composeCoverageCostToBeneficiaryComponent.

protected void composeCoverageCostToBeneficiaryComponent(Complex parent, String parentType, String name, Coverage.CostToBeneficiaryComponent element, int index) {
    if (element == null)
        return;
    Complex t;
    if (Utilities.noString(parentType))
        t = parent;
    else {
        t = parent.predicate("fhir:" + parentType + '.' + name);
    }
    composeBackboneElement(t, "costToBeneficiary", name, element, index);
    if (element.hasType())
        composeCodeableConcept(t, "Coverage", "type", element.getType(), -1);
    if (element.hasValue())
        composeType(t, "Coverage", "value", element.getValue(), -1);
    for (int i = 0; i < element.getException().size(); i++) composeCoverageExemptionComponent(t, "Coverage", "exception", element.getException().get(i), i);
}
Also used : Complex(org.hl7.fhir.r4.utils.formats.Turtle.Complex)

Example 57 with Coverage

use of org.hl7.fhir.r4.model.Coverage in project org.hl7.fhir.core by hapifhir.

the class RdfParser method composeInsurancePlan.

protected void composeInsurancePlan(Complex parent, String parentType, String name, InsurancePlan element, int index) {
    if (element == null)
        return;
    Complex t;
    if (Utilities.noString(parentType))
        t = parent;
    else {
        t = parent.predicate("fhir:" + parentType + '.' + name);
    }
    composeDomainResource(t, "InsurancePlan", name, element, index);
    for (int i = 0; i < element.getIdentifier().size(); i++) composeIdentifier(t, "InsurancePlan", "identifier", element.getIdentifier().get(i), i);
    if (element.hasStatusElement())
        composeEnum(t, "InsurancePlan", "status", element.getStatusElement(), -1);
    for (int i = 0; i < element.getType().size(); i++) composeCodeableConcept(t, "InsurancePlan", "type", element.getType().get(i), i);
    if (element.hasNameElement())
        composeString(t, "InsurancePlan", "name", element.getNameElement(), -1);
    for (int i = 0; i < element.getAlias().size(); i++) composeString(t, "InsurancePlan", "alias", element.getAlias().get(i), i);
    if (element.hasPeriod())
        composePeriod(t, "InsurancePlan", "period", element.getPeriod(), -1);
    if (element.hasOwnedBy())
        composeReference(t, "InsurancePlan", "ownedBy", element.getOwnedBy(), -1);
    if (element.hasAdministeredBy())
        composeReference(t, "InsurancePlan", "administeredBy", element.getAdministeredBy(), -1);
    for (int i = 0; i < element.getCoverageArea().size(); i++) composeReference(t, "InsurancePlan", "coverageArea", element.getCoverageArea().get(i), i);
    for (int i = 0; i < element.getContact().size(); i++) composeInsurancePlanInsurancePlanContactComponent(t, "InsurancePlan", "contact", element.getContact().get(i), i);
    for (int i = 0; i < element.getEndpoint().size(); i++) composeReference(t, "InsurancePlan", "endpoint", element.getEndpoint().get(i), i);
    for (int i = 0; i < element.getNetwork().size(); i++) composeReference(t, "InsurancePlan", "network", element.getNetwork().get(i), i);
    for (int i = 0; i < element.getCoverage().size(); i++) composeInsurancePlanInsurancePlanCoverageComponent(t, "InsurancePlan", "coverage", element.getCoverage().get(i), i);
    for (int i = 0; i < element.getPlan().size(); i++) composeInsurancePlanInsurancePlanPlanComponent(t, "InsurancePlan", "plan", element.getPlan().get(i), i);
}
Also used : Complex(org.hl7.fhir.r4.utils.formats.Turtle.Complex)

Example 58 with Coverage

use of org.hl7.fhir.r4.model.Coverage in project org.hl7.fhir.core by hapifhir.

the class RdfParser method composeClaimInsuranceComponent.

protected void composeClaimInsuranceComponent(Complex parent, String parentType, String name, Claim.InsuranceComponent element, int index) {
    if (element == null)
        return;
    Complex t;
    if (Utilities.noString(parentType))
        t = parent;
    else {
        t = parent.predicate("fhir:" + parentType + '.' + name);
    }
    composeBackboneElement(t, "insurance", name, element, index);
    if (element.hasSequenceElement())
        composePositiveInt(t, "Claim", "sequence", element.getSequenceElement(), -1);
    if (element.hasFocalElement())
        composeBoolean(t, "Claim", "focal", element.getFocalElement(), -1);
    if (element.hasIdentifier())
        composeIdentifier(t, "Claim", "identifier", element.getIdentifier(), -1);
    if (element.hasCoverage())
        composeReference(t, "Claim", "coverage", element.getCoverage(), -1);
    if (element.hasBusinessArrangementElement())
        composeString(t, "Claim", "businessArrangement", element.getBusinessArrangementElement(), -1);
    for (int i = 0; i < element.getPreAuthRef().size(); i++) composeString(t, "Claim", "preAuthRef", element.getPreAuthRef().get(i), i);
    if (element.hasClaimResponse())
        composeReference(t, "Claim", "claimResponse", element.getClaimResponse(), -1);
}
Also used : Complex(org.hl7.fhir.r4.utils.formats.Turtle.Complex)

Example 59 with Coverage

use of org.hl7.fhir.r4.model.Coverage in project CRD by HL7-DaVinci.

the class FhirBundleProcessor method createCriteriaList.

private List<CoverageRequirementRuleCriteria> createCriteriaList(CodeableConcept codeableConcept, List<Reference> insurance, List<Organization> payorList) {
    try {
        List<Coding> codings = codeableConcept.getCoding();
        if (codings.size() > 0) {
            logger.info("r4/FhirBundleProcessor::createCriteriaList: code[0]: " + codings.get(0).getCode() + " - " + codings.get(0).getSystem());
        } else {
            logger.info("r4/FhirBundleProcessor::createCriteriaList: empty codes list!");
        }
        List<Organization> payors = new ArrayList<>();
        if (insurance != null) {
            List<Coverage> coverages = insurance.stream().map(reference -> (Coverage) reference.getResource()).collect(Collectors.toList());
            // Remove null coverages that may not have resolved.
            coverages = coverages.stream().filter(coverage -> coverage != null).collect(Collectors.toList());
            payors = Utilities.getPayors(coverages);
        } else if (payorList != null) {
            payors = payorList;
        }
        if (payors.size() > 0) {
            logger.info("r4/FhirBundleProcessor::createCriteriaList: payer[0]: " + payors.get(0).getName());
        } else {
            // default to CMS if no payer was provided
            logger.info("r4/FhirBundleProcessor::createCriteriaList: empty payers list, working around by adding CMS!");
            Organization org = new Organization().setName("Centers for Medicare and Medicaid Services");
            // how to get ID
            org.setId("75f39025-65db-43c8-9127-693cdf75e712");
            payors.add(org);
        // remove the exception to use CMS if no payer is provided
        // JIRA ticket https://jira.mitre.org/browse/DMEERX-894
        // throw new RequestIncompleteException("No Payer found in coverage resource, cannot find documentation.");
        }
        List<CoverageRequirementRuleCriteria> criteriaList = CoverageRequirementRuleCriteria.createQueriesFromR4(codings, payors);
        return criteriaList;
    } catch (RequestIncompleteException e) {
        // rethrow incomplete request exceptions
        throw e;
    } catch (Exception e) {
        // catch all remaining exceptions
        System.out.println(e);
        throw new RequestIncompleteException("Unable to parse list of codes, codesystems, and payors from a device request.");
    }
}
Also used : Logger(org.slf4j.Logger) CoverageRequirementRuleCriteria(org.hl7.davinci.endpoint.rules.CoverageRequirementRuleCriteria) org.hl7.fhir.r4.model(org.hl7.fhir.r4.model) LoggerFactory(org.slf4j.LoggerFactory) RuleMapping(org.hl7.davinci.endpoint.database.RuleMapping) CqlExecutionContextBuilder(org.hl7.davinci.endpoint.cql.r4.CqlExecutionContextBuilder) FileStore(org.hl7.davinci.endpoint.files.FileStore) HashMap(java.util.HashMap) Collectors(java.util.stream.Collectors) ArrayList(java.util.ArrayList) List(java.util.List) CoverageRequirementRuleResult(org.hl7.davinci.endpoint.rules.CoverageRequirementRuleResult) CqlRule(org.hl7.davinci.endpoint.cql.CqlRule) RequestIncompleteException(org.hl7.davinci.RequestIncompleteException) Utilities(org.hl7.davinci.r4.Utilities) CoverageRequirementRuleCriteria(org.hl7.davinci.endpoint.rules.CoverageRequirementRuleCriteria) RequestIncompleteException(org.hl7.davinci.RequestIncompleteException) ArrayList(java.util.ArrayList) RequestIncompleteException(org.hl7.davinci.RequestIncompleteException)

Example 60 with Coverage

use of org.hl7.fhir.r4.model.Coverage in project CRD by HL7-DaVinci.

the class CardBuilder method createSuggestionWithNote.

public static Suggestion createSuggestionWithNote(Card card, IBaseResource request, FhirComponentsT fhirComponents, String label, String description, boolean isRecommended, CoverageGuidance coverageGuidance) {
    Date now = new Date();
    Suggestion requestWithNoteSuggestion = new Suggestion();
    requestWithNoteSuggestion.setLabel(label);
    requestWithNoteSuggestion.setIsRecommended(isRecommended);
    List<Action> actionList = new ArrayList<>();
    // build the Annotation
    Annotation annotation = new Annotation();
    StringType author = new StringType();
    author.setValue(card.getSource().getLabel());
    annotation.setAuthor(author);
    String text = card.getSummary() + ": " + card.getDetail();
    annotation.setText(text);
    // set the date and time to now
    annotation.setTime(now);
    IBaseResource resource = FhirRequestProcessor.addNoteToRequest(request, annotation);
    try {
        // build the Extension with the coverage information
        Extension extension = new Extension();
        extension.setUrl("http://hl7.org/fhir/us/davinci-crd/StructureDefinition/ext-coverage-information");
        Extension coverageInfo = new Extension();
        coverageInfo.setUrl("coverageInfo").setValue(coverageGuidance.getCoding());
        extension.addExtension(coverageInfo);
        Extension coverageExtension = new Extension();
        Reference coverageReference = new Reference();
        // TODO: get the coverage from the prefetch and pass it into here instead of retrieving it from the request
        coverageReference.setReference(FhirRequestProcessor.getCoverageFromRequest(request).getReference());
        coverageExtension.setUrl("coverage").setValue(coverageReference);
        extension.addExtension(coverageExtension);
        Extension date = new Extension();
        date.setUrl("date").setValue(new DateType().setValue(now));
        extension.addExtension(date);
        Extension identifier = new Extension();
        String id = UUID.randomUUID().toString();
        identifier.setUrl("identifier").setValue(new StringType(id));
        extension.addExtension(identifier);
        resource = FhirRequestProcessor.addExtensionToRequest(resource, extension);
    } catch (NoCoverageException e) {
        logger.warn("No Coverage, discrete coverage extension will not be included: " + e.getMessage());
    }
    Action updateAction = new Action(fhirComponents);
    updateAction.setType(Action.TypeEnum.update);
    updateAction.setDescription(description);
    updateAction.setResource(resource);
    actionList.add(updateAction);
    requestWithNoteSuggestion.setActions(actionList);
    return requestWithNoteSuggestion;
}
Also used : NoCoverageException(org.hl7.davinci.endpoint.cdshooks.services.crd.r4.NoCoverageException) Extension(org.hl7.fhir.r4.model.Extension) IBaseResource(org.hl7.fhir.instance.model.api.IBaseResource)

Aggregations

Test (org.junit.jupiter.api.Test)34 Coverage (org.hl7.fhir.r4.model.Coverage)31 BundleEntryComponent (org.hl7.fhir.r4.model.Bundle.BundleEntryComponent)17 Beneficiary (gov.cms.bfd.model.rif.Beneficiary)16 MedicareSegment (gov.cms.bfd.server.war.commons.MedicareSegment)15 Coverage (org.hl7.fhir.dstu3.model.Coverage)15 List (java.util.List)14 Reference (org.hl7.fhir.r4.model.Reference)14 Resource (org.hl7.fhir.r4.model.Resource)14 TransformerConstants (gov.cms.bfd.server.war.commons.TransformerConstants)13 Arrays (java.util.Arrays)13 Instant (java.time.Instant)12 Bundle (org.hl7.fhir.r4.model.Bundle)12 Logger (org.slf4j.Logger)12 LoggerFactory (org.slf4j.LoggerFactory)12 Date (java.util.Date)11 Complex (org.hl7.fhir.dstu2016may.formats.RdfGenerator.Complex)11 Constants (ca.uhn.fhir.rest.api.Constants)10 Timer (com.codahale.metrics.Timer)10 IBaseResource (org.hl7.fhir.instance.model.api.IBaseResource)10