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 RequestMulOperationUsageDetailProtocol : ModelProtocol
    {
        public RequestMulOperationUsageDetailProtocol()
        {
        }
        public String? No { get; set; }
        public UserInfoProtocol? UserInfo { get; set; }
        public string? RoomCode { get; set; }
        public String? OperationID { get; set; }
        public DateTime? CreateTime { get; set; }
        public List<DrugUsageProtocol>? ListDrugs { get; set; }
        public override string GetContent()
        {
            return null;
        }
        public bool ParseContent(string[] lines)
        {
            if (lines == null
                || lines.Length < 6)
            {
                return false;
            }
            No = EleMedKitProtocolHelper.GetLineContent(lines[0]);
            UserInfo = new UserInfoProtocol();
            if (!UserInfo.ParseContent(lines[1]))
            {
                return false;
            }
            RoomCode = EleMedKitProtocolHelper.GetLineContent(lines[2]);
            OperationID = EleMedKitProtocolHelper.GetLineContent(lines[3]);
            DateTime? createTime = EleMedKitProtocolHelper.GetDateTimeByLineContent(lines[4]);
            if (createTime == null) 
            {
                return false;
            }
            CreateTime = createTime.Value;
            ListDrugs = new List<DrugUsageProtocol>();
            for (int i = 5; i < lines.Length; i++)
            {
                DrugUsageProtocol drugInfo = new DrugUsageProtocol();
                if (drugInfo.ParseContent(lines[i]))
                {
                    ListDrugs.Add(drugInfo);
                }
                else
                {
                    return false;
                }
            }
            return true;
        }
    }
}
