Search in sources :

Example 1 with REJECTED

use of org.hl7.fhir.r4.model.Consent.ConsentState.REJECTED in project fhir-bridge by ehrbase.

the class FindConsentTransactionIT method findConsentSearch.

@Test
void findConsentSearch() throws IOException {
    for (int i = 0; i < 3; i++) {
        create("Consent/transactions/find-consent-search.json");
    }
    Bundle bundle = search("Consent?patient.identifier=" + PATIENT_ID + "&status=rejected");
    Assertions.assertEquals(3, bundle.getTotal());
    bundle.getEntry().forEach(entry -> {
        var consent = (Consent) entry.getResource();
        Assertions.assertEquals(PATIENT_ID, consent.getPatient().getIdentifier().getValue());
        Assertions.assertEquals(Consent.ConsentState.REJECTED, consent.getStatus());
    });
}
Also used : Consent(org.hl7.fhir.r4.model.Consent) Bundle(org.hl7.fhir.r4.model.Bundle) Test(org.junit.jupiter.api.Test)

Example 2 with REJECTED

use of org.hl7.fhir.r4.model.Consent.ConsentState.REJECTED in project CRD by HL7-DaVinci.

the class JwtAuthorizationFilter method doFilterInternal.

@Override
protected void doFilterInternal(HttpServletRequest req, HttpServletResponse res, FilterChain chain) throws IOException, ServletException {
    String requestStr;
    try {
        ObjectMapper mapper = new ObjectMapper();
        ObjectWriter w = mapper.writer();
        requestStr = w.writeValueAsString(req);
    } catch (Exception e) {
        logger.error("failed to write request json: " + e.getMessage());
        requestStr = "{\"error\": \"Authorization failed, request rejected\"}";
    }
    RequestLog requestLog = new RequestLog(requestStr.getBytes(), new Date().getTime());
    String header = req.getHeader("Authorization");
    if (header == null || !header.startsWith("Bearer")) {
        requestService.create(requestLog);
        logger.warn("JWT authorization failed - no bearer auth token present");
        chain.doFilter(req, res);
        return;
    }
    logger.info("Bearer auth token recieved");
    UsernamePasswordAuthenticationToken authentication = getAuthentication(req);
    SecurityContextHolder.getContext().setAuthentication(authentication);
    if (authentication == null) {
        requestService.create(requestLog);
    }
    chain.doFilter(req, res);
}
Also used : RequestLog(org.hl7.davinci.endpoint.database.RequestLog) ObjectWriter(com.fasterxml.jackson.databind.ObjectWriter) UsernamePasswordAuthenticationToken(org.springframework.security.authentication.UsernamePasswordAuthenticationToken) ObjectMapper(com.fasterxml.jackson.databind.ObjectMapper) ServletException(javax.servlet.ServletException) IOException(java.io.IOException) Date(java.util.Date)

Example 3 with REJECTED

use of org.hl7.fhir.r4.model.Consent.ConsentState.REJECTED in project openmrs-module-fhir2 by openmrs.

the class BaseServiceRequestTranslator method determineServiceRequestStatus.

protected ServiceRequest.ServiceRequestStatus determineServiceRequestStatus(String orderUuid) {
    IBundleProvider results = taskService.searchForTasks(new ReferenceAndListParam().addAnd(new ReferenceOrListParam().add(new ReferenceParam("ServiceRequest", null, orderUuid))), null, null, null, null, null, null);
    Collection<Task> serviceRequestTasks = results.getResources(START_INDEX, END_INDEX).stream().map(p -> (Task) p).collect(Collectors.toList());
    ServiceRequest.ServiceRequestStatus serviceRequestStatus = ServiceRequest.ServiceRequestStatus.UNKNOWN;
    if (serviceRequestTasks.size() != 1) {
        return serviceRequestStatus;
    }
    Task serviceRequestTask = serviceRequestTasks.iterator().next();
    if (serviceRequestTask.hasStatus()) {
        switch(serviceRequestTask.getStatus()) {
            case ACCEPTED:
            case REQUESTED:
                serviceRequestStatus = ServiceRequest.ServiceRequestStatus.ACTIVE;
                break;
            case REJECTED:
                serviceRequestStatus = ServiceRequest.ServiceRequestStatus.REVOKED;
                break;
            case COMPLETED:
                serviceRequestStatus = ServiceRequest.ServiceRequestStatus.COMPLETED;
                break;
        }
    }
    return serviceRequestStatus;
}
Also used : ReferenceOrListParam(ca.uhn.fhir.rest.param.ReferenceOrListParam) IBundleProvider(ca.uhn.fhir.rest.api.server.IBundleProvider) Setter(lombok.Setter) Collection(java.util.Collection) Autowired(org.springframework.beans.factory.annotation.Autowired) ReferenceAndListParam(ca.uhn.fhir.rest.param.ReferenceAndListParam) Reference(org.hl7.fhir.r4.model.Reference) Collectors(java.util.stream.Collectors) Task(org.hl7.fhir.r4.model.Task) AccessLevel(lombok.AccessLevel) FhirTaskService(org.openmrs.module.fhir2.api.FhirTaskService) ReferenceParam(ca.uhn.fhir.rest.param.ReferenceParam) ServiceRequest(org.hl7.fhir.r4.model.ServiceRequest) Task(org.hl7.fhir.r4.model.Task) ReferenceParam(ca.uhn.fhir.rest.param.ReferenceParam) IBundleProvider(ca.uhn.fhir.rest.api.server.IBundleProvider) ReferenceAndListParam(ca.uhn.fhir.rest.param.ReferenceAndListParam) ReferenceOrListParam(ca.uhn.fhir.rest.param.ReferenceOrListParam) ServiceRequest(org.hl7.fhir.r4.model.ServiceRequest)

