Health Level-7 data
application/octet-stream
Magic Bytes
Offset: 0
4D 53 48 7C 42 53 48 7C
The Health Level-7 (HL7) file format is a standard for exchanging electronic health information, developed and maintained by Health Level Seven International. These files are primarily utilized to transmit clinical and administrative data, such as patient admissions, orders, and laboratory results, between disparate healthcare software systems. While the text-based Version 2 standard remains prevalent in legacy infrastructure, strict access controls are required due to the presence of sensitive Protected Health Information (PHI).
Validation Code
How to validate .hl7 files in Python
Python
def is_hl7(file_path: str) -> bool:
"""Check if file is a valid HL7 by magic bytes."""
signature = bytes([0x4D, 0x53, 0x48, 0x7C, 0x42, 0x53, 0x48, 0x7C])
with open(file_path, "rb") as f:
return f.read(8) == signature
How to validate .hl7 files in Node.js
Node.js
function isHL7(buffer: Buffer): boolean {
const signature = Buffer.from([0x4D, 0x53, 0x48, 0x7C, 0x42, 0x53, 0x48, 0x7C]);
return buffer.subarray(0, 8).equals(signature);
}
Go
func IsHL7(data []byte) bool {
signature := []byte{0x4D, 0x53, 0x48, 0x7C, 0x42, 0x53, 0x48, 0x7C}
if len(data) < 8 {
return false
}
return bytes.Equal(data[:8], signature)
}
API Endpoint
GET
/api/v1/hl7
curl https://filesignature.org/api/v1/hl7