Search This Blog

Wednesday, September 11, 2013

Mirth to connect PostgreSQL


Steps:-

1. Create a role mirthdb as password mirthdb in postgres and assign super user priviledge.

 CREATE ROLE mirthdb LOGIN
 ENCRYPTED PASSWORD 'md5ffedeac0808a4430dd3bfa01f1d02bac'
  SUPERUSER INHERIT CREATEDB CREATEROLE REPLICATION;
2. Open the attached sql and run the script.

3. Go to Mirth installe folder ex:- D:\MirthConnect2.2\conf\mirth.properties

    Change the below properties :-
            database = postgres
            database.url = jdbc:postgresql://localhost:5432/mirthdb
            database.username = mirthdb
            database.password = mirthdb

4. Restart the server. ENJOY !!!!!









postgres-database.sql

-- Role: mirthdb

-- DROP ROLE mirthdb;

-- CREATE ROLE mirthdb LOGIN
--  ENCRYPTED PASSWORD 'md5ffedeac0808a4430dd3bfa01f1d02bac'
--  SUPERUSER INHERIT CREATEDB CREATEROLE REPLICATION;

CREATE TABLE SCHEMA_INFO
 (VERSION VARCHAR(40));

CREATE SEQUENCE EVENT_SEQUENCE START WITH 1;

CREATE TABLE EVENT
 (ID INTEGER DEFAULT nextval('EVENT_SEQUENCE') NOT NULL PRIMARY KEY,
 DATE_CREATED TIMESTAMP DEFAULT CURRENT_TIMESTAMP,
 NAME TEXT NOT NULL,
 EVENT_LEVEL VARCHAR(40) NOT NULL,
 OUTCOME VARCHAR(40) NOT NULL,
 ATTRIBUTES TEXT,
 USER_ID INTEGER NOT NULL,
 IP_ADDRESS VARCHAR(40));
 
CREATE TABLE CHANNEL
 (ID CHAR(36) NOT NULL PRIMARY KEY,
 NAME VARCHAR(40) NOT NULL,
 DESCRIPTION TEXT,
 IS_ENABLED BOOLEAN NOT NULL,
 VERSION VARCHAR(40),
 REVISION INTEGER,
 LAST_MODIFIED TIMESTAMP DEFAULT CURRENT_TIMESTAMP,
 SOURCE_CONNECTOR TEXT,
 DESTINATION_CONNECTORS TEXT,
 PROPERTIES TEXT,
 PREPROCESSING_SCRIPT TEXT,
 POSTPROCESSING_SCRIPT TEXT,
 DEPLOY_SCRIPT TEXT,
 SHUTDOWN_SCRIPT TEXT);
 
CREATE TABLE CHANNEL_STATISTICS
 (SERVER_ID CHAR(36) NOT NULL,
 CHANNEL_ID CHAR(36) NOT NULL REFERENCES CHANNEL(ID) ON DELETE CASCADE,
 RECEIVED NUMERIC,
 FILTERED NUMERIC,
 SENT NUMERIC,
 ERROR NUMERIC,
 QUEUED NUMERIC,
 ALERTED NUMERIC,
 PRIMARY KEY(SERVER_ID, CHANNEL_ID));

CREATE SEQUENCE MESSAGE_SEQUENCE START WITH 1;

CREATE TABLE ATTACHMENT
    (ID VARCHAR(255) NOT NULL PRIMARY KEY,
     MESSAGE_ID VARCHAR(255) NOT NULL,
     ATTACHMENT_DATA BYTEA,
     ATTACHMENT_SIZE INTEGER,
     ATTACHMENT_TYPE VARCHAR(40));

CREATE INDEX ATTACHMENT_INDEX1 ON ATTACHMENT(MESSAGE_ID);

CREATE TABLE MESSAGE
 (SEQUENCE_ID INTEGER DEFAULT NEXTVAL('MESSAGE_SEQUENCE') NOT NULL PRIMARY KEY,
 ID CHAR(36) NOT NULL,
 SERVER_ID CHAR(36) NOT NULL,
 CHANNEL_ID CHAR(36) NOT NULL REFERENCES CHANNEL(ID) ON DELETE CASCADE,
 SOURCE VARCHAR(255),
 TYPE VARCHAR(255),
 DATE_CREATED TIMESTAMP NOT NULL,
 VERSION VARCHAR(40),
 IS_ENCRYPTED BOOLEAN NOT NULL,
 STATUS VARCHAR(40),
 RAW_DATA TEXT,
 RAW_DATA_PROTOCOL VARCHAR(40),
 TRANSFORMED_DATA TEXT,
 TRANSFORMED_DATA_PROTOCOL VARCHAR(40),
 ENCODED_DATA TEXT,
 ENCODED_DATA_PROTOCOL VARCHAR(40),
 CONNECTOR_MAP TEXT,
 CHANNEL_MAP TEXT,
 RESPONSE_MAP TEXT,
 CONNECTOR_NAME VARCHAR(255),
 ERRORS TEXT,
 CORRELATION_ID VARCHAR(255),
 ATTACHMENT BOOLEAN, 
 UNIQUE (ID));

