Search in sources :

Example 1 with CreateConsentFactory

use of org.hl7.gravity.refimpl.sdohexchange.fhir.factory.resource.CreateConsentFactory 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)1 Consent (org.hl7.fhir.r4.model.Consent)1 Reference (org.hl7.fhir.r4.model.Reference)1 ConsentToDtoConverter (org.hl7.gravity.refimpl.sdohexchange.dto.converter.ConsentToDtoConverter)1 CreateConsentFactory (org.hl7.gravity.refimpl.sdohexchange.fhir.factory.resource.CreateConsentFactory)1