SwatInc / SwatInc.Lis.Lis01A2

This library is an OO implementation of the CLSI LIS01-A2 standard. Specification for Low-Level Protocol to Transfer Messages Between Clinical Laboratory Instruments and Computer Systems
GNU General Public License v3.0
18 stars 16 forks source link

The frame is not included in the tempSnedString? #1

Closed ying234 closed 3 years ago

ying234 commented 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); } }

ibrahimhuycn commented 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.

ibrahimhuycn commented 3 years ago

@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.

Add these namespaces to your code

using SwatInc.Lis.Lis01A2.Interfaces;
using SwatInc.Lis.Lis01A2.Services;
using SwatInc.Lis.Lis02A2;

TCP/IP

      var someIP = "192.168.1.11";
      UInt16 somePort = 1111;
      var lowLevelConnection = new Lis01A02TCPConnection(someIP, somePort);
      var lisConnection = new Lis01A2Connection(lowLevelConnection);

Serial port

      var sp = new System.IO.Ports.SerialPort("COM1");
      // Config Serial port to your needs
      var lowLevelConnection = new Lis01A02RS232Connection(sp);
      var lisConnection = new Lis01A2Connection(lowLevelConnection);

Create LIS parser object and connect

      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)
    {

    }

Now you are ready to receive incoming packets or you can transmit data

            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.

ibrahimhuycn commented 3 years ago

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

ibrahimhuycn commented 3 years ago

Please open another issue if you need more help. I will close this for now