CREATE INDEX MESSAGE_INDEX1 ON MESSAGE(CHANNEL_ID, DATE_CREATED);

CREATE INDEX MESSAGE_INDEX2 ON MESSAGE(CHANNEL_ID, DATE_CREATED, CONNECTOR_NAME);

CREATE INDEX MESSAGE_INDEX3 ON MESSAGE(CHANNEL_ID, DATE_CREATED, RAW_DATA_PROTOCOL);

CREATE INDEX MESSAGE_INDEX4 ON MESSAGE(CHANNEL_ID, DATE_CREATED, SOURCE);

CREATE INDEX MESSAGE_INDEX5 ON MESSAGE(CHANNEL_ID, DATE_CREATED, STATUS);

CREATE INDEX MESSAGE_INDEX6 ON MESSAGE(CHANNEL_ID, DATE_CREATED, TYPE);

CREATE INDEX MESSAGE_INDEX7 ON MESSAGE(CORRELATION_ID, CONNECTOR_NAME);

CREATE INDEX MESSAGE_INDEX8 ON MESSAGE(ATTACHMENT) WHERE (ATTACHMENT=TRUE);
 
CREATE TABLE SCRIPT
 (GROUP_ID VARCHAR(40) NOT NULL,
 ID VARCHAR(40) NOT NULL,
 SCRIPT TEXT,
 PRIMARY KEY(GROUP_ID, ID));

CREATE TABLE TEMPLATE
 (GROUP_ID VARCHAR(255) NOT NULL,
 ID VARCHAR(255) NOT NULL,
 TEMPLATE TEXT,
 PRIMARY KEY(GROUP_ID, ID)); 

CREATE SEQUENCE PERSON_SEQUENCE START WITH 1;

CREATE TABLE PERSON
 (ID INTEGER DEFAULT nextval('PERSON_SEQUENCE') NOT NULL PRIMARY KEY,
 USERNAME VARCHAR(40) NOT NULL,
 FIRSTNAME VARCHAR(40),
 LASTNAME VARCHAR(40),
 ORGANIZATION VARCHAR(255),
 EMAIL VARCHAR(255),
 PHONENUMBER VARCHAR(40),
 DESCRIPTION VARCHAR(255),
 LAST_LOGIN TIMESTAMP DEFAULT CURRENT_TIMESTAMP,
 GRACE_PERIOD_START TIMESTAMP DEFAULT NULL,
 LOGGED_IN BOOLEAN NOT NULL);

CREATE TABLE PERSON_PASSWORD
 (PERSON_ID INTEGER NOT NULL REFERENCES PERSON(ID) ON DELETE CASCADE,
 PASSWORD VARCHAR(256) NOT NULL,
 PASSWORD_DATE TIMESTAMP DEFAULT CURRENT_TIMESTAMP);

CREATE TABLE ALERT
 (ID CHAR(36) NOT NULL PRIMARY KEY,
 NAME VARCHAR(40) NOT NULL,
 IS_ENABLED BOOLEAN NOT NULL,
 EXPRESSION TEXT,
 TEMPLATE TEXT,
 SUBJECT VARCHAR(998));
 
CREATE TABLE CODE_TEMPLATE
 (ID VARCHAR(255) NOT NULL PRIMARY KEY,
 NAME VARCHAR(40) NOT NULL,
 CODE_SCOPE VARCHAR(40) NOT NULL,
 CODE_TYPE VARCHAR(40) NOT NULL,
 TOOLTIP VARCHAR(255),
 CODE TEXT);  
 
CREATE TABLE CHANNEL_ALERT
 (CHANNEL_ID CHAR(36) NOT NULL,
 ALERT_ID CHAR(36) NOT NULL REFERENCES ALERT(ID) ON DELETE CASCADE);

CREATE TABLE ALERT_EMAIL
 (ALERT_ID CHAR(36) NOT NULL REFERENCES ALERT(ID) ON DELETE CASCADE,
 EMAIL VARCHAR(255) NOT NULL);

CREATE SEQUENCE CONFIGURATION_SEQUENCE START WITH 1;

