Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

FM2-640: added FHIR Flag resource #80

Merged
merged 33 commits into from
Aug 17, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
33 commits
Select commit Hold shift + click to select a range
4ed742a
FM2-640: added FHIR FLag resource
ManojLL Jul 9, 2024
3e43860
FM2-640: fixed fhir module loading issue
ManojLL Jul 11, 2024
4db1284
FM2-640: added priority translator
ManojLL Jul 13, 2024
abf7082
FM2-640: remove unwanted imports
ManojLL Jul 13, 2024
44fc7f5
FM2-640: added flag translator
ManojLL Jul 15, 2024
426021e
FM2-640: added flag translator
ManojLL Jul 16, 2024
5ae17b0
FM2-640: added flag search for patient
ManojLL Jul 16, 2024
b3db661
FM2-640: added FHIR2 omod dependency
ManojLL Jul 17, 2024
13e0f84
FM2-640: added search flag using ref patient
ManojLL Jul 17, 2024
4042779
FM2-640: added search params for search patient flags
ManojLL Jul 18, 2024
7dcf60d
FM2-640: Improved the flag search by adding date and category
ManojLL Jul 19, 2024
87bec2d
FLAG 67: fixed flags rendering issue on patient page (#77)
ManojLL Jul 10, 2024
1791da9
(chore) O3-3551: Use latest Actions in GH Actions (#81)
Jul 10, 2024
d898a0e
FLAG-67: fixed flag rendering on platform lower versions (#82)
ManojLL Jul 14, 2024
8bb38c0
FLAG-75: refactor getFlagsForPatient method with stream API (#65)
ManojLL Jul 17, 2024
676e850
FLAG-78: added test for priority services (#84)
ManojLL Jul 20, 2024
5961c59
FLAG 78: added unit tests for patient flag (#78)
ManojLL Jul 20, 2024
83b44cb
FM2-640: added unit tests for fhir module
ManojLL Jul 20, 2024
8596b8a
FM2-640: added unit test for service
ManojLL Jul 22, 2024
74d14f7
FM2-640: added flag dao test
ManojLL Jul 22, 2024
2e8f8d7
FM2-640: updated pom file
ManojLL Jul 22, 2024
7d76bfc
Merge branch 'master' into FM2-640
ManojLL Jul 22, 2024
fadbbd2
FM2-640: fixed the test error
ManojLL Jul 22, 2024
003c8f4
FM2-640: add test for FHIR flag service
ManojLL Jul 23, 2024
3558739
FM2-640: added test for fhirFlagDao
ManojLL Jul 24, 2024
d885314
FM2-640: fixed Dao test executing issue
ManojLL Jul 24, 2024
1d36ae2
FM2-640: fixed Dao test executing issue
ManojLL Jul 24, 2024
95241ea
FM2-640: fixed Dao test executing issue
ManojLL Jul 25, 2024
17e90b8
FM2-640: added FhirFlagDao tests
ManojLL Jul 26, 2024
acc7041
FM2-640: added unit test for search queries
ManojLL Jul 26, 2024
df8718b
FM2-640: changed fhir2 module version 2.2 to 2.0
ManojLL Aug 1, 2024
60fe9a5
FM2-640: localized using FHIR FhirUtils #getMetadataTranslation()
ManojLL Aug 1, 2024
0e60f5d
FM2-640: Implement requested changes
ManojLL Aug 7, 2024
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 1 addition & 2 deletions api/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@
<artifactId>openmrs-test</artifactId>
<type>pom</type>
</dependency>

<!-- include groovy, but mark as provided since it is included with openmrs-core v1.10+-->
<dependency>
<groupId>org.codehaus.groovy</groupId>
Expand All @@ -46,7 +46,6 @@
<type>jar</type>
<scope>provided</scope>
</dependency>

</dependencies>

<build>
Expand Down
105 changes: 105 additions & 0 deletions fhir/pom.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,105 @@
<?xml version="1.0" encoding="UTF-8"?>
<project xmlns="http://maven.apache.org/POM/4.0.0"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
<modelVersion>4.0.0</modelVersion>
<parent>
<groupId>org.openmrs.module</groupId>
<artifactId>patientflags</artifactId>
<version>3.0.8-SNAPSHOT</version>
</parent>

<artifactId>patientflags-fhir</artifactId>
<packaging>jar</packaging>
<name>Patient Flags Module FHIR</name>
<description>FHIR project for Patient Flags Module</description>

<dependencies>
<dependency>
<groupId>org.openmrs.api</groupId>
<artifactId>openmrs-api</artifactId>
<type>jar</type>
</dependency>
<dependency>
<groupId>org.openmrs.web</groupId>
<artifactId>openmrs-web</artifactId>
<type>jar</type>
</dependency>
<dependency>
<groupId>org.openmrs.module</groupId>
<artifactId>patientflags-api</artifactId>
<version>${project.parent.version}</version>
</dependency>
<dependency>
<groupId>org.openmrs.api</groupId>
<artifactId>openmrs-api</artifactId>
<type>test-jar</type>
</dependency>
<dependency>
<groupId>org.openmrs.web</groupId>
<artifactId>openmrs-web</artifactId>
<type>test-jar</type>
</dependency>
<dependency>
<groupId>org.openmrs.test</groupId>
<artifactId>openmrs-test</artifactId>
<type>pom</type>
</dependency>

<!-- include groovy, but mark as provided since it is included with openmrs-core v1.10+-->
<dependency>
<groupId>org.codehaus.groovy</groupId>
<artifactId>groovy</artifactId>
<version>1.7.6</version>
<type>jar</type>
<scope>provided</scope>
</dependency>

<dependency>
<groupId>org.openmrs.module</groupId>
<artifactId>fhir2-api</artifactId>
</dependency>
<dependency>
<groupId>org.openmrs.module</groupId>
<artifactId>fhir2-api</artifactId>
<type>test-jar</type>
</dependency>
<dependency>
<groupId>org.projectlombok</groupId>
<artifactId>lombok</artifactId>
</dependency>
</dependencies>

<build>
<resources>
<resource>
<directory>src/main/resources</directory>
<filtering>true</filtering>
</resource>
</resources>

<testResources>
<testResource>
<directory>src/test/resources</directory>
<filtering>true</filtering>
<includes>
<include>**/*.xml</include>
<include>**/*.txt</include>
<include>**/*.properties</include>
</includes>
</testResource>
<testResource>
<directory>src/test/resources</directory>
<filtering>false</filtering>
<excludes>
<exclude>**/*.xml</exclude>
<exclude>**/*.txt</exclude>
<exclude>**/*.properties</exclude>
</excludes>
</testResource>
<testResource>
<directory>../api/src/test/resources</directory>
</testResource>
</testResources>
</build>
</project>
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
/*
* 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.patienttflags;

import ca.uhn.fhir.rest.api.server.IBundleProvider;
import org.hl7.fhir.r4.model.Flag;
import org.openmrs.module.fhir2.api.FhirService;
import org.openmrs.module.patienttflags.search.param.FlagSearchParams;

import javax.annotation.Nonnull;

public interface FhirFlagService extends FhirService<Flag> {

@Override
Flag get(@Nonnull String uuid);

IBundleProvider searchFlags(FlagSearchParams patient);
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
/*
* 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.patienttflags.dao;

import org.openmrs.module.fhir2.api.dao.FhirDao;
import org.openmrs.module.fhir2.api.search.param.SearchParameterMap;
import org.openmrs.module.patientflags.PatientFlag;

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

public interface FhirFlagDao extends FhirDao<PatientFlag> {

@Override
PatientFlag get(@Nonnull String uuid);

@Override
List<PatientFlag> getSearchResults(@Nonnull SearchParameterMap theParams);
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,69 @@
/*
* 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.patienttflags.dao.impl;

import ca.uhn.fhir.rest.param.DateRangeParam;
import ca.uhn.fhir.rest.param.ReferenceAndListParam;
import ca.uhn.fhir.rest.param.TokenAndListParam;
import lombok.Setter;
import org.hibernate.Criteria;
import org.openmrs.module.fhir2.FhirConstants;
import org.openmrs.module.fhir2.api.dao.impl.BaseFhirDao;
import org.openmrs.module.fhir2.api.search.param.SearchParameterMap;
import org.openmrs.module.patientflags.PatientFlag;
import org.openmrs.module.patienttflags.dao.FhirFlagDao;
import org.springframework.stereotype.Component;

import java.util.Optional;

import static org.hibernate.criterion.Restrictions.eq;


@Component
@Setter
public class FhirFlagDaoImpl extends BaseFhirDao<PatientFlag> implements FhirFlagDao {

/**
* @param criteria
* @param theParams
*/
@Override
protected void setupSearchParams(Criteria criteria, SearchParameterMap theParams) {
theParams.getParameters().forEach(entry -> {
switch (entry.getKey()) {
case FhirConstants.PATIENT_REFERENCE_SEARCH_HANDLER:
entry.getValue().forEach(param -> handlePatientReference(criteria, (ReferenceAndListParam) param.getParam()));
break;
case FhirConstants.CATEGORY_SEARCH_HANDLER:
entry.getValue().forEach(param -> handleCategory(criteria, (TokenAndListParam) param.getParam()));
break;
case FhirConstants.DATE_RANGE_SEARCH_HANDLER:
entry.getValue().forEach(param -> handleDateRange("dateCreated", (DateRangeParam) param.getParam()).ifPresent(criteria::add));
break;
case FhirConstants.CODED_SEARCH_HANDLER:
entry.getValue().forEach(param -> handleCode(criteria, (TokenAndListParam) param.getParam()));
break;
}
});
}

private void handleCode(Criteria criteria, TokenAndListParam code) {
if (code != null)
handleAndListParam(code, (message) -> Optional.of(eq("message", message.getValue()))).ifPresent(criteria::add);
}

private void handleCategory(Criteria criteria, TokenAndListParam category) {
if (category != null) {
criteria.createAlias("flag", "f");
criteria.createAlias("f.tags", "ft");
handleAndListParam(category, (tag) -> Optional.of(eq("ft.name", tag.getValue()))).ifPresent(criteria::add);
}
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,51 @@
/*
* 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.patienttflags.impl;

import ca.uhn.fhir.rest.api.server.IBundleProvider;
import lombok.Getter;
import lombok.Setter;
import org.hl7.fhir.r4.model.Flag;

import org.openmrs.module.fhir2.api.impl.BaseFhirService;
import org.openmrs.module.fhir2.api.search.SearchQuery;
import org.openmrs.module.fhir2.api.search.SearchQueryInclude;
import org.openmrs.module.patientflags.PatientFlag;
import org.openmrs.module.patienttflags.dao.FhirFlagDao;
import org.openmrs.module.patienttflags.search.param.FlagSearchParams;
import org.openmrs.module.patienttflags.FhirFlagService;
import org.openmrs.module.patienttflags.translators.PatientFlagTranslator;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Component;
import org.springframework.transaction.annotation.Transactional;

@Component
@Transactional
@Setter
@Getter
public class FhirFlagServiceImpl extends BaseFhirService<Flag, PatientFlag> implements FhirFlagService {

@Autowired
private FhirFlagDao dao;

@Autowired
private PatientFlagTranslator translator;

@Autowired
private SearchQueryInclude<Flag> searchQueryInclude;

@Autowired
private SearchQuery<PatientFlag, Flag, FhirFlagDao, PatientFlagTranslator, SearchQueryInclude<Flag>> searchQuery;

@Override
public IBundleProvider searchFlags(FlagSearchParams patient) {
return searchQuery.getQueryResults(patient.toSearchParameterMap(), dao, translator, searchQueryInclude);
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,77 @@
/*
* 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.patienttflags.providers;

import ca.uhn.fhir.rest.annotation.IdParam;
import ca.uhn.fhir.rest.annotation.OptionalParam;
import ca.uhn.fhir.rest.annotation.Read;
import ca.uhn.fhir.rest.annotation.Search;
import ca.uhn.fhir.rest.api.server.IBundleProvider;
import ca.uhn.fhir.rest.param.DateRangeParam;
import ca.uhn.fhir.rest.param.ReferenceAndListParam;
import ca.uhn.fhir.rest.param.StringAndListParam;
import ca.uhn.fhir.rest.param.TokenAndListParam;
import ca.uhn.fhir.rest.server.IResourceProvider;
import ca.uhn.fhir.rest.server.exceptions.ResourceNotFoundException;
import lombok.Setter;
import org.hl7.fhir.instance.model.api.IBaseResource;
import org.hl7.fhir.r4.model.IdType;
import org.hl7.fhir.r4.model.Flag;
import org.hl7.fhir.r4.model.Patient;
import org.openmrs.module.fhir2.api.annotations.R4Provider;
import org.openmrs.module.patienttflags.FhirFlagService;
import org.openmrs.module.patienttflags.search.param.FlagSearchParams;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Component;

import javax.annotation.Nonnull;

import static lombok.AccessLevel.PACKAGE;

@Component("FlagFhirR4ResourceProvider")
@R4Provider
@Setter
public class FlagFhirResourceProvider implements IResourceProvider {

@Autowired
private FhirFlagService flagService;

@Override
public Class<? extends IBaseResource> getResourceType() {
return Flag.class;
}

@Read
public Flag getFlagById(@IdParam @Nonnull IdType id) {
Flag flag = flagService.get(id.getIdPart());
if (flag == null) {
throw new ResourceNotFoundException("Could not find Flag with Id " + id.getIdPart());
}
return flag;
}

@Search
public IBundleProvider searchFlags(@OptionalParam(name = Flag.SP_PATIENT, chainWhitelist = { "", Patient.SP_IDENTIFIER,
Patient.SP_GIVEN, Patient.SP_FAMILY, Patient.SP_NAME }, targetTypes = Patient.class) ReferenceAndListParam patientReference,
@OptionalParam(name = Flag.SP_RES_ID) TokenAndListParam id,
@OptionalParam(name = "code") TokenAndListParam codeParam,
@OptionalParam(name = "category") TokenAndListParam category,
@OptionalParam(name = Flag.SP_DATE) DateRangeParam dateRangeParam) {

FlagSearchParams searchParams = new FlagSearchParams();
searchParams.setPatient(patientReference);
searchParams.setCategory(category);
searchParams.setCode(codeParam);
searchParams.setDate(dateRangeParam);
searchParams.setId(id);
return flagService.searchFlags(searchParams);
}

}
Loading