Skip to content

Commit

Permalink
Merge remote-tracking branch 'origin/master' into FM2-626
Browse files Browse the repository at this point in the history
  • Loading branch information
ibacher committed Oct 9, 2024
2 parents f9adbcf + 983b724 commit 8bac94e
Show file tree
Hide file tree
Showing 115 changed files with 2,179 additions and 710 deletions.
18 changes: 9 additions & 9 deletions .github/workflows/main.yml
Original file line number Diff line number Diff line change
Expand Up @@ -20,36 +20,36 @@ jobs:
JAVA_VERSION: ${{ matrix.java-version }}

steps:
- uses: actions/checkout@v3
- uses: actions/checkout@v4
- name: Set up JDK
uses: actions/setup-java@v3
uses: actions/setup-java@v4
with:
distribution: 'temurin'
java-version: ${{ matrix.java-version }}
- name: Build with Maven
id: build_with_maven
run: |
mvn verify --batch-mode -P integration-test --file pom.xml
- uses: actions/upload-artifact@v3
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@v1
uses: codecov/codecov-action@v4
with:
env_vars: PLATFORM, JAVA_VERSION
test:
name: Run e2e tests
needs: build
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
- uses: actions/checkout@v4
- name: Set up JDK
uses: actions/setup-java@v3
uses: actions/setup-java@v4
with:
distribution: 'temurin'
java-version: 8
- uses: actions/download-artifact@v3
- uses: actions/download-artifact@v4
with:
name: build_artifact
path: ${{ github.workspace }}/omod/target
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.1.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.1.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.1.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
4 changes: 4 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 @@ -269,12 +269,16 @@ private FhirConstants() {

public static final String STATUS_SEARCH_HANDLER = "status.search.handler";

public static final String TASK_CODE_SEARCH_HANDLER = "task.code.search.handler";

public static final String FULFILLER_STATUS_SEARCH_HANDLER = "fullfillerStatus.search.handler";

public static final String BASED_ON_REFERENCE_SEARCH_HANDLER = "based.on.reference.search.handler";

public static final String OWNER_REFERENCE_SEARCH_HANDLER = "owner.reference.search.handler";

public static final String FOR_REFERENCE_SEARCH_HANDLER = "for.reference.search.handler";

public static final String RESULT_SEARCH_HANDLER = "result.search.handler";

public static final String COMMON_SEARCH_HANDLER = "common.search.handler";
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 @@ -48,6 +48,13 @@ protected <U> void setupSearchParams(OpenmrsFhirCriteriaContext<FhirTask, U> cri
entry.getValue().forEach(param -> handleReference(criteriaContext,
(ReferenceAndListParam) param.getParam(), "ownerReference", "o"));
break;
case FhirConstants.FOR_REFERENCE_SEARCH_HANDLER:
entry.getValue().forEach(
param -> handleReference(criteria, (ReferenceAndListParam) param.getParam(), "forReference", "f"));
break;
case FhirConstants.TASK_CODE_SEARCH_HANDLER:
entry.getValue().forEach(code -> handleTaskCodeConcept(criteria, (TokenAndListParam) code.getParam()));
break;
case FhirConstants.STATUS_SEARCH_HANDLER:
entry.getValue().forEach(param -> handleStatus(criteriaContext, (TokenAndListParam) param.getParam())
.ifPresent(handler -> criteriaContext.addPredicate(handler).finalizeQuery()));
Expand Down Expand Up @@ -111,4 +118,14 @@ private <U> void handleReference(OpenmrsFhirCriteriaContext<FhirTask, U> criteri
return Optional.empty();
}).ifPresent(c -> criteriaContext.addPredicate(c).finalizeQuery());
}

private void handleTaskCodeConcept(Criteria criteria, TokenAndListParam code) {
if (code != null) {
if (lacksAlias(criteria, "tc")) {
criteria.createAlias("taskCode", "tc");
}

handleCodeableConcept(criteria, code, "tc", "tcm", "tcrt").ifPresent(criteria::add);
}
}
}
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;
}
Loading

0 comments on commit 8bac94e

Please sign in to comment.