Giter VIP home page Giter VIP logo

net_hl7's Introduction

HL7 API: README

Contents

1.0 Introduction
2.0 Usage
2.1 Creating messages
2.2 Sending/receiving

1.0 Introduction

This is the PHP HL7 API. It is a very simple, but rather flexible API for use in PHP applications. The API is a word for word translation of the Perl Net-HL7 package, based on version 0.72.

The focus of this API is on providing functionality for the composition, manipulation and decomposition of HL7 messages, not providing hundreds of prefab HL7 messages. In HL7 terms: this API focuses on the HL7 syntax, not the semantics. This makes the API support all versions that use the classic HL7 syntax, that is, versions untill 3.x. This API does not do XML!

2.0 Usage

2.1 Creating messages

To create an HL7 message, simply do this:

$msg = new Net_HL7_Message();

this gives you an empty message, that doesn't containt ANY segments (not even the header segment). You might also have a string representation of your message at hand, in which case you can do this:

$msg = new Net_HL7_Message(<your string>);

Make sure to escape any characters that have special meaning in PHP!

2.2 Sending/receiving

A full example of sending and receiving a message is listed here, assuming you have an HL7 server on your localhost, listening to port 12002 (you might want to use the hl7d from the Perl HL7 Toolkit package as a simple test server; http://hl7toolkit.sourceforge.net/):

<?php
require_once "Net/HL7/Segments/MSH.php";
require_once "Net/HL7/Message.php";
require_once "Net/HL7/Connection.php";

$msg  = new Net_HL7_Message();
$msg->addSegment(new Net_HL7_Segments_MSH());

$seg1 = new Net_HL7_Segment("PID");

$seg1->setField(3, "XXX");

$msg->addSegment($seg1);

echo "Trying to connect";
$socket = new Net_Socket();
$success = $socket->connect("localhost", 12002);

if ($success instanceof PEAR_Error) {
    echo "Error: {$success->getMessage()}";
    exit(-1);
}

$conn = new Net_HL7_Connection($socket);

echo "Sending message\n" . $msg->toString(true);

$resp = $conn->send($msg);

$resp || exit(-1);

echo "Received answer\n" . $resp->toString(true);

$conn->close();
?>

net_hl7's People

Contributors

clockwerx avatar kenguest avatar till avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.