"If a worker wants to do his job well, he must first sharpen his tools." - Confucius, "The Analects of Confucius. Lu Linggong"
Front page > Programming > HLHealth Level Seven)

HLHealth Level Seven)

Published on 2024-11-02
Browse:400

HLHealth Level Seven)

HL7, also known as Health Level 7, is a messaging and clinical standards standard used for the integration, exchange, management and retrieval of electronic information in different health systems. It is a protocol based on transactions that are triggered by events, such as the admission of a patient to a hospital. HL7 facilitates the exchange of information in the field of public health.

This is a widely accepted international standard for data exchange in the health sector, being independent of the platform and technology used.

Why use HL7?

Healthcare systems usually use different applications, developed in different programming languages ​​and with varied functionalities. For example, hospitals often have complex, customized systems, while general practitioners often use off-the-shelf practice management software. Medical research institutes, for their part, may use software that is part of a larger network, such as that of a university. On many occasions, these institutions need to exchange data about patients.

The purpose of HL7 is to enable healthcare organizations to generate consistent data, accessible to any authorized person, regardless of the system they use. Interoperability between healthcare organizations requires that the interfaces of the different systems use a common protocol such as HL7.

Who uses HL7?

  • Hospitals
  • Medical imaging centers
  • Doctors
  • Government clinics
  • Laboratories
  • Residences
  • Pharmacies, among others

Types of HL7 Messages

  • ACK — General acknowledgment
  • ADT — Patient admission, discharge and transfer
  • BAR — Billing Account Creation/Change
  • DFT — Detailed financial transaction
  • MDM — Medical Document Management
  • MFN — Master File Notification
  • ORM — Order (Pharmacy/treatment)
  • ORU — Observation result (unsolicited)
  • QRY — Query, original mode
  • RAS — Pharmacy/treatment administration
  • RDE — Pharmacy/Treatment Coded Order
  • RGV — Pharmacy/treatment administration
  • SIU — Unsolicited scheduling information

Most common ADT messages:

  • ADT-A01: Patient admission.
  • ADT-A02: Patient transfer.
  • ADT-A03: Patient discharge.
  • ADT-A04: Patient registration.
  • ADT-A05: Patient pre-admission.
  • ADT-A08: Update patient information.
  • ADT-A11: Cancellation of the patient's admission.
  • ADT-A12: Cancellation of patient transfer.

How are HL7 messages transmitted?

Generally, HL7 messages are transmitted using the TCP/IP protocol over a local network, such as within a hospital network. TCP/IP data is sent as a stream of bytes, allowing multiple messages to be sent in a continuous stream. This can cause confusion, so it is necessary to clearly define the start and end point of each message. For this, the Minimum Lower Layer Protocol (MLP) is used, which adds a header and a footer to each message.

Minimum Lower Layer Protocol (MLP) refers to a basic protocol that operates at the lower layers of the network stack, such as the physical or data link layer. Provides the fundamental functions necessary for communication between network devices, specifying how to wrap an HL7 message with a header and footer to ensure that the beginning and end of each message, as well as the beginning of the next, are correctly identified.

Basic example of a Java program that takes an HL7 message, saves it to an object, and then prints its details to the console:

public class HL7Message {
    private String message;

    public HL7Message(String message) {
        this.message = message;
    }

    public String getMessageType() {
        return message.split("\\|")[8];
    }

    public String getPatientID() {
        return message.split("\\|")[3];
    }

    public String getPatientName() {
        return message.split("\\|")[5];
    }

    public void printDetails() {
        System.out.println("HL7 Message Details:");
        System.out.println("Message Type: "   getMessageType());
        System.out.println("Patient ID: "   getPatientID());
        System.out.println("Patient Name: "   getPatientName());
    }

    public static void main(String[] args) {
        String hl7Message = "MSH|^~\\&|HIS|RIH|EKG|EKG|202308120830||ADT^A01|MSG00001|P|2.5|"
                            "PID|1||123456||DOE^JOHN^A||19680219|M|||123 MAIN ST^^ANYTOWN^OH^12345|(555)555-1234|||M|NON|||123-45-6789";

        HL7Message message = new HL7Message(hl7Message);
        message.printDetails();
    }
}

Explanation:

HL7Message Class: This class contains the HL7 message and provides methods to extract and display some basic details such as the message type, patient ID, and patient name.

getMessageType: This method extracts the message type from HL7 (field 9).

getPatientID: This method extracts the patient ID (field 4).

getPatientName: This method extracts the patient name (field 6).

printDetails: This method prints the details of the HL7 message.

