Skip to content

Commit

Permalink
Merge branch 'master' into feat/has-parameter
Browse files Browse the repository at this point in the history
  • Loading branch information
icrc-jofrancisco authored Nov 27, 2024
2 parents 827ccdb + 10a5c39 commit 0621277
Show file tree
Hide file tree
Showing 103 changed files with 1,585 additions and 635 deletions.
4 changes: 2 additions & 2 deletions .github/workflows/main.yml
Original file line number Diff line number Diff line change
Expand Up @@ -29,11 +29,11 @@ jobs:
- name: Build with Maven
id: build_with_maven
run: |
mvn verify --batch-mode -P integration-test --file pom.xml
mvn clean verify --batch-mode -P integration-test --file pom.xml
- uses: actions/upload-artifact@v4
with:
name: build_artifact
path: ${{ github.workspace }}/omod/target
path: ${{ github.workspace }}/omod/target/*.omod
- name: Send data to Codecov
uses: codecov/codecov-action@v4
with:
Expand Down
2 changes: 1 addition & 1 deletion api-2.5/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
<parent>
<artifactId>fhir2</artifactId>
<groupId>org.openmrs.module</groupId>
<version>2.2.0-SNAPSHOT</version>
<version>2.3.0-SNAPSHOT</version>
</parent>
<modelVersion>4.0.0</modelVersion>

Expand Down
2 changes: 1 addition & 1 deletion api-2.6/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
<parent>
<artifactId>fhir2</artifactId>
<groupId>org.openmrs.module</groupId>
<version>2.2.0-SNAPSHOT</version>
<version>2.3.0-SNAPSHOT</version>
</parent>
<modelVersion>4.0.0</modelVersion>

Expand Down
2 changes: 1 addition & 1 deletion api/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
<parent>
<groupId>org.openmrs.module</groupId>
<artifactId>fhir2</artifactId>
<version>2.2.0-SNAPSHOT</version>
<version>2.3.0-SNAPSHOT</version>
</parent>

<artifactId>fhir2-api</artifactId>
Expand Down
22 changes: 18 additions & 4 deletions api/src/main/java/org/openmrs/module/fhir2/FhirActivator.java
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@
import ca.uhn.fhir.rest.server.IResourceProvider;
import lombok.Getter;
import lombok.extern.slf4j.Slf4j;
import org.openmrs.api.context.Context;
import org.openmrs.module.BaseModuleActivator;
import org.openmrs.module.Module;
import org.openmrs.module.ModuleException;
Expand All @@ -36,6 +37,7 @@
import org.openmrs.module.fhir2.api.spi.ModuleLifecycleListener;
import org.openmrs.module.fhir2.api.spi.ServiceClassLoader;
import org.openmrs.module.fhir2.api.translators.FhirTranslator;
import org.openmrs.module.fhir2.api.util.FhirGlobalPropertyHolder;
import org.openmrs.module.fhir2.model.GroupMember;
import org.springframework.beans.BeansException;
import org.springframework.context.ApplicationContext;
Expand All @@ -53,6 +55,8 @@ public class FhirActivator extends BaseModuleActivator implements ApplicationCon
@Getter
private static ConfigurableApplicationContext applicationContext;

private static FhirGlobalPropertyHolder globalPropertyHolder = null;

private final Map<String, Set<Class<?>>> services = new HashMap<>();

private final List<ModuleLifecycleListener> lifecycleListeners = new ArrayList<>();
Expand All @@ -65,8 +69,6 @@ public void started() {
throw new ModuleException("Cannot load FHIR2 module as the main application context is not available");
}

applicationContext.getBean("fhirR4", FhirContext.class).registerCustomType(GroupMember.class);

loadModules();
started = true;
log.info("Started FHIR");
Expand All @@ -86,6 +88,13 @@ public void contextRefreshed() {
return;
}

if (globalPropertyHolder == null) {
globalPropertyHolder = new FhirGlobalPropertyHolder();
Context.getAdministrationService().addGlobalPropertyListener(globalPropertyHolder);
}

FhirGlobalPropertyHolder.reset();

applicationContext.getBean("fhirR4", FhirContext.class).registerCustomType(GroupMember.class);
loadModules();

Expand All @@ -95,13 +104,18 @@ public void contextRefreshed() {
@Override
public void willStop() {
lifecycleListeners.forEach(ModuleLifecycleListener::willStop);
unloadModules();

if (globalPropertyHolder != null) {
Context.getAdministrationService().removeGlobalPropertyListener(globalPropertyHolder);
}
}

@Override
public void stopped() {
lifecycleListeners.forEach(ModuleLifecycleListener::stopped);
unloadModules();

globalPropertyHolder = null;
started = false;
log.info("Shutdown FHIR");
}
Expand All @@ -117,7 +131,7 @@ public void removeModuleLifecycleLister(@Nonnull ModuleLifecycleListener lifecyc
}

@Override
public void setApplicationContext(ApplicationContext applicationContext) throws BeansException {
public void setApplicationContext(@Nonnull ApplicationContext applicationContext) throws BeansException {
if (applicationContext instanceof ConfigurableApplicationContext) {
FhirActivator.applicationContext = (ConfigurableApplicationContext) applicationContext;
}
Expand Down
8 changes: 8 additions & 0 deletions api/src/main/java/org/openmrs/module/fhir2/FhirConstants.java
Original file line number Diff line number Diff line change
Expand Up @@ -227,6 +227,14 @@ private FhirConstants() {

public static final String FAMILY_PROPERTY = "family.property";

public static final String GENDER_PROPERTY = "gender";

public static final String BIRTHDATE_PROPERTY = "birthdate";

public static final String DEATHDATE_PROPERTY = "deathDate";

public static final String DECEASED_PROPERTY = "dead";

public static final String CITY_PROPERTY = "city.property";

public static final String COUNTRY_PROPERTY = "country.property";
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
/*
* 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/. OpenMRS is also distributed under
* the terms of the Healthcare Disclaimer located at http://openmrs.org/license.
*
* Copyright (C) OpenMRS Inc. OpenMRS is a registered trademark and the OpenMRS
* graphic logo is a trademark of OpenMRS Inc.
*/
package org.openmrs.module.fhir2.api;

