web stats
Repeated both OBR and SAC segments - Mirth Community

Go Back   Mirth Community > Mirth Connect > Support

Reply
 
Thread Tools Display Modes
  #1  
Old 11-06-2014, 09:08 AM
andresilva3 andresilva3 is offline
OBX.1 Kenobi
 
Join Date: Oct 2014
Posts: 27
andresilva3 is on a distinguished road
Default Repeated both OBR and SAC segments

So I'm trying to create repeated segments, OBR and SAC. I know many have asked the same question and I've looked at pretty much at every single post out there without success. If I try to create multiple OBR segments it works perfectly but if I do the following code:

Quote:
for(i = 0; i < analises.length(); i++) {
//Criar o segmento para a análise no final da mensagem
var obr = createSegment('OBR');

//Id da Transaccao
obr['OBR.2']['OBR.2.1'] = msg['ORC']['ORC.2']['ORC.2.1'].toString();
tmp.appendChild(obr);

//Percorrer todos os tubos da análise
var tubosAnalise = analises[i].edeia::TubosAnalise.edeia::ProTuboAnalise;

for(j = 0; j < tubosAnalise.length(); j++) {
//Criar o segmento do tubo
var sac = createSegment('SAC');

//SAC.5.1 - Nome do Tubo
sac['SAC.5']['SAC.5.1'] = Descodificar(tubosAnalise[j].edeia:escricao.toString());

//SAC.3.1 - Código de Barras do Tubo
var posicaoEtiqueta = tubosAnalise[j].edeia::PosicaoCodEtiqueta.toString();
var codigoEtiqueta = tubosAnalise[j].edeia::CodEtiqueta.toString();

if(posicaoEtiqueta == "Sufixo" || posicaoEtiqueta == "NaoDefinido") {
sac['SAC.3']['SAC.3.1'] = numeroTubo + codigoEtiqueta;
}

if(posicaoEtiqueta == "Prefixo") {
sac['SAC.3']['SAC.3.1'] = codigoEtiqueta + numeroTubo;
}

tmp.appendChild(sac);
}
}
The ouput message will be like this:

Quote:
MSH|^~\&|CPCHS|CHPVVC|ALERT|CHPVVC|20080814122626| |ORL^O22|1117263|P|2.4|||AL
MSA|AA|15037|OK
PID|||38240505^^^IPO^NS|143162110^^^NIF^PT|FERRAO^ MARIA EDUARDA COELHO CASTANHEIRA CARVALHO ANTAS||20140307000000|F|||RUA CALLOUSTE GULBENKIAN N.\XBA\ 42 3\XBA\ ESQ.^^FIGUEIRA DA FOZ^Coimbra^3080-084^PT|
ORC|OK|286063|341743_S701||||||20080814122626|||99 ^Definido^N\XE3\o
OBR||8187968
SAC|||||Bioquimica|LA192BQ
This means that even if I try to create multiple OBR and SAC segments it will only appear the last of them. createSegmentAfter won't work since I don't really know what the last segment will be.

Any ideas? And again sorry for the thread since this question was asked so many times but after reading all of them I couldn't make this work.

The desired format is something like this :

Quote:
OBR|||||
SAC||||||
SAC||||
OBR|||
SAC||||

Last edited by andresilva3; 11-06-2014 at 09:10 AM.
Reply With Quote
Reply

Tags
loop, reapeated, segment

Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump


All times are GMT -8. The time now is 08:03 AM.


Powered by vBulletin® Version 3.8.7
Copyright ©2000 - 2019, vBulletin Solutions, Inc.
Mirth Corporation