Skip to content

Commit

Permalink
OZ-708: Add missing docs and include fhir in the URL mappings
Browse files Browse the repository at this point in the history
  • Loading branch information
corneliouzbett committed Sep 26, 2024
1 parent 2e32beb commit 0d2960d
Show file tree
Hide file tree
Showing 7 changed files with 24 additions and 10 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand All @@ -25,10 +26,10 @@ public class ChargeItemDefinitionMapper<O extends BaseOdooModel & OdooResource>

@Override
public ChargeItemDefinition toFhir(Map<String, O> 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);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand All @@ -26,7 +27,7 @@ public class InventoryItemMapper<O extends BaseOdooModel & OdooResource> impleme

@Override
public InventoryItem toFhir(Map<String, O> resourceMap) {
if (resourceMap == null || resourceMap.isEmpty()) {
if (MapUtils.isEmpty(resourceMap)) {
return null;
}
InventoryItem inventoryItem = new InventoryItem();
Expand Down
8 changes: 4 additions & 4 deletions fhir-odoo/src/main/java/com/ozonehis/fhir/FhirOdooConfig.java
Original file line number Diff line number Diff line change
Expand Up @@ -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");
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ public class FhirOdooRestfulServletConfig {

@Bean
public ServletRegistrationBean<FhirOdooRestfulServlet> 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;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,5 +14,11 @@

public interface ChargeItemDefinitionService extends FhirService<ChargeItemDefinition> {

/**
* Search for ChargeItemDefinitions by code
*
* @param code TokenAndListParam code to search for
* @return Bundle of ChargeItemDefinitions
*/
Bundle searchForChargeItemDefinitions(TokenAndListParam code);
}
Original file line number Diff line number Diff line change
Expand Up @@ -14,5 +14,11 @@

public interface InventoryItemService extends FhirService<InventoryItem> {

/**
* Search for InventoryItems by code
*
* @param code TokenAndListParam code to search for
* @return Bundle of InventoryItems
*/
Bundle searchForInventoryItems(TokenAndListParam code);
}
Original file line number Diff line number Diff line change
Expand Up @@ -28,12 +28,12 @@ class FhirOdooRestfulServletConfigTest {
ServletRegistrationBean<FhirOdooRestfulServlet> 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());
}
}

0 comments on commit 0d2960d

Please sign in to comment.