main: In the main method, you define a sample HL7 message, create an HL7Message object with the message, and print the details.

This program is basic and only handles a very simple HL7 message. Depending on the requirements, you may need a more advanced implementation to handle the full structure of HL7 messages.

Basic Java program that generates an HL7 message from a prepopulated HL7Message object:

public class HL7Message {
    private String sendingApplication;
    private String sendingFacility;
    private String receivingApplication;
    private String receivingFacility;
    private String messageDateTime;
    private String messageType;
    private String messageControlID;
    private String processingID;
    private String versionID;
    private String patientID;
    private String patientLastName;
    private String patientFirstName;
    private String patientDOB;
    private String patientGender;
    private String patientAddress;
    private String patientPhoneNumber;
    private String patientSSN;

    // Constructor
    public HL7Message(String sendingApplication, String sendingFacility, String receivingApplication,
                      String receivingFacility, String messageDateTime, String messageType,
                      String messageControlID, String processingID, String versionID, String patientID,
                      String patientLastName, String patientFirstName, String patientDOB, String patientGender,
                      String patientAddress, String patientPhoneNumber, String patientSSN) {
        this.sendingApplication = sendingApplication;
        this.sendingFacility = sendingFacility;
        this.receivingApplication = receivingApplication;
        this.receivingFacility = receivingFacility;
        this.messageDateTime = messageDateTime;
        this.messageType = messageType;
        this.messageControlID = messageControlID;
        this.processingID = processingID;
        this.versionID = versionID;
        this.patientID = patientID;
        this.patientLastName = patientLastName;
        this.patientFirstName = patientFirstName;
        this.patientDOB = patientDOB;
        this.patientGender = patientGender;
        this.patientAddress = patientAddress;
        this.patientPhoneNumber = patientPhoneNumber;
        this.patientSSN = patientSSN;
    }

    // Método para generar el mensaje HL7
    public String generateHL7Message() {
        StringBuilder hl7Message = new StringBuilder();

        // MSH Segment
        hl7Message.append("MSH|^~\\&|")
                  .append(sendingApplication).append("|")
                  .append(sendingFacility).append("|")
                  .append(receivingApplication).append("|")
                  .append(receivingFacility).append("|")
                  .append(messageDateTime).append("||")
                  .append(messageType).append("|")
                  .append(messageControlID).append("|")
                  .append(processingID).append("|")
                  .append(versionID).append("\r");

        // PID Segment
        hl7Message.append("PID|1||")
                  .append(patientID).append("||")
                  .append(patientLastName).append("^")
                  .append(patientFirstName).append("||")
                  .append(patientDOB).append("|")
                  .append(patientGender).append("|||")
                  .append(patientAddress).append("|")
                  .append(patientPhoneNumber).append("|||||||")
                  .append(patientSSN).append("\r");

        return hl7Message.toString();
    }

    public static void main(String[] args) {
        // Llenar los datos del objeto HL7Message
        HL7Message message = new HL7Message(
            "HIS",               // sendingApplication
            "RIH",               // sendingFacility
            "EKG",               // receivingApplication
            "EKG",               // receivingFacility
            "202308120830",      // messageDateTime
            "ADT^A01",           // messageType
            "MSG00001",          // messageControlID
            "P",                 // processingID
            "2.5",               // versionID
            "123456",            // patientID
            "DOE",               // patientLastName
            "JOHN",              // patientFirstName
            "19680219",          // patientDOB
            "M",                 // patientGender
            "123 MAIN ST^^ANYTOWN^OH^12345", // patientAddress
            "(555)555-1234",     // patientPhoneNumber
            "123-45-6789"        // patientSSN
        );

        // Generar y mostrar el mensaje HL7
        String hl7Message = message.generateHL7Message();
        System.out.println("Generated HL7 Message:\n"   hl7Message);
    }
}

Explanation:

HL7Message Class: This class contains the fields necessary for a simple HL7 message, including information about the sending application, the receiving application, and patient details.

generateHL7Message: This method constructs the HL7 message using the provided fields and formats them in a standard HL7 format. Two segments are being generated here: MSH (message header)

Release Statement This article is reproduced at: https://dev.to/fullsnacker/hl7-health-level-seven-1738?1 If there is any infringement, please contact [email protected] to delete it
Latest tutorial More>

Disclaimer: All resources provided are partly from the Internet. If there is any infringement of your copyright or other rights and interests, please explain the detailed reasons and provide proof of copyright or rights and interests and then send it to the email: [email protected] We will handle it for you as soon as possible.

Copyright© 2022 湘ICP备2022001581号-3