Exemplo n.º 1
0
        private List <string> CreateOrderFrame(List <string> orderList, string patientName)
        {
            var retList = new List <string>();

            //Tạo Header mới
            var newHeaderRecord = (Access2HeaderRecord)_clsHRecord.Clone();

            newHeaderRecord.SenderNameOrId.Data       = _clsHRecord.ReceiverId.Data;
            newHeaderRecord.ReceiverId.Data           = _clsHRecord.SenderNameOrId.Data;
            newHeaderRecord.DateAndTimeOfMessage.Data = DateTime.Now.ToString("yyyyMMddHHmmss");

            var sTemp    = string.Format("{0}{1}{2}{3}", DeviceHelper.STX, "1", newHeaderRecord.Create(), DeviceHelper.ETX);
            var checksum = DeviceHelper.GetCheckSumValue(sTemp);

            retList.Add(string.Format("{0}{1}{2}", sTemp, checksum, DeviceHelper.CRLF));

            //string sTemp = newHeaderRecord.Create();
            _clsPRecord.SequenceNumber.Data = "1";

            //Todo: TestOnly
            //_clsPRecord.PatientId.Data = "0003";
            //_clsPRecord.PatientName.Data = "NGUYEN VAN A^^";
            //_clsPRecord.PatientSex.Data = "U";
            _clsPRecord.PracticeAssignedPatientId.Data = _sQBarcode;
            _clsPRecord.DateOfBirth.Data = "20000101";
            _clsPRecord.PatientName.Data = string.Format("{0}^^^^", patientName);
            _clsPRecord.PatientSex.Data  = "U";

            sTemp    = string.Format("{0}{1}{2}{3}", DeviceHelper.STX, "2", _clsPRecord.Create(), DeviceHelper.ETX);
            checksum = DeviceHelper.GetCheckSumValue(sTemp);
            retList.Add(string.Format("{0}{1}{2}", sTemp, checksum, DeviceHelper.CRLF));

            //Xử lý kết quả )
            if ((orderList != null) && (orderList.Count != 0))
            {
                //Add OrderRecord
                _clsORecord = new Access2TestOrderRecord();
                _clsORecord.SequenceNumber.Data  = "1";
                _clsORecord.SpecimenId.Data      = _sQBarcode;
                _clsORecord.UniversalTestId.Data = _clsORecord.CreateUniversalTestid(orderList);
                sTemp    = string.Format("{0}{1}{2}{3}", DeviceHelper.STX, "3", _clsORecord.Create(), DeviceHelper.ETX);
                checksum = DeviceHelper.GetCheckSumValue(sTemp);
                retList.Add(string.Format("{0}{1}{2}", sTemp, checksum, DeviceHelper.CRLF));

                _clsTRecord = new Access2TerminationRecord {
                    TerminationCode = { Data = "F" }
                };
                sTemp    = string.Format("{0}{1}{2}{3}", DeviceHelper.STX, "4", _clsTRecord.Create(), DeviceHelper.ETX);
                checksum = DeviceHelper.GetCheckSumValue(sTemp);
                retList.Add(string.Format("{0}{1}{2}", sTemp, checksum, DeviceHelper.CRLF));
            }
            else
            {
                _clsTRecord = new Access2TerminationRecord {
                    TerminationCode = { Data = "F" }
                };
                sTemp    = string.Format("{0}{1}{2}{3}", DeviceHelper.STX, "3", _clsTRecord.Create(), DeviceHelper.ETX);
                checksum = DeviceHelper.GetCheckSumValue(sTemp);
                retList.Add(string.Format("{0}{1}{2}", sTemp, checksum, DeviceHelper.CRLF));
            }
            return(retList);
        }