Copyright © infotec016 . Powered by Blogger.

Saturday, February 23, 2019

Hl7 Simple Java Client


HL7 Sender Java Code


package hl7sender;
import ca.uhn.hl7v2.DefaultHapiContext;
import ca.uhn.hl7v2.HapiContext;
import ca.uhn.hl7v2.app.Connection;
import ca.uhn.hl7v2.app.Initiator;
import ca.uhn.hl7v2.model.Message;
import ca.uhn.hl7v2.parser.Parser;

public class hl7sender {

   public static void main(String[] args) {

final int PORT_NUMBER = 9014;
// In HAPI, almost all things revolve around a context object.
HapiContext context = new DefaultHapiContext();

      try {
        String adtMessage = "MSH|^~\\&|NES|NINTENDO|TESTSYSTEM|TESTFACILITY|" + "20010101000000||ADT^A01|Q123456789T123456789X123456|P|2.3\r" + "EVN|A01|20010101000000|||^KOOPA^BOWSER\r" + "PID|1||123456789|0123456789^AA^^JP|BROS^MARIO||19850101000000|" + "M|||123 FAKE STREET^MARIO \\T\\ LUIGI BROS PLACE^TOADSTOOL" + "KINGDOM^NES^A1B2C3^JP^HOME^^1234|1234|(555)555-0123^HOME^JP:" + "1234567|||S|MSH|12345678|||||||0|||||N\r" + "NK1|1|PEACH^PRINCESS|SO|ANOTHER CASTLE^^TOADSTOOL KINGDOM" + "^NES^^JP|(123)555-1234|(123)555-2345|NOK\r" + "NK1|2|TOADSTOOL^PRINCESS|SO|YET ANOTHER CASTLE^^TOADSTOOL" + "KINGDOM^NES^^JP|(123)555-3456|(123)555-4567|EMC\r" + "PV1|1|O|ABCD^EFGH||||123456^DINO^YOSHI^^^^^^MSRM^CURRENT" + "^^^NEIGHBOURHOOD DR NBR|^DOG^DUCKHUNT^^^^^^^CURRENT||CRD||" + "|||||123456^DINO^YOSHI^^^^^^MSRM^CURRENT^^^NEIGHBOURHOOD DR" + " NBR|AO|0123456789|1|||||||||||||||||||MSH||A|||20010101000000\r" + "IN1|1|PAR^PARENT||||LUIGI\r";

// create a new MLLP client over the specified port.
Connection connection = context.newClient("localhost", PORT_NUMBER, false);

// The initiator which will be used to transmit our message.
Initiator initiator = connection.getInitiator();

// send the created HL7 message over the connection established
Parser parser = context.getPipeParser();

System.out.println("Sending message:" + "\n" + adtMessage);
Message response = initiator.sendAndReceive(parser.parse(adtMessage));

// display the message response received from the remote party
String responseString = parser.encode(response);
System.out.println("Received response:\n" + responseString.replaceAll("\r", "\n"));
        }
        catch (Exception e) {
           e.printStackTrace();
        }
   }
}


HL7 Receiver Java Code

This main class is used to


package hl7receiver;

import ca.uhn.hl7v2.DefaultHapiContext;

import ca.uhn.hl7v2.HapiContext;
import ca.uhn.hl7v2.app.HL7Service;
import ca.uhn.hl7v2.parser.Parser;
import ca.uhn.hl7v2.parser.PipeParser;

public class hl7receiver {

    public static void main(String args[]) {

        final int PORT_NUMBER = 9014;
        //In HAPI,almost all things revolve around a context object
        HapiContext context = new DefaultHapiContext();
        try {
            Parser parser = new PipeParser();
            HL7Service ourHl7Server =                   context.newServer(PORT_NUMBER, false);
            // You can set up routing rules for your HL7 listener by extending the AppRoutingData class
            ourHl7Server.registerApplication(new     RegisterEventRouter(), new ourSimpleApplication());
            ourHl7Server.setShutdownTimeout(10000);
            ourHl7Server.startAndWait();
        } catch (Exception e) {
            e.printStackTrace();
        }
    }
}


