/* Copyright (c) 2009, Oracle and/or its affiliates. All rights reserved. */


        Installation Guide for Running BDB-DICOM Sample on WinCE Devices

The Oracle Berkeley DB DICOM Sample (BDB-DICOM for short) is a demo program 
that proofs the concept of using Oracle Berkeley DB to manage the DICOM 
standard based medical images (X-ray, CT, MRI, etc) which runs on mobile 
devices and talks to the back-end application systems via the http protocol.

The document is the installation guide talking about how to setup, configure
and run the BDB-DICOM demo on a WinCE mobile device. It also covers briefly 
on how to setup and configure the middle tier server (DICOM server) and the 
back-end Oracle Multimedia database, where the DICOM images are from and/or 
sent to.

1. Prerequisite

All source code and resources required to run the BDB-DICOM sample program 
could be downloaded from Berkeley DB OTN website, except the Oracle database
installation file. Please visit "http://www.oracle.com/technetwork/database/
database-technologies/berkeleydb/learnmore/index.html" to get the latest copy.
Let's assume the directory "wce_dicom" ($HOME for short) is the home directory
where the BDB-DICOM sample program resides.

To run the sample program, you need to download, install and start up an 
Oracle database, the DICOM server and the BDB client. Oracle database and 
DICOM server could be installed and deployed on any Linux or Windows
machine. The BDB client could be installed and deployed on Pocket PC with  
windows mobile 5.0 SDK.

2. Setup the Oracle Multimedia database
2.1 Install the Oracle Database 11g Software
Download the latest Oracle Database 11g software from www.oracle.com. Follow
the installation instructions, install and configure a database instance  
using the UTF-8 character set. After that, you should be able to see that a
listener service named like OracleOraDb11g_home1* and an oracle service  
named like OracleService* are running on your machine. For detailed  
information about installing and configuring Oracle 11g database, please  
refer to http://download.oracle.com/docs/cd/B28359_01/install.111/b32002/
toc.htm.

2.2 Create the image table and indexes
2.2.1 Change your directory to $HOME/oracle_db_sql and run the Oracle 
SQL*Plus command line tool. Log into the Oracle database by entering your 
username/password.

2.2.2 Create the medical_image_table by executing "@create_dicom_table.sql" 
from the SQL*Plus prompt.
If you meet "ORA-43853: SECUREFILE lobs cannot be used in non-ASSM  
tablespace "SYSTEM"", please go to 2.2.1 and create a ASSM tablespace (Refer
to http://www.orafaq.com/wiki/ASSM) and a user in that tablespace. DICOM 
will be stored as SecureFile lobs in Oracle Database and SecureFile lobs 
could only be used in ASSM tablespace. The tablespace should be large enough
to store all DICOM images. Log on with the user in the ASSM tablespace and 
execute the create_dicom_table.sql.

2.2.3 Create indexes by executing "@create_indexes.sql". The indexes are 
created to support fast queries by patient¡¯s name and/or modality, which is
required by the DICOM server.

Please refer to PL/SQL and administrator's guide at http://tahiti-stage.us.
oracle.com/pls/db112/homepage, if you want to understand the *.sql scripts.

2.3 Import DICOM images
Set $HOME/oracle_db_sql/dicom as the image directory. Execute "@
create_import_procedure.sql" to create the store procedure to import DICOM 
images into oracle multimedia in the image directory. If there is no error, 
specify the image name and export it by executing "execute image_import(1,'<
image name>')".

You could refer to chapter 1.2 and chapter 1.3 in http://www.oracle.com/
technology/obe/11gr1_db/datamgmt/dicom/dicom.htm.
 
3. DICOM server
3.1 Compile DICOM server
The source code of the DICOM server are under $HOME/dicom_server/src. It is 
programmed in Java. Its dependent libraries are under $HOME/dicom_server/
libs. Before compiling, please update the IP address of Oracle database at 
line 221 in DICOMService.java.

The source code could be compiled in command line or in Java IDE tools. 
Let's take the command line compilation for example, run "javac -classpath=.
:../libs/libocijdbc11.so:../libs/ojdbc5.jar:../libs/orddicom.jar:../libs/
ordim.jar:../libs/xdb.jar:../libs/xmlparserv2.jar *.java" under $HOME/
dicom_server/src.

3.2 Run DICOM server
After successfully compiling the source code, you can run 
"java DICOMServer -classpath 
.:../libs/libocijdbc11.so:../libs/ojdbc5.jar:../libs/orddicom.jar:..
/libs/ordim.jar:../libs/xdb.jar:../libs/xmlparserv2.jar" to start up the 
DICOM server via command line. If "[LOG] Start server on port 8080" and 
"[LOG] Start DICOM service" show up, the DICOM download service is already 
available to serve. Since the DICOM server uses HTTP protocol, you could 
test it by web browser. And if IP address and port is correct, a popup page 
will request for authorized user and password during connecting to DICOM 
server. Inputting "oracle" as user and "welcome" as password, a large bunch 
of byte array will be returned.

4. BDB client (WinCE mobile device)
4.1 Compile the BDB client
The BDB client is programmed in C++ and requires Visual Studio and Windows 
Mobile 5.0 SDK to compile. Open $HOME/dicom_client/clientUI.sln. Build the 
solution with release/debug mode.

Please update the source code with the IP address of the latest DICOM server
in DicomService::Download method of DicomService.cpp.

4.2 Run BDB client
BDB client could be run either on an emulator or on a device. Before running
BDB client, Microsoft ActiveSync is needed to install. Please download it 
from http://www.microsoft.com/windowsmobile/en-us/downloads/microsoft/
activesync-download.mspx.

To run the DICOM client on an emulator, open Visual Studio to start up the 
emulator. Go to Tools in the menu bar and click the Device Emulator Manager.
Choose the Windows Mobile 5.0 Pocket PC Emulator in the available emulators 
and connect it. The emulator will show up. And right click the Windows 
Mobile 5.0 Pocket PC Emulator in the Device Emulator Manager again, the one
just connected, and choose cradle. The emulator is syncing with the 
computer. You could see Mobile Device in Windows Resource Explorer or "My 
Computer". Copy the clientUI.exe from the output directory to //program 
files in the emulator and the clientUI.exe could be run.

To run on a device, connect the device to the computer and copy clientUI.exe
to //program files in the device.

To run the clientUI.exe, please create a "dicom" directory under the root 
directory (//) as the environment home directory.

4.3 Network
There is two ways to connect the device to the Internet.
- First, connect network via wifi. Ensure that the DICOM server is deployed 
on a machine that could be connected by wifi.
- Second, connect network via ActiveSync. After syncing with the computer, 
click the "start" in device or emulator, go to "setting" to configure the 
connection. The network cards should be set to "NE2000 Compatible Ethernet 
Drive" when connected to "Work". In this way, the device could be connected
to Internet through the network in your computer.

If you have any question, please email to michael.brey@oracle.com.