CREATE TABLE CONFIGURATION
 (CATEGORY VARCHAR(255) NOT NULL,
 NAME VARCHAR(255) NOT NULL,
 VALUE TEXT);
 
INSERT INTO PERSON (USERNAME, LOGGED_IN) VALUES('admin', FALSE);

INSERT INTO PERSON_PASSWORD (PERSON_ID, PASSWORD) VALUES(1, 'YzKZIAnbQ5m+3llggrZvNtf5fg69yX7pAplfYg0Dngn/fESH93OktQ==');

INSERT INTO SCHEMA_INFO (VERSION) VALUES ('9');

INSERT INTO CONFIGURATION (CATEGORY, NAME, VALUE) VALUES ('core', 'update.url', 'http://updates.mirthcorp.com');

INSERT INTO CONFIGURATION (CATEGORY, NAME, VALUE) VALUES ('core', 'update.enabled', '1');

INSERT INTO CONFIGURATION (CATEGORY, NAME, VALUE) VALUES ('core', 'stats.enabled', '1');

INSERT INTO CONFIGURATION (CATEGORY, NAME, VALUE) VALUES ('core', 'firstlogin', '1');

INSERT INTO CONFIGURATION (CATEGORY, NAME, VALUE) VALUES ('core', 'server.resetglobalvariables', '1');

INSERT INTO CONFIGURATION (CATEGORY, NAME, VALUE) VALUES ('core', 'smtp.timeout', '5000');

INSERT INTO CONFIGURATION (CATEGORY, NAME, VALUE) VALUES ('core', 'smtp.auth', '0');

INSERT INTO CONFIGURATION (CATEGORY, NAME, VALUE) VALUES ('core', 'smtp.secure', '0');

INSERT INTO CONFIGURATION (CATEGORY, NAME, VALUE) VALUES ('core', 'server.maxqueuesize', '0');

Open XDS make WAR steps



Use Internet Explorer for better solution.

1)     Extract the openxds-web.war file and create a folder [if u want to change] like openxds-web.war

2)    Go to D:\jboss-4.2.3.GA\server\default\deploy\openxds-web.war\WEB-INF\classes folder.


3)   Change your [database] settings in omar.properties, openxds.properties, repository.jdbc.cfg.xml

4)    Find the openxds.properties under the classes folder. Make sure the ihe.actors.dir property uses /conf/axis2repository instead of ./conf/axis2repository . You need to modify the same for the other two properties (axis2 .repo.dir and xds.schema.dir) as well.


5)    Run the server->

Load your actor config files
Give the full path in the file text field instead of selecting browse button.

Ex: D:\jboss-4.2.3.GA\server\default\deploy\openxds-web.war\WEB-INF\classes\conf\actors\IheActors.xml
           
5.1 See below the page [scroll down].
Select all the check box and click start
Takes few min to start…

6)    Open application-context.xml change if u want
update
true

7)    http://localhost:8010/axis2/services/ after you can see the services

8)    Copy the *.jar ‘s file from your openxds-web\web-inf\lib folder to axis\lib [D:\jboss-4.2.3.GA\server\default\deploy\axis2.war\WEB-INF\lib].

Note: Go to the code download and make jar file for common-ws, common-util packages from eclipse and copied into lib folder.


9)   Copy your *.aar file from D:\jboss-4.2.3.GA\server\default\deploy\openxds-web.war\WEB-INF\classes\conf\axis2repository\services
to
D:\jboss-4.2.3.GA\server\default\deploy\axis2.war\WEB-INF\services

10)  



Open XDS - Compile Steps

1) Goto D:\trunk\openxds\openxds-web

type
 mvn install -DskipTests



2)type mvn package
    NOTE: if you found any artifacts missing, copy the command from the console and change the file path. check those jar is in D:\repo or in internet.

