Search in sources :

Example 26 with Consent

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();
}
Also used : Consent(org.hl7.fhir.dstu3.model.Consent) ConsentEntity(gov.cms.dpc.common.consent.entities.ConsentEntity) UnitOfWork(io.dropwizard.hibernate.UnitOfWork) ApiOperation(io.swagger.annotations.ApiOperation) FHIR(gov.cms.dpc.fhir.annotations.FHIR) ApiResponses(io.swagger.annotations.ApiResponses)

Example 27 with Consent

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);
    });
}
Also used : Consent(org.hl7.fhir.dstu3.model.Consent) ConsentEntity(gov.cms.dpc.common.consent.entities.ConsentEntity) Test(org.junit.jupiter.api.Test)

Example 28 with Consent

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);
}
Also used : List(java.util.List) Bundle(org.hl7.fhir.dstu3.model.Bundle) Consent(org.hl7.fhir.dstu3.model.Consent) Optional(java.util.Optional) IGenericClient(ca.uhn.fhir.rest.client.api.IGenericClient) Named(javax.inject.Named) DPCIdentifierSystem(gov.cms.dpc.fhir.DPCIdentifierSystem) Collectors(java.util.stream.Collectors) Consent(org.hl7.fhir.dstu3.model.Consent) Bundle(org.hl7.fhir.dstu3.model.Bundle)

Example 29 with Consent

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;
}
Also used : Consent(org.hl7.fhir.r4.model.Consent)

Example 30 with 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;
}
Also used : Task(org.hl7.fhir.r4.model.Task) Bundle(org.hl7.fhir.r4.model.Bundle) ServiceRequest(org.hl7.fhir.r4.model.ServiceRequest)

Aggregations

Consent (org.hl7.fhir.r4.model.Consent)15 Consent (org.hl7.fhir.dstu3.model.Consent)8 Complex (org.hl7.fhir.dstu3.utils.formats.Turtle.Complex)8 Complex (org.hl7.fhir.r4.utils.formats.Turtle.Complex)7 Test (org.junit.jupiter.api.Test)7 MethodOutcome (ca.uhn.fhir.rest.api.MethodOutcome)6 List (java.util.List)5 Bundle (org.hl7.fhir.r4.model.Bundle)5 Reference (org.hl7.fhir.r4.model.Reference)5 ResourceNotFoundException (ca.uhn.fhir.rest.server.exceptions.ResourceNotFoundException)4 ConsentEntity (gov.cms.dpc.common.consent.entities.ConsentEntity)4 Optional (java.util.Optional)4 Collectors (java.util.stream.Collectors)4 IIdType (org.hl7.fhir.instance.model.api.IIdType)4 ConsentCreateException (org.hl7.gravity.refimpl.sdohexchange.exception.ConsentCreateException)4 IGenericClient (ca.uhn.fhir.rest.client.api.IGenericClient)3 SmartOnFhirContext (com.healthlx.smartonfhir.core.SmartOnFhirContext)2 DPCIdentifierSystem (gov.cms.dpc.fhir.DPCIdentifierSystem)2 FHIR (gov.cms.dpc.fhir.annotations.FHIR)2 UnitOfWork (io.dropwizard.hibernate.UnitOfWork)2