-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Showing
1 changed file
with
102 additions
and
0 deletions.
There are no files selected for viewing
102 changes: 102 additions & 0 deletions
102
src/main/java/de/samply/directory_sync_service/directory/DirectoryApi.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,102 @@ | ||
package de.samply.directory_sync_service.directory; | ||
|
||
import de.samply.directory_sync_service.directory.model.Biobank; | ||
import de.samply.directory_sync_service.directory.model.DirectoryCollectionGet; | ||
import de.samply.directory_sync_service.directory.model.DirectoryCollectionPut; | ||
import de.samply.directory_sync_service.model.BbmriEricId; | ||
import de.samply.directory_sync_service.model.StarModelData; | ||
import org.hl7.fhir.r4.model.OperationOutcome; | ||
import org.slf4j.Logger; | ||
import org.slf4j.LoggerFactory; | ||
|
||
import java.util.List; | ||
import java.util.Map; | ||
|
||
/** | ||
* The DirectoryApi class provides an interface for interacting with the Directory service. | ||
* This class allows for fetching and updating biobank and collection information, managing star models, | ||
* and performing various validation and correction operations. | ||
* It supports a mock mode for testing purposes, where no real Directory interactions are performed. | ||
*/ | ||
public abstract class DirectoryApi { | ||
protected static final Logger logger = LoggerFactory.getLogger(DirectoryApi.class); | ||
// Setting this variable to true will prevent any contact being made to the Directory. | ||
// All public methods will return feasible fake results. | ||
protected boolean mockDirectory = false; | ||
|
||
/** | ||
* Constructs a new DirectoryApiRest instance. | ||
* If we are not in mocking mode, log in to the Directory. | ||
* | ||
* @param baseUrl The base URL of the Directory service. | ||
* @param mockDirectory If true, the instance operates in mock mode, returning fake data. | ||
* @param username The username for authenticating with the Directory. | ||
* @param password The password for authenticating with the Directory. | ||
*/ | ||
public DirectoryApi(String baseUrl, boolean mockDirectory, String username, String password) { | ||
this.mockDirectory = mockDirectory; | ||
} | ||
|
||
/** | ||
* @return true if this API is accessible, false otherwise. | ||
*/ | ||
public abstract boolean isAvailable(); | ||
|
||
/** | ||
* Log in to the Directory. You can log in as many times as you like. | ||
*/ | ||
public abstract boolean login(); | ||
|
||
/** | ||
* Fetches the Biobank with the given {@code id}. | ||
* | ||
* @param id the ID of the Biobank to fetch. | ||
* @return either the Biobank or null if an error occurs | ||
*/ | ||
public abstract Biobank fetchBiobank(BbmriEricId id); | ||
|
||
/** | ||
* Make API calls to the Directory to fill a DirectoryCollectionGet object containing attributes | ||
* for all of the collections listed in collectionIds. The countryCode is used solely for | ||
* constructing the URL for the API call. | ||
* | ||
* @param countryCode E.g. "DE". | ||
* @param collectionIds IDs of the collections whose data will be harvested. | ||
* @return | ||
*/ | ||
public abstract DirectoryCollectionGet fetchCollectionGetOutcomes(String countryCode, List<String> collectionIds); | ||
|
||
/** | ||
* Send aggregated collection information to the Directory. | ||
* | ||
* @param directoryCollectionPut Summary information about one or more collections | ||
* @return an outcome, either successful or null | ||
*/ | ||
public abstract boolean updateEntities(DirectoryCollectionPut directoryCollectionPut); | ||
|
||
/** | ||
* Updates the Star Model data in the Directory service based on the provided StarModelInputData. | ||
* <p> | ||
* Before sending any star model data to the Directory, the original | ||
* star model data for all known collections will be deleted from the | ||
* Directory. | ||
* | ||
* @param starModelInputData The input data for updating the Star Model. | ||
* @return An OperationOutcome indicating the success or failure of the update. | ||
*/ | ||
public abstract OperationOutcome updateStarModel(StarModelData starModelInputData); | ||
|
||
/** | ||
* Collects diagnosis corrections from the Directory. | ||
* <p> | ||
* It checks with the Directory if the diagnosis codes are valid ICD values and corrects them if necessary. | ||
* <p> | ||
* Two levels of correction are possible: | ||
* <p> | ||
* 1. If the full code is not correct, remove the number after the period and try again. If the new truncated code is OK, use it to replace the existing diagnosis. | ||
* 2. If that doesn't work, replace the existing diagnosis with null. | ||
* | ||
* @param diagnoses A string map containing diagnoses to be corrected. | ||
*/ | ||
public abstract void collectDiagnosisCorrections(Map<String, String> diagnoses); | ||
} |