Simple Application class that is used to receive the message and create and send the acknowledgement

package hl7receiver;

import ca.uhn.hl7v2.HL7Exception;

import ca.uhn.hl7v2.model.Message;
import ca.uhn.hl7v2.parser.PipeParser;
import ca.uhn.hl7v2.protocol.ReceivingApplication;
import ca.uhn.hl7v2.protocol.ReceivingApplicationException;

import java.io.IOException;
import java.util.Map;

public class ourSimpleApplication implements ReceivingApplication {

    PipeParser pipeParser = new PipeParser();

    public Message processMessage(Message message, Map map) throws
 ReceivingApplicationException, HL7Exception {

        System.out.println("Received Message\n" + pipeParser.encode(message));
        Message response = null;
        try {
            response = message.generateACK();
            System.out.println("Sent Response\n" + pipeParser.encode(response));
        } catch (IOException e) {
            e.printStackTrace();
        }
        return response;
    }

    public boolean canProcess(Message message) {

        return true;
    }
}



Event Router class that is used to rout the message to the appropriate versions and types.


package hl7receiver;

import ca.uhn.hl7v2.protocol.ApplicationRouter;


public class RegisterEventRouter implements ApplicationRouter.AppRoutingData {

    public String getMessageType() {

        return "*";
    }

    public String getTriggerEvent() {

        return "*";
    }

    public String getProcessingId() {

        return "*";
    }

    public String getVersion() {

        return "*";
    }

}

Friday, February 22, 2019

Hl7 Java Client with Tls


HL7 Sender Java Code


package hl7senderwithTls;

import ca.uhn.hl7v2.DefaultHapiContext;
import ca.uhn.hl7v2.HL7Exception;
import ca.uhn.hl7v2.HapiContext;
import ca.uhn.hl7v2.app.Connection;
import ca.uhn.hl7v2.app.Initiator;
import ca.uhn.hl7v2.hoh.sockets.CustomCertificateTlsSocketFactory;
import ca.uhn.hl7v2.hoh.util.HapiSocketTlsFactoryWrapper;
import ca.uhn.hl7v2.hoh.util.KeystoreUtils;
import ca.uhn.hl7v2.llp.LLPException;
import ca.uhn.hl7v2.model.Message;
import ca.uhn.hl7v2.parser.Parser;

import java.io.IOException;
import java.security.KeyStore;
import java.security.KeyStoreException;
import java.security.NoSuchAlgorithmException;
import java.security.cert.CertificateException;

public class hl7senderwithTls {

    public static void main(String[] args) throws HL7Exception, 
     LLPException, IOException {

        final int PORT_NUMBER = 9014;
        final String tlsKeystoreFilepath = "src/main/resources/keystore.jks";
        final String tlsKeystorePassphrase = "changeit";
        final String tlsKeystoreType = "JKS";

        // InHAPI almost all things revolve around a context object
        HapiContext context = new DefaultHapiContext();

        String adtMessage = "MSH|^~\\&|NES|NINTENDO|TESTSYSTEM|TESTFACILITY" + 
                "|20010101000000||ADT^A01|Q123456789T123456789X123456|P|2.3\r" +
                "EVN|A01|20010101000000|||^KOOPA^BOWSER\r";
        try {
            //To validate the keystore
            KeyStore keyStore = KeystoreUtils.loadKeystore(tlsKeystoreFilepath, 
             tlsKeystorePassphrase);
            KeyStore.getInstance(tlsKeystoreType);
            KeystoreUtils.validateKeystoreForTlsSending(keyStore);
            CustomCertificateTlsSocketFactory tlsFac = new 
             CustomCertificateTlsSocketFactory(tlsKeystoreType,
                    tlsKeystoreFilepath, tlsKeystorePassphrase);
            context.setSocketFactory(new HapiSocketTlsFactoryWrapper(tlsFac));
        } catch (IOException e) {
            e.printStackTrace();
        } catch (CertificateException e) {
            e.printStackTrace();
        } catch (NoSuchAlgorithmException e) {
            e.printStackTrace();
        } catch (KeyStoreException e) {
            e.printStackTrace();
        }
        // create a new MLLP client over the specified port
        Connection connection = context.newClient("localhost", PORT_NUMBER, true);

        // The initiator which will be used to transmit our message
        Initiator initiator = connection.getInitiator();

        // send the created HL7 message over the connection established
        Parser parser = context.getPipeParser();
        System.out.println("Sending message:" + "\n" + adtMessage);
        Message response = initiator.sendAndReceive(parser.parse(adtMessage));

        // display the message response received from the remote party
        String responseString = parser.encode(response);
        System.out.println("Received response:\n" + responseString.replaceAll("\r", "\n"));

    }
}

