Skip to content

Commit

Permalink
Merge branch 'main' of https://github.com/IBM/FHIR into main
Browse files Browse the repository at this point in the history
  • Loading branch information
prb112 committed Nov 5, 2021
2 parents 48ae33e + 9fae77b commit a4cece3
Show file tree
Hide file tree
Showing 14 changed files with 381 additions and 34 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
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,7 @@
import com.ibm.fhir.database.utils.api.TableSpaceRemovalException;
import com.ibm.fhir.database.utils.api.TenantStatus;
import com.ibm.fhir.database.utils.api.UndefinedNameException;
import com.ibm.fhir.database.utils.api.UniqueConstraintViolationException;
import com.ibm.fhir.database.utils.common.DataDefinitionUtil;
import com.ibm.fhir.database.utils.common.JdbcConnectionProvider;
import com.ibm.fhir.database.utils.common.JdbcPropertyAdapter;
Expand Down Expand Up @@ -384,6 +385,9 @@ protected void updateSchemas() {
IDatabaseAdapter adapter = getDbAdapter(dbType, connectionPool);
try (ITransaction tx = transactionProvider.getTransaction()) {
CreateControl.createTableIfNeeded(schema.getAdminSchemaName(), adapter);
} catch (UniqueConstraintViolationException x) {
// Race condition - two or more instances trying to create the CONTROL table
throw new ConcurrentUpdateException("Concurrent update - create control table");
}

if (updateFhirSchema) {
Expand Down Expand Up @@ -2531,6 +2535,9 @@ protected void logStatusMessage(int status) {
case EXIT_RUNTIME_ERROR:
logger.severe("SCHEMA CHANGE: RUNTIME ERROR");
break;
case EXIT_CONCURRENT_UPDATE:
logger.warning("SCHEMA CHANGE: CONCURRENT UPDATE");
break;
case EXIT_VALIDATION_FAILED:
logger.warning("SCHEMA CHANGE: FAILED");
break;
Expand Down Expand Up @@ -2582,7 +2589,8 @@ public static void main(String[] args) {
logger.warning("Tablespace removal is not complete, as an async dependency has not finished dettaching. Please re-try.");
exitStatus = EXIT_TABLESPACE_REMOVAL_NOT_COMPLETE;
} catch (ConcurrentUpdateException x) {
logger.log(Level.WARNING, "Update is already running. Please re-try later.", x);
// We handle this, so no need to log the exception
logger.log(Level.WARNING, "Please try again later: update is already running - " + x.getMessage());
exitStatus = EXIT_CONCURRENT_UPDATE;
} catch (DatabaseNotReadyException x) {
logger.log(Level.SEVERE, "The database is not yet available. Please re-try.", x);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -95,6 +95,9 @@ private class ByteInputStream extends InputStream {
// each read stream gets its own read offset in the buffer
private int posn = 0;

// maintains the position of the last call to mark
private int mark = 0;

@Override
public int read() throws IOException {
return posn < offset ? (buffer[posn++] & 0xff) : -1;
Expand Down Expand Up @@ -139,6 +142,21 @@ public long skip(long n) {
posn += n;
return n;
}

@Override
public void reset() throws IOException {
posn = mark;
}

@Override
public void mark(int readlimit) {
mark = posn;
}

@Override
public boolean markSupported() {
return true;
}
}

/**
Expand Down Expand Up @@ -221,7 +239,7 @@ public InputStream inputStream() {
public ByteBuffer wrap() {
return ByteBuffer.wrap(this.buffer, 0, size()).asReadOnlyBuffer();
}

/**
* Reset the offset to make the buffer appear empty. Does not change the current
* length (capacity). Note that any streams currently being used to read the data
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -49,9 +49,42 @@ public void testBasicOperation() throws IOException {
assertEquals(compare(source, 0, source.length-1, readBack2, 0, len2-1), 0);
}

@Test
public void testBasicOperationWithMarkAndReset() throws IOException {
InputOutputByteStream iobs = new InputOutputByteStream(10);
byte[] source = {0x01, 0x02, 0x03, 0x04};
OutputStream os = iobs.outputStream();
os.write(source);

// read back and check
InputStream is = iobs.inputStream();
byte[] readBack = new byte[8];
int len = is.read(readBack);
assertEquals(len, source.length);
assertEquals(compare(source, 0, source.length-1, readBack, 0, len-1), 0);

// If it's not supported then it'll throw an exception.
is.reset();

// Read 3 of 4 bytes, and then iterate.
byte[] readReset = new byte[3];
int lenReset = is.read(readReset);
assertEquals(lenReset, 3);

// Fixing the mark to the current posn
is.mark(100);
lenReset = is.read(readReset);
assertEquals(lenReset, 1);

// Reset to marked point
is.reset();
lenReset = is.read(readReset);
assertEquals(lenReset, 1);
}

/**
* Check that the two arrays are equal. Can't use {@link Arrays#compare(byte[], int, int, byte[], int, int)}
* because that's since J9 and we still supprt J8.
* because that's since Java9 and we still support Java8.
* @param left
* @param leftFrom
* @param leftTo
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>
Loading

0 comments on commit a4cece3

Please sign in to comment.