There are a number of open-source libraries available for parsing HL7v2 messages in JavaScript.
@redoxengine/redox-hl7-v2
@amida-tech/hl7