Search in sources :

Example 1 with ConsentToDtoConverter

use of org.hl7.gravity.refimpl.sdohexchange.dto.converter.ConsentToDtoConverter 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 2 with ConsentToDtoConverter

use of org.hl7.gravity.refimpl.sdohexchange.dto.converter.ConsentToDtoConverter 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)

Aggregations

MethodOutcome (ca.uhn.fhir.rest.api.MethodOutcome)2 Consent (org.hl7.fhir.r4.model.Consent)2 Reference (org.hl7.fhir.r4.model.Reference)2 ConsentToDtoConverter (org.hl7.gravity.refimpl.sdohexchange.dto.converter.ConsentToDtoConverter)2 CreateConsentFactory (org.hl7.gravity.refimpl.sdohexchange.fhir.factory.resource.CreateConsentFactory)2 IGenericClient (ca.uhn.fhir.rest.client.api.IGenericClient)1 ResourceNotFoundException (ca.uhn.fhir.rest.server.exceptions.ResourceNotFoundException)1 SmartOnFhirContext (com.healthlx.smartonfhir.core.SmartOnFhirContext)1 List (java.util.List)1 Optional (java.util.Optional)1 Collectors (java.util.stream.Collectors)1 RequiredArgsConstructor (lombok.RequiredArgsConstructor)1 Slf4j (lombok.extern.slf4j.Slf4j)1 Attachment (org.hl7.fhir.r4.model.Attachment)1 Bundle (org.hl7.fhir.r4.model.Bundle)1 Patient (org.hl7.fhir.r4.model.Patient)1 PractitionerRole (org.hl7.fhir.r4.model.PractitionerRole)1 ConsentRepository (org.hl7.gravity.refimpl.sdohexchange.dao.impl.ConsentRepository)1 AttachmentDto (org.hl7.gravity.refimpl.sdohexchange.dto.response.AttachmentDto)1 BaseConsentDto (org.hl7.gravity.refimpl.sdohexchange.dto.response.BaseConsentDto)1