Example 4 with REJECTED

use of org.hl7.fhir.r4.model.Consent.ConsentState.REJECTED in project Gravity-SDOH-Exchange-RI by FHIR.

the class TaskProcessor method process.

public Bundle process(Task task) {
    Bundle bundle = new Bundle();
    bundle.setType(Bundle.BundleType.TRANSACTION);
    List<String> errors = taskValidator.validate(task);
    if (errors.isEmpty()) {
        log.info("Loading reference resources for Task '" + task.getIdElement().getIdPart() + "'");
        bundle.getEntry().addAll(taskReferenceResourcesLoader.getReferenceResources(task).getEntry());
        log.info("Setting status RECEIVED for Task '" + task.getIdElement().getIdPart() + "'");
        bundle.addEntry(FhirUtil.createPutEntry(task.setStatus(Task.TaskStatus.RECEIVED).setLastModified(new Date())));
    } else {
        log.warn("Setting status REJECTED for Task '" + task.getIdElement().getIdPart() + "'. Reason: " + String.join(";", errors));
        bundle.addEntry(FhirUtil.createPutEntry(task.setStatus(Task.TaskStatus.REJECTED).setStatusReason(new CodeableConcept().setText(String.join("\n", errors))).setLastModified(new Date())));
    }
    return bundle;
}
Also used : Bundle(org.hl7.fhir.r4.model.Bundle) Date(java.util.Date) CodeableConcept(org.hl7.fhir.r4.model.CodeableConcept)

Example 5 with REJECTED

use of org.hl7.fhir.r4.model.Consent.ConsentState.REJECTED in project odm2fhir by num-codex.

the class BroadConsent method createConsent.

