Back in the day (BizTalk 2002) the incremental numbers in the HL Segments were something that an average developer did not need to worry about.
However, with newer versions comes enhancements, built in tools that make it easier and quicker to develop the same solution. HL Numbering however is actually harder. Microsoft has decided that it is not going to modify any of the data inside of the Transaction using the HIPAA adapter. I had to create a process that would do the numbering.
The trick was to get the numbers to increment regardless of where in the transaction the work was being done. I used some simple C# code to create a constant variable and increment the number.
I created a self contained orchestration that would accept a Claim (institutional or professional) re number it and then send it back. I did this so I can do my mapping logic and then finally plug this in.