-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
OZ-684: Implement FHIR Odoo HAPI plain server
- Loading branch information
1 parent
158d54a
commit 0bdaf17
Showing
11 changed files
with
157 additions
and
2 deletions.
There are no files selected for viewing
File renamed without changes.
File renamed without changes.
File renamed without changes.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
20 changes: 20 additions & 0 deletions
20
fhir-odoo/src/main/java/com/ozonehis/fhir/FhirOdooConfig.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,20 @@ | ||
/* | ||
* Copyright © 2024, Ozone HIS <[email protected]> | ||
* | ||
* This Source Code Form is subject to the terms of the Mozilla Public | ||
* License, v. 2.0. If a copy of the MPL was not distributed with this | ||
* file, You can obtain one at http://mozilla.org/MPL/2.0/. | ||
*/ | ||
package com.ozonehis.fhir; | ||
|
||
import lombok.Data; | ||
import org.springframework.beans.factory.annotation.Value; | ||
import org.springframework.context.annotation.Configuration; | ||
|
||
@Data | ||
@Configuration | ||
public class FhirOdooConfig { | ||
|
||
@Value("${fhir.odoo.server-url}") | ||
private String OdooServerUrl; | ||
} |
34 changes: 34 additions & 0 deletions
34
fhir-odoo/src/main/java/com/ozonehis/fhir/FhirOdooRestfulServlet.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,34 @@ | ||
/* | ||
* Copyright © 2024, Ozone HIS <[email protected]> | ||
* | ||
* This Source Code Form is subject to the terms of the Mozilla Public | ||
* License, v. 2.0. If a copy of the MPL was not distributed with this | ||
* file, You can obtain one at http://mozilla.org/MPL/2.0/. | ||
*/ | ||
package com.ozonehis.fhir; | ||
|
||
import ca.uhn.fhir.context.FhirContext; | ||
import ca.uhn.fhir.rest.api.EncodingEnum; | ||
import ca.uhn.fhir.rest.server.IResourceProvider; | ||
import ca.uhn.fhir.rest.server.RestfulServer; | ||
import com.ozonehis.fhir.annotations.FhirOdooProvider; | ||
import java.util.Collection; | ||
import org.springframework.beans.factory.annotation.Autowired; | ||
import org.springframework.stereotype.Component; | ||
|
||
@Component | ||
public class FhirOdooRestfulServlet extends RestfulServer { | ||
|
||
@Override | ||
protected void initialize() { | ||
setFhirContext(FhirContext.forR4()); | ||
setDefaultResponseEncoding(EncodingEnum.JSON); | ||
} | ||
|
||
@Override | ||
@Autowired | ||
@FhirOdooProvider | ||
public void setResourceProviders(Collection<IResourceProvider> theProviders) { | ||
super.setResourceProviders(theProviders); | ||
} | ||
} |
30 changes: 30 additions & 0 deletions
30
fhir-odoo/src/main/java/com/ozonehis/fhir/FhirOdooRestfulServletConfig.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,30 @@ | ||
/* | ||
* Copyright © 2024, Ozone HIS <[email protected]> | ||
* | ||
* This Source Code Form is subject to the terms of the Mozilla Public | ||
* License, v. 2.0. If a copy of the MPL was not distributed with this | ||
* file, You can obtain one at http://mozilla.org/MPL/2.0/. | ||
*/ | ||
package com.ozonehis.fhir; | ||
|
||
import org.springframework.beans.factory.annotation.Autowired; | ||
import org.springframework.boot.web.servlet.ServletRegistrationBean; | ||
import org.springframework.context.annotation.Bean; | ||
import org.springframework.context.annotation.Configuration; | ||
|
||
@Configuration | ||
public class FhirOdooRestfulServletConfig { | ||
|
||
private final String FHIR_ODOO_SERVLET_NAME = "FhirOdooRestfulServlet"; | ||
|
||
@Autowired | ||
private FhirOdooRestfulServlet fhirOdooRestfulServlet; | ||
|
||
@Bean | ||
public ServletRegistrationBean<FhirOdooRestfulServlet> fhirOdooRestfulServletRegistrationBean() { | ||
var servletRegistrationBean = new ServletRegistrationBean<>(fhirOdooRestfulServlet, "/odoo/R4/*"); | ||
servletRegistrationBean.setName(FHIR_ODOO_SERVLET_NAME); | ||
servletRegistrationBean.setLoadOnStartup(1); | ||
return servletRegistrationBean; | ||
} | ||
} |
22 changes: 22 additions & 0 deletions
22
fhir-odoo/src/main/java/com/ozonehis/fhir/annotations/FhirOdooProvider.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,22 @@ | ||
/* | ||
* Copyright © 2024, Ozone HIS <[email protected]> | ||
* | ||
* This Source Code Form is subject to the terms of the Mozilla Public | ||
* License, v. 2.0. If a copy of the MPL was not distributed with this | ||
* file, You can obtain one at http://mozilla.org/MPL/2.0/. | ||
*/ | ||
package com.ozonehis.fhir.annotations; | ||
|
||
import java.lang.annotation.ElementType; | ||
import java.lang.annotation.Inherited; | ||
import java.lang.annotation.Retention; | ||
import java.lang.annotation.RetentionPolicy; | ||
import java.lang.annotation.Target; | ||
import org.springframework.beans.factory.annotation.Qualifier; | ||
import org.springframework.stereotype.Component; | ||
|
||
@Target({ElementType.CONSTRUCTOR, ElementType.FIELD, ElementType.METHOD, ElementType.TYPE}) | ||
@Retention(RetentionPolicy.RUNTIME) | ||
@Inherited | ||
@Component | ||
@Qualifier public @interface FhirOdooProvider {} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,10 @@ | ||
# | ||
# Copyright © 2024, Ozone HIS <[email protected]> | ||
# | ||
# This Source Code Form is subject to the terms of the Mozilla Public | ||
# License, v. 2.0. If a copy of the MPL was not distributed with this | ||
# file, You can obtain one at http://mozilla.org/MPL/2.0/. | ||
# | ||
|
||
# The URL of the Odoo server | ||
fhir-odoo.server-url=http://localhost:8069 |
39 changes: 39 additions & 0 deletions
39
fhir-odoo/src/test/java/com/ozonehis/fhir/FhirOdooRestfulServletConfigTest.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,39 @@ | ||
/* | ||
* Copyright © 2024, Ozone HIS <[email protected]> | ||
* | ||
* This Source Code Form is subject to the terms of the Mozilla Public | ||
* License, v. 2.0. If a copy of the MPL was not distributed with this | ||
* file, You can obtain one at http://mozilla.org/MPL/2.0/. | ||
*/ | ||
package com.ozonehis.fhir; | ||
|
||
import static org.junit.jupiter.api.Assertions.assertEquals; | ||
import static org.junit.jupiter.api.Assertions.assertNotNull; | ||
import static org.junit.jupiter.api.Assertions.assertTrue; | ||
|
||
import org.junit.jupiter.api.DisplayName; | ||
import org.junit.jupiter.api.Test; | ||
import org.springframework.beans.factory.annotation.Autowired; | ||
import org.springframework.boot.test.context.SpringBootTest; | ||
import org.springframework.boot.test.mock.mockito.MockBean; | ||
import org.springframework.boot.web.servlet.ServletRegistrationBean; | ||
|
||
@SpringBootTest(classes = FhirOdooRestfulServletConfig.class) | ||
class FhirOdooRestfulServletConfigTest { | ||
|
||
@MockBean | ||
FhirOdooRestfulServlet fhirOdooRestfulServlet; | ||
|
||
@Autowired | ||
ServletRegistrationBean<FhirOdooRestfulServlet> fhirOdooRestfulServletRegistrationBean; | ||
|
||
@Test | ||
@DisplayName("Should register FhirOdooRestfulServlet with URL mapping /odoo/R4/*") | ||
void shouldReturnFhirOdooRestfulServletRegistrationBeanWithCorrectMappings() { | ||
// Assert | ||
assertNotNull(fhirOdooRestfulServletRegistrationBean); | ||
assertNotNull(fhirOdooRestfulServletRegistrationBean.getServlet()); | ||
assertTrue(fhirOdooRestfulServletRegistrationBean.getUrlMappings().contains("/odoo/R4/*")); | ||
assertEquals("FhirOdooRestfulServlet", fhirOdooRestfulServletRegistrationBean.getServletName()); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters