From ae07902e66cd90ab568d87a65d39792cf3661790 Mon Sep 17 00:00:00 2001 From: hospel Date: Tue, 14 Nov 2023 15:43:16 +0000 Subject: [PATCH] NIAD-2772: adding identifier block to practitioner section (#371) * adding identifier to practitioner section * small test optimizations * fixing integration tests * empty or null string check optimization --- .../output-json/PWTP10-output.json | 12 +- .../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 +- .../output-json/PWTP7_vis-output.json | 12 +- .../e2e-mapping/output-json/PWTP9-output.json | 12 +- .../LargeMessage/expectedBundleScenario1.json | 12 +- .../expectedBundleScenario10.json | 6 +- .../expectedBundleScenario11.json | 6 +- .../LargeMessage/expectedBundleScenario2.json | 12 +- .../LargeMessage/expectedBundleScenario3.json | 12 +- .../LargeMessage/expectedBundleScenario4.json | 12 +- .../LargeMessage/expectedBundleScenario5.json | 12 +- .../LargeMessage/expectedBundleScenario6.json | 6 +- .../LargeMessage/expectedBundleScenario7.json | 12 +- .../LargeMessage/expectedBundleScenario8.json | 12 +- .../LargeMessage/expectedBundleScenario9.json | 12 +- .../mapper/AgentDirectoryMapper.java | 15 +- .../mapper/AgentDirectoryMapperTest.java | 225 ++++++++++-------- ...t_org_with_general_practitioner_number.xml | 19 ++ 23 files changed, 326 insertions(+), 143 deletions(-) create mode 100644 gp2gp-translator/src/test/resources/xml/AgentDirectory/agent_org_with_general_practitioner_number.xml 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 06dafaeeb..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; @@ -71,9 +72,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 +87,26 @@ 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())); + if (isNotEmpty(gpNumber)) { + 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..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 @@ -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 @@ -134,15 +149,15 @@ public void mapAgentDirectoryOnlyAgentPersonNoOptionalFields() { 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"); - 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 @@ -151,15 +166,15 @@ 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"); 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 @@ -168,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"); @@ -185,15 +200,15 @@ 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"); 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 @@ -202,15 +217,15 @@ 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"); 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