Search in sources :

Example 36 with CONSENT

use of org.hl7.fhir.r4.model.codesystems.ResourceTypes.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);
}
Also used : Reference(org.hl7.fhir.dstu3.model.Reference) ArrayList(java.util.ArrayList) Encounter(org.hl7.fhir.dstu3.model.Encounter) QuestionnaireResponse(org.hl7.fhir.dstu3.model.QuestionnaireResponse) INT(uk.nhs.connect.iucds.cda.ucr.INT) CodeableConcept(org.hl7.fhir.dstu3.model.CodeableConcept) BeforeEach(org.junit.jupiter.api.BeforeEach)

Example 37 with CONSENT

use of org.hl7.fhir.r4.model.codesystems.ResourceTypes.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;
}
Also used : Condition(org.hl7.fhir.dstu3.model.Condition) ReferralRequest(org.hl7.fhir.dstu3.model.ReferralRequest) Composition(org.hl7.fhir.dstu3.model.Composition) Bundle(org.hl7.fhir.dstu3.model.Bundle) Device(org.hl7.fhir.dstu3.model.Device) HealthcareService(org.hl7.fhir.dstu3.model.HealthcareService) PractitionerRole(org.hl7.fhir.dstu3.model.PractitionerRole) QuestionnaireResponse(org.hl7.fhir.dstu3.model.QuestionnaireResponse) RelatedPerson(org.hl7.fhir.dstu3.model.RelatedPerson) CarePlan(org.hl7.fhir.dstu3.model.CarePlan) Consent(org.hl7.fhir.dstu3.model.Consent) Observation(org.hl7.fhir.dstu3.model.Observation) Encounter(org.hl7.fhir.dstu3.model.Encounter) MessageHeader(org.hl7.fhir.dstu3.model.MessageHeader) ListResource(org.hl7.fhir.dstu3.model.ListResource)

Example 38 with CONSENT

use of org.hl7.fhir.r4.model.codesystems.ResourceTypes.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);
}
Also used : Consent(org.hl7.fhir.dstu3.model.Consent) POCDMT000002UK01Consent(uk.nhs.connect.iucds.cda.ucr.POCDMT000002UK01Consent) Reference(org.hl7.fhir.dstu3.model.Reference) Patient(org.hl7.fhir.dstu3.model.Patient) Test(org.junit.jupiter.api.Test)

Example 39 with CONSENT

use of org.hl7.fhir.r4.model.codesystems.ResourceTypes.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());
}
Also used : DNRAnordnungComposition(org.ehrbase.fhirbridge.ehr.opt.dnranordnungcomposition.DNRAnordnungComposition) Consent(org.hl7.fhir.r4.model.Consent) DnrAnordnungCompositionConverter(org.ehrbase.fhirbridge.ehr.converter.specific.dnranordnung.DnrAnordnungCompositionConverter) Diff(org.javers.core.diff.Diff)

Example 40 with CONSENT

use of org.hl7.fhir.r4.model.codesystems.ResourceTypes.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);
}
Also used : ItemData(de.difuture.uds.odm2fhir.odm.model.ItemData) PERMIT(org.hl7.fhir.r4.model.Consent.ConsentProvisionType.PERMIT) INACTIVE(org.hl7.fhir.r4.model.Consent.ConsentState.INACTIVE) FormData(de.difuture.uds.odm2fhir.odm.model.FormData) ConsentPolicyComponent(org.hl7.fhir.r4.model.Consent.ConsentPolicyComponent) Period(org.hl7.fhir.r4.model.Period) Consent(org.hl7.fhir.r4.model.Consent) CONSENT(org.hl7.fhir.r4.model.codesystems.ResourceTypes.CONSENT) Item(de.difuture.uds.odm2fhir.fhir.mapper.Item) DomainResource(org.hl7.fhir.r4.model.DomainResource) HashMap(java.util.HashMap) LOINC(de.difuture.uds.odm2fhir.fhir.util.CommonCodeSystem.LOINC) List(java.util.List) REJECTED(org.hl7.fhir.r4.model.Consent.ConsentState.REJECTED) Collectors.toList(java.util.stream.Collectors.toList) Stream(java.util.stream.Stream) ConsentState(org.hl7.fhir.r4.model.Consent.ConsentState) GERMAN_CONSENT(de.difuture.uds.odm2fhir.fhir.util.CommonStructureDefinition.GERMAN_CONSENT) Map(java.util.Map) DateUtils.addYears(org.apache.commons.lang3.time.DateUtils.addYears) Predicate.not(java.util.function.Predicate.not) StringUtils.removeStart(org.apache.commons.lang3.StringUtils.removeStart) DENY(org.hl7.fhir.r4.model.Consent.ConsentProvisionType.DENY) ConsentPolicyComponent(org.hl7.fhir.r4.model.Consent.ConsentPolicyComponent) Consent(org.hl7.fhir.r4.model.Consent) Period(org.hl7.fhir.r4.model.Period) ItemData(de.difuture.uds.odm2fhir.odm.model.ItemData)

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