import javax.annotation.Nonnull;

import org.hl7.fhir.r4.model.EpisodeOfCare;

public interface FhirEpisodeOfCareService extends FhirService<EpisodeOfCare> {

@Override
EpisodeOfCare get(@Nonnull String uuid);
}
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ public interface FhirGlobalPropertyService {

String getGlobalProperty(String property) throws APIException;

Integer getGlobalProperty(String property, Integer defaultValue);
int getGlobalPropertyAsInteger(String property, int defaultValue);

String getGlobalProperty(String property, String defaultValue);

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,21 +9,15 @@
*/
package org.openmrs.module.fhir2.api.dao;

import java.util.Map;
import javax.annotation.Nonnull;

import org.openmrs.GlobalProperty;
import org.openmrs.PatientProgram;
import org.openmrs.annotation.Authorized;
import org.openmrs.api.APIException;
import org.openmrs.util.PrivilegeConstants;

public interface FhirGlobalPropertyDao {
public interface FhirEpisodeOfCareDao extends FhirDao<PatientProgram> {

@Authorized(PrivilegeConstants.GET_GLOBAL_PROPERTIES)
String getGlobalProperty(String property) throws APIException;

@Authorized(PrivilegeConstants.GET_GLOBAL_PROPERTIES)
GlobalProperty getGlobalPropertyObject(String property);

@Authorized(PrivilegeConstants.GET_GLOBAL_PROPERTIES)
Map<String, String> getGlobalProperties(String... properties);
@Override
@Authorized(PrivilegeConstants.GET_PATIENT_PROGRAMS)
PatientProgram get(@Nonnull String uuid);
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
/*
* 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/. OpenMRS is also distributed under
* the terms of the Healthcare Disclaimer located at http://openmrs.org/license.
*
* Copyright (C) OpenMRS Inc. OpenMRS is a registered trademark and the OpenMRS
* graphic logo is a trademark of OpenMRS Inc.
*/
package org.openmrs.module.fhir2.api.dao.impl;

import lombok.AccessLevel;
import lombok.Setter;
import org.openmrs.PatientProgram;
import org.openmrs.module.fhir2.api.dao.FhirEpisodeOfCareDao;
import org.springframework.stereotype.Component;

@Component
@Setter(AccessLevel.PACKAGE)
public class FhirEpisodeOfCareDaoImpl extends BaseFhirDao<PatientProgram> implements FhirEpisodeOfCareDao {

}

This file was deleted.

Original file line number Diff line number Diff line change
Expand Up @@ -101,8 +101,9 @@ protected void setupSearchParams(Criteria criteria, SearchParameterMap theParams
handleNames(criteria, entry.getValue());
break;
case FhirConstants.GENDER_SEARCH_HANDLER:
entry.getValue().forEach(
p -> handleGender(p.getPropertyName(), (TokenAndListParam) p.getParam()).ifPresent(criteria::add));
entry.getValue()
.forEach(p -> handleGender(FhirConstants.GENDER_PROPERTY, (TokenAndListParam) p.getParam())
.ifPresent(criteria::add));
break;
case FhirConstants.IDENTIFIER_SEARCH_HANDLER:
entry.getValue()
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,8 @@ protected void setupSearchParams(Criteria criteria, SearchParameterMap theParams
break;
case FhirConstants.GENDER_SEARCH_HANDLER:
entry.getValue().forEach(
param -> handleGender("gender", (TokenAndListParam) param.getParam()).ifPresent(criteria::add));
param -> handleGender(FhirConstants.GENDER_PROPERTY, (TokenAndListParam) param.getParam())
.ifPresent(criteria::add));
break;
case FhirConstants.DATE_RANGE_SEARCH_HANDLER:
entry.getValue().forEach(
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
/*
* 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/. OpenMRS is also distributed under
* the terms of the Healthcare Disclaimer located at http://openmrs.org/license.
*
* Copyright (C) OpenMRS Inc. OpenMRS is a registered trademark and the OpenMRS
* graphic logo is a trademark of OpenMRS Inc.
*/
package org.openmrs.module.fhir2.api.impl;

import lombok.AccessLevel;
import lombok.Getter;
import lombok.Setter;
import org.hl7.fhir.r4.model.EpisodeOfCare;
import org.openmrs.PatientProgram;
import org.openmrs.module.fhir2.api.FhirEpisodeOfCareService;
import org.openmrs.module.fhir2.api.dao.FhirEpisodeOfCareDao;
import org.openmrs.module.fhir2.api.translators.EpisodeOfCareTranslator;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Component;
import org.springframework.transaction.annotation.Transactional;

@Component
@Transactional
@Setter(AccessLevel.PACKAGE)
@Getter(AccessLevel.PROTECTED)
public class FhirEpisodeOfCareServiceImpl extends BaseFhirService<EpisodeOfCare, PatientProgram> implements FhirEpisodeOfCareService {

@Autowired
private FhirEpisodeOfCareDao dao;

@Autowired
private EpisodeOfCareTranslator translator;
}
Original file line number Diff line number Diff line change
Expand Up @@ -15,45 +15,30 @@
import lombok.Setter;
import org.openmrs.api.APIException;
import org.openmrs.module.fhir2.api.FhirGlobalPropertyService;
import org.openmrs.module.fhir2.api.dao.FhirGlobalPropertyDao;
import org.springframework.beans.factory.annotation.Autowired;
import org.openmrs.module.fhir2.api.util.FhirGlobalPropertyHolder;
import org.springframework.stereotype.Component;
import org.springframework.transaction.annotation.Transactional;

@Component
@Transactional
@Setter(AccessLevel.PACKAGE)
public class FhirGlobalPropertyServiceImpl implements FhirGlobalPropertyService {

@Autowired
private FhirGlobalPropertyDao dao;

@Override
@Transactional(readOnly = true)
public String getGlobalProperty(String property) throws APIException {
return dao.getGlobalProperty(property);
return FhirGlobalPropertyHolder.getGlobalProperty(property);
}

@Override
@Transactional(readOnly = true)
public Integer getGlobalProperty(String property, Integer defaultValue) {
try {
return Integer.valueOf(getGlobalProperty(property, String.valueOf(defaultValue)));
}
catch (NumberFormatException e) {
return defaultValue;
}
public int getGlobalPropertyAsInteger(String property, int defaultValue) {
return FhirGlobalPropertyHolder.getGlobalPropertyAsInteger(property, defaultValue);
}

@Override
@Transactional(readOnly = true)
public String getGlobalProperty(String property, String defaultValue) {
return this.getGlobalProperty(property) == null ? defaultValue : this.getGlobalProperty(property);
return FhirGlobalPropertyHolder.getGlobalProperty(property, defaultValue);
}

@Override
@Transactional(readOnly = true)
public Map<String, String> getGlobalProperties(String... properties) {
return dao.getGlobalProperties(properties);
return FhirGlobalPropertyHolder.getGlobalProperties(properties);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -93,7 +93,7 @@ public List<IBaseResource> getResources(int fromIndex, int toIndex) {
@Override
public Integer preferredPageSize() {
if (pageSize == null) {
pageSize = globalPropertyService.getGlobalProperty(FhirConstants.OPENMRS_FHIR_DEFAULT_PAGE_SIZE, 10);
pageSize = globalPropertyService.getGlobalPropertyAsInteger(FhirConstants.OPENMRS_FHIR_DEFAULT_PAGE_SIZE, 10);
}

return pageSize;
Expand Down
Loading

0 comments on commit 0621277

Please sign in to comment.