Skip to content

Commit

Permalink
add onedirectory url to system settings.
Browse files Browse the repository at this point in the history
  • Loading branch information
ihabzee committed Nov 4, 2024
1 parent ea7b296 commit 8f17865
Show file tree
Hide file tree
Showing 3 changed files with 60 additions and 3 deletions.
32 changes: 31 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
@@ -1,2 +1,32 @@
# RedcapOneDirectoryLookup
EM to lookup users using OneDirectory(Elastic Cache)
The RedcapOneDirectoryLookup External Module allows users to search for information within the Stanford University, Stanford Health Care, and Stanford Children's Hospital directories using the OneDirectory Elastic Search engine. This module provides an efficient, privacy-compliant interface for retrieving user information across these organizations.

### Features
1. Comprehensive Search: Search across all available attributes in the OneDirectory database.
2. Stanford Affiliates Only: Retrieves information for Stanford University, Stanford Health Care, and Stanford Children's Hospital users.
3. Privacy-Conscious: Excludes private Stanford University users to ensure compliance with privacy standards.
4. Efficient Querying: Uses ElasticSearch for fast and responsive search capabilities.
### Requirements
- REDCap Admin Access: To configure and enable the External Module (EM) on REDCap projects.
- OneDirectory Access: URL endpoint to connect with OneDirectory.
### Configuration
1. Enable the Module: Enable RedcapOneDirectoryLookup on your REDCap project.
2. Define Lookup Field: In the EM settings, specify the main field in your project that will be used for user lookup. This field will contain the search term passed to OneDirectory.
3. Attribute Mapping: Map the OneDirectory attributes in the EM settings to fields in your REDCap project. The module will populate these mapped fields with data returned from OneDirectory.
### Supported Fields
The following attributes are currently supported by OneDirectory:

1. OneDirectoryId
2. affiliate
3. jobId
4. first_name
5. last_name
6. fullname
7. phone
8. phone2
9. email
10. title
11. SunetId or SID

### License
This project is licensed under the MIT License. See the LICENSE file for more details.
25 changes: 23 additions & 2 deletions RedcapOneDirectoryLookup.php
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ class RedcapOneDirectoryLookup extends \ExternalModules\AbstractExternalModule

private $client;

const ELASTIC_CACHE_URL = "https://onedirectory.stanford.edu/api/onedirectory/_search?size=50";
private $serverURL = '';


public function __construct()
Expand Down Expand Up @@ -65,7 +65,7 @@ public function searchUsers($term)
// $search->query->multi_match->fields = [ "first_name", "last_name", "fullname", "email", "affiliate", "title", "suid" ];

// Do a search
$q = $this->getClient()->request('GET', self::ELASTIC_CACHE_URL, [
$q = $this->getClient()->request('GET', $this->getServerURL(), [
'body' => json_encode($search)
]);

Expand Down Expand Up @@ -190,4 +190,25 @@ public function setClient(\GuzzleHttp\Client $client)
{
$this->client = $client;
}

/**
* @return string
*/
public function getServerURL(): string
{
if(!$this->serverURL){
$this->setServerURL($this->getSystemSetting('onedirectory-url'));
}
return $this->serverURL;
}

/**
* @param string $serverURL
*/
public function setServerURL(string $serverURL): void
{
$this->serverURL = $serverURL;
}


}
6 changes: 6 additions & 0 deletions config.json
Original file line number Diff line number Diff line change
Expand Up @@ -126,6 +126,12 @@
}
],
"system-settings": [
{
"key": "onedirectory-url",
"name": "<b>URL to Onedirectory server:</b>",
"required": true,
"type": "text"
},
{
"key": "enable-system-debug-logging",
"name": "<b>Enable Debug Logging (system-wide)</b><i>(optional)</i> Requires installation and configuration of emLogger",
Expand Down

0 comments on commit 8f17865

Please sign in to comment.