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());
});
}
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);
}
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;
}
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;
}
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);
}
Aggregations