using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace Rdh.SocketServer.Client.Models
{
    /// <summary>
    /// 表示药品使用信息的协议
    /// </summary>
    public class DrugUsageProtocol : ModelProtocol
    {
        /// <summary>
        /// 获取或设置药品EPC/条码
        /// </summary>
        public string? Barcode { get; set; }
        /// <summary>
        /// 获取或设置药品主键
        /// </summary>
        public string? DrugKey { get; set; }
        /// <summary>
        /// 
        /// </summary>
        public string? DrugBatchCode { get; set; }
        /// <summary>
        /// 获取或设置使用情况
        /// </summary>
        public string? UsageCode { get; set; }
        public override string GetContent()
        {
            return Barcode
                + AddBlockContent(DrugKey)
                + AddBlockContent(UsageCode);
        }
        public override bool ParseContent(string content)
        {
            if (base.ParseContent(content))
            {
                string[] blocks = EleMedKitProtocolHelper.GetContentBlocks(content);
                if (blocks.Length > 3)
                {
                    Barcode = blocks[0];
                    DrugKey = blocks[1];
                    DrugBatchCode = blocks[2];
                    UsageCode = blocks[3];
                    return true;
                }
            }
            return false;
        }
    }
}
