Skip to content

Shortening up OBX segments #6235

Answered by pacmano1
dmyers-afk asked this question in Q&A
Jun 28, 2024 · 2 comments · 15 replies
Discussion options

You must be logged in to vote

I would not use my chunker function anymore. @tonygermano pointed out that Apache WordUtils is a better idea.

Not fully QAed, but:

var WordUtils = Packages.org.apache.commons.lang3.text.WordUtils;
var largeString = msg['OBX']['OBX.5']['OBX.5.1'].toString()
var obx_id = msg['OBX']['OBX.3']['OBX.3.1'].toString()
delete msg.OBX
var maxLength = 30;
var wrappedString = WordUtils.wrap(largeString, maxLength);
var brokenStringsArray = wrappedString.split("\n");
// Output the result
var new_obx;
for (var i = 0; i < brokenStringsArray.length; i++) {
    if (i == 0) {
        new_obx = createSegmentAfter('OBX', msg.OBR);
    } else {
        new_obx = createSegmentAfter('OBX', new_obx);    
    }
    

Replies: 2 comments 15 replies

Comment options

You must be logged in to vote
2 replies
@dmyers-afk
Comment options

@dmyers-afk
Comment options

Comment options

You must be logged in to vote
13 replies
@pacmano1
Comment options

@dmyers-afk
Comment options

@dmyers-afk
Comment options

@pacmano1
Comment options

@dmyers-afk
Comment options

Answer selected by pacmano1
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
None yet
2 participants