import HL7Message from "hl7-standard";
this is my function
export function buildHl7OrderMessage(data: HL7OrderMessage): string {
const message = new HL7Message();
console.log('MEssage', message)
if (!data.msh) {
logger.error("Msh is required field cannot process without this");
return "";
}
// --- MSH ---
message.addSegment("MSH", buildMSHSegment(data.msh));
// --- PID ---
message.addSegment("PID", buildPIDSegment(data.pid));
// --- PV1 ---
if (data.pv1) {
message.addSegment("PV1", buildPV1Segment(data.pv1));
}
// --- ORC ---
message.addSegment("ORC", buildORCSegment(data.orc));
// --- OBR ---
data.obr.forEach((ob) => {
message.addSegment("OBR", buildOBRSegment(ob));
});
// --- NTE (multiple allowed) ---
if (data.nte && data.nte.length > 0) {
data.nte.forEach((note, i) => {
message.addSegment("NTE", buildNTESegment(note, note.setId || (i + 1).toString()));
});
}
return message.toString();
}
white executing this function i am getting this issue
TypeError: message.addSegment is not a function
at buildHl7OrderMessage (c:\Projects\bloom-health-api\src\mappers\objectToHl7OrderMapper.ts:23:11)
at VHLBloodTestIntegrationService.uploadTestFromIntervention (c:\Projects\bloom-health-api\src\service\bloodTestIntegration\vhl.ts:64:27)
at process.processTicksAndRejections (node:internal/process/task_queues:95:5)
Node.js v18.19.1
and this same is working on another machine
import HL7Message from "hl7-standard";
this is my function
export function buildHl7OrderMessage(data: HL7OrderMessage): string {
const message = new HL7Message();
console.log('MEssage', message)
if (!data.msh) {
logger.error("Msh is required field cannot process without this");
return "";
}
// --- MSH ---
message.addSegment("MSH", buildMSHSegment(data.msh));
// --- PID ---
message.addSegment("PID", buildPIDSegment(data.pid));
// --- PV1 ---
if (data.pv1) {
message.addSegment("PV1", buildPV1Segment(data.pv1));
}
// --- ORC ---
message.addSegment("ORC", buildORCSegment(data.orc));
// --- OBR ---
data.obr.forEach((ob) => {
message.addSegment("OBR", buildOBRSegment(ob));
});
// --- NTE (multiple allowed) ---
if (data.nte && data.nte.length > 0) {
data.nte.forEach((note, i) => {
message.addSegment("NTE", buildNTESegment(note, note.setId || (i + 1).toString()));
});
}
return message.toString();
}
white executing this function i am getting this issue
TypeError: message.addSegment is not a function
at buildHl7OrderMessage (c:\Projects\bloom-health-api\src\mappers\objectToHl7OrderMapper.ts:23:11)
at VHLBloodTestIntegrationService.uploadTestFromIntervention (c:\Projects\bloom-health-api\src\service\bloodTestIntegration\vhl.ts:64:27)
at process.processTicksAndRejections (node:internal/process/task_queues:95:5)
Node.js v18.19.1
and this same is working on another machine