### Install MariaDB Source: https://github.com/appertafoundation/openeyes/wiki/Installation-Instructions-v6.0 Installs MariaDB server and client, and runs the secure installation script. ```bash sudo apt update \ && sudo apt install -y mariadb-client-core-10.* \ && sudo apt install mariadb-server \ && sudo mysql_secure_installation \ && echo "Success" ``` -------------------------------- ### Install Node.js Source: https://github.com/appertafoundation/openeyes/wiki/Installation-Instructions-v6.0 Installs Node.js and npm, then restarts the Apache service. ```bash sudo apt install nodejs unzip \ && sudo apt-get install -y npm nodejs \ && sudo service apache2 restart \ && echo "Success" ``` -------------------------------- ### Install Composer and Dependencies Source: https://github.com/appertafoundation/openeyes/wiki/Installation-Instructions-v6.0 Installs PHP Composer and project dependencies. ```bash cd /var/www/openeyes \ && curl -sS https://getcomposer.org/installer -o /tmp/composer-setup.php \ && sudo php /tmp/composer-setup.php --install-dir=/usr/local/bin --filename=composer \ && composer install \ && echo "Success" ``` -------------------------------- ### Install MariaDB via Docker Source: https://github.com/appertafoundation/openeyes/wiki/Installation-Instructions-v6.0 Recommended development installation using Docker. ```bash sudo apt install -y docker.io \ && sudo docker run --detach --name openeyes -e MYSQL_ROOT_PASSWORD=password -p 3306:3306 mariadb:10.4 \ && echo "Success" ``` -------------------------------- ### Install Apache2 Web Server Source: https://github.com/appertafoundation/openeyes/wiki/Installation-Instructions-v6.0 Installs the Apache2 web server on Ubuntu. This command updates the package list and installs Apache2, confirming with 'Success'. ```bash sudo apt update -y \ && sudo apt install apache2 -y \ && echo "Success" ``` -------------------------------- ### Install dialog-polyfill via package managers Source: https://github.com/appertafoundation/openeyes/blob/master/protected/assets/components/dialog-polyfill/README.md Commands to install the polyfill using NPM or Bower. ```bash $ npm install dialog-polyfill $ bower install dialog-polyfill ``` -------------------------------- ### Install PHP 7.4 Source: https://github.com/appertafoundation/openeyes/wiki/Installation-Instructions-v6.0 Updates the system and installs PHP 7.4 from the ondrej/php repository. ```bash sudo apt-get update -y \ && sudo apt -y install software-properties-common \ && sudo add-apt-repository "ppa:ondrej/php" -y \ && sudo apt update -y \ && sudo apt install -y php7.4 \ && php -v ``` -------------------------------- ### Implement a basic dialog Source: https://github.com/appertafoundation/openeyes/blob/master/protected/assets/components/dialog-polyfill/README.md Standard setup including script/CSS inclusion, HTML structure, and JavaScript registration. ```html
``` -------------------------------- ### Install NVM and Node.js LTS Source: https://github.com/appertafoundation/openeyes/wiki/Installation-Instructions-v6.0 Install Node Version Manager (NVM) and then install and use the Long Term Support (LTS) version of Node.js. This manages Node.js environments for OpenEyes. ```bash cd /var/www/openeyes/ \ && curl -o- https://raw.githubusercontent.com/nvm-sh/nvm/v0.39.1/install.sh | bash \ && source ~/.bashrc \ && nvm --version \ && echo "Success" ``` ```bash nvm install 16.20.2 \ && nvm use 16.20.2 \ && echo "Success" ``` -------------------------------- ### Import Standard Fields via API Source: https://github.com/appertafoundation/openeyes/blob/master/protected/modules/OphInVisualfields/README.md Example command to send standard visual fields data to the OpenEyes server. Requires specifying the server host, username, password, and the ImageMagick installation path. Files are processed from the 'fields/in' directory. ```bash ./yiic importstandardfields --host=openeyes --credentials='fields_user,admin' --global-search-path='ImageMagick-6.8.8-Q16' --importDir='fields/in' ``` -------------------------------- ### Install PHP Dependencies Source: https://github.com/appertafoundation/openeyes/wiki/Installation-Instructions-v6.0 Installs necessary PHP extensions and libraries required for OpenEyes. ```bash sudo apt install -y \ php7.4-curl \ php7.4-mysql \ php7.4-xml \ php7.4-gd \ php7.4-mbstring \ php7.4-zip \ php7.4-gd \ phpunit \ libnss3 \ libxss1 \ libasound2 \ php7.4-soap \ php7.4-imagick \ && echo "Success" ``` -------------------------------- ### Install rrule via Bower Source: https://github.com/appertafoundation/openeyes/blob/master/protected/assets/components/rrule/README.md Use Bower to install the rrule library for client-side projects. ```bash $ bower install rrule ``` -------------------------------- ### Run NPM Update Source: https://github.com/appertafoundation/openeyes/wiki/Installation-Instructions-v6.0 Installs Node.js dependencies. ```bash cd /var/www/openeyes/ \ && npm i \ && echo "Success" ``` -------------------------------- ### Install rrule via NPM Source: https://github.com/appertafoundation/openeyes/blob/master/protected/assets/components/rrule/README.md Use NPM to install the rrule library for server-side projects. ```bash $ npm install rrule ``` -------------------------------- ### Mocha and Chai Setup Source: https://github.com/appertafoundation/openeyes/blob/master/protected/modules/Api/tests/js/runners/index.html Initializes Mocha with Chai assertions for BDD testing. Excludes PhantomJS from running tests. ```javascript this.expect = chai.expect; this.assert = chai.assert; mocha.setup('bdd'); if (navigator.userAgent.indexOf('PhantomJS') < 0) { mocha.run(function done() { }); } ``` -------------------------------- ### Example C++ Code Source: https://github.com/appertafoundation/openeyes/blob/master/protected/assets/components/google-code-prettify/README.html This is an example of C++ code that will be pretty-printed. It demonstrates class definition and static constants. ```cpp class Voila { public: // Voila static const string VOILA = "Voila"; // will not interfere with embedded [tags](#voila1). } ``` ```cpp class Voila { public: // Voila static const string VOILA = "Voila"; // will not interfere with embedded [tags](#voila2). } ``` -------------------------------- ### Install OpenEyes Dependencies Source: https://github.com/appertafoundation/openeyes/wiki/Installation-Instructions-v6.0 Installs necessary PHP extensions and updates Git submodules for OpenEyes. Ensure you are in the correct directory before running. ```bash apt-get install php7.4-imagick \ && git submodule update \ && cd protected/modules/eyedraw && git checkout -f v6.8.0 \ && echo "Success"; ``` -------------------------------- ### Install Node Dependencies Source: https://github.com/appertafoundation/openeyes/wiki/Installation-Instructions-v6.0 Install the 'sortablejs' Node.js package. This is a specific dependency required by OpenEyes. ```bash npm install sortablejs \ && echo "Success" ``` -------------------------------- ### Mocha and Chai Setup for Testing Source: https://github.com/appertafoundation/openeyes/blob/master/protected/modules/OphCiExamination/tests/js/runners/index.html Configures Mocha with Chai for BDD testing. Excludes PhantomJS user agent from running tests. ```javascript this.expect = chai.expect; this.assert = chai.assert; mocha.setup('bdd'); if (navigator.userAgent.indexOf('PhantomJS') < 0) { mocha.run(function done() {}); } ``` -------------------------------- ### Enable Line Numbers with Starting Line Source: https://github.com/appertafoundation/openeyes/blob/master/protected/assets/components/google-code-prettify/README.html Use the `linenums` class to enable line numbering. Specify a starting line number by appending it after a colon, e.g., `linenums:52`. ```html// This is line 4.
foo();
bar();
baz();
boo();
far();
faz();
```
--------------------------------
### Seeder Invokable Class Example
Source: https://github.com/appertafoundation/openeyes/blob/master/protected/seeders/README.md
This seeder uses a factory to create a model and then converts it to an array using a resource. Ensure the model and resource classes are correctly defined and namespaced.
```PHP
public function __invoke(): array
{
$model = ExampleModel::factory()->create();
return [
'created_model' => GenericModelResource::from($model)->toArray()
];
}
```
--------------------------------
### Text Input Format
Source: https://github.com/appertafoundation/openeyes/blob/master/protected/assets/components/rrule/index.html
Examples of natural language text input that can be parsed by rrule.js.
```APIDOC
## Text Input Format
### Description
Examples of natural language text that can be parsed into recurrence rules.
### Examples
- `Every weekday`
- `Every 2 weeks on Tuesday`
- `Every week on Monday, Wednesday`
- `Every month on the 2nd last Friday for 7 times`
- `Every 6 months`
```
--------------------------------
### Restart Apache Service
Source: https://github.com/appertafoundation/openeyes/wiki/Installation-Instructions-v6.0
Reload the Apache web server configuration and ensure the MariaDB service is running and enabled. This applies configuration changes and starts necessary services.
```bash
sudo systemctl reload apache2 \
&& sudo systemctl start mariadb \
&& sudo systemctl enable mariadb \
&& echo "Success"
```
--------------------------------
### Download Sample Database
Source: https://github.com/appertafoundation/openeyes/wiki/Installation-Instructions-v6.0
Downloads the sample database zip file.
```bash
wget
https://github.com/AppertaFoundation/openeyes-sample-db/raw/refs/heads/release/v6.8.0/sql/sample_db.zip
```
--------------------------------
### Import Sample Database
Source: https://github.com/appertafoundation/openeyes/wiki/Installation-Instructions-v6.0
Imports the sample database into the openeyes database.
```bash
mysql --host= --user openeyes --password=openeyes --database openeyes < sample_db \
&& echo "Success"
```
--------------------------------
### Manage System Configuration
Source: https://context7.com/appertafoundation/openeyes/llms.txt
Configure application components and parameters in local config files, or retrieve dynamic settings from the database.
```php
array(
'db' => array(
'connectionString' => 'mysql:host=localhost;dbname=openeyes',
'class' => 'OEDbConnection',
'username' => 'openeyes',
'password' => 'your_password',
'emulatePrepare' => true,
'charset' => 'utf8',
'schemaCachingDuration' => 300,
),
'session' => array(
'timeout' => 86400, // 24 hours
),
),
'params' => array(
'institution_code' => 'NEW',
'default_country' => 'United Kingdom',
'hos_num_regex' => '/^[0-9]{6,9}$/',
'nhs_num_regex' => '/^[0-9]{10}$/',
'OphCoDocument' => array(
'allowed_file_types' => array(
'application/pdf',
'image/jpeg',
'image/png',
),
),
),
);
return $config;
// Accessing settings from database
$setting = SettingMetadata::model()->getSetting('general_practitioner_label');
echo "GP Label: {$setting}\n";
// Institution-specific settings
$instSetting = SettingInstallation::model()->findByAttributes([
'key' => 'default_country'
]);
```
--------------------------------
### Create Cache and Assets Directories
Source: https://github.com/appertafoundation/openeyes/wiki/Installation-Instructions-v6.0
Create necessary cache and assets directories and set appropriate permissions. This is crucial for application performance and functionality.
```bash
mkdir -p /var/www/openeyes/cache \
mkdir -p /var/www/openeyes/protected/cache \
mkdir -p /var/www/openeyes/assets \
&& chmod -R 755 /var/www/openeyes/assets
```
--------------------------------
### Initialize Yii and Eyedraw
Source: https://github.com/appertafoundation/openeyes/wiki/Installation-Instructions-v6.0
Initializes the Yii framework and updates the Eyedraw submodule.
```bash
cd /var/www/openeyes/protected \
&& git submodule init \
&& git submodule update \
&& echo "Success"
```
--------------------------------
### Access MariaDB
Source: https://github.com/appertafoundation/openeyes/wiki/Installation-Instructions-v6.0
Connects to the MariaDB instance.
```bash
mariadb --host --user root -p
```
--------------------------------
### Test Database Connection
Source: https://github.com/appertafoundation/openeyes/wiki/Installation-Instructions-v6.0
Verifies the database connection with the new user credentials.
```bash
mysql --host= --user=openeyes --password=openeyes --database=openeyes --execute="SELECT now()" && echo "Success"
```
--------------------------------
### Run Legacy Visual Fields Import Command
Source: https://github.com/appertafoundation/openeyes/blob/master/protected/modules/OphInVisualfields/README.md
Execute the legacy import script with specified directories for input, archiving, errors, and duplicates. Ensure the 'interval' argument is set as a PHP time interval.
```bash
./yiic importlegacyvf import --importDir=runtime/fields/legacy --archiveDir=runtime/fields/out --errorDir=runtime/fields/err --dupDir=runtime/fields/dups
```
--------------------------------
### Configure OphCiExamination Module
Source: https://github.com/appertafoundation/openeyes/blob/master/protected/modules/OphCiExamination/README.md
Set the module configuration in the core application using the specified namespace.
```php
'OphCiExamination' => array(
'class' => '\OEModule\OphCiExamination\OphCiExaminationModule',
),
```
--------------------------------
### Patient Update Constraint
Source: https://github.com/appertafoundation/openeyes/blob/master/protected/modules/PASAPI/README.md
Example of using the deprecated updateOnly attribute to prevent patient creation.
```xml
0123456789
...
```
--------------------------------
### Create Directories for Legacy Import
Source: https://github.com/appertafoundation/openeyes/blob/master/protected/modules/OphInVisualfields/README.md
Set up the necessary directory structure on the OpenEyes VM for the legacy visual fields import process. This includes directories for legacy files, output, errors, and duplicates.
```bash
cd /var/www/protected; \
mkdir runtime/fields; \
mkdir runtime/fields/legacy; \
mkdir runtime/fields/out; \
mkdir runtime/fields/err; \
mkdir runtime/fields/dups;
```
--------------------------------
### Run Database Migrations
Source: https://context7.com/appertafoundation/openeyes/llms.txt
Commands for executing pending migrations and creating new migration files via the CLI.
```bash
# Run all pending migrations
cd /var/www/openeyes/protected
php yiic migrate --interactive=0
# Run module migrations
php yiic migratemodules --interactive=0
# Create a new migration
php yiic migrate create add_new_column_to_patient
```
--------------------------------
### Disable Firewall
Source: https://github.com/appertafoundation/openeyes/wiki/Installation-Instructions-v6.0
Disables the Uncomplicated Firewall (ufw). Note: This is a security risk and should be re-enabled with appropriate rules after installation.
```bash
sudo ufw disable \
&& echo "Success"
```
--------------------------------
### Using Processing Instructions for Prettify
Source: https://github.com/appertafoundation/openeyes/blob/master/protected/assets/components/google-code-prettify/README.html
If classes cannot be added directly to code (e.g., from Markdown), use a processing instruction like ``.
```html
```
--------------------------------
### Alternative Event Listener Call
Source: https://github.com/appertafoundation/openeyes/blob/master/protected/assets/components/google-code-prettify/README.html
This is an example of how NOT to call `prettyPrint` via an event handler, as it passes the event object directly.
```javascript
addEventListener('load', prettyPrint, false);
```
--------------------------------
### RRule Weekday Constants
Source: https://github.com/appertafoundation/openeyes/blob/master/protected/assets/components/rrule/README.md
Constants representing days of the week, used for specifying the week start day or byweekday options.
```javascript
RRule.MO
```
```javascript
RRule.TU
```
```javascript
RRule.WE
```
--------------------------------
### Create/Update Patient Response (Success)
Source: https://github.com/appertafoundation/openeyes/blob/master/protected/modules/PASAPI/README.md
This is an example of a successful response when creating or updating a patient. It includes a confirmation message and the internal patient ID.
```xml
Patient created
[internal patient id]
```
--------------------------------
### Initialize Prettify Themes Data
Source: https://github.com/appertafoundation/openeyes/blob/master/protected/assets/components/google-code-prettify/styles/index.html
Defines the list of available themes and their respective metadata.
```javascript
var allThemes = [ { name: 'default' }, { name: 'desert', authorHtml: '' + 'techto…@<\/a>' }, { name: 'sunburst', authorHtml: 'David Leibovic' }, { name: 'sons-of-obsidian', authorHtml: 'Alex Ford<\/a>' }, { name: 'doxy', authorHtml: 'Robert Sperberg' }, ];
```
--------------------------------
### Create/Update Patient Request
Source: https://github.com/appertafoundation/openeyes/blob/master/protected/modules/PASAPI/README.md
This is an example of a PUT request to create or update patient information. The URL includes the external ID, and the request body contains patient details in XML format.
```http
http://[oe-base-url]/PASAPI/V1/Patient/[external-id]
```
```xml
0123456789
92312423
MRS
Violet
Coffin
1978-03-01
F
82 Scarisbrick Lane
Bethersden
West Yorkshire
QA88 2GC
GB
HOME
03040 6024378
A
F001
G0102926
alb
alb
```
--------------------------------
### Access Module API for Data Retrieval
Source: https://context7.com/appertafoundation/openeyes/llms.txt
This pattern allows modules to expose functionality for cross-module communication. Use Yii::app()->moduleAPI->get('ModuleName') to obtain an API instance and call its methods.
```php
moduleAPI->get('OphCiExamination');
// Get the latest examination event for a patient
$latestEvent = $examApi->getLatestEvent($patient, $use_context = false);
// Get all visible events for a patient
$events = $examApi->getVisibleEvents($patient);
// Get a specific element from the latest event
$visualAcuity = $examApi->getLatestElement(
'OEModule\OphCiExamination\models\Element_OphCiExamination_VisualAcuity',
$patient,
$use_context = false
);
if ($visualAcuity) {
echo "Right Eye VA: " . $visualAcuity->getBestReading('right') . "\n";
echo "Left Eye VA: " . $visualAcuity->getBestReading('left') . "\n";
}
// Get IOP values
$iop = $examApi->getBaseIOPValues($patient);
if ($iop) {
echo "Right IOP: {$iop['right']} mmHg (Date: {$iop['date']})\n";
echo "Left IOP: {$iop['left']} mmHg\n";
}
```
--------------------------------
### Execute IOLMaster Import Command
Source: https://github.com/appertafoundation/openeyes/blob/master/protected/cli_commands/file_watcher/testrun.txt
Command used to run the IOLMaster import utility with specific classpath dependencies and configuration files.
```bash
cd ../../javamodules/IOLMasterImport/dist && java -cp ./lib/antlr-2.7.7.jar:./lib/dcm4che-core-3.3.7.jar:./lib/dom4j-1.6.1.jar:./lib/geronimo-jta_1.1_spec-1.1.1.jar:./lib/hibernate-commons-annotations-5.0.0.Final.jar:./lib/hibernate-core-5.0.0.Final.jar:./lib/hibernate-jpa-2.1-api-1.0.0.Final.jar:./lib/jandex-1.2.2.Final.jar:./lib/javassist-3.18.1-GA.jar:./lib/jboss-logging-3.3.0.Final.jar:./lib/log4j-1.2.17.jar:./lib/slf4j-api-1.7.5.jar:./lib/slf4j-log4j12-1.7.5.jar:./lib/mysql-connector-java-5.1.23-bin.jar:./lib/json-simple-1.1.1.jar:./lib/commons-cli-1.3.1.jar:./lib/jaxen-1.1.6.jar:./OE_IOLMasterImport.jar uk.org.openeyes.OE_IOLMasterImport -c /etc/openeyes/hibernate.cfg.xml -d -f /home/iolmaster/incoming/test/1.2.276.0.75.2.1.10.0.2.150925111615937.15295058.118_0000_000001_144317611300ad.dcm
```
```bash
cd ../../javamodules/IOLMasterImport/dist && java -cp ./lib/antlr-2.7.7.jar:./lib/dcm4che-core-3.3.7.jar:./lib/dom4j-1.6.1.jar:./lib/geronimo-jta_1.1_spec-1.1.1.jar:./lib/hibernate-commons-annotations-5.0.0.Final.jar:./lib/hibernate-core-5.0.0.Final.jar:./lib/hibernate-jpa-2.1-api-1.0.0.Final.jar:./lib/jandex-1.2.2.Final.jar:./lib/javassist-3.18.1-GA.jar:./lib/jboss-logging-3.3.0.Final.jar:./lib/log4j-1.2.17.jar:./lib/slf4j-api-1.7.5.jar:./lib/slf4j-log4j12-1.7.5.jar:./lib/mysql-connector-java-5.1.23-bin.jar:./lib/json-simple-1.1.1.jar:./lib/commons-cli-1.3.1.jar:./lib/jaxen-1.1.6.jar:./OE_IOLMasterImport.jar uk.org.openeyes.OE_IOLMasterImport -c /etc/openeyes/hibernate.cfg.xml -d -f /home/iolmaster/incoming/1.2.276.0.75.2.1.10.0.2.150925111615937.15295058.118_0000_000001_144317611300ad.dcm
```
```bash
cd ../../javamodules/IOLMasterImport/dist && java -cp ./lib/antlr-2.7.7.jar:./lib/dcm4che-core-3.3.7.jar:./lib/dom4j-1.6.1.jar:./lib/geronimo-jta_1.1_spec-1.1.1.jar:./lib/hibernate-commons-annotations-5.0.0.Final.jar:./lib/hibernate-core-5.0.0.Final.jar:./lib/hibernate-jpa-2.1-api-1.0.0.Final.jar:./lib/jandex-1.2.2.Final.jar:./lib/javassist-3.18.1-GA.jar:./lib/jboss-logging-3.3.0.Final.jar:./lib/log4j-1.2.17.jar:./lib/slf4j-api-1.7.5.jar:./lib/slf4j-log4j12-1.7.5.jar:./lib/mysql-connector-java-5.1.23-bin.jar:./lib/json-simple-1.1.1.jar:./lib/commons-cli-1.3.1.jar:./lib/jaxen-1.1.6.jar:./OE_IOLMasterImport.jar uk.org.openeyes.OE_IOLMasterImport -c /etc/openeyes/hibernate.cfg.xml -d -f /home/iolmaster/incoming/1.2.276.0.75.2.1.10.0.2.150925111615937.15295058.118_0000_000001_144317636500b1.dcm
```
```bash
cd ../../javamodules/IOLMasterImport/dist && java -cp ./lib/antlr-2.7.7.jar:./lib/dcm4che-core-3.3.7.jar:./lib/dom4j-1.6.1.jar:./lib/geronimo-jta_1.1_spec-1.1.1.jar:./lib/hibernate-commons-annotations-5.0.0.Final.jar:./lib/hibernate-core-5.0.0.Final.jar:./lib/hibernate-jpa-2.1-api-1.0.0.Final.jar:./lib/jandex-1.2.2.Final.jar:./lib/javassist-3.18.1-GA.jar:./lib/jboss-logging-3.3.0.Final.jar:./lib/log4j-1.2.17.jar:./lib/slf4j-api-1.7.5.jar:./lib/slf4j-log4j12-1.7.5.jar:./lib/mysql-connector-java-5.1.23-bin.jar:./lib/json-simple-1.1.1.jar:./lib/commons-cli-1.3.1.jar:./lib/jaxen-1.1.6.jar:./OE_IOLMasterImport.jar uk.org.openeyes.OE_IOLMasterImport -c /etc/openeyes/hibernate.cfg.xml -d -f /home/iolmaster/incoming/test2/code_test1.docx
```
--------------------------------
### Find All Reference Data for Context (Future Implementation)
Source: https://github.com/appertafoundation/openeyes/blob/master/docs/adr/0006-reference-data-lookup-filtering-should-be-implemented-in-a-consistent-fashion.md
This method is a future implementation for automatically resolving relevant attributes for data retrieval based on the provided or current context. It aims to abstract the level filtering logic from the calling code.
```php
public function findAllForContext(?DataContext $context = null)
{
$context ??= DataContext::getCurrent();
// magic resolution of relevant attributes for data retrieval
}
```
--------------------------------
### Create and Manage Prescriptions
Source: https://context7.com/appertafoundation/openeyes/llms.txt
This code demonstrates creating a prescription event, adding prescription details, and specifying individual prescription items with drug, dose, route, frequency, and duration. It also shows how to generate a PDF of the prescription.
```php
findByAttributes(['class_name' => 'OphDrPrescription']);
$event = new Event();
$event->episode_id = $episode->id;
$event->event_type_id = $prescriptionEventType->id;
$event->event_date = date('Y-m-d');
$event->save();
// Add prescription details element
$details = new Element_OphDrPrescription_Details();
$details->event_id = $event->id;
$details->comments = 'Review in 4 weeks';
$details->save();
// Add prescription items
$item = new OphDrPrescription_Item();
$item->prescription_id = $details->id;
$item->drug_id = $drug->id; // Medication from DM+D
$item->dose = '1 drop';
$item->route_id = $routeId; // e.g., Eye drops
$item->frequency_id = $frequencyId; // e.g., Twice daily
$item->duration_id = $durationId; // e.g., 4 weeks
$item->dispense_location_id = $locationId;
$item->dispense_condition_id = $conditionId;
$item->save();
// Generate prescription PDF
$controller = new OphDrPrescription_DefaultController('default');
$controller->actionPDFPrint($event->id);
```
--------------------------------
### Add Module to Application Configuration
Source: https://github.com/appertafoundation/openeyes/blob/master/protected/modules/OphCoCvi/README.md
Include this line in your application's configuration to register the OphCoCvi module.
```php
'OphCoCvi' => array('class' => '\\OEModule\\OphCoCvi\\OphCoCviModule')
```
--------------------------------
### Initialize Mocha Test Suite
Source: https://github.com/appertafoundation/openeyes/blob/master/protected/assets/components/dialog-polyfill/test.html
Sets up the Mocha environment with TDD interface and attaches a global error listener to report script errors during page load.
```javascript
var assert = chai.assert; mocha.setup({ ui: 'tdd' }); (function() { var pageError = null; window.addEventListener('error', function(event) { pageError = event.filename + ':' + event.lineno + ' ' + event.message; }); window.addEventListener('load', function() { if (pageError) { suite('page-script-errors', function() { test('no script errors on page', function() { assert.fail(null, null, pageError); }); }); } mocha.run(); }); })();
```
--------------------------------
### Use Prettify in a Global Context
Source: https://github.com/appertafoundation/openeyes/blob/master/protected/assets/components/google-code-prettify/README.md
This snippet shows how to use Google Code Prettify in a global context, applying syntax highlighting to elements with the 'prettyprint' class.
```javascript
(function(){
$('pre').addClass('prettyprint');
prettyPrint();
})();
```
--------------------------------
### Create Database
Source: https://github.com/appertafoundation/openeyes/wiki/Installation-Instructions-v6.0
Creates the openeyes database.
```sql
CREATE database openeyes;
```
--------------------------------
### Configure RequireJS for Prettify
Source: https://github.com/appertafoundation/openeyes/blob/master/protected/assets/components/google-code-prettify/README.md
Configure RequireJS to map a convenient name to the Google Code Prettify module path.
```javascript
// using RequireJS
require.config({
prettify: 'bower_components/google-code-prettify/prettify'
});
```
--------------------------------
### Use Prettify in an AMD Module
Source: https://github.com/appertafoundation/openeyes/blob/master/protected/assets/components/google-code-prettify/README.md
This snippet demonstrates how to use Google Code Prettify within an AMD module, applying syntax highlighting to elements with the 'prettyprint' class.
```javascript
define(['jquery', 'prettify'], function($, prettify){
var code = null;
$('pre').addClass('prettyprint').each(function(idx, el){
code = el.firstChild;
code.innerHTML = prettify.prettyPrintOne(code.innerHTML);
})
);
});
```
--------------------------------
### Create and Make Model Instances
Source: https://github.com/appertafoundation/openeyes/blob/master/docs/testing/modelfactories.md
Use ModelFactory to create persisted model instances or make non-persisted instances with custom attributes.
```php
$patient = ModelFactory::for(Patient::class)->create();
$this->assertNotNull($patient->dob);
$patient = ModelFactory::for(Patient::class)->create(['dob' => '2005-03-05']);
$this->assertEquals(10, $patient->ageOn('2015-03-05'));
```
```php
$patient = ModelFactory::for(Patient::class)->make();
$this->assertNull($patient->id);
```
--------------------------------
### Verify Database Content
Source: https://github.com/appertafoundation/openeyes/wiki/Installation-Instructions-v6.0
Queries the database to verify data import.
```bash
mysql --host= --user=openeyes --password=openeyes --database=openeyes --execute="SELECT username FROM user LIMIT 1"
```
--------------------------------
### Configure curl.js for Prettify
Source: https://github.com/appertafoundation/openeyes/blob/master/protected/assets/components/google-code-prettify/README.md
Configure curl.js to map a convenient name to the Google Code Prettify module path.
```javascript
// using curl.js
curl.config({
prettify: 'bower_components/google-code-prettify/prettify'
});
```
--------------------------------
### Module API System
Source: https://context7.com/appertafoundation/openeyes/llms.txt
Demonstrates how to interact with module APIs for cross-module communication, such as retrieving examination data.
```APIDOC
### Module API Interaction
#### Description
OpenEyes utilizes a module API pattern for inter-module communication. This allows modules to expose and consume functionality from each other.
#### Getting a Module API Instance
```php
// Getting a module API instance
$examApi = Yii::app()->moduleAPI->get('OphCiExamination');
```
#### Common Operations
##### Get Latest Examination Event
```php
// Get the latest examination event for a patient
$latestEvent = $examApi->getLatestEvent($patient, $use_context = false);
```
##### Get All Visible Events
```php
// Get all visible events for a patient
$events = $examApi->getVisibleEvents($patient);
```
##### Get Specific Element from Latest Event
```php
// Get a specific element from the latest event
$visualAcuity = $examApi->getLatestElement(
'OEModule\OphCiExamination\models\Element_OphCiExamination_VisualAcuity',
$patient,
$use_context = false
);
if ($visualAcuity) {
echo "Right Eye VA: " . $visualAcuity->getBestReading('right') . "\n";
echo "Left Eye VA: " . $visualAcuity->getBestReading('left') . "\n";
}
```
##### Get Base IOP Values
```php
// Get IOP values
$iop = $examApi->getBaseIOPValues($patient);
if ($iop) {
echo "Right IOP: {$iop['right']} mmHg (Date: {$iop['date']})\n";
echo "Left IOP: {$iop['left']} mmHg\n";
}
```
```
--------------------------------
### Create a new patient programmatically
Source: https://context7.com/appertafoundation/openeyes/llms.txt
Instantiates and saves a new Patient record along with associated contact, identifier, and address data.
```php
dob = '1985-03-15';
$patient->gender = 'M';
$patient->patient_source = Patient::PATIENT_SOURCE_REFERRAL;
$patient->is_local = 1;
$patient->primary_institution_id = Institution::model()->getCurrent()->id;
$contact = new Contact('manualAddPatient');
$contact->title = 'Mr';
$contact->first_name = 'John';
$contact->last_name = 'Smith';
$contact->primary_phone = '01onal234567';
$contact->created_institution_id = Yii::app()->session['selected_institution_id'];
if ($contact->save()) {
$patient->contact_id = $contact->id;
if ($patient->save()) {
// Create patient identifier
$identifier = new PatientIdentifier();
$identifier->patient_id = $patient->id;
$identifier->patient_identifier_type_id = $identifierTypeId;
$identifier->value = 'HOS123456';
$identifier->save();
// Add address
$address = new Address();
$address->contact_id = $contact->id;
$address->address1 = '123 Main Street';
$address->city = 'London';
$address->postcode = 'SW1A 1AA';
$address->country_id = Country::model()->findByAttributes(['code' => 'GB'])->id;
$address->save();
}
}
```
--------------------------------
### Generate Theme Preview Iframes
Source: https://github.com/appertafoundation/openeyes/blob/master/protected/assets/components/google-code-prettify/styles/index.html
Iterates through the theme list to create and inject iframes into the document body.
```javascript
(function () { // Produce an iframe per theme. // We pass the threme name to the iframe via its URI query, and // it loads prettify and the theme CSS, and calls back to this page // to resize the iframe. for (var i = 0, n = allThemes.length; i < n; ++i) { var theme = allThemes[i]; if (!theme) { continue; } var iframe = document.createElement('iframe'); iframe.name = theme.name; iframe.src = 'demo.html?' + encodeURIComponent(theme.name); var header = document.createElement('h2'); header.id = theme.name; var linkToThemeSrc = document.createElement('a'); linkToThemeSrc.href = ( 'http://code.google.com/p/google-code-prettify/source/browse/trunk/' + (theme.name === 'default' ? 'src/prettify.css' : 'styles/' + encodeURIComponent(theme.name) + '.css')); linkToThemeSrc.appendChild(document.createTextNode( theme.name.replace(/\b[a-z]/g, // Capitalize first letter of each word function (letter) { return letter.toUpperCase(); }))); header.appendChild(linkToThemeSrc); var attribution; if (theme.authorHtml) { attribution = document.createElement('span'); attribution.className = 'attribution'; attribution.innerHTML = 'by ' + theme.authorHtml; } var div = document.createElement('div'); div.appendChild(header); if (attribution) { div.appendChild(attribution); } div.appendChild(iframe); document.body.appendChild(div); } })()
```
--------------------------------
### Hello World JavaScript Function
Source: https://github.com/appertafoundation/openeyes/blob/master/protected/assets/components/google-code-prettify/styles/demo.html
A simple JavaScript function that alerts 'Hello' multiple times. It's intended for demonstration purposes.
```javascript
function helloWorld(world) {
for (var i = 42; --i >= 0;) {
alert('Hello ' + String(world));
}
}
```
--------------------------------
### Dispatch a System Event
Source: https://github.com/appertafoundation/openeyes/blob/master/protected/modules/OESysEvent/README.md
Use the static dispatch accessor to trigger events with required parameters.
```php
FooSystemEvent::dispatch(true);
FooSystemEvent::dispatch(false, 5);
```
--------------------------------
### Copy Legacy Test Files
Source: https://github.com/appertafoundation/openeyes/blob/master/protected/modules/OphInVisualfields/README.md
Copy sample legacy .fmes files into the designated legacy import directory. Remember to update patient IDs in the XML files to match your system's users.
```bash
cp modules/OphInVisualfields/tests/fields/legacy/* runtime/fields/legacy/
```
--------------------------------
### Configure Portal API Settings
Source: https://github.com/appertafoundation/openeyes/blob/master/protected/modules/OphCoCvi/README.md
Add this configuration block to your config/local/common.php params section to set up the portal API connection details, including URIs, endpoints, and credentials.
```php
'portal' => array(
'uri' => 'http://api.localhost:8000',
'endpoints' => array(
'auth' => '/oauth/access',
'examinations' => '/examinations/searches',
'signatures' => '/signatures/searches'
),
'credentials' => array(
'username' => 'user@example.com',
'password' => 'apipass',
'grant_type' => 'password',
'client_id' => 'f3d259ddd3ed8ff3843839b',
'client_secret' => '4c7f6f8fa93d59c45502c0ae8c4a95b',
),
)
```
--------------------------------
### Create Database Migrations in OpenEyes
Source: https://context7.com/appertafoundation/openeyes/llms.txt
Use the OEMigration class to define schema changes. Ensure both up and down methods are implemented to support migration rollbacks.
```php
addColumn('patient', 'custom_field', 'varchar(255)');
$this->createIndex('idx_patient_custom_field', 'patient', 'custom_field');
}
public function down()
{
$this->dropIndex('idx_patient_custom_field', 'patient');
$this->dropColumn('patient', 'custom_field');
}
}
```
--------------------------------
### Configure Mocha Test Environment
Source: https://github.com/appertafoundation/openeyes/blob/master/protected/modules/OphCiDidNotAttend/tests/js/runners/index.html
Initializes the Mocha BDD interface and executes the test runner, with a conditional check for the PhantomJS user agent.
```css
html, body { background: #fff; }
```
```javascript
this.expect = chai.expect; this.assert = chai.assert; mocha.setup('bdd'); if (navigator.userAgent.indexOf('PhantomJS') < 0) { mocha.run(function done() {}); }
```
--------------------------------
### Define a System Event
Source: https://github.com/appertafoundation/openeyes/blob/master/protected/modules/OESysEvent/README.md
Inherit from SystemEvent to create a new event class with strict parameter definitions.
```php
class FooSystemEvent extends SystemEvent
{
public bool $bar;
public int $count;
public function __construct(bool $bar, int $count = 0)
{
$this->bar = $bar;
$this->count = $count;
}
}
```
--------------------------------
### Run Tests in Separate Processes
Source: https://github.com/appertafoundation/openeyes/blob/master/protected/tests/README.md
Use these annotations to ensure correct class loading when dealing with potential class name collisions, especially for controllers.
```php
/**
* @runTestsInSeparateProcesses
* @preserveGlobalState disabled
*/
class ExampleTest extends OEDbTestCasse
{}
```
--------------------------------
### Run OpenEyes Migrations
Source: https://github.com/appertafoundation/openeyes/wiki/Installation-Instructions-v6.0
Execute database migrations for OpenEyes and its modules. This updates the database schema to the required version.
```bash
cd /var/www/openeyes/protected && php yiic migrate --interactive=0 && php yiic migratemodules --interactive=0 \
&& echo "Success";
```
--------------------------------
### Run OpenEyes Migrations
Source: https://github.com/appertafoundation/openeyes/wiki/Installation-Instructions-v6.0
Executes database migrations for various OpenEyes versions. This command sequence ensures that all necessary database schema updates are applied.
```bash
git checkout -f v6.2.19 \
&& cd /var/www/openeyes/protected && php yiic migrate --interactive=0 && php yiic migratemodules --interactive=0 \
&& git checkout -f v6.4.1 \
&& cd /var/www/openeyes/protected && php yiic migrate --interactive=0 && php yiic migratemodules --interactive=0 \
&& git checkout -f v6.6.21 \
&& cd /var/www/openeyes/protected && php yiic migrate --interactive=0 && php yiic migratemodules --interactive=0 \
&& git checkout -f v6.8.0 \
&& cd /var/www/openeyes/protected && php yiic migrate --interactive=0 && php yiic migratemodules --interactive=0 \
&& echo "Success";
```
--------------------------------
### Configure Event Observers
Source: https://github.com/appertafoundation/openeyes/blob/master/protected/modules/OESysEvent/README.md
Link events to listeners using the standard Yii configuration component.
```php
'components' => [
'event' => {
'observers' => [
[
'system_event' => FooSystemEvent::class
'listener' => FooListener::class,
]
]
}
]
```
--------------------------------
### Specify HTML Language for Prettify
Source: https://github.com/appertafoundation/openeyes/blob/master/protected/assets/components/google-code-prettify/README.html
Use the `lang-*` class to specify the language for code highlighting. Supported extensions include 'html', 'js', 'java', etc.
```html
The lang-* class specifies the language file extensions.
File extensions supported by default include
"bsh", "c", "cc", "cpp", "cs", "csh", "cyc", "cv", "htm", "html",
"java", "js", "m", "mxml", "perl", "pl", "pm", "py", "rb", "sh",
"xhtml", "xml", "xsl".
```
--------------------------------
### Create Database User
Source: https://github.com/appertafoundation/openeyes/wiki/Installation-Instructions-v6.0
Creates a new database user for OpenEyes.
```sql
CREATE User openeyes;
```