So there's a way to use a for loop to iterate through an HL7 section, such as OBX.
Now imagine the HL7 message looks something like this:
OBX|1||Name|1|This is a line of text
OBX|1||Name|2|This is the second line
OBX|1||Name|3|
OBX|1||Name|4|
OBX|1||Name|5|
OBX|1||Name|6|
OBX|1||Name|7|This is now the second paragraph.
OBX|1||Name|8|
OBX|1||Name|9|This starts the third paragraph.
If in formatting the message, we'd like to keep a single blank line when it exists, but remove multiple blank lines with a single one (ie 3-6 with a single blank line) is there a way to do this?
You can iterate and then do something like StringUtils.isBlank, but how do you track how many lines are blank, and then delete them, given this number could change in how many blank lines there are between segments?
Could this be something like identifying when the first instance happens, then the last, and iterate between them? Would that be a for loop inside the for loop? Something like having a variable that iterates, and when isblank it is increased, and when it isn't, it's compared to see if it's greater than 1, and if so, you delete i-1 obx segments?