Search in sources :

Example 31 with Consent

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

the class TaskBundleFactory method createServiceRequest.

protected ServiceRequest createServiceRequest(Consent consent) {
    ServiceRequest serviceRequest = new ServiceRequest();
    serviceRequest.getMeta().addProfile(SDOHProfiles.SERVICE_REQUEST);
    serviceRequest.setId(IdType.newRandomUuid());
    serviceRequest.setStatus(ServiceRequest.ServiceRequestStatus.ACTIVE);
    serviceRequest.setIntent(ServiceRequest.ServiceRequestIntent.ORDER);
    serviceRequest.setPriority(priority.getServiceRequestPriority());
    serviceRequest.setAuthoredOnElement(DateTimeType.now());
    if (occurrence.isPeriod()) {
        serviceRequest.setOccurrence(new Period().setStartElement(occurrence.getStart()).setEndElement(occurrence.getEnd()));
    } else {
        serviceRequest.setOccurrence(occurrence.getEnd());
    }
    serviceRequest.addCategory(new CodeableConcept().addCoding(category));
    serviceRequest.getCode().addCoding(requestCode);
    serviceRequest.setSubject(getPatientReference());
    conditions.forEach(condition -> serviceRequest.addReasonReference(FhirUtil.toReference(Condition.class, condition.getIdElement().getIdPart(), condition.getCode().getCodingFirstRep().getDisplay())));
    goals.forEach(goal -> serviceRequest.addSupportingInfo(FhirUtil.toReference(Goal.class, goal.getIdElement().getIdPart(), goal.getDescription().getCodingFirstRep().getDisplay())));
    serviceRequest.addSupportingInfo(FhirUtil.toReference(Consent.class, consent.getId(), consent.getScope().getCodingFirstRep().getDisplay()));
    return serviceRequest;
}
Also used : Consent(org.hl7.fhir.r4.model.Consent) Period(org.hl7.fhir.r4.model.Period) ServiceRequest(org.hl7.fhir.r4.model.ServiceRequest) CodeableConcept(org.hl7.fhir.r4.model.CodeableConcept)

Example 32 with Consent

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

the class ConsentService method listConsents.

public List<ConsentDto> listConsents() {
    Bundle bundle = consentRepository.findAllByPatient(SmartOnFhirContext.get().getPatient());
    List<Consent> consentResources = FhirUtil.getFromBundle(bundle, Consent.class);
    return consentResources.stream().map(consent -> new ConsentToDtoConverter().convert(consent)).collect(Collectors.toList());
}
Also used : BaseConsentDto(org.hl7.gravity.refimpl.sdohexchange.dto.response.BaseConsentDto) RequiredArgsConstructor(lombok.RequiredArgsConstructor) Consent(org.hl7.fhir.r4.model.Consent) Autowired(org.springframework.beans.factory.annotation.Autowired) MethodOutcome(ca.uhn.fhir.rest.api.MethodOutcome) AttachmentDto(org.hl7.gravity.refimpl.sdohexchange.dto.response.AttachmentDto) Reference(org.hl7.fhir.r4.model.Reference) Attachment(org.hl7.fhir.r4.model.Attachment) Service(org.springframework.stereotype.Service) IGenericClient(ca.uhn.fhir.rest.client.api.IGenericClient) ResourceNotFoundException(ca.uhn.fhir.rest.server.exceptions.ResourceNotFoundException) Patient(org.hl7.fhir.r4.model.Patient) UserDto(org.hl7.gravity.refimpl.sdohexchange.dto.response.UserDto) ConsentToDtoConverter(org.hl7.gravity.refimpl.sdohexchange.dto.converter.ConsentToDtoConverter) ConsentRepository(org.hl7.gravity.refimpl.sdohexchange.dao.impl.ConsentRepository) ConsentDto(org.hl7.gravity.refimpl.sdohexchange.dto.response.ConsentDto) Collectors(java.util.stream.Collectors) PractitionerRole(org.hl7.fhir.r4.model.PractitionerRole) ConsentCreateException(org.hl7.gravity.refimpl.sdohexchange.exception.ConsentCreateException) Slf4j(lombok.extern.slf4j.Slf4j) List(java.util.List) ConsentPrepareBundleFactory(org.hl7.gravity.refimpl.sdohexchange.fhir.factory.ConsentPrepareBundleFactory) CreateConsentFactory(org.hl7.gravity.refimpl.sdohexchange.fhir.factory.resource.CreateConsentFactory) SmartOnFhirContext(com.healthlx.smartonfhir.core.SmartOnFhirContext) MultipartFile(org.springframework.web.multipart.MultipartFile) Optional(java.util.Optional) Bundle(org.hl7.fhir.r4.model.Bundle) FhirUtil(org.hl7.gravity.refimpl.sdohexchange.util.FhirUtil) Consent(org.hl7.fhir.r4.model.Consent) Bundle(org.hl7.fhir.r4.model.Bundle) ConsentToDtoConverter(org.hl7.gravity.refimpl.sdohexchange.dto.converter.ConsentToDtoConverter)

Example 33 with Consent

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

the class ConsentService method createConsent.

