Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 2 additions & 1 deletion hl7/Ballerina.toml
Original file line number Diff line number Diff line change
@@ -1,12 +1,13 @@
[package]
org = "ballerinax"
name = "health.clients.hl7"
version = "1.0.2"
version = "2.0.0"
distribution = "2201.12.3"
authors=["Ballerina"]
keywords=["Healthcare", "HL7", "client", "HL7V2"]
icon = "icon.png"
repository="https://github.com/ballerina-platform/module-ballerinax-health.clients"
readme = "Package.md"

[build-options]
observabilityIncluded = true
2 changes: 1 addition & 1 deletion hl7/Dependencies.toml
Original file line number Diff line number Diff line change
Expand Up @@ -144,7 +144,7 @@ modules = [
[[package]]
org = "ballerinax"
name = "health.clients.hl7"
version = "1.0.2"
version = "2.0.0"
dependencies = [
{org = "ballerina", name = "log"},
{org = "ballerina", name = "tcp"},
Expand Down
94 changes: 94 additions & 0 deletions hl7/Package.md
Original file line number Diff line number Diff line change
Expand Up @@ -14,3 +14,97 @@ This package is used to connect to a HL7 exchange(server) using the HL7Client.
### Features and Capabilities

* Send HL7 message to remote HL7 exchage using TCP

## Usage

This module provides the `HL7Client` client to send HL7 messages to remote HL7 endpoints.

```ballerina
import ballerinax/hl7v2;
import ballerinax/health.clients.hl7;

public function main() returns error? {
// Initialize the client
hl7:HL7Client hl7Client = check new("localhost", 9876);

// Create an HL7 message
hl7v2:Message adtMessage = check getHL7Message();
hl7v23:adt_a01 adtMessage = {
msh: {
msh1: "|",
msh2: "^~\\&",
msh3: {
hd1: "HOSPITAL_EMR"
},
msh4: {
hd1: "MAIN_HOSPITAL"
},
msh5: {
hd1: "RAPP"
},
msh6: {
hd1: "198808181126"
},
msh7: {
ts1: "2020-05-08T13:06:43"
},
msh9: {
msg1: "ADT",
msg2: "A01"
},
msh10: "99302882jsh",
msh11: {
pt1: "P"
},
msh12: {
vid1: hl7v24:VERSION
},
msh15: "AL",
msh17: "44",
msh18: ["ASCII"]
},
evn: {
evn1: "NEW_ADMISSION"
},
pid: {
pid5: [
{
xpn1: {
fn1: "Doe"},
xpn2: "John",
xpn3: "Hamish"
}
]
},pv1: {}
};

// Send the message
hl7v2:Message|hl7v2:HL7Error response = hl7Client->sendMessage(adtMessage);

if response is hl7v2:Message {
// Process response
} else {
// Handle error
}
}
```

#### Configuring Secure Connection
To configure TLS for the HL7 client, you can pass a `secureSocket` configuration in the `tcp:ClientConfiguration` when initializing the client. This allows secure communication with the HL7 server.

```ballerina
hl7:HL7Client hl7Client = check new("localhost", 9876, config = {
secureSocket: {
// public certificate for server verification
cert: "../resource/path/to/public.crt"
}
});
```

## Error Handling

The client returns various types of `hl7v2:HL7Error` instances based on the type of error:

- `HL7_V2_MSG_VALIDATION_ERROR`: When there are issues with the message content (empty message, invalid version, etc.)
- `HL7_V2_CLIENT_ERROR`: When there are issues with the client connection
- `HL7_V2_PARSER_ERROR`: When there are issues parsing the response message
Loading