3) type the below lines one by one


    mvn install:install-file -DgroupId=org.openhealthexchange.openpixpdq -DartifactId=openpixpdq -Dversion=1.0 -Dpackaging=jar -Dfile=D:\repo\org\openhealthexchange\openpixpdq\openpixpdq\1.0\openpixpdq-1.0.jar
    mvn install:install-file -DgroupId=com.misys.braid -DartifactId=braid-base -Dversion=1.2.2 -Dpackaging=jar -Dfile=D:\repo\com\misys\braid\braid-base\1.2.2\braid-base-1.2.2.jar
    mvn install:install-file -DgroupId=org.openhealthtools.openxds -DartifactId=openxds-core -Dversion=1.0.1 -Dpackaging=jar -Dfile=D:\repo\org\openhealthtools\openxds\openxds-core\1.0.1-SNAPSHOT\openxds-core-1.0.1-SNAPSHOT.jar
    mvn install:install-file -DgroupId=org.openhealthtools.openxds -DartifactId=iheos -Dversion=1.0.1 -Dpackaging=jar -Dfile=D:\repo\org\openhealthtools\openxds\iheos\1.0.1-SNAPSHOT\iheos-1.0.1-SNAPSHOT.jar
        mvn install:install-file -DgroupId=org.openhealthtools.openexchange -DartifactId=openexchange-audit -Dversion=1.0 -Dpackaging=jar -Dfile=D:\repo\org\openhealthtools\openexchange\openexchange-audit\1.0-SNAPSHOT\openexchange-audit-1.0-SNAPSHOT.jar
    mvn install:install-file -DgroupId=org.openhealthtools.openexchange -DartifactId=openexchange-actorconfig -Dversion=1.0 -Dpackaging=jar -Dfile=D:\repo\org\openhealthtools\openexchange\openexchange-actorconfig\1.0-SNAPSHOT\openexchange-actorconfig-1.0-SNAPSHOT.jar

mvn install:install-file -DgroupId=org.openhealthtools.openexchange -DartifactId=openexchange-config -Dversion=1.0 -Dpackaging=jar -Dfile=D:\repo\org\openhealthtools\openexchange\openexchange-config\1.0-SNAPSHOT\openexchange-config-1.0-SNAPSHOT.jar

4) type mvn package


5) Copied the jars from D:\repo into c:\users\\.m2\repository [ if u needed ] or you can point as local repository



Open ATNA

1) Download the source https://www.projects.openhealthtools.org/sf/projects/openatna/


2) Download Maven 2.x

3) Download postgres9.x & install it


4) Type = D:\openatna\trunk\openatna> mvn install:install-file -DgroupId=org.openhealthtools.openexchange -DartifactId=openexchange-actorconfig -Dversion=1.0 -Dpackaging=jar -Dfile=D:\openxds\repo\org\openhealthtools\openexchange\openexchange-actorconfig\1.0-SNAPSHOT\openexchange-actorconfig-1.0-SNAPSHOT.jar


5) Change = D:\openatna\trunk\openatna\audit\pom.xml
    Change to 1.0 for actor-config [ which version you have in ur repo of openxds svn checkout ]

6) Type = D:\openatna\trunk\openatna> mvn install -DskipTests


Database
********

7) Go to D:\openatna\trunk\openatna\audit\src\main\resources\sql
    Use the files to create user and tables etc...


RUN
***

8)To create an executable version of OpenATNA use the following command:

    d:\xxxx> mvn -P exec install

9) COPY =  get D:\openxds\repo\org\openhealthtools\openexchange\openexchange-utils\1.0-SNAPSHOT\openexchange-utils-1.0.jar" 
    OR you can take in from openxds-web.war file web-inf\lib folder
    OR download it
   
    & copy that into D:\openatna\trunk\openatna\all\build\lib

10) Change =
    Go to D:\openatna\trunk\openatna\all\build\openatna-1.2.1-    SNAPSHOT.jar
    extract the META-INF\MANIFEST.MF
    Open it
     add the jar in last line [ one space ].
        lib\openatna-1.2.1-SNAPSHOT.jar

11) This uses a maven profile (-P command). This will create an executable jar file in the "all" directory. Change directory into the all/build folder. You should see a jar file called openatna-version.jar, where version is the version you have downloaded. This is the executable jar file. The dependencies are in the all/build/lib/ directory. To run OpenATNA, type:

    D:\openatna\trunk\openatna\all\build> java -jar openatna-1.2.1-SNAPSHOT.jar


RUN CLIENT
**********
Use eclipse to run it if u cant run the file in command prompt

12) RUN FILE = D:\openatna\trunk\openatna\all\src\test\java\org\openhealthtools\openatna\all\test\TlsClientTest0.java in eclipse [ run as JUNIT ]

13) OUTPUT = go to database tables \ messages etc..


Testing
*******
You can test against the server by running the clients in the "test" directory of the all module. These are JUnit tests and are probably easiest to run inside your IDE. The classes that are designed to run against the server are:


    org.openhealthtools.openatna.dist.test.TlsClientTest0     -    sends messages to the ARR using TLS and Syslog RFC 5424 style messages. The first set of messages use mutually authentication with message encryption. The second set of messages use mutual authentication without message encryption.

    org.openhealthtools.openatna.dist.test.UdpClientTest0     -    sends messages to the ARR using UDP and Syslog RFC 5424 style messages.

    org.openhealthtools.openatna.dist.test.BsdClientTest0     -    sends messages to the ARR using UDP and Syslog BSD style messages.

