From 0d2960d45596e1eb461dba778b901861c7318912 Mon Sep 17 00:00:00 2001 From: "Kipchumba C. Bett" Date: Tue, 24 Sep 2024 15:45:06 +0300 Subject: [PATCH] OZ-708: Add missing docs and include fhir in the URL mappings --- .../fhir/odoo/mappers/ChargeItemDefinitionMapper.java | 5 +++-- .../ozonehis/fhir/odoo/mappers/InventoryItemMapper.java | 3 ++- .../src/main/java/com/ozonehis/fhir/FhirOdooConfig.java | 8 ++++---- .../com/ozonehis/fhir/FhirOdooRestfulServletConfig.java | 2 +- .../chargeItemDefinition/ChargeItemDefinitionService.java | 6 ++++++ .../fhir/odoo/inventoryItem/InventoryItemService.java | 6 ++++++ .../ozonehis/fhir/FhirOdooRestfulServletConfigTest.java | 4 ++-- 7 files changed, 24 insertions(+), 10 deletions(-) diff --git a/fhir-odoo-mapper/src/main/java/com/ozonehis/fhir/odoo/mappers/ChargeItemDefinitionMapper.java b/fhir-odoo-mapper/src/main/java/com/ozonehis/fhir/odoo/mappers/ChargeItemDefinitionMapper.java index f672f76..7696433 100644 --- a/fhir-odoo-mapper/src/main/java/com/ozonehis/fhir/odoo/mappers/ChargeItemDefinitionMapper.java +++ b/fhir-odoo-mapper/src/main/java/com/ozonehis/fhir/odoo/mappers/ChargeItemDefinitionMapper.java @@ -14,6 +14,7 @@ import com.ozonehis.fhir.odoo.model.OdooResource; import com.ozonehis.fhir.odoo.model.Product; import java.util.Map; +import org.apache.commons.collections4.MapUtils; import org.hl7.fhir.r4.model.ChargeItemDefinition; import org.hl7.fhir.r4.model.Enumerations; import org.hl7.fhir.r4.model.Money; @@ -25,10 +26,10 @@ public class ChargeItemDefinitionMapper @Override public ChargeItemDefinition toFhir(Map resourceMap) { - ChargeItemDefinition chargeItemDefinition = new ChargeItemDefinition(); - if (resourceMap == null || resourceMap.isEmpty()) { + if (MapUtils.isEmpty(resourceMap)) { return null; } + ChargeItemDefinition chargeItemDefinition = new ChargeItemDefinition(); Product product = (Product) resourceMap.get(OdooConstants.MODEL_PRODUCT); ExtId extId = (ExtId) resourceMap.get(OdooConstants.MODEL_EXTERNAL_IDENTIFIER); Currency currency = (Currency) resourceMap.get(OdooConstants.MODEL_CURRENCY); diff --git a/fhir-odoo-mapper/src/main/java/com/ozonehis/fhir/odoo/mappers/InventoryItemMapper.java b/fhir-odoo-mapper/src/main/java/com/ozonehis/fhir/odoo/mappers/InventoryItemMapper.java index 4b96d8b..4901980 100644 --- a/fhir-odoo-mapper/src/main/java/com/ozonehis/fhir/odoo/mappers/InventoryItemMapper.java +++ b/fhir-odoo-mapper/src/main/java/com/ozonehis/fhir/odoo/mappers/InventoryItemMapper.java @@ -15,6 +15,7 @@ import com.ozonehis.fhir.odoo.model.OdooResource; import com.ozonehis.fhir.odoo.model.Product; import java.util.Map; +import org.apache.commons.collections4.MapUtils; import org.hl7.fhir.r4.model.CodeableConcept; import org.hl7.fhir.r4.model.Coding; import org.hl7.fhir.r4.model.Quantity; @@ -26,7 +27,7 @@ public class InventoryItemMapper impleme @Override public InventoryItem toFhir(Map resourceMap) { - if (resourceMap == null || resourceMap.isEmpty()) { + if (MapUtils.isEmpty(resourceMap)) { return null; } InventoryItem inventoryItem = new InventoryItem(); diff --git a/fhir-odoo/src/main/java/com/ozonehis/fhir/FhirOdooConfig.java b/fhir-odoo/src/main/java/com/ozonehis/fhir/FhirOdooConfig.java index accb48e..5a19fd7 100644 --- a/fhir-odoo/src/main/java/com/ozonehis/fhir/FhirOdooConfig.java +++ b/fhir-odoo/src/main/java/com/ozonehis/fhir/FhirOdooConfig.java @@ -30,16 +30,16 @@ public class FhirOdooConfig { private String OdooProtocol; public void validateOdooProperties() { - if (StringUtils.isEmpty(OdooHost) && StringUtils.isBlank(OdooHost)) { + if (StringUtils.isEmpty(OdooHost) || StringUtils.isBlank(OdooHost)) { throw new IllegalArgumentException("OdooHost is required"); } - if (StringUtils.isEmpty(OdooDatabase) && StringUtils.isBlank(OdooDatabase)) { + if (StringUtils.isEmpty(OdooDatabase) || StringUtils.isBlank(OdooDatabase)) { throw new IllegalArgumentException("OdooDatabase is required"); } - if (StringUtils.isEmpty(OdooPort) && StringUtils.isBlank(OdooPort)) { + if (StringUtils.isEmpty(OdooPort) || StringUtils.isBlank(OdooPort)) { throw new IllegalArgumentException("OdooPort is required"); } - if (StringUtils.isEmpty(OdooProtocol) && StringUtils.isBlank(OdooProtocol)) { + if (StringUtils.isEmpty(OdooProtocol) || StringUtils.isBlank(OdooProtocol)) { throw new IllegalArgumentException("OdooProtocol is required"); } } diff --git a/fhir-odoo/src/main/java/com/ozonehis/fhir/FhirOdooRestfulServletConfig.java b/fhir-odoo/src/main/java/com/ozonehis/fhir/FhirOdooRestfulServletConfig.java index 0cce758..2e8662c 100644 --- a/fhir-odoo/src/main/java/com/ozonehis/fhir/FhirOdooRestfulServletConfig.java +++ b/fhir-odoo/src/main/java/com/ozonehis/fhir/FhirOdooRestfulServletConfig.java @@ -22,7 +22,7 @@ public class FhirOdooRestfulServletConfig { @Bean public ServletRegistrationBean fhirOdooRestfulServletRegistrationBean() { - var servletRegistrationBean = new ServletRegistrationBean<>(fhirOdooRestfulServlet, "/odoo/R4/*"); + var servletRegistrationBean = new ServletRegistrationBean<>(fhirOdooRestfulServlet, "/odoo/fhir/R4/*"); servletRegistrationBean.setName(FHIR_ODOO_SERVLET_NAME); servletRegistrationBean.setLoadOnStartup(1); return servletRegistrationBean; diff --git a/fhir-odoo/src/main/java/com/ozonehis/fhir/odoo/chargeItemDefinition/ChargeItemDefinitionService.java b/fhir-odoo/src/main/java/com/ozonehis/fhir/odoo/chargeItemDefinition/ChargeItemDefinitionService.java index bcc0473..c44a78e 100644 --- a/fhir-odoo/src/main/java/com/ozonehis/fhir/odoo/chargeItemDefinition/ChargeItemDefinitionService.java +++ b/fhir-odoo/src/main/java/com/ozonehis/fhir/odoo/chargeItemDefinition/ChargeItemDefinitionService.java @@ -14,5 +14,11 @@ public interface ChargeItemDefinitionService extends FhirService { + /** + * Search for ChargeItemDefinitions by code + * + * @param code TokenAndListParam code to search for + * @return Bundle of ChargeItemDefinitions + */ Bundle searchForChargeItemDefinitions(TokenAndListParam code); } diff --git a/fhir-odoo/src/main/java/com/ozonehis/fhir/odoo/inventoryItem/InventoryItemService.java b/fhir-odoo/src/main/java/com/ozonehis/fhir/odoo/inventoryItem/InventoryItemService.java index 9c6fecb..23d8006 100644 --- a/fhir-odoo/src/main/java/com/ozonehis/fhir/odoo/inventoryItem/InventoryItemService.java +++ b/fhir-odoo/src/main/java/com/ozonehis/fhir/odoo/inventoryItem/InventoryItemService.java @@ -14,5 +14,11 @@ public interface InventoryItemService extends FhirService { + /** + * Search for InventoryItems by code + * + * @param code TokenAndListParam code to search for + * @return Bundle of InventoryItems + */ Bundle searchForInventoryItems(TokenAndListParam code); } diff --git a/fhir-odoo/src/test/java/com/ozonehis/fhir/FhirOdooRestfulServletConfigTest.java b/fhir-odoo/src/test/java/com/ozonehis/fhir/FhirOdooRestfulServletConfigTest.java index 7aa17a0..514a749 100644 --- a/fhir-odoo/src/test/java/com/ozonehis/fhir/FhirOdooRestfulServletConfigTest.java +++ b/fhir-odoo/src/test/java/com/ozonehis/fhir/FhirOdooRestfulServletConfigTest.java @@ -28,12 +28,12 @@ class FhirOdooRestfulServletConfigTest { ServletRegistrationBean fhirOdooRestfulServletRegistrationBean; @Test - @DisplayName("Should register FhirOdooRestfulServlet with URL mapping /odoo/R4/*") + @DisplayName("Should register FhirOdooRestfulServlet with URL mapping /odoo/fhir/R4/*") void shouldReturnFhirOdooRestfulServletRegistrationBeanWithCorrectMappings() { // Assert assertNotNull(fhirOdooRestfulServletRegistrationBean); assertNotNull(fhirOdooRestfulServletRegistrationBean.getServlet()); - assertTrue(fhirOdooRestfulServletRegistrationBean.getUrlMappings().contains("/odoo/R4/*")); + assertTrue(fhirOdooRestfulServletRegistrationBean.getUrlMappings().contains("/odoo/fhir/R4/*")); assertEquals("FhirOdooRestfulServlet", fhirOdooRestfulServletRegistrationBean.getServletName()); } }