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

Feature mal #515

Open
wants to merge 8 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
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: 3 additions & 0 deletions .vscode/settings.json
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@
"java.test.defaultConfig": "test-config",
"java.checkstyle.configuration": "${workspaceFolder}/config/checkstyle/checkstyle.xml",
"java.checkstyle.version": "9.2.1",
"java.format.settings.url": "https://raw.githubusercontent.com/google/styleguide/gh-pages/eclipse-java-google-style.xml",
"cSpell.enabledLanguageIds": [
"java",
"json",
Expand All @@ -34,6 +35,7 @@
"autoconfigure",
"BCSEHEDISMY",
"CAREGAP",
"cdshooks",
"Checkstyle",
"classpath",
"Codeable",
Expand All @@ -50,6 +52,7 @@
"mgsc",
"multiversion",
"mvnw",
"NOCHANGE",
"numer",
"opencds",
"pdmp",
Expand Down
12 changes: 11 additions & 1 deletion core/pom.xml
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
<?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">
<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.opencds.cqf.ruler</groupId>
Expand Down Expand Up @@ -117,4 +118,13 @@
</dependency>

</dependencies>

<build>
<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-checkstyle-plugin</artifactId>
</plugin>
</plugins>
</build>
</project>
49 changes: 26 additions & 23 deletions core/src/main/java/org/opencds/cqf/ruler/Server.java
Original file line number Diff line number Diff line change
@@ -1,13 +1,10 @@
package org.opencds.cqf.ruler;

import static com.google.common.base.MoreObjects.firstNonNull;

import java.util.List;
import java.util.Map;
import java.util.stream.Collectors;

import javax.servlet.ServletException;

import org.hl7.fhir.dstu3.model.CapabilityStatement;
import org.hl7.fhir.instance.model.api.IBaseConformance;
import org.opencds.cqf.ruler.api.Interceptor;
Expand All @@ -23,7 +20,6 @@
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.context.ApplicationContext;

import ca.uhn.fhir.context.FhirVersionEnum;
import ca.uhn.fhir.context.support.IValidationSupport;
import ca.uhn.fhir.jpa.api.config.DaoConfig;
Expand Down Expand Up @@ -67,7 +63,7 @@ public Server() {
}

@Override
@SuppressWarnings({ "rawtypes", "unchecked" })
@SuppressWarnings({"rawtypes", "unchecked"})
protected void initialize() throws ServletException {
super.initialize();

Expand All @@ -76,7 +72,8 @@ protected void initialize() throws ServletException {
this.registerProvider(valueSetOperationProvider);

log.info("Loading operation providers from plugins");
Map<String, OperationProvider> providers = applicationContext.getBeansOfType(OperationProvider.class);
Map<String, OperationProvider> providers =
applicationContext.getBeansOfType(OperationProvider.class);
for (OperationProvider o : providers.values()) {
log.info("Registering {}", o.getClass().getName());
this.registerProvider(o);
Expand All @@ -88,9 +85,10 @@ protected void initialize() throws ServletException {
log.info("Registering {} interceptor", o.getClass().getName());
this.registerInterceptor(o);
}

log.info("Loading metadata extenders from plugins");
Map<String, MetadataExtender> extenders = applicationContext.getBeansOfType(MetadataExtender.class);
Map<String, MetadataExtender> extenders =
applicationContext.getBeansOfType(MetadataExtender.class);
for (MetadataExtender o : extenders.values()) {
log.info("Found {} extender", o.getClass().getName());
}
Expand All @@ -101,38 +99,43 @@ protected void initialize() throws ServletException {
if (fhirVersion == FhirVersionEnum.DSTU2) {
List<MetadataExtender<Conformance>> extenderList = extenders.values().stream()
.map(x -> (MetadataExtender<Conformance>) x).collect(Collectors.toList());
ExtensibleJpaConformanceProviderDstu2 confProvider = new ExtensibleJpaConformanceProviderDstu2(this,
myFhirSystemDao,
myDaoConfig, extenderList);
confProvider.setImplementationDescription(firstNonNull(implementationDescription, "CQF RULER DSTU2 Server"));
ExtensibleJpaConformanceProviderDstu2 confProvider =
new ExtensibleJpaConformanceProviderDstu2(this, myFhirSystemDao, myDaoConfig,
extenderList);
confProvider.setImplementationDescription(
firstNonNull(implementationDescription, "CQF RULER DSTU2 Server"));
setServerConformanceProvider(confProvider);
} else {
if (fhirVersion == FhirVersionEnum.DSTU3) {
List<MetadataExtender<CapabilityStatement>> extenderList = extenders.values().stream()
.map(x -> (MetadataExtender<CapabilityStatement>) x).collect(Collectors.toList());
ExtensibleJpaConformanceProviderDstu3 confProvider = new ExtensibleJpaConformanceProviderDstu3(this,
myFhirSystemDao, myDaoConfig, mySearchParamRegistry, extenderList);
confProvider
.setImplementationDescription(firstNonNull(implementationDescription, "CQF RULER DSTU3 Server"));
ExtensibleJpaConformanceProviderDstu3 confProvider =
new ExtensibleJpaConformanceProviderDstu3(this, myFhirSystemDao, myDaoConfig,
mySearchParamRegistry, extenderList);
confProvider.setImplementationDescription(
firstNonNull(implementationDescription, "CQF RULER DSTU3 Server"));
setServerConformanceProvider(confProvider);
} else if (fhirVersion == FhirVersionEnum.R4) {
List<MetadataExtender<IBaseConformance>> extenderList = extenders.values().stream()
.map(x -> (MetadataExtender<IBaseConformance>) x).collect(Collectors.toList());
ExtensibleJpaCapabilityStatementProvider confProvider = new ExtensibleJpaCapabilityStatementProvider(this,
myFhirSystemDao, myDaoConfig, mySearchParamRegistry, myValidationSupport, extenderList);
confProvider.setImplementationDescription(firstNonNull(implementationDescription, "CQF RULER R4 Server"));
ExtensibleJpaCapabilityStatementProvider confProvider =
new ExtensibleJpaCapabilityStatementProvider(this, myFhirSystemDao, myDaoConfig,
mySearchParamRegistry, myValidationSupport, extenderList);
confProvider.setImplementationDescription(
firstNonNull(implementationDescription, "CQF RULER R4 Server"));
setServerConformanceProvider(confProvider);
} else if (fhirVersion == FhirVersionEnum.R5) {
List<MetadataExtender<IBaseConformance>> extenderList = extenders.values().stream()
.map(x -> (MetadataExtender<IBaseConformance>) x).collect(Collectors.toList());
ExtensibleJpaCapabilityStatementProvider confProvider = new ExtensibleJpaCapabilityStatementProvider(this,
myFhirSystemDao, myDaoConfig, mySearchParamRegistry, myValidationSupport, extenderList);
confProvider.setImplementationDescription(firstNonNull(implementationDescription, "CQF RULER R5 Server"));
ExtensibleJpaCapabilityStatementProvider confProvider =
new ExtensibleJpaCapabilityStatementProvider(this, myFhirSystemDao, myDaoConfig,
mySearchParamRegistry, myValidationSupport, extenderList);
confProvider.setImplementationDescription(
firstNonNull(implementationDescription, "CQF RULER R5 Server"));
setServerConformanceProvider(confProvider);
} else {
throw new IllegalStateException();
}
}

}
}
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,6 @@
import ca.uhn.fhir.jpa.api.model.DaoMethodOutcome;
import ca.uhn.fhir.jpa.searchparam.SearchParameterMap;
import ca.uhn.fhir.rest.api.server.RequestDetails;
import ca.uhn.fhir.rest.server.exceptions.ResourceNotFoundException;

/**
* Simulate FhirDal operations until that's fully baked. This interface is
Expand Down
248 changes: 248 additions & 0 deletions plugin/atr/MAL-API's.postman_collection.json

Large diffs are not rendered by default.

26 changes: 26 additions & 0 deletions plugin/atr/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
# Plugin

This is the repository for reference implementation of the DaVinci Risk Based Contracts Member Attribution List project.

## Setup

To setup the project follow the instructions mentioned [here](https://github.com/DBCG/cqf-ruler#development)

## Usage

To use the Member Attribution List API's import the [Postman collection](https://github.com/DBCG/cqf-ruler/blob/feature-mal/mal/MAL-API's.postman_collection.json) added as part of this plugin into the Postman client.

### Instructions to test the MAL API's
1. Create a Bundle of type transaction and add Patient, Coverage, RelatedPerson, Practitioner, PractitionerRole, Organization, Location resources as bundle entries.
2. Use the POST Bundle request from postman collection to save all the resources into database.
3. Create a Group resource and use POST Group request from postman collection to save the Group resource into database.
4. Use Group Member add request from postman collection to add a new member into the `Group.member` data element.
5. Use Group Member remove request from postman collection to remove a member from the `Group.member` data element.
6. Use Group Export request from postman collection to initiate the request to export all the members data.
7. Use the Polling Location endpoint received in the response headers of Group Export Operation call to know the status of export operation.
8. Use the links received in the response body for each resource to download the data from Binary resource.


## Docker

The Dockerfile builds on top of the base cqf-ruler image and simply copies the jar into the `plugin` directory of the image.
20 changes: 20 additions & 0 deletions plugin/atr/pom.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
<?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.opencds.cqf.ruler</groupId>
<artifactId>cqf-ruler-plugin</artifactId>
<version>0.5.0-SNAPSHOT</version>
</parent>

<artifactId>cqf-ruler-atr</artifactId>
<dependencies>
<dependency>
<groupId>org.opencds.cqf.ruler</groupId>
<artifactId>cqf-ruler-test</artifactId>
<version>0.5.0-SNAPSHOT</version>
<scope>test</scope>
</dependency>
</dependencies>
</project>
38 changes: 38 additions & 0 deletions plugin/atr/src/main/java/org/opencds/cqf/ruler/atr/AtrConfig.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
package org.opencds.cqf.ruler.atr;

import org.opencds.cqf.ruler.api.OperationProvider;
import org.opencds.cqf.ruler.atr.service.MalService;
import org.opencds.cqf.ruler.external.annotations.OnR4Condition;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Conditional;
import org.springframework.context.annotation.Configuration;


/**
* The Class MALConfig.
*/
@Configuration
public class AtrConfig {

/**
* Member add provider.
*
* @return the operation provider
*/
@Bean
@Conditional(OnR4Condition.class)
public OperationProvider memberAddProvider() {
return new MalProvider();
}

/**
* Mal service.
*
* @return the MAL service
*/
@Bean
@Conditional(OnR4Condition.class)
public MalService malService() {
return new MalService();
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,44 @@
package org.opencds.cqf.ruler.atr;

import org.hl7.fhir.r4.model.Group;
import org.hl7.fhir.r4.model.IdType;
import org.hl7.fhir.r4.model.Parameters;
import org.opencds.cqf.ruler.atr.service.MalService;
import org.opencds.cqf.ruler.provider.DaoRegistryOperationProvider;
import org.springframework.beans.factory.annotation.Autowired;
import ca.uhn.fhir.model.api.annotation.Description;
import ca.uhn.fhir.rest.annotation.IdParam;
import ca.uhn.fhir.rest.annotation.Operation;
import ca.uhn.fhir.rest.annotation.ResourceParam;
import ca.uhn.fhir.rest.api.server.RequestDetails;


public class MalProvider extends DaoRegistryOperationProvider {
@Autowired
private MalService malService;

/**
* Member add.
*
* @param groupId the group id
* @param requestDetails the request details
* @param request the request
* @param response the response
*/
@Description(shortDefinition = "Add new Member to the Group",
value = "Implements the $member-add operation")
@Operation(idempotent = true, name = "$member-add", type = Group.class)
public Group memberAdd(@IdParam IdType groupId, @ResourceParam Parameters theParameters,
RequestDetails requestDetails) {
return malService.processAddMemberToGroup(theParameters, groupId, requestDetails);
}


@Description(shortDefinition = "Remove Member from the Group",
value = "Implements the $member-remove operation")
@Operation(idempotent = true, name = "$member-remove")
public Group memberRemove(@IdParam IdType groupId, @ResourceParam Parameters theParameters,
RequestDetails requestDetails) {
return malService.processRemoveMemberToGroup(theParameters, groupId.getIdPart());
}
}
Loading