@SuppressWarnings("fallthrough")
private Consent createConsent(FormData formData) {
    var identifier = createIdentifier(CONSENT, formData.getItemData("miibc_consent_status"));
    var consent = (Consent) new Consent().addIdentifier(identifier).setDateTimeElement(createDateTimeType(formData.getItemData("miibc_dat_dok"))).addOrganization(getOrganizationReference()).setScope(RESEARCH).addCategory(createCodeableConcept(createCoding(LOINC, "57016-8", "Privacy policy acknowledgment Document"))).addPolicy(new ConsentPolicyComponent().setUri(POLICY)).setMeta(createMeta(GERMAN_CONSENT));
    switch(formData.getItemData("miibc_consent_status").getValue()) {
        case // agreed
        "1":
            consent.setStatus(ConsentState.ACTIVE);
            break;
        case // rejected
        "2":
            consent.setStatus(REJECTED);
            break;
        case // revoked
        "3":
            var revocationDateItem = formData.getItemData("miibc_w_dat_dok");
            switch(formData.getItemData("miibc_widerruf").getValue()) {
                case // fully revoked
                "1":
                    consent.setStatus(INACTIVE).setDateTimeElement(// revocation -> replace 'consentDate' by 'revocationDate'
                    createDateTimeType(revocationDateItem));
                    break;
                case // partly revoked
                "2":
                    // revocation -> replace 'consentDate' by 'revocationDate'
                    consent.setDateTimeElement(createDateTimeType(revocationDateItem));
                // not revoked
                case "3":
                case // unknown (REVOCATION-Status, not CONSENT-Status!)
                "4":
                    // default if not revoked
                    consent.setStatus(ConsentState.ACTIVE);
                    break;
            }
            break;
        case // unknown
        "4":
            // skip if general CONSENT-Status is 'unknown'
            return new Consent();
    }
    var mainProvisionComponent = new Consent.provisionComponent().setType(DENY);
    if (consent.getDateTime() != null) {
        mainProvisionComponent.setPeriod(new Period().setStart(consent.getDateTime()).setEnd(addYears(consent.getDateTime(), 30)));
    }
    if (ConsentState.ACTIVE == consent.getStatus()) {
        // add more Consent details only if consented/not fully revoked
        mainProvisionComponent.setProvision(ELEMENTS.stream().map(key -> "gee_" + key).map(formData::getItemData).filter(not(ItemData::isEmpty)).map(itemData -> {
            var specificAnswerItemName = itemData.getItemOID();
            var specificAnswerItemValue = itemData.getValue();
            var partProvisionComponent = new Consent.provisionComponent().addCode(createCodeableConcept(createCoding("urn:oid:" + BASE_OID, BASE_OID + "." + OIDS.get(removeStart(specificAnswerItemName, "gee_") + "_" + specificAnswerItemValue), specificAnswerItemName)));
            if (!mainProvisionComponent.getPeriod().isEmpty()) {
                var period = mainProvisionComponent.getPeriod().copy();
                if ("gee_krankenkassendaten_retro".equals(specificAnswerItemName)) {
                    period.setEnd(period.getStart()).setStart(addYears(period.getStart(), -5));
                } else if ("gee_krankenkassendaten_pro".equals(specificAnswerItemName)) {
                    period.setEnd(addYears(period.getStart(), 5));
                }
                partProvisionComponent.setPeriod(period);
            }
            switch(specificAnswerItemValue) {
                case // agreed
                "1":
                    partProvisionComponent.setType(PERMIT);
                    break;
                // rejected
                case "2":
                case // revoked
                "4":
                    partProvisionComponent.setType(DENY);
                    break;
                // unknown
                case "3":
            }
            return partProvisionComponent;
        }).collect(toList()));
    }
    return consent.setProvision(mainProvisionComponent);
}
Also used : ItemData(de.difuture.uds.odm2fhir.odm.model.ItemData) PERMIT(org.hl7.fhir.r4.model.Consent.ConsentProvisionType.PERMIT) INACTIVE(org.hl7.fhir.r4.model.Consent.ConsentState.INACTIVE) FormData(de.difuture.uds.odm2fhir.odm.model.FormData) ConsentPolicyComponent(org.hl7.fhir.r4.model.Consent.ConsentPolicyComponent) Period(org.hl7.fhir.r4.model.Period) Consent(org.hl7.fhir.r4.model.Consent) CONSENT(org.hl7.fhir.r4.model.codesystems.ResourceTypes.CONSENT) Item(de.difuture.uds.odm2fhir.fhir.mapper.Item) DomainResource(org.hl7.fhir.r4.model.DomainResource) HashMap(java.util.HashMap) LOINC(de.difuture.uds.odm2fhir.fhir.util.CommonCodeSystem.LOINC) List(java.util.List) REJECTED(org.hl7.fhir.r4.model.Consent.ConsentState.REJECTED) Collectors.toList(java.util.stream.Collectors.toList) Stream(java.util.stream.Stream) ConsentState(org.hl7.fhir.r4.model.Consent.ConsentState) GERMAN_CONSENT(de.difuture.uds.odm2fhir.fhir.util.CommonStructureDefinition.GERMAN_CONSENT) Map(java.util.Map) DateUtils.addYears(org.apache.commons.lang3.time.DateUtils.addYears) Predicate.not(java.util.function.Predicate.not) StringUtils.removeStart(org.apache.commons.lang3.StringUtils.removeStart) DENY(org.hl7.fhir.r4.model.Consent.ConsentProvisionType.DENY) ConsentPolicyComponent(org.hl7.fhir.r4.model.Consent.ConsentPolicyComponent) Consent(org.hl7.fhir.r4.model.Consent) Period(org.hl7.fhir.r4.model.Period) ItemData(de.difuture.uds.odm2fhir.odm.model.ItemData)

Aggregations

Date (java.util.Date)2 Bundle (org.hl7.fhir.r4.model.Bundle)2 Consent (org.hl7.fhir.r4.model.Consent)2 IBundleProvider (ca.uhn.fhir.rest.api.server.IBundleProvider)1 ReferenceAndListParam (ca.uhn.fhir.rest.param.ReferenceAndListParam)1 ReferenceOrListParam (ca.uhn.fhir.rest.param.ReferenceOrListParam)1 ReferenceParam (ca.uhn.fhir.rest.param.ReferenceParam)1 ObjectMapper (com.fasterxml.jackson.databind.ObjectMapper)1 ObjectWriter (com.fasterxml.jackson.databind.ObjectWriter)1 Item (de.difuture.uds.odm2fhir.fhir.mapper.Item)1 LOINC (de.difuture.uds.odm2fhir.fhir.util.CommonCodeSystem.LOINC)1 GERMAN_CONSENT (de.difuture.uds.odm2fhir.fhir.util.CommonStructureDefinition.GERMAN_CONSENT)1 FormData (de.difuture.uds.odm2fhir.odm.model.FormData)1 ItemData (de.difuture.uds.odm2fhir.odm.model.ItemData)1 IOException (java.io.IOException)1 Collection (java.util.Collection)1 HashMap (java.util.HashMap)1 List (java.util.List)1 Map (java.util.Map)1 Predicate.not (java.util.function.Predicate.not)1