use of org.hl7.fhir.dstu3.model.Consent in project dpc-app by CMSgov.
the class ConsentResource method create.
@POST
@FHIR
@UnitOfWork
@ApiOperation(value = "Create a Consent resource")
@ApiResponses(value = { @ApiResponse(code = 201, message = "Consent resource was created"), @ApiResponse(code = 400, message = "Consent resource was not created due to bad request") })
public Response create(@ApiParam(value = "Consent resource") Consent consent) {
ConsentEntity entity = ConsentEntityConverter.fromFhir(consent);
entity = dao.persistConsent(entity);
Consent result = ConsentEntityConverter.toFhir(entity, fhirReferenceURL);
return Response.status(Response.Status.CREATED).entity(result).build();
}
use of org.hl7.fhir.dstu3.model.Consent in project dpc-app by CMSgov.
the class ConsentEntityConverterTest method convert_correctlyConverts_fromOptOutEntity.
@Test
final void convert_correctlyConverts_fromOptOutEntity() {
ConsentEntity ce = ConsentEntity.defaultConsentEntity(Optional.empty(), Optional.of(TEST_HICN), Optional.of(TEST_MBI));
ce.setPolicyCode(ConsentEntity.OPT_OUT);
final Consent result = ConsentEntityConverter.toFhir(ce, TEST_FHIR_URL);
assertEquals(ConsentEntityConverter.OPT_OUT_MAGIC, result.getPolicyRule());
assertDoesNotThrow(() -> {
FhirContext.forDstu3().newJsonParser().encodeResourceToString(result);
});
}
use of org.hl7.fhir.dstu3.model.Consent in project dpc-app by CMSgov.
the class ConsentServiceImpl method getConsent.
@Override
public Optional<List<ConsentResult>> getConsent(String mbi) {
final Bundle bundle = doConsentSearch(mbi);
List<ConsentResult> results = bundle.getEntry().stream().map(entryComponent -> {
Consent consent = (Consent) entryComponent.getResource();
ConsentResult consentResult = new ConsentResult();
consentResult.setActive(Consent.ConsentState.ACTIVE.equals(consent.getStatus()));
consentResult.setConsentDate(consent.getDateTime());
consentResult.setConsentId(consent.getId());
consentResult.setPolicyType(ConsentResult.PolicyType.fromPolicyUrl(consent.getPolicyRule()));
return consentResult;
}).collect(Collectors.toList());
return Optional.of(results);
}
use of org.hl7.fhir.dstu3.model.Consent in project Gravity-SDOH-Exchange-RI by FHIR.
the class ServiceRequestReferenceResolver method getConsent.
public Consent getConsent(IIdType iIdType) {
Consent consent = localConsents.get(iIdType.getIdPart());
if (consent == null) {
consent = externalConsents.get(iIdType.getIdPart()).copy();
// Remove SDOH profile, Logica does not support this.
// TODO Use SDOH Profiles.
consent.setMeta(null);
// Set identifier to link resource from EHR
consent.addIdentifier().setSystem(identifierSystem).setValue(consent.getIdElement().getIdPart());
consent.setId(IdType.newRandomUuid());
}
return consent;
}
use of org.hl7.fhir.dstu3.model.Consent in project Gravity-SDOH-Exchange-RI by FHIR.
the class TaskBundleFactory method createBundle.
public Bundle createBundle() {
Assert.notNull(name, "Name cannot be null.");
Assert.notNull(patient, "Patient cannot be null.");
Assert.notNull(category, "SDOH DomainCode cannot be null.");
Assert.notNull(requestCode, "SDOH RequestCode cannot be null.");
Assert.notNull(priority, "Priority cannot be null.");
Assert.notNull(occurrence, "Occurrence cannot be null.");
Assert.notNull(performer, "Performer (Organization) cannot be null.");
Assert.notNull(requester, "Requester (Organization) cannot be null.");
Bundle bundle = new Bundle();
bundle.setType(Bundle.BundleType.TRANSACTION);
ServiceRequest serviceRequest = createServiceRequest(consent);
Task task = createTask(serviceRequest);
bundle.addEntry(FhirUtil.createPostEntry(serviceRequest));
bundle.addEntry(FhirUtil.createPostEntry(task));
return bundle;
}
Aggregations