Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Feature Request: Support for HTTP Server to Receive HL7 Messages #93

Open
soniharshil54 opened this issue Aug 28, 2023 · 1 comment
Open

Comments

@soniharshil54
Copy link

I'm reaching out to see if there's any interest or plans in adding support for receiving HL7 messages over HTTP. I've got scenarios where receiving HL7 via HTTP POST would fit the bill perfectly.

@bluepuma77
Copy link

You can create your own http server, pass incoming HL7 message to parser, build and send back the ack.

import moment from 'moment';
import {Message, Parser} from 'simple-hl7';

function parseHL7(raw) {
    // parse HL7 message
    let parser = new Parser({ segmentSeperator: '\r' })
    let hl7 = parser.parse(raw);

    // fallback: process regular line break
    if (!hl7.getSegment('PV1')) {
        parser = new Parser({ segmentSeperator: '\n' })
        hl7 = parser.parse(raw);
    }

    //  build HL7 acknowledge message
    var ack = new Message(
        hl7.header.getField(3),
        hl7.header.getField(4),
        hl7.header.getField(1),
        hl7.header.getField(2),
        moment().format('YYYYMMDDHHmmss'),
        '',
        ['ACK', hl7.header.getComponent(7, 2), 'ACK'],
        'ACK' + moment().format('YYYYMMDDHHmmss'),
        'P',
        hl7.header.getField(10),
    );
    ack.addSegment("MSA", "AA", hl7.header.getField(8))

    return ack.toString()+'\n'
}

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants