ConsentExportMapperImpl implements ConsentExportMapper { @Override public ConsentDto map(Consent consent) { ConsentDto consentDto = new ConsentDto(); consentDto.setConsentReferenceid(consent.getConsentReferenceId()); PatientDto patientDto = modelMapper.map(consent.getPatient(), PatientDto.class); consentDto.setPatientDto(patientDto); if (consent.getLegalRepresentative() != null) { PatientDto legalRepresentativeDto = modelMapper.map( consent.getLegalRepresentative(), PatientDto.class); consentDto.setLegalRepresentative(legalRepresentativeDto); } Set<IndividualProviderDto> indiprovidersPermittedToDisclose = new HashSet<IndividualProviderDto>(); for (ConsentIndividualProviderPermittedToDisclose pptd : consent .getProvidersPermittedToDisclose()) { IndividualProviderDto iptd = modelMapper.map( pptd.getIndividualProvider(), IndividualProviderDto.class); indiprovidersPermittedToDisclose.add(iptd); } consentDto .setProvidersPermittedToDisclose(indiprovidersPermittedToDisclose); Set<IndividualProviderDto> indiprovidersDisclosureIsMadeTo = new HashSet<IndividualProviderDto>(); for (ConsentIndividualProviderDisclosureIsMadeTo pdmt : consent .getProvidersDisclosureIsMadeTo()) { IndividualProviderDto iptd2 = modelMapper.map( pdmt.getIndividualProvider(), IndividualProviderDto.class); indiprovidersDisclosureIsMadeTo.add(iptd2); } consentDto .setProvidersDisclosureIsMadeTo(indiprovidersDisclosureIsMadeTo); Set<OrganizationalProviderDto> orgaprovidersPermittedToDisclose = new HashSet<OrganizationalProviderDto>(); for (ConsentOrganizationalProviderPermittedToDisclose coptd : consent .getOrganizationalProvidersPermittedToDisclose()) { OrganizationalProviderDto optd = modelMapper.map( coptd.getOrganizationalProvider(), OrganizationalProviderDto.class); orgaprovidersPermittedToDisclose.add(optd); } consentDto .setOrganizationalProvidersPermittedToDisclose(orgaprovidersPermittedToDisclose); Set<OrganizationalProviderDto> orgaprovidersDisclosureIsMadeTo = new HashSet<OrganizationalProviderDto>(); for (ConsentOrganizationalProviderDisclosureIsMadeTo opdmt : consent .getOrganizationalProvidersDisclosureIsMadeTo()) { OrganizationalProviderDto optd2 = modelMapper.map( opdmt.getOrganizationalProvider(), OrganizationalProviderDto.class); orgaprovidersDisclosureIsMadeTo.add(optd2); } consentDto .setOrganizationalProvidersDisclosureIsMadeTo(orgaprovidersDisclosureIsMadeTo); Set<TypeCodesDto> consentDoNotShareClinicalDocumentTypeCode = new HashSet<TypeCodesDto>(); for (ConsentDoNotShareClinicalDocumentTypeCode item : consent .getDoNotShareClinicalDocumentTypeCodes()) { TypeCodesDto tcd = new TypeCodesDto(); tcd.setDisplayName(item.getClinicalDocumentTypeCode() .getDisplayName()); tcd.setCode(item.getClinicalDocumentTypeCode().getCode()); tcd.setCodeSystem(item.getClinicalDocumentTypeCode() .getCodeSystem()); tcd.setCodeSystemName(item.getClinicalDocumentTypeCode() .getCodeSystemName()); consentDoNotShareClinicalDocumentTypeCode.add(tcd); } consentDto .setDoNotShareClinicalDocumentTypeCodes(consentDoNotShareClinicalDocumentTypeCode); Set<TypeCodesDto> consentDoNotShareClinicalDocumentSectionTypeCode = new HashSet<TypeCodesDto>(); for (ConsentDoNotShareClinicalDocumentSectionTypeCode item : consent .getDoNotShareClinicalDocumentSectionTypeCodes()) { TypeCodesDto tcd1 = new TypeCodesDto(); tcd1.setDisplayName(item.getMedicalSection().getName()); tcd1.setCode(item.getMedicalSection().getCode()); tcd1.setCodeSystem(null); tcd1.setCodeSystemName(null); consentDoNotShareClinicalDocumentSectionTypeCode.add(tcd1); } consentDto .setDoNotShareClinicalDocumentSectionTypeCodes(consentDoNotShareClinicalDocumentSectionTypeCode); Set<TypeCodesDto> consentDoNotShareSensitivityPolicyCode = new HashSet<TypeCodesDto>(); for (ConsentDoNotShareSensitivityPolicyCode item : consent .getDoNotShareSensitivityPolicyCodes()) { TypeCodesDto tcd2 = new TypeCodesDto(); tcd2.setDisplayName(item.getValueSetCategory().getName()); tcd2.setCode(item.getValueSetCategory().getCode()); tcd2.setCodeSystem(null); tcd2.setCodeSystemName(null); consentDoNotShareSensitivityPolicyCode.add(tcd2); } consentDto .setDoNotShareSensitivityPolicyCodes(consentDoNotShareSensitivityPolicyCode); Set<TypeCodesDto> consentShareForPurposeOfUseCode = new HashSet<TypeCodesDto>(); for (ConsentShareForPurposeOfUseCode item : consent .getShareForPurposeOfUseCodes()) { TypeCodesDto tcd3 = new TypeCodesDto(); tcd3.setDisplayName(item.getPurposeOfUseCode().getDisplayName()); tcd3.setCode(item.getPurposeOfUseCode().getCode()); tcd3.setCodeSystem(item.getPurposeOfUseCode().getCodeSystem()); tcd3.setCodeSystemName(item.getPurposeOfUseCode() .getCodeSystemName()); consentShareForPurposeOfUseCode.add(tcd3); } consentDto .setShareForPurposeOfUseCodes(consentShareForPurposeOfUseCode); Set<TypeCodesDto> consentDoNotShareClinicalConceptCodes = new HashSet<TypeCodesDto>(); for (ClinicalConceptCode item : consent .getDoNotShareClinicalConceptCodes()) { TypeCodesDto tcd4 = new TypeCodesDto(); tcd4.setDisplayName(item.getDisplayName()); tcd4.setCode(item.getCode()); tcd4.setCodeSystem(item.getCodeSystem()); tcd4.setCodeSystemName(item.getCodeSystemName()); consentDoNotShareClinicalConceptCodes.add(tcd4); } consentDto .setDoNotShareClinicalConceptCodes(consentDoNotShareClinicalConceptCodes); consentDto.setConsentStart(consent.getStartDate()); consentDto.setConsentEnd(consent.getEndDate()); consentDto.setSignedDate(consent.getSignedDate()); consentDto.setVersion(consent.getVersion()); consentDto.setRevocationDate(consent.getRevocationDate()); return consentDto; } ConsentExportMapperImpl(ModelMapper modelMapper); @Override ConsentDto map(Consent consent); ModelMapper getModelMapper(); void setModelMapper(ModelMapper modelMapper);  }
@Test public void testMap_when_mapping_providersDisclosureIsMadeTo() { Consent consent = new Consent(); setDataBasicConsent(consent); Set<ConsentIndividualProviderDisclosureIsMadeTo> providersDisclosureIsMadeTo = new HashSet<ConsentIndividualProviderDisclosureIsMadeTo>(); List<IndividualProvider> indProviders = setDataIndividualProviders(); for (IndividualProvider individualProvider : indProviders) { ConsentIndividualProviderDisclosureIsMadeTo consentIndividualProviderPermittedToDisclose = new ConsentIndividualProviderDisclosureIsMadeTo( individualProvider); providersDisclosureIsMadeTo .add(consentIndividualProviderPermittedToDisclose); } consent.setProvidersDisclosureIsMadeTo(providersDisclosureIsMadeTo); ConsentDto consentDto = sut.map(consent); assertEquals(consent.getProvidersDisclosureIsMadeTo().getClass(), consentDto.getProvidersDisclosureIsMadeTo().getClass()); assertEquals(consent.getProvidersDisclosureIsMadeTo().size(), consentDto.getProvidersDisclosureIsMadeTo().size()); for (ConsentIndividualProviderDisclosureIsMadeTo pdmt : consent .getProvidersDisclosureIsMadeTo()) { String consentNpi = pdmt.getIndividualProvider().getNpi(); for (IndividualProviderDto indiprovidersDisclosureIsMadeTo : consentDto .getProvidersDisclosureIsMadeTo()) { String consentDtoNpi = indiprovidersDisclosureIsMadeTo.getNpi(); if (!consentNpi.equalsIgnoreCase(consentDtoNpi)) { continue; } assertEquals(pdmt.getIndividualProvider().getFirstName(), indiprovidersDisclosureIsMadeTo.getFirstName()); assertEquals(pdmt.getIndividualProvider().getLastName(), indiprovidersDisclosureIsMadeTo.getLastName()); assertEquals(pdmt.getIndividualProvider().getMiddleName(), indiprovidersDisclosureIsMadeTo.getMiddleName()); assertEquals(pdmt.getIndividualProvider().getNamePrefix(), indiprovidersDisclosureIsMadeTo.getNamePrefix()); assertEquals(pdmt.getIndividualProvider().getNameSuffix(), indiprovidersDisclosureIsMadeTo.getNameSuffix()); assertEquals(pdmt.getIndividualProvider() .getPracticeLocationAddressCityName(), indiprovidersDisclosureIsMadeTo .getPracticeLocationAddressCityName()); assertEquals(pdmt.getIndividualProvider() .getPracticeLocationAddressCountryCode(), indiprovidersDisclosureIsMadeTo .getPracticeLocationAddressCountryCode()); assertEquals(pdmt.getIndividualProvider() .getPracticeLocationAddressPostalCode(), indiprovidersDisclosureIsMadeTo .getPracticeLocationAddressPostalCode()); assertEquals(pdmt.getIndividualProvider() .getPracticeLocationAddressStateName(), indiprovidersDisclosureIsMadeTo .getPracticeLocationAddressStateName()); } } }
@Test public void testMap_when_mapping_ProvidersPermittedToDisclose() { Consent consent = new Consent(); setDataBasicConsent(consent); Set<ConsentIndividualProviderPermittedToDisclose> ProvidersPermittedToDisclose = new HashSet<ConsentIndividualProviderPermittedToDisclose>(); List<IndividualProvider> indProviders = setDataIndividualProviders(); for (IndividualProvider individualProvider : indProviders) { ConsentIndividualProviderPermittedToDisclose consentIndividualProviderPermittedToDisclose = new ConsentIndividualProviderPermittedToDisclose( individualProvider); ProvidersPermittedToDisclose .add(consentIndividualProviderPermittedToDisclose); } consent.setProvidersPermittedToDisclose(ProvidersPermittedToDisclose); ConsentDto consentDto = sut.map(consent); assertEquals(consent.getProvidersPermittedToDisclose().getClass(), consentDto.getProvidersPermittedToDisclose().getClass()); assertEquals(consent.getProvidersPermittedToDisclose().size(), consentDto.getProvidersPermittedToDisclose().size()); for (ConsentIndividualProviderPermittedToDisclose pdmt : consent .getProvidersPermittedToDisclose()) { String consentNpi = pdmt.getIndividualProvider().getNpi(); for (IndividualProviderDto indiProvidersPermittedToDisclose : consentDto .getProvidersPermittedToDisclose()) { String consentDtoNpi = indiProvidersPermittedToDisclose .getNpi(); if (!consentNpi.equalsIgnoreCase(consentDtoNpi)) { continue; } assertEquals(pdmt.getIndividualProvider().getFirstName(), indiProvidersPermittedToDisclose.getFirstName()); assertEquals(pdmt.getIndividualProvider().getLastName(), indiProvidersPermittedToDisclose.getLastName()); assertEquals(pdmt.getIndividualProvider().getMiddleName(), indiProvidersPermittedToDisclose.getMiddleName()); assertEquals(pdmt.getIndividualProvider().getNamePrefix(), indiProvidersPermittedToDisclose.getNamePrefix()); assertEquals(pdmt.getIndividualProvider().getNameSuffix(), indiProvidersPermittedToDisclose.getNameSuffix()); assertEquals(pdmt.getIndividualProvider() .getPracticeLocationAddressCityName(), indiProvidersPermittedToDisclose .getPracticeLocationAddressCityName()); assertEquals(pdmt.getIndividualProvider() .getPracticeLocationAddressCountryCode(), indiProvidersPermittedToDisclose .getPracticeLocationAddressCountryCode()); assertEquals(pdmt.getIndividualProvider() .getPracticeLocationAddressPostalCode(), indiProvidersPermittedToDisclose .getPracticeLocationAddressPostalCode()); assertEquals(pdmt.getIndividualProvider() .getPracticeLocationAddressStateName(), indiProvidersPermittedToDisclose .getPracticeLocationAddressStateName()); } } }
@Test public void testMap_when_mapping_OrganizationalProvidersPermittedToDisclose() { Consent consent = new Consent(); setDataBasicConsent(consent); Set<ConsentOrganizationalProviderPermittedToDisclose> organizationalProvidersPermittedToDisclose = new HashSet<ConsentOrganizationalProviderPermittedToDisclose>(); List<OrganizationalProvider> orgProviders = setDataOrgProviders(); for (OrganizationalProvider organizationalProvider : orgProviders) { ConsentOrganizationalProviderPermittedToDisclose consentOrganizationalProviderPermittedToDisclose = new ConsentOrganizationalProviderPermittedToDisclose( organizationalProvider); organizationalProvidersPermittedToDisclose .add(consentOrganizationalProviderPermittedToDisclose); } consent.setOrganizationalProvidersPermittedToDisclose(organizationalProvidersPermittedToDisclose); ConsentDto consentDto = sut.map(consent); assertEquals(consent.getProvidersPermittedToDisclose().getClass(), consentDto.getProvidersPermittedToDisclose().getClass()); assertEquals(consent.getProvidersPermittedToDisclose().size(), consentDto.getProvidersPermittedToDisclose().size()); for (ConsentOrganizationalProviderPermittedToDisclose pdmt : consent .getOrganizationalProvidersPermittedToDisclose()) { String consentNpi = pdmt.getOrganizationalProvider().getNpi(); for (OrganizationalProviderDto organizationalPermittedToDisclose : consentDto .getOrganizationalProvidersPermittedToDisclose()) { String consentDtoNpi = organizationalPermittedToDisclose .getNpi(); if (!consentNpi.equalsIgnoreCase(consentDtoNpi)) { continue; } assertEquals(pdmt.getOrganizationalProvider().getOrgName(), organizationalPermittedToDisclose.getOrgName()); assertEquals(pdmt.getOrganizationalProvider() .getPracticeLocationAddressCityName(), organizationalPermittedToDisclose .getPracticeLocationAddressCityName()); assertEquals(pdmt.getOrganizationalProvider() .getPracticeLocationAddressStateName(), organizationalPermittedToDisclose .getPracticeLocationAddressStateName()); assertEquals(pdmt.getOrganizationalProvider() .getPracticeLocationAddressCountryCode(), organizationalPermittedToDisclose .getPracticeLocationAddressCountryCode()); assertEquals(pdmt.getOrganizationalProvider() .getSecondLinePracticeLocationAddress(), organizationalPermittedToDisclose .getSecondLinePracticeLocationAddress()); assertEquals(pdmt.getOrganizationalProvider() .getPracticeLocationAddressPostalCode(), organizationalPermittedToDisclose .getPracticeLocationAddressPostalCode()); assertEquals(pdmt.getOrganizationalProvider() .getPracticeLocationAddressStateName(), organizationalPermittedToDisclose .getPracticeLocationAddressStateName()); } } }
@Test public void testMap_when_mapping_OrganizationalProvidersDisclosureIsMadeTo() { Consent consent = new Consent(); setDataBasicConsent(consent); Set<ConsentOrganizationalProviderDisclosureIsMadeTo> OrganizationalProvidersDisclosureIsMadeTo = new HashSet<ConsentOrganizationalProviderDisclosureIsMadeTo>(); List<OrganizationalProvider> orgProviders = setDataOrgProviders(); for (OrganizationalProvider organizationalProvider : orgProviders) { ConsentOrganizationalProviderDisclosureIsMadeTo consentOrganizationalProviderDisclosureIsMadeTo = new ConsentOrganizationalProviderDisclosureIsMadeTo( organizationalProvider); OrganizationalProvidersDisclosureIsMadeTo .add(consentOrganizationalProviderDisclosureIsMadeTo); } consent.setOrganizationalProvidersDisclosureIsMadeTo(OrganizationalProvidersDisclosureIsMadeTo); ConsentDto consentDto = sut.map(consent); assertEquals(consent.getProvidersDisclosureIsMadeTo().getClass(), consentDto.getProvidersDisclosureIsMadeTo().getClass()); assertEquals(consent.getProvidersDisclosureIsMadeTo().size(), consentDto.getProvidersDisclosureIsMadeTo().size()); for (ConsentOrganizationalProviderDisclosureIsMadeTo pdmt : consent .getOrganizationalProvidersDisclosureIsMadeTo()) { String consentNpi = pdmt.getOrganizationalProvider().getNpi(); for (OrganizationalProviderDto organizationalProvidersDisclosureIsMadeTo : consentDto .getOrganizationalProvidersDisclosureIsMadeTo()) { String consentDtoNpi = organizationalProvidersDisclosureIsMadeTo .getNpi(); if (!consentNpi.equalsIgnoreCase(consentDtoNpi)) { continue; } assertEquals(pdmt.getOrganizationalProvider().getOrgName(), organizationalProvidersDisclosureIsMadeTo.getOrgName()); assertEquals(pdmt.getOrganizationalProvider() .getPracticeLocationAddressCityName(), organizationalProvidersDisclosureIsMadeTo .getPracticeLocationAddressCityName()); assertEquals(pdmt.getOrganizationalProvider() .getPracticeLocationAddressStateName(), organizationalProvidersDisclosureIsMadeTo .getPracticeLocationAddressStateName()); assertEquals(pdmt.getOrganizationalProvider() .getPracticeLocationAddressCountryCode(), organizationalProvidersDisclosureIsMadeTo .getPracticeLocationAddressCountryCode()); assertEquals(pdmt.getOrganizationalProvider() .getSecondLinePracticeLocationAddress(), organizationalProvidersDisclosureIsMadeTo .getSecondLinePracticeLocationAddress()); assertEquals(pdmt.getOrganizationalProvider() .getPracticeLocationAddressPostalCode(), organizationalProvidersDisclosureIsMadeTo .getPracticeLocationAddressPostalCode()); assertEquals(pdmt.getOrganizationalProvider() .getPracticeLocationAddressStateName(), organizationalProvidersDisclosureIsMadeTo .getPracticeLocationAddressStateName()); } } }
@Test public void testMap_with_ClinicalConceptCode() { Consent consent = new Consent(); setDataBasicConsent(consent); Set<ClinicalConceptCode> doNotShareClinicalConceptCodes = new HashSet<ClinicalConceptCode>(); ClinicalConceptCode clinicalConceptCode = new ClinicalConceptCode(); clinicalConceptCode.setCode("6"); clinicalConceptCode.setCodeSystemName("Code System Name"); clinicalConceptCode.setDisplayName("Code Display Name"); doNotShareClinicalConceptCodes.add(clinicalConceptCode); consent.setDoNotShareClinicalConceptCodes(doNotShareClinicalConceptCodes); ConsentDto consentDto = sut.map(consent); assertEquals(consent.getDoNotShareClinicalConceptCodes().size(), consentDto.getDoNotShareClinicalConceptCodes().size()); }
@Test public void testMap_DoNotShareClinicalDocumentTypeCodes() { Consent consent = new Consent(); setDataBasicConsent(consent); Set<ConsentDoNotShareClinicalDocumentTypeCode> doNotShareClinicalDocumentTypeCodes = new HashSet<ConsentDoNotShareClinicalDocumentTypeCode>(); ClinicalDocumentTypeCode clinicalDocumentTypeCode = new ClinicalDocumentTypeCode(); clinicalDocumentTypeCode.setCode("code"); clinicalDocumentTypeCode.setDisplayName("display name"); clinicalDocumentTypeCode.setCodeSystem("code system"); clinicalDocumentTypeCode.setCodeSystemName("code system name"); ConsentDoNotShareClinicalDocumentTypeCode consentDoNotShareClinicalDocumentTypeCode = new ConsentDoNotShareClinicalDocumentTypeCode( clinicalDocumentTypeCode); doNotShareClinicalDocumentTypeCodes .add(consentDoNotShareClinicalDocumentTypeCode); consent.setDoNotShareClinicalDocumentTypeCodes(doNotShareClinicalDocumentTypeCodes); ConsentDto consentDto = sut.map(consent); assertNotNull("typecodesdto is empty", consentDto.getDoNotShareClinicalConceptCodes()); assertEquals(consent.getDoNotShareClinicalDocumentTypeCodes().size(), consentDto.getDoNotShareClinicalDocumentTypeCodes().size()); }
@Test public void testMap_DoNotShareClinicalDocumentSectionTypeCode() { Consent consent = new Consent(); setDataBasicConsent(consent); Set<ConsentDoNotShareClinicalDocumentSectionTypeCode> doNotShareClinicalDocumentSectionTypeCodes = new HashSet<ConsentDoNotShareClinicalDocumentSectionTypeCode>(); MedicalSection medicalSection = new MedicalSection(); medicalSection.setCode("code"); medicalSection.setName("display name"); ConsentDoNotShareClinicalDocumentSectionTypeCode consentDoNotShareClinicalDocumentSectionTypeCode = new ConsentDoNotShareClinicalDocumentSectionTypeCode( medicalSection); doNotShareClinicalDocumentSectionTypeCodes .add(consentDoNotShareClinicalDocumentSectionTypeCode); consent.setDoNotShareClinicalDocumentSectionTypeCodes(doNotShareClinicalDocumentSectionTypeCodes); ConsentDto consentDto = sut.map(consent); assertNotNull("typecodesdto is empty", consentDto.getDoNotShareClinicalDocumentSectionTypeCodes()); assertEquals(consent.getDoNotShareClinicalDocumentSectionTypeCodes() .size(), consentDto .getDoNotShareClinicalDocumentSectionTypeCodes().size()); }
@Test public void testMap_DoNotShareSensitivityPolicyCode() { Consent consent = new Consent(); setDataBasicConsent(consent); Set<ConsentDoNotShareSensitivityPolicyCode> doNotShareSensitivityPolicyCodes = new HashSet<ConsentDoNotShareSensitivityPolicyCode>(); ValueSetCategory valueSetCategory = new ValueSetCategory(); valueSetCategory.setCode("code"); valueSetCategory.setName("display name"); ConsentDoNotShareSensitivityPolicyCode consentDoNotShareSensitivityPolicyCode = new ConsentDoNotShareSensitivityPolicyCode( valueSetCategory); doNotShareSensitivityPolicyCodes .add(consentDoNotShareSensitivityPolicyCode); consent.setDoNotShareSensitivityPolicyCodes(doNotShareSensitivityPolicyCodes); ConsentDto consentDto = sut.map(consent); assertNotNull("typecodesdto is empty", consentDto.getDoNotShareSensitivityPolicyCodes()); assertEquals(consent.getDoNotShareSensitivityPolicyCodes().size(), consentDto.getDoNotShareSensitivityPolicyCodes().size()); }
@Test public void testMap_ShareForPurposeOfUseCodes() { Consent consent = new Consent(); setDataBasicConsent(consent); Set<ConsentShareForPurposeOfUseCode> shareForPurposeOfUseCodes = new HashSet<ConsentShareForPurposeOfUseCode>(); PurposeOfUseCode purposeOfUseCode = new PurposeOfUseCode(); purposeOfUseCode.setCode("code"); purposeOfUseCode.setDisplayName("display name"); purposeOfUseCode.setCodeSystem("code system"); purposeOfUseCode.setCodeSystemName("code system name"); ConsentShareForPurposeOfUseCode consentShareForPurposeOfUseCode = new ConsentShareForPurposeOfUseCode( purposeOfUseCode); shareForPurposeOfUseCodes.add(consentShareForPurposeOfUseCode); consent.setShareForPurposeOfUseCodes(shareForPurposeOfUseCodes); ConsentDto consentDto = sut.map(consent); assertNotNull("typecodesdto is empty", consentDto.getShareForPurposeOfUseCodes()); assertEquals(consent.getShareForPurposeOfUseCodes().size(), consentDto .getShareForPurposeOfUseCodes().size()); }