Some of these tests send erroneous messages to the ARR (on purpose :-)), so you may see error stack traces.


Reporting
*********
The 'web' module contains a simple servlet for querying the database. During the build (when you run 'mvn install') the Servlet is built and and a << war file >> is created. This war file can be dropped into a Servlet container such as Tomcat. For testing purposes, it can also be run using maven. If you change directory into the 'web' directory and type:

D:\openatna\trunk\openatna\web\target\atna.war



Tomcat 6.0
***********
simply copy the war file and run it


JBOSS 6 or Jboss eap 6
**********************

While run from eclipse, add the line in the VM arguments
    Double Click server in the server Prespective
        Open launch Configuration
        add this in VM arg at end with double quotes to avoid logging.properties null error before give one space
       
         "-Dorg.jboss.as.logging.per-deployment=false"



URL : http://localhost:8080/atna





















Log4j SocketAppender with DailyRollingFileAppender

This will create a centralized logging mechanism by using log4j
This will create daily one log-file



Step 1: -
     Create a file called log4j-server.properties and add the below content
log4j.rootLogger=INFO, R
log4j.appender.R=org.apache.log4j.DailyRollingFileAppender
log4j.appender.R.layout=org.apache.log4j.PatternLayout
log4j.appender.R.layout.ConversionPattern=%d [%t] %-5p - %m%n
log4j.appender.R.File=C:/logs/examples
log4j.appender.R.DatePattern='-'yyyyMMdd'.log'

Step 2:-
    Copy log4j-1.2.7.jar into your folder or where log4j-server.properties


Step 3:-   
    Go to cmd prompt and run with the following command.

    Ex:-
   
        D:\Log4j-server\server>    java -classpath log4j-1.2.17.jar org.apache.log4j.net.SimpleSocketServer 4712 log4j-Server.properties
        or
        D:\Log4j-server>   java -classpath .\Server\log4j-1.2.17.jar org.apache.log4j.net.SimpleSocketServer 4712 .\Server\log4j-Server.properties


Step 4:-
    Create a client log4j.properties
and add the below content
log4j.rootLogger=INFO, R
log4j.appender.R=org.apache.log4j.net.SocketAppender
log4j.appender.R.Port=4712
log4j.appender.R.RemoteHost=localhost
log4j.appender.R.ReconnectionDelay=10000

Step 5:- 

            Your Java program.

public class LogTest
{
    private static org.apache.log4j.Logger    log    = Logger.getLogger ( LogTest.class );
public static void main ( String [] args ) throws Exception
    {
      
            log.info ( "First Info Message!" );

            log.trace ( "First Trace Message!" );
            log.debug ( "First Debug Message!" );
            log.warn ( "First Warn Message!" );
            log.error ( "First Error Message!" );
            log.fatal ( "First Fatal Message!" );

}
}





OUTPUT :-

 2013-09-12 00:40:04,395 [main] INFO  - Listening on port 4712
 2013-09-12 00:40:04,400 [main] INFO  - Waiting to accept a new client.
 2013-09-12 00:40:04,751 [main] INFO  - Connected to client at /192.168.7.9
 2013-09-12 00:40:04,751 [main] INFO  - Starting new socket node.
 2013-09-12 00:40:04,760 [main] INFO  - Waiting to accept a new client.
 2013-09-12 00:40:07,736 [main] INFO  - Second Info Message!
 2013-09-12 00:40:07,737 [main] WARN  - Second Warn Message!
 2013-09-12 00:40:07,738 [main] ERROR - Second Error Message!
 2013-09-12 00:40:07,740 [main] FATAL - Second Fatal Message!
 2013-09-12 00:40:12,754 [main] INFO  - Second Info Message!
 2013-09-12 00:40:12,755 [main] WARN  - Second Warn Message!
 2013-09-12 00:40:12,757 [main] ERROR - Second Error Message!
 2013-09-12 00:40:12,758 [main] FATAL - Second Fatal Message!
 2013-09-12 00:40:13,402 [main] INFO  - Connected to client at /192.168.7.9
 2013-09-12 00:40:13,402 [main] INFO  - Starting new socket node.
 2013-09-12 00:40:13,403 [main] INFO  - Waiting to accept a new client.
 2013-09-12 00:40:13,405 [main] INFO  - First Info Message!
 2013-09-12 00:40:13,414 [main] WARN  - First Warn Message!



Hit Counter


View My Stats