HL7 Receiver Java Code

This main class is used to


package hl7receiverwithTls;

import ca.uhn.hl7v2.DefaultHapiContext;
import ca.uhn.hl7v2.HapiContext;
import ca.uhn.hl7v2.app.HL7Service;
import ca.uhn.hl7v2.hoh.sockets.CustomCertificateTlsSocketFactory;
import ca.uhn.hl7v2.hoh.util.HapiSocketTlsFactoryWrapper;
import ca.uhn.hl7v2.hoh.util.KeystoreUtils;
import ca.uhn.hl7v2.parser.Parser;
import ca.uhn.hl7v2.parser.PipeParser;

import java.io.IOException;
import java.security.KeyStore;
import java.security.KeyStoreException;
import java.security.NoSuchAlgorithmException;
import java.security.cert.CertificateException;

public class hl7receiverwithTls {
    public static void main(String[] args) throws InterruptedException {

        final int PORT_NUMBER = 9014;
        final String tlsKeystoreFilepath = "src/main/resources/keystore.jks";
        final String tlsKeystorePassphrase = "changeit";
        final String tlsKeystoreType = "JKS";
        // In HAPI, almost all things revolve around a context object
        HapiContext context = new DefaultHapiContext();
        try {
            //To validate the keystore
            KeyStore keyStore = KeystoreUtils.loadKeystore(tlsKeystoreFilepath, tlsKeystorePassphrase);
            KeyStore.getInstance(tlsKeystoreType);
            KeystoreUtils.validateKeystoreForTlsSending(keyStore);
            CustomCertificateTlsSocketFactory tlsFac = new CustomCertificateTlsSocketFactory(tlsKeystoreType,
                    tlsKeystoreFilepath, tlsKeystorePassphrase);
            context.setSocketFactory(new HapiSocketTlsFactoryWrapper(tlsFac));
        } catch (IOException e) {
            e.printStackTrace();
        } catch (CertificateException e) {
            e.printStackTrace();
        } catch (NoSuchAlgorithmException e) {
            e.printStackTrace();
        } catch (KeyStoreException e) {
            e.printStackTrace();
        }
            Parser parser = new PipeParser();
            HL7Service ourHl7Server = context.newServer(PORT_NUMBER, true);
            // You can set up routing rules for your HL7 listener by extending the AppRoutingData class
            ourHl7Server.registerApplication(new RegisterEventRouter(), new ourSimpleApplication());
            ourHl7Server.setShutdownTimeout(10000);
            ourHl7Server.startAndWait(); 
    }
}


Simple Application class that is used to receive the message and create and send the acknowledgement

package hl7receiverwithTls;

import ca.uhn.hl7v2.HL7Exception;
import ca.uhn.hl7v2.model.Message;
import ca.uhn.hl7v2.parser.PipeParser;
import ca.uhn.hl7v2.protocol.ReceivingApplication;
import ca.uhn.hl7v2.protocol.ReceivingApplicationException;

