HL7 icon indicating copy to clipboard operation
HL7 copied to clipboard

Important Question

Open juankprz opened this issue 3 years ago • 3 comments

Because when instantiating the creation of a message and sending it, the hl7 server responds with ack: list index out of limits 3, as if the message was not separating the segments with \n

juankprz avatar May 03 '21 20:05 juankprz

Can you please give an example of such message and code snippet?

senaranya avatar May 11 '21 03:05 senaranya

use Aranyasen\HL7\Message; // If Message is used use Aranyasen\HL7\Segment; // If Segment is used use Aranyasen\HL7\Segments\MSH; // If MSH is used use Aranyasen\HL7\Segments\PID; use Aranyasen\HL7\Segments\PV1; use Aranyasen\HL7\Segments\IN1; use Aranyasen\HL7\Segments\OBR; use Aranyasen\HL7\Segments\ORC; use Aranyasen\HL7\Connection; $msg = new Message(); // Either \n or \r can be used as segment endings //segmento mensaje $msh = new MSH(); $msh->setMessageType('ORM'); $msh->setSendingApplication('ABC'); $msh->setSendingFacility('HHH'); $msh->setReceivingApplication('DFC'); $msh->setReceivingFacility('GGG'); $msh->setMessageType('ORM^O01'); $msh->setVersionId('2.5'); $msh->setMessageControlId('449'); $msh->setCharacterSet('8859/1'); $msg->addSegment($msh); //segmento PID $PID = new PID();

$PID->setDateTimeOfBirth('19300101120000'); $PID->setPatientAddress('CL 26 79-247^MEDELLIN^05001^P'); $PID->setPatientAlias('YEPES ^LETICIA'); $PID->setPatientID('123456^CC'); $PID->setPatientIdentifierList('123456'); $PID->setPatientName('YEPES DE HOYOS^LETICIA'); $PID->setPhoneNumberBusiness('3004115511'); $PID->setPhoneNumberHome('2567124'); $PID->setSex('F'); $msg->addSegment($PID); $PV1 = new PV1(); $PV1 ->setPatientClass('I'); $PV1 ->setAdmissionType('406'); $PV1 ->setVisitNumber('10'); $PV1->setAdmitDateTime('20210226101822'); $msg->addSegment($PV1); $IN1 = new IN1(); $IN1->setInsuranceCompanyID('CPA'); $IN1->setInsuranceCompanyName('CLINICA S.A'); $msg->addSegment($IN1); $ORC = new ORC(); $ORC->setOrderControl('NW'); $ORC->setPlacerOrderNumber('A04-025-1'); $ORC->setOrderStatus('SC'); $ORC->setQuantityTiming('20210408111810'); $msg->addSegment($ORC); $OBR = new OBR(); $OBR->setPlacerOrderNumber('A04-025-1'); $OBR->setUniversalServiceID('872002^RADIOGRAFIA DE ABDOMEN SIMPLE'); $OBR->setRequestedDatetime('20210427115420'); $OBR->setRelevantClinicalInfo('86000'); $msg->addSegment($OBR);

$ip = '127.0.0.1'; // An IP $port = '30000';

// And Port where a HL7 listener is listening // Create a Socket and get ready to send message. Optionally add timeout in seconds as 3rd argument (default: 10 sec) $connection = new Connection($ip, $port);

$response = $connection->send($msg); // Send to the listener, and get a response back echo $response->toString(true); // Prints ACK from the listener

juankprz avatar May 11 '21 16:05 juankprz

\n is added by default. The server probably expects a \r and not \n. Please try with this:

.
.
.
$hl7Globals  = ['SEGMENT_SEPARATOR' => '\r\n'];
$msg = new Message(null, $hl7Globals); // Either \n or \r can be used as segment endings
//segmento mensaje
$msh = new MSH(null, $hl7Globals);
.
.
.

senaranya avatar Jun 01 '21 07:06 senaranya

Closing due to inactivity

senaranya avatar Apr 07 '23 06:04 senaranya