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

Rel 702 Offsite document storage #7375

Closed
wants to merge 3 commits into from
Closed
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
1 change: 1 addition & 0 deletions .env.example
Original file line number Diff line number Diff line change
Expand Up @@ -2,3 +2,4 @@
OPENEMR__ENVIRONMENT=
# Possible options are true to prevent dated reminders and background apps.Else empty or false. No spaces, no quotes.
OPENEMR__NO_BACKGROUND_TASKS=

16 changes: 16 additions & 0 deletions controllers/C_Document.class.php
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,8 @@
use OpenEMR\Services\FacilityService;
use OpenEMR\Services\PatientService;
use OpenEMR\Events\PatientDocuments\PatientDocumentTreeViewFilterEvent;
use OpenEMR\Events\PatientDocuments\PatientRetrieveOffsiteDocument;
use Symfony\Component\EventDispatcher\EventDispatcherInterface;

class C_Document extends Controller
{
Expand All @@ -39,6 +41,10 @@ class C_Document extends Controller
private $cryptoGen;
private bool $skip_acl_check = false;
private DocumentTemplateService $templateService;
/**
* @var EventDispatcherInterface $eventDispatcher
*/
private $eventDispatcher;

public function __construct($template_mod = "general")
{
Expand Down Expand Up @@ -795,6 +801,16 @@ public function retrieve_action(string $patient_id = null, $document_id, $as_fil
if (file_exists($temp_url)) {
$url = $temp_url;
}
//fire a remote call to see if the file is stored somewhere else
$s3Key = explode("//", $temp_url); //split the url to get the s3 key
$retrieveOffsiteDocument = new PatientRetrieveOffsiteDocument("/" . $s3Key[1]);
$this->eventDispatcher->dispatch($retrieveOffsiteDocument, PatientRetrieveOffsiteDocument::REMOTE_DOCUMENT_LOCATION);
//this is for the s3 bucket module. If the file is not found locally, it will be found remotely
if ($retrieveOffsiteDocument->getOffsiteUrl() != null) {
header('Content-Description: File Transfer');
header("Location: " . $retrieveOffsiteDocument->getOffsiteUrl());
exit;
}

if (!file_exists($url)) {
echo xl('The requested document is not present at the expected location on the filesystem or there are not sufficient permissions to access it.', '', '', ' ') . $url;
Expand Down
72 changes: 72 additions & 0 deletions src/Events/PatientDocuments/PatientDocumentStoreOffsite.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,72 @@
<?php

/**
* PatientDocumentStoreOffsite
*
* @package OpenEMR
* @link http://www.open-emr.org
* @author Sherwin Gaddis <sherwingaddis@gmail.com>
* @copyright Copyright (c) 2024 Sherwin Gaddis <sherwingaddis@gmail.com>
* @license https://github.com/openemr/openemr/blob/master/LICENSE GNU General Public License 3
*/

namespace OpenEMR\Events\PatientDocuments;

use Symfony\Contracts\EventDispatcher\Event;

class PatientDocumentStoreOffsite extends Event
{
const REMOTE_STORAGE_LOCATION = 'documents.remote.storage.location';
private mixed $data;
private string $remoteFileName;
private string $mimeType;
private mixed $category;
private mixed $patientId;

public function __construct($data)
{
$this->data = $data;
}
public function getData()
{
return $this->data;
}

public function setRemoteFileName(string $filename): void
{
$this->remoteFileName = $filename;
}

public function getRemoteFileName(): string
{
return $this->remoteFileName;
}

public function setRemoteMimeType(string $mimeType): void
{
$this->mimeType = $mimeType;
}

public function getRemoteMimeType(): string
{
return $this->mimeType;
}
public function setRemoteCategory($category): void
{
$this->category = $category;
}

public function getRemoteCategory(): mixed
{
return $this->category;
}

public function setPatientId(string $patientId): void
{
$this->patientId = $patientId;
}
public function getPatientId(): mixed
{
return $this->patientId;
}
}
36 changes: 36 additions & 0 deletions src/Events/PatientDocuments/PatientRetrieveOffsiteDocument.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
<?php

/**
* PatientRetrieveOffsiteDocument
*
* @package OpenEMR
* @link http://www.open-emr.org
* @author Sherwin Gaddis <sherwingaddis@gmail.com>
* @copyright Copyright (c) 2024 Sherwin Gaddis <sherwingaddis@gmail.com>
* @license https://github.com/openemr/openemr/blob/master/LICENSE GNU General Public License 3
*/

namespace OpenEMR\Events\PatientDocuments;

use Symfony\Contracts\EventDispatcher\Event;

class PatientRetrieveOffsiteDocument extends Event
{
const REMOTE_DOCUMENT_LOCATION = 'remote.document.retrieve.location';
private string $url;
private $offsiteurl;
public function __construct($url)
{
$this->url = $url;
}

public function setOffsiteUrl(string $offsitedUrl): void
{
$this->offsiteurl = $offsiteUrl;
}

public function getOffsiteUrl()
{
return $this->offsiteurl;
}
}
Loading