use of org.hl7.fhir.dstu3.model.Consent in project integration-adaptor-111 by nhsconnect.
the class EncounterReportBundleServiceTest method setUp.
@BeforeEach
public void setUp() throws XmlException {
INT versionNumber = mock(INT.class);
when(versionNumber.getValue()).thenReturn(VERSION);
when(document.getVersionNumber()).thenReturn(versionNumber);
when(document.getEffectiveTime()).thenReturn(ts);
when(ts.getValue()).thenReturn(EFFECTIVE_TIME);
List<QuestionnaireResponse> questionnaireResponseList = new ArrayList<>();
questionnaireResponseList.add(QUESTIONNAIRE_RESPONSE);
when(deviceMapper.mapDevice()).thenReturn(DEVICE);
when(encounterMapper.mapEncounter(any(), any(), any(), any())).thenReturn(ENCOUNTER);
when(conditionMapper.mapCondition(any(), any(), any())).thenReturn(CONDITION);
when(compositionMapper.mapComposition(any(), any(), any(), any(), any(), any())).thenReturn(COMPOSITION);
when(listMapper.mapList(any(), any(), any(), any())).thenReturn(LIST_RESOURCE);
when(carePlanMapper.mapCarePlan(any(), any(), any())).thenReturn(singletonList(CAREPLAN));
when(healthcareServiceMapper.mapHealthcareService(any())).thenReturn(singletonList(HEALTHCARE_SERVICE));
when(consentMapper.mapConsent(any(), any())).thenReturn(CONSENT);
when(pathwayUtil.getQuestionnaireResponses(any(), any(), any())).thenReturn(questionnaireResponseList);
when(messageHeaderService.createMessageHeader(any(), any(), eq(EFFECTIVE_TIME))).thenReturn(MESSAGE_HEADER);
when(referralRequestMapper.mapReferralRequest(any(), any(), any(), any(), any())).thenReturn(REFERRAL_REQUEST);
when(observationMapper.mapObservations(any(), eq(ENCOUNTER))).thenReturn(Arrays.asList(OBSERVATION));
when(practitionerRoleMapper.mapAuthorRoles(any())).thenReturn(singletonList(AUTHOR_ROLE));
when(practitionerRoleMapper.mapResponsibleParty(any())).thenReturn(Optional.of(PRACTITIONER_ROLE));
when(relatedPersonMapper.createEmergencyContactRelatedPerson(eq(document), eq(ENCOUNTER))).thenReturn(RELATED_PERSON);
when(deviceMapper.mapDevice()).thenReturn(DEVICE);
Encounter.DiagnosisComponent diagnosisComponent = new Encounter.DiagnosisComponent();
diagnosisComponent.setCondition(new Reference());
diagnosisComponent.setRole(new CodeableConcept());
diagnosisComponent.setRank(1);
diagnosisComponent.setConditionTarget(CONDITION);
ENCOUNTER.addDiagnosis(diagnosisComponent);
}
use of org.hl7.fhir.dstu3.model.Consent in project integration-adaptor-111 by nhsconnect.
the class EncounterReportBundleService method createEncounterBundle.
public Bundle createEncounterBundle(POCDMT000002UK01ClinicalDocument1 clinicalDocument, ItkReportHeader header, String messageId) throws XmlException {
Bundle bundle = createBundle(clinicalDocument);
MessageHeader messageHeader = messageHeaderService.createMessageHeader(header, messageId, clinicalDocument.getEffectiveTime().getValue());
List<HealthcareService> healthcareServiceList = healthcareServiceMapper.mapHealthcareService(clinicalDocument);
List<PractitionerRole> authorPractitionerRoles = practitionerRoleMapper.mapAuthorRoles(clinicalDocument.getAuthorArray());
Optional<PractitionerRole> responsibleParty = practitionerRoleMapper.mapResponsibleParty(clinicalDocument);
Encounter encounter = encounterMapper.mapEncounter(clinicalDocument, authorPractitionerRoles, responsibleParty, messageHeader.getEvent());
Consent consent = consentMapper.mapConsent(clinicalDocument, encounter);
List<QuestionnaireResponse> questionnaireResponseList = pathwayUtil.getQuestionnaireResponses(clinicalDocument, encounter.getSubject(), resourceUtil.createReference(encounter));
Condition condition = conditionMapper.mapCondition(clinicalDocument, encounter, questionnaireResponseList);
List<CarePlan> carePlans = carePlanMapper.mapCarePlan(clinicalDocument, encounter, condition);
Device device = deviceMapper.mapDevice();
ReferralRequest referralRequest = referralRequestMapper.mapReferralRequest(clinicalDocument, encounter, healthcareServiceList, resourceUtil.createReference(condition), resourceUtil.createReference(device));
Composition composition = compositionMapper.mapComposition(clinicalDocument, encounter, carePlans, questionnaireResponseList, referralRequest, authorPractitionerRoles);
List<Observation> observations = observationMapper.mapObservations(clinicalDocument, encounter);
RelatedPerson relatedPerson = relatedPersonMapper.createEmergencyContactRelatedPerson(clinicalDocument, encounter);
addMessageHeader(bundle, messageHeader);
addEncounter(bundle, encounter);
addServiceProvider(bundle, encounter);
addParticipants(bundle, encounter);
addLocation(bundle, encounter);
addSubject(bundle, encounter);
addHealthcareService(bundle, healthcareServiceList);
addIncomingReferral(bundle, referralRequest);
addAppointment(bundle, encounter);
addEntry(bundle, composition);
addCarePlan(bundle, carePlans);
addEntry(bundle, consent);
addEntry(bundle, condition);
addQuestionnaireResponses(bundle, questionnaireResponseList);
addObservations(bundle, observations);
addPractitionerRoles(bundle, authorPractitionerRoles, responsibleParty);
addRelatedPerson(bundle, relatedPerson);
addEntry(bundle, device);
ListResource listResource = getReferenceFromBundle(bundle, clinicalDocument, encounter, device);
addEntry(bundle, listResource);
return bundle;
}
use of org.hl7.fhir.dstu3.model.Consent in project integration-adaptor-111 by nhsconnect.
the class ConsentMapperTest method shouldMapITKReportToConsent.
@Test
public void shouldMapITKReportToConsent() {
Patient patient = mock(Patient.class);
Reference patientReference = new Reference(patient);
mockEncounter(patient, patientReference);
mockSection();
Consent consent = consentMapper.mapConsent(clinicalDocument, encounter);
assertThat(consent).isNotNull();
assertThat(consent.getIdElement().getValue()).isEqualTo(RANDOM_UUID);
assertThat(consent.getStatus()).isEqualTo(Consent.ConsentState.ACTIVE);
assertThat(consent.getLanguage()).isEqualTo(LANG);
assertThat(consent.getPeriod()).isEqualTo(period);
assertThat(consent.getText()).isNotNull();
assertThat(consent.getPolicyRule()).isEqualTo(OPT_OUT_URI);
assertThat(consent.getActionFirstRep().getCodingFirstRep().getCode()).isEqualTo(code.getCode());
assertThat(consent.getPatient()).isEqualTo(patientReference);
assertThat(consent.getOrganization().get(0)).isEqualTo(patientReference);
assertThat(consent.getConsentingParty().get(0)).isEqualTo(patientReference);
}
use of org.hl7.fhir.dstu3.model.Consent in project fhir-bridge by ehrbase.
the class DnrIT method testMapping.
@Override
public void testMapping(String resourcePath, String paragonPath) throws IOException {
Consent consent = (Consent) super.testFileLoader.loadResource(resourcePath);
DnrAnordnungCompositionConverter dnrAnordnungCompositionConverter = new DnrAnordnungCompositionConverter();
DNRAnordnungComposition mapped = dnrAnordnungCompositionConverter.convert(consent);
Diff diff = compareCompositions(getJaversIgnoreStartTime(), paragonPath, mapped);
assertEquals(0, diff.getChanges().size());
}
use of org.hl7.fhir.dstu3.model.Consent in project odm2fhir by num-codex.
the class BroadConsent method createConsent.
@SuppressWarnings("fallthrough")
private Consent createConsent(FormData formData) {
var identifier = createIdentifier(CONSENT, formData.getItemData("miibc_consent_status"));
var consent = (Consent) new Consent().addIdentifier(identifier).setDateTimeElement(createDateTimeType(formData.getItemData("miibc_dat_dok"))).addOrganization(getOrganizationReference()).setScope(RESEARCH).addCategory(createCodeableConcept(createCoding(LOINC, "57016-8", "Privacy policy acknowledgment Document"))).addPolicy(new ConsentPolicyComponent().setUri(POLICY)).setMeta(createMeta(GERMAN_CONSENT));
switch(formData.getItemData("miibc_consent_status").getValue()) {
case // agreed
"1":
consent.setStatus(ConsentState.ACTIVE);
break;
case // rejected
"2":
consent.setStatus(REJECTED);
break;
case // revoked
"3":
var revocationDateItem = formData.getItemData("miibc_w_dat_dok");
switch(formData.getItemData("miibc_widerruf").getValue()) {
case // fully revoked
"1":
consent.setStatus(INACTIVE).setDateTimeElement(// revocation -> replace 'consentDate' by 'revocationDate'
createDateTimeType(revocationDateItem));
break;
case // partly revoked
"2":
// revocation -> replace 'consentDate' by 'revocationDate'
consent.setDateTimeElement(createDateTimeType(revocationDateItem));
// not revoked
case "3":
case // unknown (REVOCATION-Status, not CONSENT-Status!)
"4":
// default if not revoked
consent.setStatus(ConsentState.ACTIVE);
break;
}
break;
case // unknown
"4":
// skip if general CONSENT-Status is 'unknown'
return new Consent();
}
var mainProvisionComponent = new Consent.provisionComponent().setType(DENY);
if (consent.getDateTime() != null) {
mainProvisionComponent.setPeriod(new Period().setStart(consent.getDateTime()).setEnd(addYears(consent.getDateTime(), 30)));
}
if (ConsentState.ACTIVE == consent.getStatus()) {
// add more Consent details only if consented/not fully revoked
mainProvisionComponent.setProvision(ELEMENTS.stream().map(key -> "gee_" + key).map(formData::getItemData).filter(not(ItemData::isEmpty)).map(itemData -> {
var specificAnswerItemName = itemData.getItemOID();
var specificAnswerItemValue = itemData.getValue();
var partProvisionComponent = new Consent.provisionComponent().addCode(createCodeableConcept(createCoding("urn:oid:" + BASE_OID, BASE_OID + "." + OIDS.get(removeStart(specificAnswerItemName, "gee_") + "_" + specificAnswerItemValue), specificAnswerItemName)));
if (!mainProvisionComponent.getPeriod().isEmpty()) {
var period = mainProvisionComponent.getPeriod().copy();
if ("gee_krankenkassendaten_retro".equals(specificAnswerItemName)) {
period.setEnd(period.getStart()).setStart(addYears(period.getStart(), -5));
} else if ("gee_krankenkassendaten_pro".equals(specificAnswerItemName)) {
period.setEnd(addYears(period.getStart(), 5));
}
partProvisionComponent.setPeriod(period);
}
switch(specificAnswerItemValue) {
case // agreed
"1":
partProvisionComponent.setType(PERMIT);
break;
// rejected
case "2":
case // revoked
"4":
partProvisionComponent.setType(DENY);
break;
// unknown
case "3":
}
return partProvisionComponent;
}).collect(toList()));
}
return consent.setProvision(mainProvisionComponent);
}
Aggregations