diff --git a/src/main/java/net/ihe/gazelle/adapter/connector/BusinessToFhirConverter.java b/src/main/java/net/ihe/gazelle/adapter/connector/BusinessToFhirConverter.java index e84cba28e4e81437cfcebb7945854e97086ccc71..f52e02fe96cdce755b3f04d306d62c6b1e4f5783 100644 --- a/src/main/java/net/ihe/gazelle/adapter/connector/BusinessToFhirConverter.java +++ b/src/main/java/net/ihe/gazelle/adapter/connector/BusinessToFhirConverter.java @@ -3,8 +3,19 @@ package net.ihe.gazelle.adapter.connector; import java.util.List; import org.hl7.fhir.exceptions.FHIRException; +import org.hl7.fhir.r4.model.Bundle; +import org.hl7.fhir.r4.model.Bundle.BundleEntryComponent; +import org.hl7.fhir.r4.model.Bundle.BundleType; import org.hl7.fhir.r4.model.Enumerations; import org.hl7.fhir.r4.model.HumanName; +import org.hl7.fhir.r4.model.MessageHeader; +import org.hl7.fhir.r4.model.MessageHeader.MessageDestinationComponent; +import org.hl7.fhir.r4.model.MessageHeader.MessageHeaderResponseComponent; +import org.hl7.fhir.r4.model.MessageHeader.MessageSourceComponent; +import org.hl7.fhir.r4.model.MessageHeader.ResponseType; +import org.hl7.fhir.r4.model.Meta; +import org.hl7.fhir.r4.model.Narrative; +import org.hl7.fhir.r4.model.Narrative.NarrativeStatus; import net.ihe.gazelle.app.patientregistryapi.business.Address; import net.ihe.gazelle.app.patientregistryapi.business.AddressUse; @@ -30,6 +41,39 @@ public class BusinessToFhirConverter { */ private BusinessToFhirConverter() { } + public static Bundle uuidToBundle(String uuid) { + + Bundle response = new Bundle(); + response.setId("BundlePIXmResponse"); + Meta metadata = new Meta(); + metadata.addProfile("http://fhir.ch/ig/ch-epr-mhealth/StructureDefinition/ch-pixm-bundle-response"); + response.setType(BundleType.MESSAGE); + BundleEntryComponent entry = new BundleEntryComponent(); + entry.setFullUrl("http://localhost:8081/pixm_fhir_server/fhir_ch/Patient" + uuid); + MessageHeader messageHeader = new MessageHeader(); + messageHeader.setId(uuid); + Narrative narrative = new Narrative(); + narrative.setStatus(NarrativeStatus.GENERATED); + //narrative.setDiv() + messageHeader.setText(narrative); + MessageDestinationComponent mdc = new MessageDestinationComponent(); + mdc.setEndpoint("http://localhost:8081/pixm_fhir_server/fhir_ch/Patient" + uuid); + messageHeader.addDestination(mdc); + MessageSourceComponent msc = new MessageSourceComponent(); + msc.setEndpoint("http://localhost:8081/pixm_fhir_server/fhir_ch/Patient" + uuid); + messageHeader.setSource(msc); + MessageHeaderResponseComponent mhrc = new MessageHeaderResponseComponent(); + mhrc.setIdentifier(uuid); + mhrc.setCode(ResponseType.OK); + messageHeader.setResponse(mhrc); + entry.setResource(messageHeader); + response.addEntry(entry); + response.setMeta(metadata); + + return response; + + } + public static org.hl7.fhir.r4.model.Patient patientToFhirPatient(Patient patient) throws ConversionException { org.hl7.fhir.r4.model.Patient fhirPatient = new org.hl7.fhir.r4.model.Patient(); fhirPatient.setId(patient.getUuid()); @@ -45,26 +89,26 @@ public class BusinessToFhirConverter { } private static void setNames(org.hl7.fhir.r4.model.Patient fhirPatient, Patient patient) throws ConversionException { - List<PersonName> patientNames = patient.getNames(); - if (patientNames != null) { - for (PersonName personName : patientNames) { - if (personName != null) { - HumanName name = new HumanName(); - name.setFamily(personName.getFamily()); - for (String given : personName.getGivens()) { - name.addGiven(given); - } - try { - name.setUse(HumanName.NameUse.fromCode(personName.getUse())); - } catch (FHIRException e) { - throw new ConversionException(String.format("Cannot convert PersonName use : %s", personName.getUse()), e); - } - name.addPrefix(personName.getPrefix()); - name.addSuffix(personName.getSuffix()); - fhirPatient.addName(name); - } - } - } + List<PersonName> patientNames = patient.getNames(); + if (patientNames != null) { + for (PersonName personName : patientNames) { + if (personName != null) { + HumanName name = new HumanName(); + name.setFamily(personName.getFamily()); + for (String given : personName.getGivens()) { + name.addGiven(given); + } + try { + name.setUse(HumanName.NameUse.fromCode(personName.getUse())); + } catch (FHIRException e) { + throw new ConversionException(String.format("Cannot convert PersonName use : %s", personName.getUse()), e); + } + name.addPrefix(personName.getPrefix()); + name.addSuffix(personName.getSuffix()); + fhirPatient.addName(name); + } + } + } } private static Enumerations.AdministrativeGender getGenderCode(Patient patient) throws ConversionException { @@ -87,20 +131,20 @@ public class BusinessToFhirConverter { } private static void setCrossIdentifier(org.hl7.fhir.r4.model.Patient fhirPatient, Patient patient) { - if (patient.getIdentifiers() != null) { - for (EntityIdentifier currentPatientIdentifier : patient.getIdentifiers()) { - if (currentPatientIdentifier.getSystemIdentifier() != null) { - String fhirSystem = getUniversalIDAsUrn(currentPatientIdentifier.getSystemIdentifier()); - fhirPatient.addIdentifier().setSystem(fhirSystem).setValue(currentPatientIdentifier.getValue()); - } - } - } + if (patient.getIdentifiers() != null) { + for (EntityIdentifier currentPatientIdentifier : patient.getIdentifiers()) { + if (currentPatientIdentifier.getSystemIdentifier() != null) { + String fhirSystem = getUniversalIDAsUrn(currentPatientIdentifier.getSystemIdentifier()); + fhirPatient.addIdentifier().setSystem(fhirSystem).setValue(currentPatientIdentifier.getValue()); + } + } + } } private static void setBirthDate(org.hl7.fhir.r4.model.Patient fhirPatient, Patient patient) { - if (patient.getDateOfBirth() != null) { - fhirPatient.setBirthDate(patient.getDateOfBirth()); - } + if (patient.getDateOfBirth() != null) { + fhirPatient.setBirthDate(patient.getDateOfBirth()); + } } private static void setAddresses(org.hl7.fhir.r4.model.Patient fhirPatient, Patient patient) throws ConversionException { @@ -135,81 +179,81 @@ public class BusinessToFhirConverter { } } } - - private static String getUniversalIDAsUrn(String universalID) { - if (universalID == null) { - return null; - } else if (universalID.startsWith(URN_PREFIX)) { - return universalID; - } else { - return URN_PREFIX + universalID; - } - } - - private static org.hl7.fhir.r4.model.Address.AddressUse getAddressUse(AddressUse addressUse) throws ConversionException { - if (addressUse != null) { - switch (addressUse) { - case HOME: - case PRIMARY_HOME: - return org.hl7.fhir.r4.model.Address.AddressUse.HOME; - case WORK: - return org.hl7.fhir.r4.model.Address.AddressUse.WORK; - case VACATION_HOME: - case TEMPORARY: - return org.hl7.fhir.r4.model.Address.AddressUse.TEMP; - case BAD: - return org.hl7.fhir.r4.model.Address.AddressUse.OLD; - case BILLING: - return org.hl7.fhir.r4.model.Address.AddressUse.BILLING; - default: - throw new ConversionException(String.format("Cannot map AddressUse : %s", addressUse)); - } - } - return null; - } - - private static org.hl7.fhir.r4.model.ContactPoint.ContactPointUse getContactPointUse(ContactPointUse contactPointUse) { - if (contactPointUse != null) { - switch (contactPointUse) { - case HOME: - case PRIMARY_HOME: - return org.hl7.fhir.r4.model.ContactPoint.ContactPointUse.HOME; - case MOBILE: - return org.hl7.fhir.r4.model.ContactPoint.ContactPointUse.MOBILE; - case WORK: - return org.hl7.fhir.r4.model.ContactPoint.ContactPointUse.WORK; - case TEMPORARY: - return org.hl7.fhir.r4.model.ContactPoint.ContactPointUse.TEMP; - default: - return null; - } - } - return null; - } - - private static org.hl7.fhir.r4.model.ContactPoint.ContactPointSystem getContactPointSystem(ContactPointType contactPointType) - throws ConversionException { - if (contactPointType != null) { - switch (contactPointType) { - case BEEPER: - return org.hl7.fhir.r4.model.ContactPoint.ContactPointSystem.PAGER; - case PHONE: - return org.hl7.fhir.r4.model.ContactPoint.ContactPointSystem.PHONE; - case FAX: - return org.hl7.fhir.r4.model.ContactPoint.ContactPointSystem.FAX; - case URL: - return org.hl7.fhir.r4.model.ContactPoint.ContactPointSystem.URL; - case EMAIL: - return org.hl7.fhir.r4.model.ContactPoint.ContactPointSystem.EMAIL; - case SMS: - return org.hl7.fhir.r4.model.ContactPoint.ContactPointSystem.SMS; - case OTHER: - return org.hl7.fhir.r4.model.ContactPoint.ContactPointSystem.OTHER; - default: - throw new ConversionException(String.format("Cannot map ContactPointType : %s", contactPointType)); - } - } - return null; - } + + private static String getUniversalIDAsUrn(String universalID) { + if (universalID == null) { + return null; + } else if (universalID.startsWith(URN_PREFIX)) { + return universalID; + } else { + return URN_PREFIX + universalID; + } + } + + private static org.hl7.fhir.r4.model.Address.AddressUse getAddressUse(AddressUse addressUse) throws ConversionException { + if (addressUse != null) { + switch (addressUse) { + case HOME: + case PRIMARY_HOME: + return org.hl7.fhir.r4.model.Address.AddressUse.HOME; + case WORK: + return org.hl7.fhir.r4.model.Address.AddressUse.WORK; + case VACATION_HOME: + case TEMPORARY: + return org.hl7.fhir.r4.model.Address.AddressUse.TEMP; + case BAD: + return org.hl7.fhir.r4.model.Address.AddressUse.OLD; + case BILLING: + return org.hl7.fhir.r4.model.Address.AddressUse.BILLING; + default: + throw new ConversionException(String.format("Cannot map AddressUse : %s", addressUse)); + } + } + return null; + } + + private static org.hl7.fhir.r4.model.ContactPoint.ContactPointUse getContactPointUse(ContactPointUse contactPointUse) { + if (contactPointUse != null) { + switch (contactPointUse) { + case HOME: + case PRIMARY_HOME: + return org.hl7.fhir.r4.model.ContactPoint.ContactPointUse.HOME; + case MOBILE: + return org.hl7.fhir.r4.model.ContactPoint.ContactPointUse.MOBILE; + case WORK: + return org.hl7.fhir.r4.model.ContactPoint.ContactPointUse.WORK; + case TEMPORARY: + return org.hl7.fhir.r4.model.ContactPoint.ContactPointUse.TEMP; + default: + return null; + } + } + return null; + } + + private static org.hl7.fhir.r4.model.ContactPoint.ContactPointSystem getContactPointSystem(ContactPointType contactPointType) + throws ConversionException { + if (contactPointType != null) { + switch (contactPointType) { + case BEEPER: + return org.hl7.fhir.r4.model.ContactPoint.ContactPointSystem.PAGER; + case PHONE: + return org.hl7.fhir.r4.model.ContactPoint.ContactPointSystem.PHONE; + case FAX: + return org.hl7.fhir.r4.model.ContactPoint.ContactPointSystem.FAX; + case URL: + return org.hl7.fhir.r4.model.ContactPoint.ContactPointSystem.URL; + case EMAIL: + return org.hl7.fhir.r4.model.ContactPoint.ContactPointSystem.EMAIL; + case SMS: + return org.hl7.fhir.r4.model.ContactPoint.ContactPointSystem.SMS; + case OTHER: + return org.hl7.fhir.r4.model.ContactPoint.ContactPointSystem.OTHER; + default: + throw new ConversionException(String.format("Cannot map ContactPointType : %s", contactPointType)); + } + } + return null; + } } diff --git a/src/main/java/net/ihe/gazelle/business/provider/ChPatientResourceProvider.java b/src/main/java/net/ihe/gazelle/business/provider/ChPatientResourceProvider.java index 64973caa1edf2a9bc6c5bf896cfde02f51600a3e..d7a9c6a92cf252656ff7ae1e47b434773239ecab 100644 --- a/src/main/java/net/ihe/gazelle/business/provider/ChPatientResourceProvider.java +++ b/src/main/java/net/ihe/gazelle/business/provider/ChPatientResourceProvider.java @@ -30,8 +30,8 @@ import ca.uhn.fhir.rest.server.exceptions.InternalErrorException; import ca.uhn.fhir.rest.server.exceptions.InvalidRequestException; import ca.uhn.fhir.rest.server.exceptions.ResourceNotFoundException; import net.ihe.gazelle.adapter.connector.BundleToPatientRegistryConverter; +import net.ihe.gazelle.adapter.connector.BusinessToFhirConverter; import net.ihe.gazelle.adapter.connector.ConversionException; -import net.ihe.gazelle.app.patientregistryapi.application.PatientFeedException; import net.ihe.gazelle.app.patientregistryapi.application.SearchCrossReferenceException; import net.ihe.gazelle.app.patientregistryapi.business.EntityIdentifier; import net.ihe.gazelle.application.PatientRegistryFeedClient; @@ -65,7 +65,7 @@ public class ChPatientResourceProvider implements IResourceProvider { @Inject private PatientRegistrySearchClient patientRegistrySearchClient; - + @Inject private PatientRegistryFeedClient patientRegistryCreateClient; @@ -76,7 +76,7 @@ public class ChPatientResourceProvider implements IResourceProvider { public ChPatientResourceProvider(PatientRegistryXRefSearchClient client) { this.patientRegistryXRefSearchClient = client; } - + @Package public ChPatientResourceProvider(PatientRegistryFeedClient client) { this.patientRegistryCreateClient = client; @@ -113,26 +113,26 @@ public class ChPatientResourceProvider implements IResourceProvider { } } - + /** * Method called to create a Patient * @param iti93Bundle * @return */ @Create - public Patient create(@ResourceParam Bundle iti93Bundle) { + public Bundle create(@ResourceParam Bundle iti93Bundle) { if (iti93Bundle == null || iti93Bundle.getEntry().isEmpty()) { patientLogger.error(NO_BUNDLE_PROVIDED); throw new InvalidRequestException(NO_BUNDLE_PROVIDED); } - + try { net.ihe.gazelle.app.patientregistryapi.business.Patient patient = BundleToPatientRegistryConverter.iti93BundleToPatient(iti93Bundle); - //return patientRegistryCreateClient.createPatient(patient); - + return BusinessToFhirConverter.uuidToBundle(patientRegistryCreateClient.createPatient(patient)); + } catch (ConversionException e) { throw new InvalidRequestException("Bundle Could not be converted to HL7 Patient"); - } /* catch (PatientFeedException e) { + } catch (PatientFeedException e) { switch (e.getMessage()) { case "Error feeding patient !": break; @@ -144,7 +144,7 @@ public class ChPatientResourceProvider implements IResourceProvider { break; default: } - } */ + } return null; } diff --git a/src/test/java/net/ihe/gazelle/application/PatientFeedApplicationMock.java b/src/test/java/net/ihe/gazelle/application/PatientFeedApplicationMock.java deleted file mode 100644 index 3e67600b8c3a4d576f137880f49abfd087a0b764..0000000000000000000000000000000000000000 --- a/src/test/java/net/ihe/gazelle/application/PatientFeedApplicationMock.java +++ /dev/null @@ -1,27 +0,0 @@ -package net.ihe.gazelle.application; - -import net.ihe.gazelle.app.patientregistryapi.business.Patient; -import net.ihe.gazelle.app.patientregistryservice.application.PatientFeedApplication; -import net.ihe.gazelle.app.patientregistryservice.application.dao.DomainDAO; -import net.ihe.gazelle.app.patientregistryservice.application.dao.IdentifierDAO; -import net.ihe.gazelle.app.patientregistryservice.application.dao.PatientCrossReferenceDAO; -import net.ihe.gazelle.app.patientregistryservice.application.dao.PatientDAO; - -public class PatientFeedApplicationMock extends PatientFeedApplication{ - - public PatientFeedApplicationMock(PatientDAO patientDAO, - DomainDAO domainDAO, - PatientCrossReferenceDAO patientCrossReferenceDAO, - IdentifierDAO identifierDAO) { - - super(patientDAO, domainDAO, patientCrossReferenceDAO, identifierDAO); - } - - @Override - public String createPatient(Patient patient) { - - return null; - - } - -} diff --git a/src/test/java/net/ihe/gazelle/application/PatientFeedClientMock.java b/src/test/java/net/ihe/gazelle/application/PatientFeedClientMock.java new file mode 100644 index 0000000000000000000000000000000000000000..c4f5812e248a539c979ae5c2a75d52160427a2df --- /dev/null +++ b/src/test/java/net/ihe/gazelle/application/PatientFeedClientMock.java @@ -0,0 +1,21 @@ +package net.ihe.gazelle.application; + +import com.gitb.ps.ProcessingService; + +import net.ihe.gazelle.app.patientregistryapi.business.Patient; +import net.ihe.gazelle.app.patientregistryfeedclient.adapter.PatientFeedClient; + +public class PatientFeedClientMock extends PatientFeedClient{ + + public PatientFeedClientMock(ProcessingService processingService) { + super(processingService); + } + + @Override + public String createPatient(Patient patient) { + + return null; + + } + +} diff --git a/src/test/java/net/ihe/gazelle/application/PatientFeedClientTest.java b/src/test/java/net/ihe/gazelle/application/PatientFeedClientTest.java index 070c46f874c768e80c24ddf1069bb1ca5e58365f..14efe91a600a934b6ebec727fb54bf2ed95b7f83 100644 --- a/src/test/java/net/ihe/gazelle/application/PatientFeedClientTest.java +++ b/src/test/java/net/ihe/gazelle/application/PatientFeedClientTest.java @@ -26,8 +26,8 @@ import net.ihe.gazelle.app.patientregistryapi.application.PatientFeedException; import net.ihe.gazelle.app.patientregistryapi.business.GenderCode; import net.ihe.gazelle.app.patientregistryapi.business.Patient; import net.ihe.gazelle.app.patientregistryapi.business.PersonName; -import net.ihe.gazelle.app.patientregistryservice.application.PatientFeedApplication; -import net.ihe.gazelle.app.patientregistryservice.application.exceptions.PatientCreationException; +import net.ihe.gazelle.app.patientregistryfeedclient.adapter.PatientFeedClient; +import net.ihe.gazelle.app.patientregistryfeedclient.adapter.PatientFeedProcessResponseException; import net.ihe.gazelle.framework.preferencesmodelapi.application.NamespaceException; import net.ihe.gazelle.framework.preferencesmodelapi.application.PreferenceException; @@ -38,13 +38,13 @@ public class PatientFeedClientTest { private static final String MALFORMED_UUID = "123e4567-e89b-12d3-a456-42661417400000000000000000000000000"; @Mock - static private PatientFeedApplication patientFeedApplicationMock; + static private PatientFeedClient patientFeedClientMock; @Mock private PatientRegistryFeedClient patientRegistryFeedClient; @BeforeAll static void initialize() { - patientFeedApplicationMock = Mockito.mock(PatientFeedApplication.class); + patientFeedClientMock = Mockito.mock(PatientFeedClient.class); } /*@Test @@ -69,9 +69,9 @@ public class PatientFeedClientTest { Patient patient = createPatient("","",LocalDate.of(1990, 06, 19), GenderCode.MALE); patientRegistryFeedClient = new PatientRegistryFeedClient(); - patientRegistryFeedClient.setClient(patientFeedApplicationMock); + patientRegistryFeedClient.setClient(patientFeedClientMock); - Mockito.doReturn(TEST_UUID).when(patientFeedApplicationMock).createPatient(anyObject()); + Mockito.doReturn(TEST_UUID).when(patientFeedClientMock).createPatient(anyObject()); assertEquals(TEST_UUID, patientRegistryFeedClient.createPatient(patient)); } @@ -84,7 +84,7 @@ public class PatientFeedClientTest { Patient patient = null; patientRegistryFeedClient = new PatientRegistryFeedClient(); - patientRegistryFeedClient.setClient(patientFeedApplicationMock); + patientRegistryFeedClient.setClient(patientFeedClientMock); assertThrows(InvalidRequestException.class, () -> patientRegistryFeedClient.createPatient(patient)); try { @@ -103,9 +103,9 @@ public class PatientFeedClientTest { Patient patient = createPatient("","",LocalDate.of(1990, 06, 19), GenderCode.MALE); patientRegistryFeedClient = new PatientRegistryFeedClient(); - patientRegistryFeedClient.setClient(patientFeedApplicationMock); + patientRegistryFeedClient.setClient(patientFeedClientMock); - Mockito.doReturn("").when(patientFeedApplicationMock).createPatient(anyObject()); + Mockito.doReturn("").when(patientFeedClientMock).createPatient(anyObject()); assertThrows(InternalErrorException.class, () -> patientRegistryFeedClient.createPatient(patient)); try { patientRegistryFeedClient.createPatient(patient); @@ -123,9 +123,9 @@ public class PatientFeedClientTest { Patient patient = createPatient("","",LocalDate.of(1990, 06, 19), GenderCode.MALE); patientRegistryFeedClient = new PatientRegistryFeedClient(); - patientRegistryFeedClient.setClient(patientFeedApplicationMock); + patientRegistryFeedClient.setClient(patientFeedClientMock); - Mockito.doReturn(MALFORMED_UUID).when(patientFeedApplicationMock).createPatient(anyObject()); + Mockito.doReturn(MALFORMED_UUID).when(patientFeedClientMock).createPatient(anyObject()); assertThrows(InternalErrorException.class, () -> patientRegistryFeedClient.createPatient(patient)); try { patientRegistryFeedClient.createPatient(patient); @@ -142,13 +142,13 @@ public class PatientFeedClientTest { Patient patient = createPatient("","",LocalDate.of(1990, 06, 19), GenderCode.MALE); - PatientCreationException embedException = new PatientCreationException("One patientIdentifier is malformed"); + PatientFeedProcessResponseException embedException = new PatientFeedProcessResponseException("One patientIdentifier is malformed"); PatientFeedException firstException = new PatientFeedException(embedException); patientRegistryFeedClient = new PatientRegistryFeedClient(); - patientRegistryFeedClient.setClient(patientFeedApplicationMock); + patientRegistryFeedClient.setClient(patientFeedClientMock); - Mockito.doThrow(firstException).when(patientFeedApplicationMock).createPatient(anyObject()); + Mockito.doThrow(firstException).when(patientFeedClientMock).createPatient(anyObject()); assertThrows(UnprocessableEntityException.class, () -> patientRegistryFeedClient.createPatient(patient)); try { @@ -166,13 +166,13 @@ public class PatientFeedClientTest { Patient patient = createPatient("","",LocalDate.of(1990, 06, 19), GenderCode.MALE); - PatientCreationException embedException = new PatientCreationException(" one PatientIdentifier is duplicated id DB"); + PatientFeedProcessResponseException embedException = new PatientFeedProcessResponseException(" one PatientIdentifier is duplicated id DB"); PatientFeedException firstException = new PatientFeedException(embedException); patientRegistryFeedClient = new PatientRegistryFeedClient(); - patientRegistryFeedClient.setClient(patientFeedApplicationMock); + patientRegistryFeedClient.setClient(patientFeedClientMock); - Mockito.doThrow(firstException).when(patientFeedApplicationMock).createPatient(anyObject()); + Mockito.doThrow(firstException).when(patientFeedClientMock).createPatient(anyObject()); assertThrows(ResourceNotFoundException.class, () -> patientRegistryFeedClient.createPatient(patient)); try { @@ -181,7 +181,7 @@ public class PatientFeedClientTest { assertEquals("", e.getMessage()); } } - + @Test @Description("Test on create, for particular exceptions returned from PatientFeedApplication") @Severity(SeverityLevel.CRITICAL) @@ -190,13 +190,13 @@ public class PatientFeedClientTest { Patient patient = createPatient("","",LocalDate.of(1990, 06, 19), GenderCode.MALE); - PatientCreationException embedException = new PatientCreationException("System not found"); + PatientFeedProcessResponseException embedException = new PatientFeedProcessResponseException("System not found"); PatientFeedException firstException = new PatientFeedException(embedException); patientRegistryFeedClient = new PatientRegistryFeedClient(); - patientRegistryFeedClient.setClient(patientFeedApplicationMock); + patientRegistryFeedClient.setClient(patientFeedClientMock); - Mockito.doThrow(firstException).when(patientFeedApplicationMock).createPatient(anyObject()); + Mockito.doThrow(firstException).when(patientFeedClientMock).createPatient(anyObject()); assertThrows(ResourceNotFoundException.class, () -> patientRegistryFeedClient.createPatient(patient)); try { @@ -205,7 +205,7 @@ public class PatientFeedClientTest { assertEquals("System Domain could not be found when creating Patient", e.getMessage()); } } - + @Test @Description("Test on create, for particular exceptions returned from PatientFeedApplication") @Severity(SeverityLevel.CRITICAL) @@ -214,13 +214,13 @@ public class PatientFeedClientTest { Patient patient = createPatient("","",LocalDate.of(1990, 06, 19), GenderCode.MALE); - PatientCreationException embedException = new PatientCreationException("Unexpected Exception persisting Patient !"); + PatientFeedProcessResponseException embedException = new PatientFeedProcessResponseException("Unexpected Exception persisting Patient !"); PatientFeedException firstException = new PatientFeedException(embedException); patientRegistryFeedClient = new PatientRegistryFeedClient(); - patientRegistryFeedClient.setClient(patientFeedApplicationMock); + patientRegistryFeedClient.setClient(patientFeedClientMock); - Mockito.doThrow(firstException).when(patientFeedApplicationMock).createPatient(anyObject()); + Mockito.doThrow(firstException).when(patientFeedClientMock).createPatient(anyObject()); assertThrows(InternalErrorException.class, () -> patientRegistryFeedClient.createPatient(patient)); try { @@ -229,7 +229,7 @@ public class PatientFeedClientTest { assertEquals("", e.getMessage()); } } - + @Test @Description("Test on create, for particular exceptions returned from PatientFeedApplication") @Severity(SeverityLevel.CRITICAL) @@ -238,13 +238,13 @@ public class PatientFeedClientTest { Patient patient = createPatient("","",LocalDate.of(1990, 06, 19), GenderCode.MALE); - PatientCreationException embedException = new PatientCreationException("Null crossReference parameter for creation"); + PatientFeedProcessResponseException embedException = new PatientFeedProcessResponseException("Null crossReference parameter for creation"); PatientFeedException firstException = new PatientFeedException(embedException); patientRegistryFeedClient = new PatientRegistryFeedClient(); - patientRegistryFeedClient.setClient(patientFeedApplicationMock); + patientRegistryFeedClient.setClient(patientFeedClientMock); - Mockito.doThrow(firstException).when(patientFeedApplicationMock).createPatient(anyObject()); + Mockito.doThrow(firstException).when(patientFeedClientMock).createPatient(anyObject()); assertThrows(InternalErrorException.class, () -> patientRegistryFeedClient.createPatient(patient)); try { @@ -253,7 +253,7 @@ public class PatientFeedClientTest { assertEquals("", e.getMessage()); } } - + @Test @Description("Test on create, for particular exceptions returned from PatientFeedApplication") @Severity(SeverityLevel.CRITICAL) @@ -262,13 +262,13 @@ public class PatientFeedClientTest { Patient patient = createPatient("","",LocalDate.of(1990, 06, 19), GenderCode.MALE); - PatientCreationException embedException = new PatientCreationException("Persistence Error"); + PatientFeedProcessResponseException embedException = new PatientFeedProcessResponseException("Persistence Error"); PatientFeedException firstException = new PatientFeedException(embedException); patientRegistryFeedClient = new PatientRegistryFeedClient(); - patientRegistryFeedClient.setClient(patientFeedApplicationMock); + patientRegistryFeedClient.setClient(patientFeedClientMock); - Mockito.doThrow(firstException).when(patientFeedApplicationMock).createPatient(anyObject()); + Mockito.doThrow(firstException).when(patientFeedClientMock).createPatient(anyObject()); assertThrows(InternalErrorException.class, () -> patientRegistryFeedClient.createPatient(patient)); try { @@ -277,7 +277,7 @@ public class PatientFeedClientTest { assertEquals("", e.getMessage()); } } - + @Test @Description("Test on create, for particular exceptions returned from PatientFeedApplication") @Severity(SeverityLevel.CRITICAL) @@ -286,13 +286,13 @@ public class PatientFeedClientTest { Patient patient = createPatient("","",LocalDate.of(1990, 06, 19), GenderCode.MALE); - PatientCreationException embedException = new PatientCreationException("Exception performing the read operation for requested criteria !"); + PatientFeedProcessResponseException embedException = new PatientFeedProcessResponseException("Exception performing the read operation for requested criteria !"); PatientFeedException firstException = new PatientFeedException(embedException); patientRegistryFeedClient = new PatientRegistryFeedClient(); - patientRegistryFeedClient.setClient(patientFeedApplicationMock); + patientRegistryFeedClient.setClient(patientFeedClientMock); - Mockito.doThrow(firstException).when(patientFeedApplicationMock).createPatient(anyObject()); + Mockito.doThrow(firstException).when(patientFeedClientMock).createPatient(anyObject()); assertThrows(InternalErrorException.class, () -> patientRegistryFeedClient.createPatient(patient)); try {