use of org.hl7.fhir.r4.model.codesystems.ResourceTypes.ORGANIZATION in project integration-adaptor-111 by nhsconnect.
the class PractitionerRoleMapperTest method shouldMapResponsibleParty.
@Test
public void shouldMapResponsibleParty() {
mockResponsibleParty();
when(resourceUtil.newRandomUuid()).thenReturn(new IdType(RANDOM_UUID));
PractitionerRole role = practitionerRoleMapper.mapResponsibleParty(clinicalDocument).get();
Coding codingFirstRep = role.getCodeFirstRep().getCodingFirstRep();
assertThat(codingFirstRep.getCode()).isEqualTo(CODE);
assertThat(codingFirstRep.getSystem()).isEqualTo(CODE_SYSTEM);
assertThat(codingFirstRep.getDisplay()).isEqualTo(DISPLAY_NAME);
assertThat(role.getOrganizationTarget()).isEqualTo(organization);
assertThat(role.getPractitionerTarget()).isEqualTo(practitioner);
assertThat(role.getIdElement().getValue()).isEqualTo(RANDOM_UUID);
}
use of org.hl7.fhir.r4.model.codesystems.ResourceTypes.ORGANIZATION in project integration-adaptor-111 by nhsconnect.
the class OrganizationMapperTest method mockItkOrganization.
private POCDMT000002UK01Organization mockItkOrganization() {
POCDMT000002UK01Organization itkOrganization = mock(POCDMT000002UK01Organization.class);
AD itkAddress = mock(AD.class);
TEL itkTelecom = mock(TEL.class);
CE codeEntity = mock(CE.class);
II[] iiArray = new II[] { ii };
when(itkOrganization.getIdArray()).thenReturn(iiArray);
when(ii.isSetExtension()).thenReturn(true);
when(ii.getExtension()).thenReturn(ODS_CODE);
when(itkOrganization.sizeOfIdArray()).thenReturn(1);
when(itkOrganization.getAddrArray()).thenReturn(new AD[] { itkAddress });
when(itkOrganization.getTelecomArray()).thenReturn(new TEL[] { itkTelecom });
when(itkOrganization.isSetStandardIndustryClassCode()).thenReturn(true);
when(itkOrganization.getStandardIndustryClassCode()).thenReturn(codeEntity);
when(codeEntity.getDisplayName()).thenReturn(GP_PRACTICE);
when(contactPointMapper.mapContactPoint(any())).thenReturn(contactPoint);
when(addressMapper.mapAddress(any())).thenReturn(address);
when(nodeUtil.getNodeValueString(itkOrganization.getNameArray(0))).thenReturn(ORGANIZATION_NAME);
when(resourceUtil.newRandomUuid()).thenReturn(new IdType(RANDOM_UUID));
Organization organization = organizationMapper.mapOrganization(itkOrganization);
assertThat(organization.getName()).isEqualTo(ORGANIZATION_NAME);
assertThat(organization.getAddressFirstRep()).isEqualTo(address);
assertThat(organization.getTelecomFirstRep()).isEqualTo(contactPoint);
assertThat(organization.getTypeFirstRep().getText()).isEqualTo(GP_PRACTICE);
assertThat(organization.getIdentifierFirstRep().getValue()).isEqualTo(ODS_CODE);
assertThat(organization.getIdElement().getValue()).isEqualTo(RANDOM_UUID);
return itkOrganization;
}
use of org.hl7.fhir.r4.model.codesystems.ResourceTypes.ORGANIZATION in project integration-adaptor-111 by nhsconnect.
the class LocationMapper method mapRecipientToLocation.
public Location mapRecipientToLocation(POCDMT000002UK01IntendedRecipient intendedRecipient, Organization organization) {
Location location = new Location();
if (intendedRecipient.sizeOfAddrArray() > 0) {
location.setAddress(addressMapper.mapAddress(intendedRecipient.getAddrArray(0)));
}
location.setTelecom(Arrays.stream(intendedRecipient.getTelecomArray()).map(contactPointMapper::mapContactPoint).collect(Collectors.toList()));
if (!organization.isEmpty()) {
location.setManagingOrganization(resourceUtil.createReference(organization));
location.setManagingOrganizationTarget(organization);
}
if (location.isEmpty()) {
return null;
}
location.setIdElement(resourceUtil.newRandomUuid());
return location;
}
use of org.hl7.fhir.r4.model.codesystems.ResourceTypes.ORGANIZATION in project integration-adaptor-111 by nhsconnect.
the class OrganizationMapper method mapOrganization.
public Organization mapOrganization(POCDMT000002UK01Organization itkOrganization) {
Organization fhirOrganization = new Organization();
fhirOrganization.setIdElement(resourceUtil.newRandomUuid());
fhirOrganization.setName(nodeUtil.getNodeValueString(itkOrganization.getNameArray(0)));
fhirOrganization.setAddress(Arrays.stream(itkOrganization.getAddrArray()).map(addressMapper::mapAddress).collect(Collectors.toList()));
fhirOrganization.setTelecom(Arrays.stream(itkOrganization.getTelecomArray()).map(contactPointMapper::mapContactPoint).collect(Collectors.toList()));
if (itkOrganization.isSetStandardIndustryClassCode()) {
fhirOrganization.setType(Collections.singletonList(new CodeableConcept().setText(itkOrganization.getStandardIndustryClassCode().getDisplayName())));
}
if (itkOrganization.isSetAsOrganizationPartOf()) {
if (itkOrganization.getAsOrganizationPartOf().getWholeOrganization() != null) {
Organization partOf = mapOrganization(itkOrganization.getAsOrganizationPartOf().getWholeOrganization());
fhirOrganization.setPartOf(resourceUtil.createReference(partOf));
fhirOrganization.setPartOfTarget(partOf);
}
}
if (itkOrganization.sizeOfIdArray() > 0) {
List<Identifier> identifierList = new ArrayList<>();
for (II id : itkOrganization.getIdArray()) {
if (id.isSetExtension()) {
identifierList.add(new Identifier().setValue(id.getExtension()));
}
}
fhirOrganization.setIdentifier(identifierList);
}
return fhirOrganization;
}
use of org.hl7.fhir.r4.model.codesystems.ResourceTypes.ORGANIZATION in project integration-adaptor-111 by nhsconnect.
the class EncounterReportBundleService method addSubject.
private void addSubject(Bundle bundle, Encounter encounter) {
if (encounter.getSubjectTarget() instanceof Patient) {
Patient patient = (Patient) encounter.getSubjectTarget();
addEntry(bundle, patient);
if (patient.hasGeneralPractitioner()) {
for (Reference gp : patient.getGeneralPractitioner()) {
Organization organization = (Organization) gp.getResource();
addEntry(bundle, organization);
}
}
}
if (encounter.getSubjectTarget() instanceof Group) {
Group group = (Group) encounter.getSubjectTarget();
addEntry(bundle, group);
for (Group.GroupMemberComponent groupMemberComponent : group.getMember()) {
bundle.addEntry().setFullUrl(groupMemberComponent.getIdElement().getValue()).setResource(groupMemberComponent.getEntityTarget());
}
}
}
Aggregations