use of org.hl7.fhir.r4.model.codesystems.ResourceTypes.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;
}
use of org.hl7.fhir.r4.model.codesystems.ResourceTypes.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());
}
use of org.hl7.fhir.r4.model.codesystems.ResourceTypes.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);
}
use of org.hl7.fhir.r4.model.codesystems.ResourceTypes.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;
}
use of org.hl7.fhir.r4.model.codesystems.ResourceTypes.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;
}
Aggregations