import java.io.IOException;
import java.util.Map;

public class ourSimpleApplication implements ReceivingApplication {

    PipeParser pipeParser = new PipeParser();

    public Message processMessage(Message message, Map map) throws ReceivingApplicationException, HL7Exception {

        System.out.println("Received Message\n" + pipeParser.encode(message));
        Message response = null;
        try {
            response = message.generateACK();
            System.out.println("Sent Response\n" + pipeParser.encode(response));
        } catch (IOException e) {
            e.printStackTrace();
        }
        return response;
    }

    public boolean canProcess(Message message) {

        return true;
    }
}


Event Router class that is used to rout the message to the appropriate versions and types.


package hl7receiverwithTls;

import ca.uhn.hl7v2.protocol.ApplicationRouter;

public class RegisterEventRouter implements ApplicationRouter.AppRoutingData {

    public String getMessageType() {

        return "*";
    }

    public String getTriggerEvent() {

        return "*";
    }

    public String getProcessingId() {

        return "*";
    }

    public String getVersion() {

        return "*";
    }

}


Thursday, February 21, 2019

Sunday, August 26, 2018

Friday, August 17, 2018

Evolution of Computers


First Generation (1940-1956)


    Image result for generation of computer png
  • Major Hardware Technology: Vacuum Tubes, Punch Cards
  • Used Machine language
  • High heat generation
  • Slow processing
  • Large in size
  • Not portable
  • Consumes a lot of electricity
  • Expensive
  • System Invented: ENIAC, UNIVAC, IBM704, EDVAC, EDSAC

Second Generation (1956-1963)

  • Major Hardware Technology: Transistors, Tape
  • Use of Assembly language
  • Smaller in siz
  • Less heat generation
  • Less power consumption

Tuesday, August 14, 2018

Shutdown, Sleep, Hibernate


Shutdown

when you finish your work with pc or no need or infrequently usage then you can shutdown the pc.
You should save your current works before shutting down
if not, you will permanently loss your current work.

Sleep

sleep is a power saving state that allows a computer to quickly resume full-power operation when you want to start working again.
In sleep mode, your current work is saved in the RAM.
Related image
It will consume less power and often disable hardware and suspend software to assist in reducing power consumption.
It the power is cut while sleep mode, most probably  it will lost your works where you left.
In hybrid sleep mode,with RAM it always save the current work to the hard disk for safe keeping in the event of power cut.

Image result for sleep mode icon png

Hibernate

Hibernate mode is almost the same thing as fully shutting down the PC, but it saves your place  to resume the next time you turn it on.
Instead of saving to your RAM like sleep mode, it saves straight to your hard disk so that there's no chance of losing anything if power is cut.
It takes bit longer than the sleep mode but it depends on the hard disk and RAM speed.

Friday, August 10, 2018

HTML5- Content models


Meta data
Content that sets up the presentation or behavior of the rest of the content. These elements are found in the head of the document.
Elements:
<base>, <link>, <meta>, <noscript>, <script>, <style>, <title>
Embedded
Content that imports other resources into the document.
Elements: 
<audio>,  <video>, <canvas>, <iframe>, <img>, <math>, <object>, <svg>
Interactive Content specifically intended for user interaction.
Elements:
<a>, <audio>, <video>, <button>, <details>, <embed>, <iframe>, <img>, <input>, <label>, <object>, <select>, <textarea>
Heading
Defines a section header.
Elements:
<h1>, <h2>, <h3>, <h4>, <h5>, <h6>, <hgroup>
Phrasing
This model has a number of inline level elements in common with HTML4.
Elements:
<img>, <span>, <strong>, <label>, <br />, <small>, <sub>, and more.
Flow
Contains the majority of HTML5 elements that would be included in the normal flow of the document.
Sectioning
Defines the scope of headings, content, navigation, and footers.
Elements:
<article>, <aside>, <nav>, <section>