public ConsentDto createConsent(String name, MultipartFile attachment, UserDto userDto) {
    Reference patient = FhirUtil.toReference(Patient.class, SmartOnFhirContext.get().getPatient());
    Reference organization = retrieveOrganization(userDto);
    Consent consent = new CreateConsentFactory(name, patient, attachment, organization).createConsent();
    MethodOutcome methodOutcome = ehrClient.create().resource(consent).execute();
    Consent savedConsent = (Consent) methodOutcome.getResource();
    return new ConsentToDtoConverter().convert(savedConsent);
}
Also used : Consent(org.hl7.fhir.r4.model.Consent) CreateConsentFactory(org.hl7.gravity.refimpl.sdohexchange.fhir.factory.resource.CreateConsentFactory) Reference(org.hl7.fhir.r4.model.Reference) MethodOutcome(ca.uhn.fhir.rest.api.MethodOutcome) ConsentToDtoConverter(org.hl7.gravity.refimpl.sdohexchange.dto.converter.ConsentToDtoConverter)

Example 34 with Consent

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

the class CreateConsentFactory method createConsent.

public Consent createConsent() {
    Consent consent = new Consent();
    consent.getSourceAttachment().setTitle(name);
    try {
        consent.getSourceAttachment().setData(attachment.getBytes());
    } catch (IOException e) {
        throw new ConsentCreateException("Consent attachment cannot be read.");
    }
    consent.getSourceAttachment().setContentType(MediaType.APPLICATION_PDF_VALUE);
    consent.setId(IdType.newRandomUuid());
    consent.setStatus(Consent.ConsentState.ACTIVE);
    consent.setDateTimeElement(DateTimeType.now());
    consent.getMeta().addProfile(SDOHProfiles.CONSENT);
    ConsentScope consentScope = ConsentScope.PATIENTPRIVACY;
    consent.getScope().addCoding(new Coding(consentScope.getSystem(), consentScope.toCode(), consentScope.getDisplay()));
    V3ActCode actCode = V3ActCode.IDSCL;
    consent.addCategory(new CodeableConcept().addCoding(new Coding(actCode.getSystem(), actCode.toCode(), actCode.getDisplay())));
    consent.setPatient(patient);
    ConsentPolicy consentPolicy = ConsentPolicy.HIPAAAUTH;
    consent.getPolicyRule().addCoding(new Coding(consentPolicy.getSystem(), consentPolicy.toCode(), consentPolicy.getDisplay()));
    V3RoleClass roleClass = V3RoleClass.PAT;
    consent.getProvision().addActor().setReference(patient).getRole().addCoding(new Coding(roleClass.getSystem(), roleClass.toCode(), roleClass.getDisplay()));
    ConsentAction consentAction = ConsentAction.DISCLOSE;
    consent.getProvision().addAction().getCoding().add(new Coding(consentAction.getSystem(), consentAction.toCode(), consentAction.getDisplay()));
    consent.getOrganization().add(organization);
    return consent;
}
Also used : ConsentScope(org.hl7.fhir.r4.model.codesystems.ConsentScope) ConsentCreateException(org.hl7.gravity.refimpl.sdohexchange.exception.ConsentCreateException) V3ActCode(org.hl7.fhir.r4.model.codesystems.V3ActCode) Consent(org.hl7.fhir.r4.model.Consent) Coding(org.hl7.fhir.r4.model.Coding) V3RoleClass(org.hl7.fhir.r4.model.codesystems.V3RoleClass) ConsentPolicy(org.hl7.fhir.r4.model.codesystems.ConsentPolicy) IOException(java.io.IOException) ConsentAction(org.hl7.fhir.r4.model.codesystems.ConsentAction) CodeableConcept(org.hl7.fhir.r4.model.CodeableConcept)

Example 35 with Consent

use of org.hl7.fhir.dstu3.model.Consent in project integration-adaptor-111 by nhsconnect.

the class ConsentMapper method mapConsent.

public Consent mapConsent(POCDMT000002UK01ClinicalDocument1 clinicalDocument, Encounter encounter) {
    Consent consent = new Consent();
    consent.setIdElement(resourceUtil.newRandomUuid());
    if (clinicalDocument.isSetSetId()) {
        Identifier docIdentifier = new Identifier();
        docIdentifier.setUse(Identifier.IdentifierUse.USUAL);
        docIdentifier.setValue(clinicalDocument.getSetId().getRoot());
        consent.setIdentifier(docIdentifier);
    }
    consent.setLanguage(encounter.getLanguage());
    consent.setStatus(Consent.ConsentState.ACTIVE).setPeriod(encounter.getPeriod()).setPatient(encounter.getSubject()).addConsentingParty(encounter.getSubject()).addOrganization(encounter.getServiceProvider()).setData(List.of(new ConsentDataComponent().setMeaning(ConsentDataMeaning.RELATED).setReference(resourceUtil.createReference(encounter)))).setPolicyRule(OPT_OUT_URI);
    extractAuthCodesFromDoc(consent, clinicalDocument);
    POCDMT000002UK01StructuredBody structuredBody = getStructuredBody(clinicalDocument);
    if (structuredBody != null) {
        extractDataPeriodFromDoc(consent, structuredBody);
        extractConsentSource(consent, structuredBody);
        extractTextBody(consent, structuredBody);
    }
    return consent;
}
Also used : POCDMT000002UK01StructuredBody(uk.nhs.connect.iucds.cda.ucr.POCDMT000002UK01StructuredBody) Identifier(org.hl7.fhir.dstu3.model.Identifier) Consent(org.hl7.fhir.dstu3.model.Consent) POCDMT000002UK01Consent(uk.nhs.connect.iucds.cda.ucr.POCDMT000002UK01Consent) ConsentDataComponent(org.hl7.fhir.dstu3.model.Consent.ConsentDataComponent)

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