Closed ying234 closed 3 years ago
The frame is not included in the tempSnedString?
private void SendString(string frame) { if (Status != LisConnectionStatus.Sending) { _logger.Error("Connection not in Send mode when trying to send data."); throw new Lis01A2ConnectionException("Connection not in Send mode when trying to send data."); } Connection.ClearBuffers(); int tryCounter = 0; string tempSendString = $"{STX}{_frameNumber}{CalculateChecksum(frame)}{CR}{LF}"; Connection.WriteData(tempSendString); while (!WaitForACK()) { tryCounter++; if (tryCounter > 5) { StopSendMode(); _logger.Error("Max number of send retries reached."); throw new Lis01A2ConnectionException("Max number of send retries reached."); } Connection.WriteData(tempSendString); } }
Sorry about the late reply. Just saw this today. Can you please explain a bit more, I am not sure what you mean.
@ying234 I am assuming that you are trying reply to a host query or send all pending orders in download mode. Please refer to the code sample below. Let me know if this is not what you are looking for.
using SwatInc.Lis.Lis01A2.Interfaces;
using SwatInc.Lis.Lis01A2.Services;
using SwatInc.Lis.Lis02A2;
var someIP = "192.168.1.11";
UInt16 somePort = 1111;
var lowLevelConnection = new Lis01A02TCPConnection(someIP, somePort);
var lisConnection = new Lis01A2Connection(lowLevelConnection);
var sp = new System.IO.Ports.SerialPort("COM1");
// Config Serial port to your needs
var lowLevelConnection = new Lis01A02RS232Connection(sp);
var lisConnection = new Lis01A2Connection(lowLevelConnection);
var LISParser = new LISParser(lisConnection);
LISParser.OnSendProgress += LISParser_OnSendProgress; //Send data progress will trigger this event
LISParser.OnReceivedRecord += LISParser_OnReceivedRecord; //incoming LIS frames will trigger this event
LISParser.Connection.Connect();
private static void LISParser_OnReceivedRecord(object Sender, ReceiveRecordEventArgs e)
{
}
private static void LISParser_OnSendProgress(object sender, SendProgressEventArgs e)
{
}
var lisRecordList = new List<AbstractLisRecord>();
var hr = new HeaderRecord();
hr.SenderID = "Some Sender ID Code";
hr.ProcessingID = HeaderProcessingID.Production;
lisRecordList.Add(hr);
var pr = new PatientRecord();
pr.SequenceNumber = 1;
pr.LaboratoryAssignedPatientID = "Sam001";
lisRecordList.Add(pr);
var orderRec = new OrderRecord();
orderRec.SequenceNumber = 1;
orderRec.SpecimenID = "Sam001";
orderRec.TestID = new UniversalTestID();
orderRec.TestID.ManufacturerCode = "T001";
orderRec.ReportType = OrderReportType.Final;
lisRecordList.Add(orderRec);
pr = new PatientRecord();
pr.SequenceNumber = 2;
pr.LaboratoryAssignedPatientID = "Sam002";
lisRecordList.Add(pr);
orderRec = new OrderRecord();
orderRec.SequenceNumber = 1;
orderRec.SpecimenID = "Sam002";
orderRec.TestID = new UniversalTestID();
orderRec.TestID.ManufacturerCode = "T001";
orderRec.ReportType = OrderReportType.Final;
lisRecordList.Add(orderRec);
var tr = new TerminatorRecord();
lisRecordList.Add(tr);
LISParser.SendRecords(lisRecordList);
You should not be using the private void SendString
in this case as it set private because it should not be used directly.
On another note, these two libraries are copying the functionality from Essy.LIS. I had to create this repo in C# because those libraries are written in oxygene
and I cannot modify those since oxygene
and the IDE is expensive.
Accidentally closed the issue. The above code samples are from Essy.LIS repository. But they are 100% compatible with code from this repo. Please do let me know if you face any issues
Please open another issue if you need more help. I will close this for now
The frame is not included in the tempSnedString?
private void SendString(string frame) { if (Status != LisConnectionStatus.Sending) { _logger.Error("Connection not in Send mode when trying to send data."); throw new Lis01A2ConnectionException("Connection not in Send mode when trying to send data."); } Connection.ClearBuffers(); int tryCounter = 0; string tempSendString = $"{STX}{_frameNumber}{CalculateChecksum(frame)}{CR}{LF}"; Connection.WriteData(tempSendString); while (!WaitForACK()) { tryCounter++; if (tryCounter > 5) { StopSendMode(); _logger.Error("Max number of send retries reached."); throw new Lis01A2ConnectionException("Max number of send retries reached."); } Connection.WriteData(tempSendString); } }