Skip to content

Commit

Permalink
Merge pull request #2928 from IBM/mm-demo
Browse files Browse the repository at this point in the history
Demo and Fix for Member Match
  • Loading branch information
prb112 authored Nov 5, 2021
2 parents 50edac8 + d5cc277 commit 9fae77b
Show file tree
Hide file tree
Showing 11 changed files with 319 additions and 31 deletions.
8 changes: 8 additions & 0 deletions demo/fhir-operation-member-match-demo/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
# $member-match operation demo
The contents in this module are from HL7 FHIR® Da Vinci Health Record Exchange (HRex) 0.2.0 - STU R1 - 2nd ballot. The [$member-match](http://build.fhir.org/ig/HL7/davinci-ehrx/OperationDefinition-member-match.html) operation is used to demonstrate that a custom strategy can and is used.

You must install the fhir-operation-member-match jar in the userlib (hrex, us-core as well).

```
mvn clean install -DskipTests
```
61 changes: 61 additions & 0 deletions demo/fhir-operation-member-match-demo/pom.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,61 @@
<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>com.ibm.fhir</groupId>
<artifactId>fhir-parent</artifactId>
<version>4.10.0-SNAPSHOT</version>
<relativePath>../../fhir-parent</relativePath>
</parent>
<artifactId>fhir-operation-member-match-demo</artifactId>
<dependencies>
<dependency>
<groupId>jakarta.ws.rs</groupId>
<artifactId>jakarta.ws.rs-api</artifactId>
<scope>provided</scope>
</dependency>
<dependency>
<groupId>${project.groupId}</groupId>
<artifactId>fhir-server-spi</artifactId>
<version>${project.version}</version>
<scope>provided</scope>
</dependency>
<dependency>
<groupId>${project.groupId}</groupId>
<artifactId>fhir-server</artifactId>
<version>${project.version}</version>
<scope>provided</scope>
</dependency>
<dependency>
<groupId>${project.groupId}</groupId>
<artifactId>fhir-model</artifactId>
<version>${project.version}</version>
<scope>provided</scope>
</dependency>
<dependency>
<groupId>${project.groupId}</groupId>
<artifactId>fhir-registry</artifactId>
<version>${project.version}</version>
<scope>provided</scope>
</dependency>
<dependency>
<groupId>${project.groupId}</groupId>
<artifactId>fhir-ig-us-core</artifactId>
<version>${project.version}</version>
<scope>provided</scope>
</dependency>
<dependency>
<groupId>${project.groupId}</groupId>
<artifactId>fhir-ig-davinci-hrex</artifactId>
<version>${project.version}</version>
<scope>provided</scope>
</dependency>
<dependency>
<groupId>com.ibm.fhir</groupId>
<artifactId>fhir-operation-member-match</artifactId>
<version>4.10.0-SNAPSHOT</version>
<scope>provided</scope>
</dependency>
</dependencies>
</project>
Original file line number Diff line number Diff line change
@@ -0,0 +1,45 @@
/*
* (C) Copyright IBM Corp. 2021
*
* SPDX-License-Identifier: Apache-2.0
*/

package demo.ibm.fhir.operation.davinci.hrex.provider.strategy;

import java.util.logging.Logger;

import com.ibm.fhir.config.PropertyGroup;
import com.ibm.fhir.exception.FHIROperationException;
import com.ibm.fhir.model.resource.Parameters;
import com.ibm.fhir.operation.davinci.hrex.configuration.ConfigurationFactory;
import com.ibm.fhir.operation.davinci.hrex.provider.strategy.DefaultMemberMatchStrategy;
import com.ibm.fhir.operation.davinci.hrex.provider.strategy.MemberMatchResult;

/**
* Used to Demonstrate a custom Strategy
*/
public class DemoStrategy extends DefaultMemberMatchStrategy {

private static final Logger LOG = Logger.getLogger(DemoStrategy.class.getSimpleName());

@Override
public String getMemberMatchIdentifier() {
return "demo";
}

@Override
public void validate(Parameters input) throws FHIROperationException {
LOG.info("Validating Content for strategy - " + this.getMemberMatchIdentifier());
super.validate(input);
}

@Override
public MemberMatchResult executeMemberMatch() throws FHIROperationException {
LOG.info("executeMemberMatch for strategy - " + this.getMemberMatchIdentifier());
PropertyGroup group = ConfigurationFactory.factory().getConfigurationAdapter().getExtendedStrategyPropertyGroup();
if (group != null) {
LOG.info("executeMemberMatch Extend Strategy Config is " + group.getJsonObj());
}
return super.executeMemberMatch();
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
demo.ibm.fhir.operation.davinci.hrex.provider.strategy.DemoStrategy
18 changes: 9 additions & 9 deletions docs/src/pages/guides/FHIRServerUsersGuide.md
Original file line number Diff line number Diff line change
Expand Up @@ -2207,9 +2207,9 @@ This section contains reference information about each of the configuration prop
|`fhirServer/bulkdata/storageProviders/<source>/requiresAccessToken`|boolean|controls the `$bulkdata-status` response to indicate Bulk Data storageprovider requires an accessToken using `requiresAccessToken`.|
|`fhirServer/operations/erase/enabled`|boolean|Enables the $erase operation|
|`fhirServer/operations/erase/allowedRoles`|list|The list of allowed roles, allowed entries are: `FHIRUsers` every authenticated user, `FHIROperationAdmin` which is authenticated `FHIRAdmin` users|
|`fhirServer/operations/member-match/enabled`|boolean|Enables or disables the $member-match|
|`fhirServer/operations/member-match/strategy`|string|The key identifying the Member Match strategy|
|`fhirServer/operations/member-match/extendedProps`|object|The extended options for the extended member match implementation|
|`fhirServer/operations/membermatch/enabled`|boolean|Enables or disables the $member-match|
|`fhirServer/operations/membermatch/strategy`|string|The key identifying the Member Match strategy|
|`fhirServer/operations/membermatch/extendedProps`|object|The extended options for the extended member match implementation|


### 5.1.2 Default property values
Expand Down Expand Up @@ -2351,9 +2351,9 @@ This section contains reference information about each of the configuration prop
|`fhirServer/bulkdata/storageProviders/<source>/requiresAccessToken`|false|
|`fhirServer/operations/erase/enabled`|false|
|`fhirServer/operations/erase/allowedRoles`|empty, all roles|
|`fhirServer/operations/member-match/enabled`|true|
|`fhirServer/operations/member-match/strategy`|default|
|`fhirServer/operations/member-match/extendedProps`|empty|
|`fhirServer/operations/membermatch/enabled`|true|
|`fhirServer/operations/membermatch/strategy`|default|
|`fhirServer/operations/membermatch/extendedProps`|empty|

### 5.1.3 Property attributes
Depending on the context of their use, config properties can be:
Expand Down Expand Up @@ -2527,9 +2527,9 @@ must restart the server for that change to take effect.
|`fhirServer/bulkdata/storageProviders/<source>/requiresAccessToken`|Y|Y|
|`fhirServer/operations/erase/enabled`|Y|Y|
|`fhirServer/operations/erase/allowedRoles`|Y|Y|
|`fhirServer/operations/member-match/enabled`|Y|Y|
|`fhirServer/operations/member-match/strategy`|Y|Y|
|`fhirServer/operations/member-match/extendedProps`|Y|Y|
|`fhirServer/operations/membermatch/enabled`|Y|Y|
|`fhirServer/operations/membermatch/strategy`|Y|Y|
|`fhirServer/operations/membermatch/extendedProps`|Y|Y|

## 5.2 Keystores, truststores, and the IBM FHIR server

Expand Down
8 changes: 8 additions & 0 deletions operation/fhir-operation-member-match-demo/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
# $member-match operation demo
The contents in this module are from HL7 FHIR® Da Vinci Health Record Exchange (HRex) 0.2.0 - STU R1 - 2nd ballot. The [$member-match](http://build.fhir.org/ig/HL7/davinci-ehrx/OperationDefinition-member-match.html) operation is used to demonstrate that a custom strategy can and is used.

You must install the fhir-operation-member-match jar in the userlib (hrex, us-core as well).

```
mvn clean install -DskipTests
```
61 changes: 61 additions & 0 deletions operation/fhir-operation-member-match-demo/pom.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,61 @@
<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>com.ibm.fhir</groupId>
<artifactId>fhir-parent</artifactId>
<version>4.10.0-SNAPSHOT</version>
<relativePath>../../fhir-parent</relativePath>
</parent>
<artifactId>fhir-operation-member-match-demo</artifactId>
<dependencies>
<dependency>
<groupId>jakarta.ws.rs</groupId>
<artifactId>jakarta.ws.rs-api</artifactId>
<scope>provided</scope>
</dependency>
<dependency>
<groupId>${project.groupId}</groupId>
<artifactId>fhir-server-spi</artifactId>
<version>${project.version}</version>
<scope>provided</scope>
</dependency>
<dependency>
<groupId>${project.groupId}</groupId>
<artifactId>fhir-server</artifactId>
<version>${project.version}</version>
<scope>provided</scope>
</dependency>
<dependency>
<groupId>${project.groupId}</groupId>
<artifactId>fhir-model</artifactId>
<version>${project.version}</version>
<scope>provided</scope>
</dependency>
<dependency>
<groupId>${project.groupId}</groupId>
<artifactId>fhir-registry</artifactId>
<version>${project.version}</version>
<scope>provided</scope>
</dependency>
<dependency>
<groupId>${project.groupId}</groupId>
<artifactId>fhir-ig-us-core</artifactId>
<version>${project.version}</version>
<scope>provided</scope>
</dependency>
<dependency>
<groupId>${project.groupId}</groupId>
<artifactId>fhir-ig-davinci-hrex</artifactId>
<version>${project.version}</version>
<scope>provided</scope>
</dependency>
<dependency>
<groupId>com.ibm.fhir</groupId>
<artifactId>fhir-operation-member-match</artifactId>
<version>4.10.0-SNAPSHOT</version>
<scope>provided</scope>
</dependency>
</dependencies>
</project>
Original file line number Diff line number Diff line change
@@ -0,0 +1,45 @@
/*
* (C) Copyright IBM Corp. 2021
*
* SPDX-License-Identifier: Apache-2.0
*/

package demo.ibm.fhir.operation.davinci.hrex.provider.strategy;

import java.util.logging.Logger;

import com.ibm.fhir.config.PropertyGroup;
import com.ibm.fhir.exception.FHIROperationException;
import com.ibm.fhir.model.resource.Parameters;
import com.ibm.fhir.operation.davinci.hrex.configuration.ConfigurationFactory;
import com.ibm.fhir.operation.davinci.hrex.provider.strategy.DefaultMemberMatchStrategy;
import com.ibm.fhir.operation.davinci.hrex.provider.strategy.MemberMatchResult;

/**
* Used to Demonstrate a custom Strategy
*/
public class DemoStrategy extends DefaultMemberMatchStrategy {

private static final Logger LOG = Logger.getLogger(DemoStrategy.class.getSimpleName());

@Override
public String getMemberMatchIdentifier() {
return "demo";
}

@Override
public void validate(Parameters input) throws FHIROperationException {
LOG.info("Validating Content for strategy - " + this.getMemberMatchIdentifier());
super.validate(input);
}

@Override
public MemberMatchResult executeMemberMatch() throws FHIROperationException {
LOG.info("executeMemberMatch for strategy - " + this.getMemberMatchIdentifier());
PropertyGroup group = ConfigurationFactory.factory().getConfigurationAdapter().getExtendedStrategyPropertyGroup();
if (group != null) {
LOG.info("executeMemberMatch Extend Strategy Config is " + group.getJsonObj());
}
return super.executeMemberMatch();
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
demo.ibm.fhir.operation.davinci.hrex.provider.strategy.DemoStrategy
Original file line number Diff line number Diff line change
Expand Up @@ -148,7 +148,7 @@ public MemberMatchResult executeMemberMatch() throws FHIROperationException {
// defined by the customer, it's all in the Compiler.
String type = "Patient";
String requestUri = FHIRRequestContext.get().getOriginalRequestUri();
LOG.info("SPs for Patient " + patientCompiler.getSearchParameters());
LOG.fine("SPs for Patient " + patientCompiler.getSearchParameters());
Bundle patientBundle = resourceHelper()
.doSearch(type, null, null, patientCompiler.getSearchParameters(), requestUri, null);
int size = patientBundle.getEntry().size();
Expand Down Expand Up @@ -250,13 +250,25 @@ public boolean visit(String elementName, int elementIndex, Identifier identifier
* @param identifier
*/
private void addIdValue(Identifier identifier) {
Uri sys = identifier.getSystem();
com.ibm.fhir.model.type.String val = identifier.getValue();
if (sys != null && sys.getValue() != null) {
this.system = sys.getValue();
}
if (val != null && val.getValue() != null) {
this.value = val.getValue();
if (identifier.getType() != null
&& identifier.getType().getCoding() != null) {
// If there is more than one Coding it has to be MB.
for (Coding coding : identifier.getType().getCoding()) {
if (coding.getSystem() != null
&& "http://terminology.hl7.org/CodeSystem/v2-0203"
.equals(coding.getSystem().getValue())
&& "MB".equals(coding.getCode().getValue())) {
// We only want to extract the code system v2-0203 with MB
Uri sys = identifier.getSystem();
com.ibm.fhir.model.type.String val = identifier.getValue();
if (sys != null && sys.getValue() != null) {
this.system = sys.getValue();
}
if (val != null && val.getValue() != null) {
this.value = val.getValue();
}
}
}
}
}

Expand Down Expand Up @@ -308,7 +320,8 @@ public MemberMatchPatientSearchCompiler() {
* @return
*/
public MultivaluedMap<String,String> getSearchParameters() {
MultivaluedMap<String,String> temp = new MultivaluedHashMap<String,String>(searchParams);

MultivaluedMap<String,String> temp = new MultivaluedHashMap<String, String>(searchParams);
if (!telecom.isEmpty()) {
String val = telecom.stream().collect(Collectors.joining(","));
temp.add("telecom", val);
Expand Down Expand Up @@ -391,15 +404,16 @@ private void addIdValue(Identifier identifier) {
public boolean visit(String elementName, int elementIndex, HumanName humanName) {
// SearchParameter: name
if ("name".equals(elementName)) {
if (humanName.getFamily() != null) {
if (humanName.getFamily() != null && humanName.getFamily().getValue() != null) {
family.add(humanName.getFamily().getValue());
}
given.addAll(
humanName.getGiven()
.stream()
.map(e -> e.getValue())
.filter(Objects::isNull)
.collect(Collectors.toList()));
if (humanName.getGiven() != null && !humanName.getGiven().isEmpty()) {
for (com.ibm.fhir.model.type.String hn : humanName.getGiven()) {
if (hn != null && hn.getValue() != null) {
given.add(hn.getValue());
}
}
}
}
return false;
}
Expand Down
Loading

0 comments on commit 9fae77b

Please sign in to comment.