Skip to content

Mirth JSON to HL7 Error #6212

Closed Answered by jgh1189
jgh1189 asked this question in Q&A
May 28, 2024 · 3 comments · 5 replies
Discussion options

You must be logged in to vote

This code addition resolved the original error: 'DETAILS: SyntaxError: Unexpected token: o'

// Check if msg is already a JSON object
var jsonData;
if (typeof msg === 'string') {
    // If it's a string, parse it to a JSON object
    jsonData = JSON.parse(msg);
} else {
    // If it's already an object, use it directly
    jsonData = msg;
}

// Ensure the structure is as expected
if (!jsonData || !jsonData.patientdetails || !Array.isArray(jsonData.encountermetadata)) {
    throw new Error("Invalid JSON structure");
}

Replies: 3 comments 5 replies

Comment options

You must be logged in to vote
3 replies
@jgh1189
Comment options

@pacmano1
Comment options

@jgh1189
Comment options

Comment options

You must be logged in to vote
2 replies
@jgh1189
Comment options

@kirbykn2
Comment options

Comment options

You must be logged in to vote
0 replies
Answer selected by jgh1189
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
None yet
3 participants