From 9f90ceb9a3e9b940b78cd47b3b427fb2540ba626 Mon Sep 17 00:00:00 2001 From: hospel Date: Fri, 10 Nov 2023 16:17:55 +0000 Subject: [PATCH 1/4] adding identifier to practitioner section --- .../mapper/AgentDirectoryMapper.java | 12 +- .../mapper/AgentDirectoryMapperTest.java | 215 ++++++++++-------- ...t_org_with_general_practitioner_number.xml | 19 ++ 3 files changed, 143 insertions(+), 103 deletions(-) create mode 100644 gp2gp-translator/src/test/resources/xml/AgentDirectory/agent_org_with_general_practitioner_number.xml diff --git a/gp2gp-translator/src/main/java/uk/nhs/adaptors/pss/translator/mapper/AgentDirectoryMapper.java b/gp2gp-translator/src/main/java/uk/nhs/adaptors/pss/translator/mapper/AgentDirectoryMapper.java index 06dafaeeb..ae18124a5 100644 --- a/gp2gp-translator/src/main/java/uk/nhs/adaptors/pss/translator/mapper/AgentDirectoryMapper.java +++ b/gp2gp-translator/src/main/java/uk/nhs/adaptors/pss/translator/mapper/AgentDirectoryMapper.java @@ -71,9 +71,10 @@ private void mapAgent(RCCTMT120101UK01Agent agent, List agentRes var agentOrganization = agent.getAgentOrganization(); var representedOrganization = agent.getRepresentedOrganization(); var resourceId = agent.getId().get(0).getRoot(); + var gpNumber = agent.getId().size() > 1 ? agent.getId().get(1).getExtension() : ""; if (agentPerson != null && representedOrganization != null) { - agentResourceList.add(createPractitioner(agentPerson, resourceId)); + agentResourceList.add(createPractitioner(agentPerson, resourceId, gpNumber)); var representedOrganisation = createRepresentedOrganization(representedOrganization, resourceId); Optional duplicateOrganisation = findDuplicateOrganisation(representedOrganisation, agentResourceList); @@ -85,19 +86,24 @@ private void mapAgent(RCCTMT120101UK01Agent agent, List agentRes agentResourceList.add(createPractitionerRole(resourceId, agent.getCode(), duplicateOrganisation.orElseThrow().getId())); } } else if (agentPerson != null && agentOrganization == null) { - agentResourceList.add(createPractitioner(agentPerson, resourceId)); + agentResourceList.add(createPractitioner(agentPerson, resourceId, gpNumber)); } else if (agentPerson == null && agentOrganization != null) { agentResourceList.add(createAgentOrganization(agentOrganization, resourceId, agent.getCode())); } } - private Practitioner createPractitioner(RCCTMT120101UK01Person agentPerson, String id) { + private Practitioner createPractitioner(RCCTMT120101UK01Person agentPerson, String id, String gpNumber) { var practitioner = new Practitioner(); practitioner.setId(id); practitioner.setMeta(generateMeta(PRACT_META_PROFILE)); practitioner.setName(getPractitionerName(agentPerson.getName())); + Identifier identifier = new Identifier() + .setSystem("https://fhir.hl7.org.uk/Id/gmp-number") + .setValue(gpNumber); + practitioner.setIdentifier(List.of(identifier)); + return practitioner; } diff --git a/gp2gp-translator/src/test/java/uk/nhs/adaptors/pss/translator/mapper/AgentDirectoryMapperTest.java b/gp2gp-translator/src/test/java/uk/nhs/adaptors/pss/translator/mapper/AgentDirectoryMapperTest.java index 65197118e..f1380735f 100644 --- a/gp2gp-translator/src/test/java/uk/nhs/adaptors/pss/translator/mapper/AgentDirectoryMapperTest.java +++ b/gp2gp-translator/src/test/java/uk/nhs/adaptors/pss/translator/mapper/AgentDirectoryMapperTest.java @@ -16,6 +16,7 @@ import org.junit.jupiter.api.Test; import static org.assertj.core.api.Assertions.assertThat; +import static org.junit.jupiter.api.Assertions.assertEquals; import static org.springframework.util.ResourceUtils.getFile; import static uk.nhs.adaptors.pss.translator.util.XmlUnmarshallUtil.unmarshallFile; @@ -23,6 +24,7 @@ import java.util.List; public class AgentDirectoryMapperTest { + private static final String XML_RESOURCES_BASE = "xml/AgentDirectory/"; private static final String PRACT_META_PROFILE = "https://fhir.nhs.uk/STU3/StructureDefinition/CareConnect-GPC-Practitioner-1"; private static final String ORG_META_PROFILE = "https://fhir.nhs.uk/STU3/StructureDefinition/CareConnect-GPC-Organization-1"; @@ -41,7 +43,7 @@ public void mapAgentDirectoryWithMultipleAgents() { List mappedAgents = agentDirectoryMapper.mapAgentDirectory(agentDirectory); // asserts that for the 3 varying Agents in the input, that there are correctly 5 mapped resources output - assertThat(mappedAgents.size()).isEqualTo(FIVE_RESOURCES_MAPPED); + assertEquals(FIVE_RESOURCES_MAPPED, mappedAgents.size()); } @Test @@ -50,26 +52,39 @@ public void mapAgentDirectoryWithAgentPersonAndRepresentedOrganizationNoCode() { List mappedAgents = agentDirectoryMapper.mapAgentDirectory(agentDirectory); - assertThat(mappedAgents.size()).isEqualTo(THREE_RESOURCES_MAPPED); + assertEquals(THREE_RESOURCES_MAPPED, mappedAgents.size()); var practitioner = (Practitioner) mappedAgents.get(0); - assertThat(practitioner.getId()).isEqualTo("94F00D99-0601-4A8E-AD1D-1B564307B0A6"); - assertThat(practitioner.getMeta().getProfile().get(0).getValue()).isEqualTo(PRACT_META_PROFILE); - assertThat(practitioner.getNameFirstRep().getUse()).isEqualTo(NameUse.OFFICIAL); - assertThat(practitioner.getNameFirstRep().getFamily()).isEqualTo("Test"); + assertEquals("94F00D99-0601-4A8E-AD1D-1B564307B0A6", practitioner.getId()); + assertEquals(PRACT_META_PROFILE, practitioner.getMeta().getProfile().get(0).getValue()); + assertEquals(NameUse.OFFICIAL, practitioner.getNameFirstRep().getUse()); + assertEquals("Test", practitioner.getNameFirstRep().getFamily()); var organization = (Organization) mappedAgents.get(1); - assertThat(organization.getId()).isEqualTo("94F00D99-0601-4A8E-AD1D-1B564307B0A6-ORG"); - assertThat(organization.getMeta().getProfile().get(0).getValue()).isEqualTo(ORG_META_PROFILE); - assertThat(organization.getName()).isEqualTo("TEMPLE SOWERBY MEDICAL PRACTICE"); - assertThat(organization.getType().size()).isEqualTo(0); + assertEquals("94F00D99-0601-4A8E-AD1D-1B564307B0A6-ORG", organization.getId()); + assertEquals(ORG_META_PROFILE, organization.getMeta().getProfile().get(0).getValue()); + assertEquals("TEMPLE SOWERBY MEDICAL PRACTICE", organization.getName()); + assertThat(organization.getType()).isEmpty(); var practitionerRole = (PractitionerRole) mappedAgents.get(2); - assertThat(practitionerRole.getId()).isEqualTo("94F00D99-0601-4A8E-AD1D-1B564307B0A6-PR"); - assertThat(practitionerRole.getMeta().getProfile().get(0).getValue()).isEqualTo(PRACT_ROLE_META_PROFILE); - assertThat(practitionerRole.getPractitioner().getReference()).isEqualTo("Practitioner/94F00D99-0601-4A8E-AD1D-1B564307B0A6"); - assertThat(practitionerRole.getOrganization().getReference()).isEqualTo("Organization/94F00D99-0601-4A8E-AD1D-1B564307B0A6-ORG"); - assertThat(practitionerRole.getCode().size()).isEqualTo(0); + assertEquals("94F00D99-0601-4A8E-AD1D-1B564307B0A6-PR", practitionerRole.getId()); + assertEquals(PRACT_ROLE_META_PROFILE, practitionerRole.getMeta().getProfile().get(0).getValue()); + assertEquals("Practitioner/94F00D99-0601-4A8E-AD1D-1B564307B0A6", practitionerRole.getPractitioner().getReference()); + assertEquals("Organization/94F00D99-0601-4A8E-AD1D-1B564307B0A6-ORG", practitionerRole.getOrganization().getReference()); + assertThat(practitionerRole.getCode()).isEmpty(); + } + + @Test + public void mapAgentDirectoryWithAgentPersonAndGeneralPractitionerNumber() { + var agentDirectory = unmarshallAgentDirectoryElement("agent_org_with_general_practitioner_number.xml"); + + List mappedAgents = agentDirectoryMapper.mapAgentDirectory(agentDirectory); + var practitioner = (Practitioner) mappedAgents.get(0); + + assertEquals("E7E7B550-09EF-BE85-C20F-34598014166C", practitioner.getId()); + assertThat(practitioner.getIdentifier()).isNotEmpty(); + assertEquals("https://fhir.hl7.org.uk/Id/gmp-number", practitioner.getIdentifier().get(0).getSystem()); + assertEquals("12345", practitioner.getIdentifier().get(0).getValue()); } @Test @@ -78,26 +93,26 @@ public void mapAgentDirectoryWithAgentPersonAndRepresentedOrganizationWithOrigin List mappedAgents = agentDirectoryMapper.mapAgentDirectory(agentDirectory); - assertThat(mappedAgents.size()).isEqualTo(THREE_RESOURCES_MAPPED); + assertEquals(THREE_RESOURCES_MAPPED, mappedAgents.size()); var practitioner = (Practitioner) mappedAgents.get(0); - assertThat(practitioner.getId()).isEqualTo("94F00D99-0601-4A8E-AD1D-1B564307B0A6"); - assertThat(practitioner.getMeta().getProfile().get(0).getValue()).isEqualTo(PRACT_META_PROFILE); - assertThat(practitioner.getNameFirstRep().getUse()).isEqualTo(NameUse.OFFICIAL); - assertThat(practitioner.getNameFirstRep().getFamily()).isEqualTo("Test"); + assertEquals("94F00D99-0601-4A8E-AD1D-1B564307B0A6", practitioner.getId()); + assertEquals(PRACT_META_PROFILE, practitioner.getMeta().getProfile().get(0).getValue()); + assertEquals(NameUse.OFFICIAL, practitioner.getNameFirstRep().getUse()); + assertEquals("Test", practitioner.getNameFirstRep().getFamily()); var organization = (Organization) mappedAgents.get(1); - assertThat(organization.getId()).isEqualTo("94F00D99-0601-4A8E-AD1D-1B564307B0A6-ORG"); - assertThat(organization.getMeta().getProfile().get(0).getValue()).isEqualTo(ORG_META_PROFILE); - assertThat(organization.getName()).isEqualTo("TEMPLE SOWERBY MEDICAL PRACTICE"); - assertThat(organization.getType().size()).isEqualTo(0); + assertEquals("94F00D99-0601-4A8E-AD1D-1B564307B0A6-ORG", organization.getId()); + assertEquals(ORG_META_PROFILE, organization.getMeta().getProfile().get(0).getValue()); + assertEquals("TEMPLE SOWERBY MEDICAL PRACTICE", organization.getName()); + assertThat(organization.getType()).isEmpty(); var practitionerRole = (PractitionerRole) mappedAgents.get(2); - assertThat(practitionerRole.getId()).isEqualTo("94F00D99-0601-4A8E-AD1D-1B564307B0A6-PR"); - assertThat(practitionerRole.getMeta().getProfile().get(0).getValue()).isEqualTo(PRACT_ROLE_META_PROFILE); - assertThat(practitionerRole.getPractitioner().getReference()).isEqualTo("Practitioner/94F00D99-0601-4A8E-AD1D-1B564307B0A6"); - assertThat(practitionerRole.getOrganization().getReference()).isEqualTo("Organization/94F00D99-0601-4A8E-AD1D-1B564307B0A6-ORG"); - assertThat(practitionerRole.getCodeFirstRep().getText()).isEqualTo("Clerical Worker"); + assertEquals("94F00D99-0601-4A8E-AD1D-1B564307B0A6-PR", practitionerRole.getId()); + assertEquals(PRACT_ROLE_META_PROFILE, practitionerRole.getMeta().getProfile().get(0).getValue()); + assertEquals("Practitioner/94F00D99-0601-4A8E-AD1D-1B564307B0A6", practitionerRole.getPractitioner().getReference()); + assertEquals("Organization/94F00D99-0601-4A8E-AD1D-1B564307B0A6-ORG", practitionerRole.getOrganization().getReference()); + assertEquals("Clerical Worker", practitionerRole.getCodeFirstRep().getText()); } @Test @@ -106,26 +121,26 @@ public void mapAgentDirectoryWithAgentPersonAndRepresentedOrganizationWithDispla List mappedAgents = agentDirectoryMapper.mapAgentDirectory(agentDirectory); - assertThat(mappedAgents.size()).isEqualTo(THREE_RESOURCES_MAPPED); + assertEquals(THREE_RESOURCES_MAPPED, mappedAgents.size()); var practitioner = (Practitioner) mappedAgents.get(0); - assertThat(practitioner.getId()).isEqualTo("94F00D99-0601-4A8E-AD1D-1B564307B0A6"); - assertThat(practitioner.getMeta().getProfile().get(0).getValue()).isEqualTo(PRACT_META_PROFILE); - assertThat(practitioner.getNameFirstRep().getUse()).isEqualTo(NameUse.OFFICIAL); - assertThat(practitioner.getNameFirstRep().getFamily()).isEqualTo("Test"); + assertEquals("94F00D99-0601-4A8E-AD1D-1B564307B0A6", practitioner.getId()); + assertEquals(PRACT_META_PROFILE, practitioner.getMeta().getProfile().get(0).getValue()); + assertEquals(NameUse.OFFICIAL, practitioner.getNameFirstRep().getUse()); + assertEquals("Test", practitioner.getNameFirstRep().getFamily()); var organization = (Organization) mappedAgents.get(1); - assertThat(organization.getId()).isEqualTo("94F00D99-0601-4A8E-AD1D-1B564307B0A6-ORG"); - assertThat(organization.getMeta().getProfile().get(0).getValue()).isEqualTo(ORG_META_PROFILE); - assertThat(organization.getName()).isEqualTo("TEMPLE SOWERBY MEDICAL PRACTICE"); - assertThat(organization.getType().size()).isEqualTo(0); + assertEquals("94F00D99-0601-4A8E-AD1D-1B564307B0A6-ORG", organization.getId()); + assertEquals(ORG_META_PROFILE, organization.getMeta().getProfile().get(0).getValue()); + assertEquals("TEMPLE SOWERBY MEDICAL PRACTICE", organization.getName()); + assertThat(organization.getType()).isEmpty(); var practitionerRole = (PractitionerRole) mappedAgents.get(2); - assertThat(practitionerRole.getId()).isEqualTo("94F00D99-0601-4A8E-AD1D-1B564307B0A6-PR"); - assertThat(practitionerRole.getMeta().getProfile().get(0).getValue()).isEqualTo(PRACT_ROLE_META_PROFILE); - assertThat(practitionerRole.getPractitioner().getReference()).isEqualTo("Practitioner/94F00D99-0601-4A8E-AD1D-1B564307B0A6"); - assertThat(practitionerRole.getOrganization().getReference()).isEqualTo("Organization/94F00D99-0601-4A8E-AD1D-1B564307B0A6-ORG"); - assertThat(practitionerRole.getCodeFirstRep().getText()).isEqualTo("General practice"); + assertEquals("94F00D99-0601-4A8E-AD1D-1B564307B0A6-PR", practitionerRole.getId()); + assertEquals(PRACT_ROLE_META_PROFILE, practitionerRole.getMeta().getProfile().get(0).getValue()); + assertEquals("Practitioner/94F00D99-0601-4A8E-AD1D-1B564307B0A6", practitionerRole.getPractitioner().getReference()); + assertEquals("Organization/94F00D99-0601-4A8E-AD1D-1B564307B0A6-ORG", practitionerRole.getOrganization().getReference()); + assertEquals("General practice", practitionerRole.getCodeFirstRep().getText()); } @Test @@ -137,12 +152,12 @@ public void mapAgentDirectoryOnlyAgentPersonNoOptionalFields() { assertThat(mappedAgents.size()).isEqualTo(1); var practitioner = (Practitioner) mappedAgents.get(0); - assertThat(practitioner.getId()).isEqualTo("95D00D99-0601-4A8E-AD1D-1B564307B0A6"); - assertThat(practitioner.getMeta().getProfile().get(0).getValue()).isEqualTo(PRACT_META_PROFILE); - assertThat(practitioner.getNameFirstRep().getUse()).isEqualTo(NameUse.OFFICIAL); - assertThat(practitioner.getNameFirstRep().getFamily()).isEqualTo("Test"); - assertThat(practitioner.getNameFirstRep().getGiven().size()).isEqualTo(0); - assertThat(practitioner.getNameFirstRep().getPrefix().size()).isEqualTo(0); + assertEquals("95D00D99-0601-4A8E-AD1D-1B564307B0A6", practitioner.getId()); + assertEquals(PRACT_META_PROFILE, practitioner.getMeta().getProfile().get(0).getValue()); + assertEquals(NameUse.OFFICIAL, practitioner.getNameFirstRep().getUse()); + assertEquals("Test", practitioner.getNameFirstRep().getFamily()); + assertThat(practitioner.getNameFirstRep().getGiven()).isEmpty(); + assertThat(practitioner.getNameFirstRep().getPrefix()).isEmpty(); } @Test @@ -158,8 +173,8 @@ public void mapAgentDirectoryOnlyAgentPersonUnknownName() { assertThat(practitioner.getMeta().getProfile().get(0).getValue()).isEqualTo(PRACT_META_PROFILE); assertThat(practitioner.getNameFirstRep().getUse()).isEqualTo(NameUse.OFFICIAL); assertThat(practitioner.getNameFirstRep().getFamily()).isEqualTo("Unknown"); - assertThat(practitioner.getNameFirstRep().getGiven().size()).isEqualTo(0); - assertThat(practitioner.getNameFirstRep().getPrefix().size()).isEqualTo(0); + assertThat(practitioner.getNameFirstRep().getGiven()).isEmpty(); + assertThat(practitioner.getNameFirstRep().getPrefix()).isEmpty(); } @Test @@ -191,9 +206,9 @@ public void mapAgentDirectoryOnlyAgentOrganizationNoOptionalFields() { assertThat(organization.getId()).isEqualTo("1D9BDC28-50AB-440D-B421-0E5E049526FA"); assertThat(organization.getMeta().getProfile().get(0).getValue()).isEqualTo(ORG_META_PROFILE); assertThat(organization.getName()).isEqualTo("The Health Centre"); - assertThat(organization.getIdentifier().size()).isEqualTo(0); - assertThat(organization.getTelecom().size()).isEqualTo(0); - assertThat(organization.getAddress().size()).isEqualTo(0); + assertThat(organization.getIdentifier()).isEmpty(); + assertThat(organization.getTelecom()).isEmpty(); + assertThat(organization.getAddress()).isEmpty(); } @Test @@ -208,9 +223,9 @@ public void mapAgentDirectoryOnlyAgentOrganizationUnknownName() { assertThat(organization.getId()).isEqualTo("1D9BDC28-50AB-440D-B421-0E5E049526FA"); assertThat(organization.getMeta().getProfile().get(0).getValue()).isEqualTo(ORG_META_PROFILE); assertThat(organization.getName()).isEqualTo("Unknown"); - assertThat(organization.getIdentifier().size()).isEqualTo(0); - assertThat(organization.getTelecom().size()).isEqualTo(0); - assertThat(organization.getAddress().size()).isEqualTo(0); + assertThat(organization.getIdentifier()).isEmpty(); + assertThat(organization.getTelecom()).isEmpty(); + assertThat(organization.getAddress()).isEmpty(); } @Test @@ -219,16 +234,16 @@ public void mapAgentDirectoryOnlyAgentOrganizationWithValidIdentifier() { List mappedAgents = agentDirectoryMapper.mapAgentDirectory(agentDirectory); - assertThat(mappedAgents.size()).isEqualTo(1); + assertEquals(1, mappedAgents.size()); var organization = (Organization) mappedAgents.get(0); - assertThat(organization.getId()).isEqualTo("1D9BDC28-50AB-440D-B421-0E5E049526FA"); - assertThat(organization.getMeta().getProfile().get(0).getValue()).isEqualTo(ORG_META_PROFILE); - assertThat(organization.getName()).isEqualTo("The Health Centre"); - assertThat(organization.getIdentifierFirstRep().getSystem()).isEqualTo(ORG_IDENTIFIER_SYSTEM); - assertThat(organization.getIdentifierFirstRep().getValue()).isEqualTo("A81001"); - assertThat(organization.getTelecom().size()).isEqualTo(0); - assertThat(organization.getAddress().size()).isEqualTo(0); + assertEquals("1D9BDC28-50AB-440D-B421-0E5E049526FA", organization.getId()); + assertEquals(ORG_META_PROFILE, organization.getMeta().getProfile().get(0).getValue()); + assertEquals("The Health Centre", organization.getName()); + assertEquals(ORG_IDENTIFIER_SYSTEM, organization.getIdentifierFirstRep().getSystem()); + assertEquals("A81001", organization.getIdentifierFirstRep().getValue()); + assertThat(organization.getTelecom()).isEmpty(); + assertThat(organization.getAddress()).isEmpty(); } @Test @@ -237,15 +252,15 @@ public void mapAgentDirectoryOnlyAgentOrganizationWithInvalidIdentifier() { List mappedAgents = agentDirectoryMapper.mapAgentDirectory(agentDirectory); - assertThat(mappedAgents.size()).isEqualTo(1); + assertEquals(1, mappedAgents.size()); var organization = (Organization) mappedAgents.get(0); - assertThat(organization.getId()).isEqualTo("1D9BDC28-50AB-440D-B421-0E5E049526FA"); - assertThat(organization.getMeta().getProfile().get(0).getValue()).isEqualTo(ORG_META_PROFILE); - assertThat(organization.getName()).isEqualTo("The Health Centre"); - assertThat(organization.getIdentifier().size()).isEqualTo(0); - assertThat(organization.getTelecom().size()).isEqualTo(0); - assertThat(organization.getAddress().size()).isEqualTo(0); + assertEquals("1D9BDC28-50AB-440D-B421-0E5E049526FA", organization.getId()); + assertEquals(ORG_META_PROFILE, organization.getMeta().getProfile().get(0).getValue()); + assertEquals("The Health Centre", organization.getName()); + assertThat(organization.getIdentifier()).isEmpty(); + assertThat(organization.getTelecom()).isEmpty(); + assertThat(organization.getAddress()).isEmpty(); } @Test @@ -254,15 +269,15 @@ public void mapAgentDirectoryOnlyAgentOrganizationWithNonWPAddressAndTelecom() { List mappedAgents = agentDirectoryMapper.mapAgentDirectory(agentDirectory); - assertThat(mappedAgents.size()).isEqualTo(1); + assertEquals(1, mappedAgents.size()); var organization = (Organization) mappedAgents.get(0); - assertThat(organization.getId()).isEqualTo("1D9BDC28-50AB-440D-B421-0E5E049526FA"); - assertThat(organization.getMeta().getProfile().get(0).getValue()).isEqualTo(ORG_META_PROFILE); - assertThat(organization.getName()).isEqualTo("The Health Centre"); - assertThat(organization.getIdentifier().size()).isEqualTo(0); + assertEquals("1D9BDC28-50AB-440D-B421-0E5E049526FA", organization.getId()); + assertEquals(ORG_META_PROFILE, organization.getMeta().getProfile().get(0).getValue()); + assertEquals("The Health Centre", organization.getName()); + assertThat(organization.getIdentifier()).isEmpty(); assertTelecom(organization.getTelecomFirstRep(), "01234567890"); - assertThat(organization.getAddress().size()).isEqualTo(0); + assertThat(organization.getAddress()).isEmpty(); } @Test @@ -271,15 +286,15 @@ public void mapAgentDirectoryOnlyAgentOrganizationWithWPTelecom() { List mappedAgents = agentDirectoryMapper.mapAgentDirectory(agentDirectory); - assertThat(mappedAgents.size()).isEqualTo(1); + assertEquals(1, mappedAgents.size()); var organization = (Organization) mappedAgents.get(0); - assertThat(organization.getId()).isEqualTo("1D9BDC28-50AB-440D-B421-0E5E049526FA"); - assertThat(organization.getMeta().getProfile().get(0).getValue()).isEqualTo(ORG_META_PROFILE); - assertThat(organization.getName()).isEqualTo("The Health Centre"); - assertThat(organization.getIdentifier().size()).isEqualTo(0); + assertEquals("1D9BDC28-50AB-440D-B421-0E5E049526FA", organization.getId()); + assertEquals(ORG_META_PROFILE, organization.getMeta().getProfile().get(0).getValue()); + assertEquals("The Health Centre", organization.getName()); + assertThat(organization.getIdentifier()).isEmpty(); assertTelecom(organization.getTelecomFirstRep(), "01234567890"); - assertThat(organization.getAddress().size()).isEqualTo(0); + assertThat(organization.getAddress()).isEmpty(); } @Test @@ -288,31 +303,31 @@ public void mapAgentDirectoryOnlyAgentOrganizationWithWPAddress() { List mappedAgents = agentDirectoryMapper.mapAgentDirectory(agentDirectory); - assertThat(mappedAgents.size()).isEqualTo(1); + assertEquals(1, mappedAgents.size()); var organization = (Organization) mappedAgents.get(0); - assertThat(organization.getId()).isEqualTo("1D9BDC28-50AB-440D-B421-0E5E049526FA"); - assertThat(organization.getMeta().getProfile().get(0).getValue()).isEqualTo(ORG_META_PROFILE); - assertThat(organization.getName()).isEqualTo("The Health Centre"); - assertThat(organization.getIdentifier().size()).isEqualTo(0); - assertThat(organization.getTelecom().size()).isEqualTo(0); + assertEquals("1D9BDC28-50AB-440D-B421-0E5E049526FA", organization.getId()); + assertEquals(ORG_META_PROFILE, organization.getMeta().getProfile().get(0).getValue()); + assertEquals("The Health Centre", organization.getName()); + assertThat(organization.getIdentifier()).isEmpty(); + assertThat(organization.getTelecom()).isEmpty(); assertAddress(organization.getAddressFirstRep()); } private void assertAddress(Address address) { - assertThat(address.getUse()).isEqualTo(AddressUse.WORK); - assertThat(address.getType()).isEqualTo(AddressType.PHYSICAL); - assertThat(address.getLine().get(0).getValue()).isEqualTo("234 ASHTREE ROAD"); - assertThat(address.getLine().get(1).getValue()).isEqualTo("LEEDS"); - assertThat(address.getLine().get(2).getValue()).isEqualTo("YORKSHIRE"); - assertThat(address.getPostalCode()).isEqualTo("LS12 3RT"); + assertEquals(AddressUse.WORK, address.getUse()); + assertEquals(AddressType.PHYSICAL, address.getType()); + assertEquals("234 ASHTREE ROAD", address.getLine().get(0).getValue()); + assertEquals("LEEDS", address.getLine().get(1).getValue()); + assertEquals("YORKSHIRE", address.getLine().get(2).getValue()); + assertEquals("LS12 3RT", address.getPostalCode()); } private void assertTelecom(ContactPoint telecom, String value) { - assertThat(telecom.getSystem()).isEqualTo(ContactPointSystem.PHONE); - assertThat(telecom.getUse()).isEqualTo(ContactPointUse.WORK); - assertThat(telecom.getRank()).isEqualTo(TELECOM_RANK); - assertThat(telecom.getValue()).isEqualTo(value); + assertEquals(ContactPointSystem.PHONE, telecom.getSystem()); + assertEquals(ContactPointUse.WORK, telecom.getUse()); + assertEquals(TELECOM_RANK, telecom.getRank()); + assertEquals(value, telecom.getValue()); } @SneakyThrows diff --git a/gp2gp-translator/src/test/resources/xml/AgentDirectory/agent_org_with_general_practitioner_number.xml b/gp2gp-translator/src/test/resources/xml/AgentDirectory/agent_org_with_general_practitioner_number.xml new file mode 100644 index 000000000..96eef5c18 --- /dev/null +++ b/gp2gp-translator/src/test/resources/xml/AgentDirectory/agent_org_with_general_practitioner_number.xml @@ -0,0 +1,19 @@ + + + + + + + General Medical Practitioner + + + + Dr + helen + tallantyre + + + + + \ No newline at end of file From 9f5ccc8aa048963aec6edcbc8ab4143d16fabd23 Mon Sep 17 00:00:00 2001 From: hospel Date: Fri, 10 Nov 2023 16:30:23 +0000 Subject: [PATCH 2/4] small test optimizations --- .../translator/mapper/AgentDirectoryMapperTest.java | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/gp2gp-translator/src/test/java/uk/nhs/adaptors/pss/translator/mapper/AgentDirectoryMapperTest.java b/gp2gp-translator/src/test/java/uk/nhs/adaptors/pss/translator/mapper/AgentDirectoryMapperTest.java index f1380735f..ea3c1a001 100644 --- a/gp2gp-translator/src/test/java/uk/nhs/adaptors/pss/translator/mapper/AgentDirectoryMapperTest.java +++ b/gp2gp-translator/src/test/java/uk/nhs/adaptors/pss/translator/mapper/AgentDirectoryMapperTest.java @@ -149,7 +149,7 @@ public void mapAgentDirectoryOnlyAgentPersonNoOptionalFields() { List mappedAgents = agentDirectoryMapper.mapAgentDirectory(agentDirectory); - assertThat(mappedAgents.size()).isEqualTo(1); + assertThat(mappedAgents).hasSize(1); var practitioner = (Practitioner) mappedAgents.get(0); assertEquals("95D00D99-0601-4A8E-AD1D-1B564307B0A6", practitioner.getId()); @@ -166,7 +166,7 @@ public void mapAgentDirectoryOnlyAgentPersonUnknownName() { List mappedAgents = agentDirectoryMapper.mapAgentDirectory(agentDirectory); - assertThat(mappedAgents.size()).isEqualTo(1); + assertThat(mappedAgents).hasSize(1); var practitioner = (Practitioner) mappedAgents.get(0); assertThat(practitioner.getId()).isEqualTo("95D00D99-0601-4A8E-AD1D-1B564307B0A6"); @@ -183,7 +183,7 @@ public void mapAgentDirectoryOnlyAgentPersonFullName() { List mappedAgents = agentDirectoryMapper.mapAgentDirectory(agentDirectory); - assertThat(mappedAgents.size()).isEqualTo(1); + assertThat(mappedAgents).hasSize(1); var practitioner = (Practitioner) mappedAgents.get(0); assertThat(practitioner.getId()).isEqualTo("95D00D99-0601-4A8E-AD1D-1B564307B0A6"); @@ -200,7 +200,7 @@ public void mapAgentDirectoryOnlyAgentOrganizationNoOptionalFields() { List mappedAgents = agentDirectoryMapper.mapAgentDirectory(agentDirectory); - assertThat(mappedAgents.size()).isEqualTo(1); + assertThat(mappedAgents).hasSize(1); var organization = (Organization) mappedAgents.get(0); assertThat(organization.getId()).isEqualTo("1D9BDC28-50AB-440D-B421-0E5E049526FA"); @@ -217,7 +217,7 @@ public void mapAgentDirectoryOnlyAgentOrganizationUnknownName() { List mappedAgents = agentDirectoryMapper.mapAgentDirectory(agentDirectory); - assertThat(mappedAgents.size()).isEqualTo(1); + assertThat(mappedAgents).hasSize(1); var organization = (Organization) mappedAgents.get(0); assertThat(organization.getId()).isEqualTo("1D9BDC28-50AB-440D-B421-0E5E049526FA"); From 86fc86095281150b6104578276ed3e79f95f183e Mon Sep 17 00:00:00 2001 From: hospel Date: Mon, 13 Nov 2023 15:43:46 +0000 Subject: [PATCH 3/4] fixing integration tests --- .../e2e-mapping/output-json/PWTP10-output.json | 12 ++++++++++-- .../e2e-mapping/output-json/PWTP11-output.json | 6 +++++- .../e2e-mapping/output-json/PWTP2-output.json | 12 ++++++++++-- .../e2e-mapping/output-json/PWTP3-output.json | 12 ++++++++++-- .../e2e-mapping/output-json/PWTP4-output.json | 12 ++++++++++-- .../e2e-mapping/output-json/PWTP5-output.json | 6 +++++- .../e2e-mapping/output-json/PWTP6-output.json | 12 ++++++++++-- .../e2e-mapping/output-json/PWTP7_vis-output.json | 12 ++++++++++-- .../e2e-mapping/output-json/PWTP9-output.json | 12 ++++++++++-- .../json/LargeMessage/expectedBundleScenario1.json | 12 ++++++++++-- .../json/LargeMessage/expectedBundleScenario10.json | 6 +++++- .../json/LargeMessage/expectedBundleScenario11.json | 6 +++++- .../json/LargeMessage/expectedBundleScenario2.json | 12 ++++++++++-- .../json/LargeMessage/expectedBundleScenario3.json | 12 ++++++++++-- .../json/LargeMessage/expectedBundleScenario4.json | 12 ++++++++++-- .../json/LargeMessage/expectedBundleScenario5.json | 12 ++++++++++-- .../json/LargeMessage/expectedBundleScenario6.json | 6 +++++- .../json/LargeMessage/expectedBundleScenario7.json | 12 ++++++++++-- .../json/LargeMessage/expectedBundleScenario8.json | 12 ++++++++++-- .../json/LargeMessage/expectedBundleScenario9.json | 12 ++++++++++-- .../pss/translator/mapper/AgentDirectoryMapper.java | 10 ++++++---- 21 files changed, 181 insertions(+), 39 deletions(-) diff --git a/gp2gp-translator/src/integrationTest/resources/e2e-mapping/output-json/PWTP10-output.json b/gp2gp-translator/src/integrationTest/resources/e2e-mapping/output-json/PWTP10-output.json index 4d29b0983..6bc3d6829 100644 --- a/gp2gp-translator/src/integrationTest/resources/e2e-mapping/output-json/PWTP10-output.json +++ b/gp2gp-translator/src/integrationTest/resources/e2e-mapping/output-json/PWTP10-output.json @@ -46,7 +46,11 @@ "Dr" ] } - ] + ], + "identifier": [ { + "system": "https://fhir.hl7.org.uk/Id/gmp-number", + "value": "7882315" + } ] } }, { @@ -69,7 +73,11 @@ "Dr" ] } - ] + ], + "identifier": [ { + "system": "https://fhir.hl7.org.uk/Id/gmp-number", + "value": "7889233" + } ] } }, { diff --git a/gp2gp-translator/src/integrationTest/resources/e2e-mapping/output-json/PWTP11-output.json b/gp2gp-translator/src/integrationTest/resources/e2e-mapping/output-json/PWTP11-output.json index 6f1eb0030..74fae42db 100644 --- a/gp2gp-translator/src/integrationTest/resources/e2e-mapping/output-json/PWTP11-output.json +++ b/gp2gp-translator/src/integrationTest/resources/e2e-mapping/output-json/PWTP11-output.json @@ -46,7 +46,11 @@ "Dr" ] } - ] + ], + "identifier": [ { + "system": "https://fhir.hl7.org.uk/Id/gmp-number", + "value": "7889233" + } ] } }, { diff --git a/gp2gp-translator/src/integrationTest/resources/e2e-mapping/output-json/PWTP2-output.json b/gp2gp-translator/src/integrationTest/resources/e2e-mapping/output-json/PWTP2-output.json index 47a59bff4..e36ce90b2 100644 --- a/gp2gp-translator/src/integrationTest/resources/e2e-mapping/output-json/PWTP2-output.json +++ b/gp2gp-translator/src/integrationTest/resources/e2e-mapping/output-json/PWTP2-output.json @@ -46,7 +46,11 @@ "Dr" ] } - ] + ], + "identifier": [ { + "system": "https://fhir.hl7.org.uk/Id/gmp-number", + "value": "7882315" + } ] } }, { @@ -92,7 +96,11 @@ "Dr" ] } - ] + ], + "identifier": [ { + "system": "https://fhir.hl7.org.uk/Id/gmp-number", + "value": "7889233" + } ] } }, { diff --git a/gp2gp-translator/src/integrationTest/resources/e2e-mapping/output-json/PWTP3-output.json b/gp2gp-translator/src/integrationTest/resources/e2e-mapping/output-json/PWTP3-output.json index 2fd4865ed..f308846f0 100644 --- a/gp2gp-translator/src/integrationTest/resources/e2e-mapping/output-json/PWTP3-output.json +++ b/gp2gp-translator/src/integrationTest/resources/e2e-mapping/output-json/PWTP3-output.json @@ -46,7 +46,11 @@ "Dr" ] } - ] + ], + "identifier": [ { + "system": "https://fhir.hl7.org.uk/Id/gmp-number", + "value": "7882315" + } ] } }, { @@ -69,7 +73,11 @@ "Dr" ] } - ] + ], + "identifier": [ { + "system": "https://fhir.hl7.org.uk/Id/gmp-number", + "value": "7889233" + } ] } }, { diff --git a/gp2gp-translator/src/integrationTest/resources/e2e-mapping/output-json/PWTP4-output.json b/gp2gp-translator/src/integrationTest/resources/e2e-mapping/output-json/PWTP4-output.json index dbb57f69a..081e8157f 100644 --- a/gp2gp-translator/src/integrationTest/resources/e2e-mapping/output-json/PWTP4-output.json +++ b/gp2gp-translator/src/integrationTest/resources/e2e-mapping/output-json/PWTP4-output.json @@ -63,7 +63,11 @@ "Dr" ] } - ] + ], + "identifier": [ { + "system": "https://fhir.hl7.org.uk/Id/gmp-number", + "value": "7882315" + } ] } }, { @@ -132,7 +136,11 @@ "Dr" ] } - ] + ], + "identifier": [ { + "system": "https://fhir.hl7.org.uk/Id/gmp-number", + "value": "7889233" + } ] } }, { diff --git a/gp2gp-translator/src/integrationTest/resources/e2e-mapping/output-json/PWTP5-output.json b/gp2gp-translator/src/integrationTest/resources/e2e-mapping/output-json/PWTP5-output.json index 7fc435bba..6d17c9e30 100644 --- a/gp2gp-translator/src/integrationTest/resources/e2e-mapping/output-json/PWTP5-output.json +++ b/gp2gp-translator/src/integrationTest/resources/e2e-mapping/output-json/PWTP5-output.json @@ -46,7 +46,11 @@ "Dr" ] } - ] + ], + "identifier": [ { + "system": "https://fhir.hl7.org.uk/Id/gmp-number", + "value": "7889233" + } ] } }, { diff --git a/gp2gp-translator/src/integrationTest/resources/e2e-mapping/output-json/PWTP6-output.json b/gp2gp-translator/src/integrationTest/resources/e2e-mapping/output-json/PWTP6-output.json index e725485d5..0cf6a371d 100644 --- a/gp2gp-translator/src/integrationTest/resources/e2e-mapping/output-json/PWTP6-output.json +++ b/gp2gp-translator/src/integrationTest/resources/e2e-mapping/output-json/PWTP6-output.json @@ -46,7 +46,11 @@ "Dr" ] } - ] + ], + "identifier": [ { + "system": "https://fhir.hl7.org.uk/Id/gmp-number", + "value": "7882315" + } ] } }, { @@ -69,7 +73,11 @@ "Dr" ] } - ] + ], + "identifier": [ { + "system": "https://fhir.hl7.org.uk/Id/gmp-number", + "value": "7889233" + } ] } }, { diff --git a/gp2gp-translator/src/integrationTest/resources/e2e-mapping/output-json/PWTP7_vis-output.json b/gp2gp-translator/src/integrationTest/resources/e2e-mapping/output-json/PWTP7_vis-output.json index 579293be0..5fd26b144 100644 --- a/gp2gp-translator/src/integrationTest/resources/e2e-mapping/output-json/PWTP7_vis-output.json +++ b/gp2gp-translator/src/integrationTest/resources/e2e-mapping/output-json/PWTP7_vis-output.json @@ -63,7 +63,11 @@ "Dr" ] } - ] + ], + "identifier": [ { + "system": "https://fhir.hl7.org.uk/Id/gmp-number", + "value": "7882315" + } ] } }, { @@ -86,7 +90,11 @@ "Dr" ] } - ] + ], + "identifier": [ { + "system": "https://fhir.hl7.org.uk/Id/gmp-number", + "value": "7889233" + } ] } }, { diff --git a/gp2gp-translator/src/integrationTest/resources/e2e-mapping/output-json/PWTP9-output.json b/gp2gp-translator/src/integrationTest/resources/e2e-mapping/output-json/PWTP9-output.json index c84152655..4c0400ffc 100644 --- a/gp2gp-translator/src/integrationTest/resources/e2e-mapping/output-json/PWTP9-output.json +++ b/gp2gp-translator/src/integrationTest/resources/e2e-mapping/output-json/PWTP9-output.json @@ -46,7 +46,11 @@ "Dr" ] } - ] + ], + "identifier": [ { + "system": "https://fhir.hl7.org.uk/Id/gmp-number", + "value": "7882315" + } ] } }, { @@ -92,7 +96,11 @@ "Dr" ] } - ] + ], + "identifier": [ { + "system": "https://fhir.hl7.org.uk/Id/gmp-number", + "value": "7889233" + } ] } }, { diff --git a/gp2gp-translator/src/integrationTest/resources/json/LargeMessage/expectedBundleScenario1.json b/gp2gp-translator/src/integrationTest/resources/json/LargeMessage/expectedBundleScenario1.json index 5a02d0df8..3aae5dc3f 100644 --- a/gp2gp-translator/src/integrationTest/resources/json/LargeMessage/expectedBundleScenario1.json +++ b/gp2gp-translator/src/integrationTest/resources/json/LargeMessage/expectedBundleScenario1.json @@ -97,7 +97,11 @@ "Dr" ] } - ] + ], + "identifier": [ { + "system": "https://fhir.hl7.org.uk/Id/gmp-number", + "value": "G2141239" + } ] } }, { @@ -210,7 +214,11 @@ "Dr" ] } - ] + ], + "identifier": [ { + "system": "https://fhir.hl7.org.uk/Id/gmp-number", + "value": "G9489493" + } ] } }, { diff --git a/gp2gp-translator/src/integrationTest/resources/json/LargeMessage/expectedBundleScenario10.json b/gp2gp-translator/src/integrationTest/resources/json/LargeMessage/expectedBundleScenario10.json index 8c1abafca..5a9c67aa3 100644 --- a/gp2gp-translator/src/integrationTest/resources/json/LargeMessage/expectedBundleScenario10.json +++ b/gp2gp-translator/src/integrationTest/resources/json/LargeMessage/expectedBundleScenario10.json @@ -92,7 +92,11 @@ "Dr" ] } - ] + ], + "identifier": [ { + "system": "https://fhir.hl7.org.uk/Id/gmp-number", + "value": "12345" + } ] } }, { diff --git a/gp2gp-translator/src/integrationTest/resources/json/LargeMessage/expectedBundleScenario11.json b/gp2gp-translator/src/integrationTest/resources/json/LargeMessage/expectedBundleScenario11.json index 54e76e346..d737f7b67 100644 --- a/gp2gp-translator/src/integrationTest/resources/json/LargeMessage/expectedBundleScenario11.json +++ b/gp2gp-translator/src/integrationTest/resources/json/LargeMessage/expectedBundleScenario11.json @@ -92,7 +92,11 @@ "Dr" ] } - ] + ], + "identifier": [ { + "system": "https://fhir.hl7.org.uk/Id/gmp-number", + "value": "12345" + } ] } }, { diff --git a/gp2gp-translator/src/integrationTest/resources/json/LargeMessage/expectedBundleScenario2.json b/gp2gp-translator/src/integrationTest/resources/json/LargeMessage/expectedBundleScenario2.json index a7e879cc8..9173b8720 100644 --- a/gp2gp-translator/src/integrationTest/resources/json/LargeMessage/expectedBundleScenario2.json +++ b/gp2gp-translator/src/integrationTest/resources/json/LargeMessage/expectedBundleScenario2.json @@ -97,7 +97,11 @@ "Dr" ] } - ] + ], + "identifier": [ { + "system": "https://fhir.hl7.org.uk/Id/gmp-number", + "value": "G2141239" + } ] } }, { @@ -210,7 +214,11 @@ "Dr" ] } - ] + ], + "identifier": [ { + "system": "https://fhir.hl7.org.uk/Id/gmp-number", + "value": "G9489493" + } ] } }, { diff --git a/gp2gp-translator/src/integrationTest/resources/json/LargeMessage/expectedBundleScenario3.json b/gp2gp-translator/src/integrationTest/resources/json/LargeMessage/expectedBundleScenario3.json index 335358d9c..b41b9520b 100644 --- a/gp2gp-translator/src/integrationTest/resources/json/LargeMessage/expectedBundleScenario3.json +++ b/gp2gp-translator/src/integrationTest/resources/json/LargeMessage/expectedBundleScenario3.json @@ -97,7 +97,11 @@ "Dr" ] } - ] + ], + "identifier": [ { + "system": "https://fhir.hl7.org.uk/Id/gmp-number", + "value": "G2141239" + } ] } }, { @@ -210,7 +214,11 @@ "Dr" ] } - ] + ], + "identifier": [ { + "system": "https://fhir.hl7.org.uk/Id/gmp-number", + "value": "G9489493" + } ] } }, { diff --git a/gp2gp-translator/src/integrationTest/resources/json/LargeMessage/expectedBundleScenario4.json b/gp2gp-translator/src/integrationTest/resources/json/LargeMessage/expectedBundleScenario4.json index cbc21cb77..da30d93ae 100644 --- a/gp2gp-translator/src/integrationTest/resources/json/LargeMessage/expectedBundleScenario4.json +++ b/gp2gp-translator/src/integrationTest/resources/json/LargeMessage/expectedBundleScenario4.json @@ -97,7 +97,11 @@ "Dr" ] } - ] + ], + "identifier": [ { + "system": "https://fhir.hl7.org.uk/Id/gmp-number", + "value": "G2141239" + } ] } }, { @@ -210,7 +214,11 @@ "Dr" ] } - ] + ], + "identifier": [ { + "system": "https://fhir.hl7.org.uk/Id/gmp-number", + "value": "G9489493" + } ] } }, { diff --git a/gp2gp-translator/src/integrationTest/resources/json/LargeMessage/expectedBundleScenario5.json b/gp2gp-translator/src/integrationTest/resources/json/LargeMessage/expectedBundleScenario5.json index 5e789e6f1..8a5d1f538 100644 --- a/gp2gp-translator/src/integrationTest/resources/json/LargeMessage/expectedBundleScenario5.json +++ b/gp2gp-translator/src/integrationTest/resources/json/LargeMessage/expectedBundleScenario5.json @@ -97,7 +97,11 @@ "Dr" ] } - ] + ], + "identifier": [ { + "system": "https://fhir.hl7.org.uk/Id/gmp-number", + "value": "G2141239" + } ] } }, { @@ -210,7 +214,11 @@ "Dr" ] } - ] + ], + "identifier": [ { + "system": "https://fhir.hl7.org.uk/Id/gmp-number", + "value": "G9489493" + } ] } }, { diff --git a/gp2gp-translator/src/integrationTest/resources/json/LargeMessage/expectedBundleScenario6.json b/gp2gp-translator/src/integrationTest/resources/json/LargeMessage/expectedBundleScenario6.json index 7aa1beeb1..a2d119d86 100644 --- a/gp2gp-translator/src/integrationTest/resources/json/LargeMessage/expectedBundleScenario6.json +++ b/gp2gp-translator/src/integrationTest/resources/json/LargeMessage/expectedBundleScenario6.json @@ -96,7 +96,11 @@ "Dr" ] } - ] + ], + "identifier": [ { + "system": "https://fhir.hl7.org.uk/Id/gmp-number", + "value": "G7777781" + } ] } }, { diff --git a/gp2gp-translator/src/integrationTest/resources/json/LargeMessage/expectedBundleScenario7.json b/gp2gp-translator/src/integrationTest/resources/json/LargeMessage/expectedBundleScenario7.json index 11e67d059..3475b7832 100644 --- a/gp2gp-translator/src/integrationTest/resources/json/LargeMessage/expectedBundleScenario7.json +++ b/gp2gp-translator/src/integrationTest/resources/json/LargeMessage/expectedBundleScenario7.json @@ -97,7 +97,11 @@ "Dr" ] } - ] + ], + "identifier": [ { + "system": "https://fhir.hl7.org.uk/Id/gmp-number", + "value": "G2141239" + } ] } }, { @@ -210,7 +214,11 @@ "Dr" ] } - ] + ], + "identifier": [ { + "system": "https://fhir.hl7.org.uk/Id/gmp-number", + "value": "G9489493" + } ] } }, { diff --git a/gp2gp-translator/src/integrationTest/resources/json/LargeMessage/expectedBundleScenario8.json b/gp2gp-translator/src/integrationTest/resources/json/LargeMessage/expectedBundleScenario8.json index e0998d6d2..b061b8d96 100644 --- a/gp2gp-translator/src/integrationTest/resources/json/LargeMessage/expectedBundleScenario8.json +++ b/gp2gp-translator/src/integrationTest/resources/json/LargeMessage/expectedBundleScenario8.json @@ -97,7 +97,11 @@ "Dr" ] } - ] + ], + "identifier": [ { + "system": "https://fhir.hl7.org.uk/Id/gmp-number", + "value": "G2141239" + } ] } }, { @@ -210,7 +214,11 @@ "Dr" ] } - ] + ], + "identifier": [ { + "system": "https://fhir.hl7.org.uk/Id/gmp-number", + "value": "G9489493" + } ] } }, { diff --git a/gp2gp-translator/src/integrationTest/resources/json/LargeMessage/expectedBundleScenario9.json b/gp2gp-translator/src/integrationTest/resources/json/LargeMessage/expectedBundleScenario9.json index ff7556965..c05d25489 100644 --- a/gp2gp-translator/src/integrationTest/resources/json/LargeMessage/expectedBundleScenario9.json +++ b/gp2gp-translator/src/integrationTest/resources/json/LargeMessage/expectedBundleScenario9.json @@ -97,7 +97,11 @@ "Dr" ] } - ] + ], + "identifier": [ { + "system": "https://fhir.hl7.org.uk/Id/gmp-number", + "value": "G2141239" + } ] } }, { @@ -210,7 +214,11 @@ "Dr" ] } - ] + ], + "identifier": [ { + "system": "https://fhir.hl7.org.uk/Id/gmp-number", + "value": "G9489493" + } ] } }, { diff --git a/gp2gp-translator/src/main/java/uk/nhs/adaptors/pss/translator/mapper/AgentDirectoryMapper.java b/gp2gp-translator/src/main/java/uk/nhs/adaptors/pss/translator/mapper/AgentDirectoryMapper.java index ae18124a5..c1972d758 100644 --- a/gp2gp-translator/src/main/java/uk/nhs/adaptors/pss/translator/mapper/AgentDirectoryMapper.java +++ b/gp2gp-translator/src/main/java/uk/nhs/adaptors/pss/translator/mapper/AgentDirectoryMapper.java @@ -99,10 +99,12 @@ private Practitioner createPractitioner(RCCTMT120101UK01Person agentPerson, Stri practitioner.setMeta(generateMeta(PRACT_META_PROFILE)); practitioner.setName(getPractitionerName(agentPerson.getName())); - Identifier identifier = new Identifier() - .setSystem("https://fhir.hl7.org.uk/Id/gmp-number") - .setValue(gpNumber); - practitioner.setIdentifier(List.of(identifier)); + if (gpNumber != null && !"".equals(gpNumber)) { + Identifier identifier = new Identifier() + .setSystem("https://fhir.hl7.org.uk/Id/gmp-number") + .setValue(gpNumber); + practitioner.setIdentifier(List.of(identifier)); + } return practitioner; } From 52c4de5bb54285947a4bcb180bbb564cf8d1a861 Mon Sep 17 00:00:00 2001 From: hospel Date: Tue, 14 Nov 2023 10:23:57 +0000 Subject: [PATCH 4/4] empty or null string check optimization --- .../adaptors/pss/translator/mapper/AgentDirectoryMapper.java | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/gp2gp-translator/src/main/java/uk/nhs/adaptors/pss/translator/mapper/AgentDirectoryMapper.java b/gp2gp-translator/src/main/java/uk/nhs/adaptors/pss/translator/mapper/AgentDirectoryMapper.java index c1972d758..31ffcecb9 100644 --- a/gp2gp-translator/src/main/java/uk/nhs/adaptors/pss/translator/mapper/AgentDirectoryMapper.java +++ b/gp2gp-translator/src/main/java/uk/nhs/adaptors/pss/translator/mapper/AgentDirectoryMapper.java @@ -1,5 +1,6 @@ package uk.nhs.adaptors.pss.translator.mapper; +import static org.apache.logging.log4j.util.Strings.isNotEmpty; import static uk.nhs.adaptors.pss.translator.util.OrganizationUtil.findDuplicateOrganisation; import static uk.nhs.adaptors.pss.translator.util.ResourceUtil.generateMeta; @@ -99,7 +100,7 @@ private Practitioner createPractitioner(RCCTMT120101UK01Person agentPerson, Stri practitioner.setMeta(generateMeta(PRACT_META_PROFILE)); practitioner.setName(getPractitionerName(agentPerson.getName())); - if (gpNumber != null && !"".equals(gpNumber)) { + if (isNotEmpty(gpNumber)) { Identifier identifier = new Identifier() .setSystem("https://fhir.hl7.org.uk/Id/gmp-number") .setValue(gpNumber);