Example #1
0
    public ChargeItem GetNearestChargeItem(int payType, int payNum)
    {
        if (config.Count <= 0)
        {
            Init();
        }
        ChargeItem get = null;

        foreach (var item in config.Values)
        {
            if (item.GetAddType() == payType)
            {
                if (get == null || item.GetAddNum() > get.GetAddNum())
                {
                    get = item;
                }
                if (item.GetAddNum() >= payNum)
                {
                    get = item;
                    break;
                }
            }
        }
        return(get);
    }
Example #2
0
 /// <summary>
 /// 增加一条数据
 /// </summary>
 public void AddChargeItem(ChargeItem model)
 {
     using (DBHelper db = DBHelper.Create())
     {
         db.Insert <ChargeItem>(model);
     }
 }
Example #3
0
        /// <summary>
        /// Deserialize JSON into a FHIR ChargeItem
        /// </summary>
        public static void DeserializeJson(this ChargeItem current, ref Utf8JsonReader reader, JsonSerializerOptions options)
        {
            string propertyName;

            while (reader.Read())
            {
                if (reader.TokenType == JsonTokenType.EndObject)
                {
                    return;
                }

                if (reader.TokenType == JsonTokenType.PropertyName)
                {
                    propertyName = reader.GetString();
                    if (Hl7.Fhir.Serialization.FhirSerializerOptions.Debug)
                    {
                        Console.WriteLine($"ChargeItem >>> ChargeItem.{propertyName}, depth: {reader.CurrentDepth}, pos: {reader.BytesConsumed}");
                    }
                    reader.Read();
                    current.DeserializeJsonProperty(ref reader, options, propertyName);
                }
            }

            throw new JsonException($"ChargeItem: invalid state! depth: {reader.CurrentDepth}, pos: {reader.BytesConsumed}");
        }
Example #4
0
        public ActionResult ModifyChargeItem(ChargeItem item)
        {
            AjaxResult result = new AjaxResult();

            try
            {
                item.PY = Pinyin.GetPinyin(item.Name);
                bool flag = new ChargeItemRule().Update(item);
                if (flag)
                {
                    result.Success = true;
                    result.Message = "收费项修改成功";
                }
                else
                {
                    result.Success = false;
                    result.Message = "收费项修改失败";
                }
            }
            catch (Exception ex)
            {
                result.Success = false;
                result.Message = ex.Message;
                return(Json(result, JsonRequestBehavior.AllowGet));
            }
            return(Json(result, JsonRequestBehavior.AllowGet));
        }
Example #5
0
 /// <summary>
 /// 更新一条数据
 /// </summary>
 public bool Update(ChargeItem model)
 {
     using (DBHelper db = DBHelper.Create())
     {
         db.Update <ChargeItem>(model);
         return(true);
     }
 }
Example #6
0
 public void DoItemPay(int payType, int payNum)
 {
     CurChargeItem = PaymentManager.instance.GetNearestChargeItem(payType, payNum);
     if (CurChargeItem != null)
     {
         PaymentManager.instance.DoPay(CurChargeItem, PayBackSuccess, PayBackFail);
     }
 }
Example #7
0
 /// <summary>
 /// 检查当前输入的项目是否满足处方规则
 /// </summary>
 /// <param name="item">项目对象</param>
 /// <param name="amount">数量</param>
 /// <param name="unit">当前数量使用的单位</param>
 public void CheckItem(ChargeItem item, decimal amount, ItemUnit unit)
 {
     if (m_HadInitialized && (item != null) && item.KeyInitialized)
     {
         string itemKind = Convert.ToInt32(item.Kind).ToString();
         CheckItemOrDruggery(false, itemKind, 0, item.Code);
         CheckItemAmount(0, item.Code, amount, unit, item.BaseUnit, item.BaseUnit);
     }
 }
Example #8
0
    public void Init(ChargeItem item)
    {
        myItem = item;
        string spName = DataController.iconPathSkill + ItemManager.instance.GetItem((ItemID)item.GetAddType()).spriteName;

        icon.sprite = Resources.Load(spName, typeof(Sprite)) as Sprite;
        icon.SetNativeSize();
        txAddNum.text = "" + item.GetAddNum();
        txPrice.text  = item.price + "";
    }
Example #9
0
            public void AddChargeItemValues(double Quantitiy, double Amount, string Description, double VATRate, string ftChargeItemCase)
            {
                var item = new ChargeItem();

                item.Quantity         = Quantitiy;
                item.Amount           = Amount;
                item.Description      = Description;
                item.VATRate          = VATRate;
                item.ftChargeItemCase = ftChargeItemCase;
                _requestChargeItems.Add(item.ftChageItem());
            }
Example #10
0
 void FormSubjectItem_Load(object sender, EventArgs e)
 {
     if (ThreadExcute(BindData))
     {
         if (_List != null)
         {
             ChargeItem item = _List.Find(m => m.ChargeItemID == _ChargeItemID);
             if (item != null)
             {
                 _List.Remove(item);
             }
         }
         this.gc_charge_item.DataSource = _List;
         this.gc_charge_item.RefreshDataSource();
     }
 }
Example #11
0
        public async Task <CompaniesHouseClientResponse <ChargeItem> > GetCompanyChargeItemAsync(string companyNumber, string chargeId, CancellationToken cancellationToken = default(CancellationToken))
        {
            var requestUri = _chargeItemUriBuilder.Build(companyNumber, chargeId);

            var response = await _httpClient.GetAsync(requestUri, cancellationToken).ConfigureAwait(false);

            // Return a null profile on 404s, but raise exception for all other error codes
            if (response.StatusCode != System.Net.HttpStatusCode.NotFound)
            {
                response.EnsureSuccessStatusCode();
            }

            ChargeItem result = response.IsSuccessStatusCode
                ? await response.Content.ReadAsJsonAsync <ChargeItem>().ConfigureAwait(false)
                : null;

            return(new CompaniesHouseClientResponse <ChargeItem>(result));
        }
Example #12
0
    public ChargeItem GetGiftChargeItemByType(string type)
    {
        if (config.Count <= 0)
        {
            Init();
        }
        ChargeItem get = null;

        foreach (var item in config.Values)
        {
            if (item.type == type)
            {
                get = item;
                break;
            }
        }
        return(get);
    }
Example #13
0
 public void DoPay(ChargeItem item, Action _callbackSuccess, Action _callbackFail)
 {
     payItem         = item;
     callbackSuccess = _callbackSuccess;
     callbackFail    = _callbackFail;
     if (isTestPay)
     {
         PayJavaBack("1");
         return;
     }
     if (Application.isMobilePlatform)
     {
         ActivityManager.Instance().GetAndriod().CallStatic("Pay", item.chargeId.ToString());
         //androidCall.CallStatic("Pay", item.chargeId.ToString());
     }
     else
     {
         PayJavaBack("1");
     }
 }
Example #14
0
    public bool Init(ChargeRewardsTableItem chargedata)
    {
        //等待新机制修改
        UIWindow   ChargeUI = WindowManager.Instance.GetUI("charge");
        UIGrid     mGrid    = ChargeUI.FindComponent <UIGrid>("ScrollView/UIGrid");
        GameObject mClone   = ChargeUI.FindChild("ChargeItem");
        GameObject clone    = WindowManager.Instance.CloneGameObject(mClone);

        mUI = new ChargeItem(clone, chargedata);
        mUI.gameObject.transform.parent     = mGrid.transform;
        mUI.gameObject.transform.localScale = Vector3.one;
        mGrid.Reposition();
        mGrid.repositionNow = true;
        SetDiamond(chargedata.Diamondnum.ToString());
        SetIcon(chargedata.icon);
        SetMoney(chargedata.money.ToString());
        SetReward(chargedata.rewards.ToString());

        Show();

        return(true);
    }
Example #15
0
        public ActionResult AddChargeItem(ChargeItem item)
        {
            AjaxResult result = new AjaxResult();

            item.ID = Guid.NewGuid().ToString("N").ToUpper();
            item.PY = Pinyin.GetPinyin(item.Name);
            ChargeItemRule rule = new ChargeItemRule();

            item.Code = rule.GetNewCode();
            try
            {
                rule.Add(item);
                result.Success = true;
                result.Message = "缴费项目添加成功。";
            }
            catch (Exception ex)
            {
                result.Success = false;
                result.Message = ex.Message;
            }
            return(Json(result, JsonRequestBehavior.AllowGet));
        }
Example #16
0
        private const int updateIntervalSec = 15; //30 seconds

        public bool Init()
        {
            try
            {
                GeneralCachingXmlMgr.RemoveCachingXml(Global.GameResPath(CfgFile));
                XElement xml = GeneralCachingXmlMgr.GetXElement(Global.GameResPath(CfgFile));
                if (null == xml)
                {
                    return(false);
                }

                XElement args = xml.Element("Activities");
                if (null != args)
                {
                    FromDate     = Global.GetSafeAttributeStr(args, "FromDate");
                    ToDate       = Global.GetSafeAttributeStr(args, "ToDate");
                    ActivityType = (int)Global.GetSafeAttributeLong(args, "ActivityType");

                    AwardStartDate = Global.GetSafeAttributeStr(args, "AwardStartDate");
                    AwardEndDate   = Global.GetSafeAttributeStr(args, "AwardEndDate");
                }

                args = xml.Element("GiftList");
                if (null != args)
                {
                    IEnumerable <XElement> xmlItems = args.Elements();
                    foreach (var xmlItem in xmlItems)
                    {
                        if (null == xmlItem)
                        {
                            continue;
                        }
                        ChargeItem ci = new ChargeItem();
                        ci.Rank         = (int)Global.GetSafeAttributeLong(xmlItem, "ID");
                        ci.NeedChargeYB = (int)Global.GetSafeAttributeLong(xmlItem, "MinYuanBao");

                        chargeItemList.Add(ci);
                    }

                    // 多个档次,按照档次Id从小到大排序
                    chargeItemList.Sort((left, right) =>
                    {
                        if (left.Rank < right.Rank)
                        {
                            return(-1);
                        }
                        else if (left.Rank > right.Rank)
                        {
                            return(1);
                        }
                        else
                        {
                            return(0);
                        }
                    });
                }

                PredealDateTime();
            }
            catch (Exception ex)
            {
                LogManager.WriteLog(LogTypes.Fatal, string.Format("{0}解析出现异常, {1}", CfgFile, ex.Message));
                return(false);
            }

            return(true);
        }
Example #17
0
        /// <summary>
        /// Danh sách user nạp thẻ, sms
        /// </summary>
        /// <param name="from"></param>
        /// <param name="to"></param>
        /// <param name="skip"></param>
        /// <param name="take"></param>
        /// <returns></returns>
        public ChargeResult GetCharged(DateTime from, DateTime to, int skip, int take)
        {
            var             rs          = new ChargeResult();
            var             data        = new List <ChargeItem>();
            int             totalRecord = 0;
            string          sql         = "SELECT b.id AS 'user_id', b.username,b.fullname,'card' as 'type', cardNumber, cardSerial, cp,cardPrice, refNo, tranNo, source, dateCreated FROM portal.a_paycard a inner join portal.user b on a.username=b.id where a.cardPrice > 0 and a.dateCreated >= @date1 and dateCreated <= @date2 union all SELECT b.id AS 'user_id', b.username, b.fullname, 'sms' AS 'type', '' as 'cardNumber','' as 'cardSerial', telco as 'cp',amount as 'cardPrice', '' as 'refNo', '' as 'tranNo', '' as 'source' , responeTime as 'dateCreated' FROM portal.a_smsplus a INNER JOIN portal.user b ON a.targetUser=b.username WHERE amount > 0 AND a.responeTime >= @date3 AND a.responeTime <= @date4 ORDER BY dateCreated DESC LIMIT @skip, @take";
            MySqlConnection conn        = new MySqlConnection(Constants.DBConnection);
            MySqlCommand    MyCommand   = new MySqlCommand(sql, conn);

            MyCommand.Parameters.AddWithValue("date1", from.ToString(Constants.DateFormat));
            MyCommand.Parameters.AddWithValue("date2", to.ToString(Constants.DateFormat));
            MyCommand.Parameters.AddWithValue("date3", from.ToString(Constants.DateFormat));
            MyCommand.Parameters.AddWithValue("date4", to.ToString(Constants.DateFormat));
            MyCommand.Parameters.AddWithValue("skip", skip);
            MyCommand.Parameters.AddWithValue("take", take);
            MySqlDataReader MyReader;

            conn.Open();
            MyReader = MyCommand.ExecuteReader();
            int stt = 1;

            while (MyReader.Read())
            {
                ChargeItem item1 = new ChargeItem();
                item1.Stt        = stt;
                item1.uid        = MyReader.GetInt64("user_id");
                item1.username   = MyReader.GetString("username");
                item1.fullname   = MyReader.GetString("fullname");
                item1.type       = MyReader.GetString("type");
                item1.cardNumber = MyReader.GetString("cardNumber");
                item1.cardSerial = MyReader.GetString("cardSerial");
                item1.telco      = MyReader.GetString("cp");
                item1.Price      = MyReader.GetInt64("cardPrice");
                item1.refNo      = MyReader.GetString("refNo");
                item1.tranNo     = MyReader.GetString("tranNo");
                item1.source     = MyReader.GetString("source");
                item1.time       = MyReader.GetDateTime("dateCreated");
                item1.timeString = item1.time.ToString("dd-MM-yyyy");

                data.Add(item1);
                stt++;
            }
            MyReader.Close();
            sql       = "Select count(*) as totalRecord from portal.a_paycard where cardPrice > 0 and dateCreated >= @date1 and dateCreated <= @date2";
            MyCommand = new MySqlCommand(sql, conn);
            MyCommand.Parameters.AddWithValue("date1", from.ToString(Constants.DateFormat));
            MyCommand.Parameters.AddWithValue("date2", to.ToString(Constants.DateFormat));
            MyReader = MyCommand.ExecuteReader();
            while (MyReader.Read())
            {
                totalRecord += MyReader.GetInt32("totalRecord");
            }
            MyReader.Close();
            sql       = "Select count(*) as totalRecord from portal.a_smsplus WHERE amount > 0 AND responeTime >= @date3 AND responeTime <= @date4";
            MyCommand = new MySqlCommand(sql, conn);
            MyCommand.Parameters.AddWithValue("date3", from.ToString(Constants.DateFormat));
            MyCommand.Parameters.AddWithValue("date4", to.ToString(Constants.DateFormat));
            MyReader = MyCommand.ExecuteReader();
            while (MyReader.Read())
            {
                totalRecord += MyReader.GetInt32("totalRecord");
            }
            MyReader.Close();
            conn.Close();
            rs.data        = data;
            rs.totalRecord = totalRecord;
            return(rs);
        }
Example #18
0
 public void AddChargeItem(ChargeItem item)
 {
     _requestChargeItems.Add(item.ftChageItem());
 }
Example #19
0
        public ChargeResult ExportExcel(DateTime?from, DateTime?to, string type = "")
        {
            var rs   = new ChargeResult();
            var data = new List <ChargeItem>();
            var sql  = "";

            if (string.IsNullOrEmpty(type) || type == "card")
            {
                sql += "SELECT b.id AS 'user_id', b.username,b.fullname,'card' as 'type', cardNumber, cardSerial, cp,cardPrice, refNo, tranNo, source, dateCreated FROM [portal].[dbo].a_paycard a inner join [portal].[dbo].user b on a.username=b.id where a.cardPrice > 0";
                if (from != null && to != null)
                {
                    sql += " and a.dateCreated >= '" + from.Value.ToString("yyyy-MM-dd HH:mm:ss") + "' and a.dateCreated <= '" + to.Value.ToString("yyyy-MM-dd HH:mm:ss") + "'";
                }
            }


            if (string.IsNullOrEmpty(type))
            {
                sql += " union all ";
            }

            if (string.IsNullOrEmpty(type) || type == "sms")
            {
                sql += "SELECT b.id AS 'user_id', b.username, b.fullname, 'sms' AS 'type', '' as 'cardNumber','' as 'cardSerial', telco as 'cp',amount as 'cardPrice', '' as 'refNo', '' as 'tranNo', '' as 'source' , responeTime as 'dateCreated' FROM [portal].[dbo].a_smsplus a INNER JOIN [portal].[dbo].user b ON a.targetUser=b.username WHERE amount > 0";
                if (from != null && to != null)
                {
                    sql += " and responeTime >= '" + from.Value.ToString("yyyy-MM-dd HH:mm:ss") + "' and responeTime <= '" + to.Value.ToString("yyyy-MM-dd HH:mm:ss") + "'";
                }
            }


            sql += " ORDER BY dateCreated DESC";

            var conn      = new SqlConnection(Constants.DBConnection);
            var myCommand = new SqlCommand(sql, conn);

            conn.Open();
            var MyReader = myCommand.ExecuteReader();
            var stt      = 1;

            while (MyReader.Read())
            {
                var item1 = new ChargeItem
                {
                    Stt        = stt,
                    uid        = MyReader.GetInt64(MyReader.GetOrdinal("user_id")),
                    username   = MyReader.GetString(MyReader.GetOrdinal("username")),
                    fullname   = MyReader.GetString(MyReader.GetOrdinal("fullname")),
                    type       = MyReader.GetString(MyReader.GetOrdinal("type")),
                    cardNumber = MyReader.GetString(MyReader.GetOrdinal("cardNumber")),
                    cardSerial = MyReader.GetString(MyReader.GetOrdinal("cardSerial")),
                    telco      = MyReader.GetString(MyReader.GetOrdinal("cp")),
                    Price      = MyReader.GetInt64(MyReader.GetOrdinal("cardPrice")),
                    refNo      = MyReader.GetString(MyReader.GetOrdinal("refNo")),
                    tranNo     = MyReader.GetString(MyReader.GetOrdinal("tranNo")),
                    source     = MyReader.GetString(MyReader.GetOrdinal("source")),
                    time       = MyReader.GetDateTime(MyReader.GetOrdinal("dateCreated"))
                };
                item1.timeString = item1.time.ToString("dd-MM-yyyy");

                data.Add(item1);
                stt++;
            }
            MyReader.Close();

            rs.data = data;
            return(rs);
        }
Example #20
0
 public void AddChargeItemValues(double Quantitiy, double Amount, string Description, double VATRate, string ftChargeItemCase)
 {
     var item = new ChargeItem();
     item.Quantity = Quantitiy;
     item.Amount = Amount;
     item.Description = Description;
     item.VATRate = VATRate;
     item.ftChargeItemCase = ftChargeItemCase;
     _requestChargeItems.Add(item.ftChageItem());
 }
Example #21
0
 public void AddChargeItem(ChargeItem item)
 {
     _requestChargeItems.Add(item.ftChageItem());
 }
Example #22
0
        public ChargeResult GetAll(string type = "", string username = "", int currentRecord = 0, int numberRecord = 10)
        {
            var rs          = new ChargeResult();
            var data        = new List <ChargeItem>();
            var totalRecord = 0;
            var sql         = "";

            if (string.IsNullOrEmpty(type) || type == "card")
            {
                sql += "SELECT b.id AS 'user_id', b.username,b.fullname,'card' as 'type', cardNumber, cardSerial, cp,cardPrice, refNo, tranNo, source, dateCreated FROM [portal].[dbo].a_paycard a inner join [portal].[dbo].user b on a.username=b.id where a.cardPrice > 0";
                if (!string.IsNullOrEmpty(username))
                {
                    sql += " and b.username like '%" + username + "%' ";
                }
            }

            if (string.IsNullOrEmpty(type))
            {
                sql += " union all ";
            }

            if (string.IsNullOrEmpty(type) || type == "sms")
            {
                sql += "SELECT b.id AS 'user_id', b.username, b.fullname, 'sms' AS 'type', '' as 'cardNumber','' as 'cardSerial', telco as 'cp',amount as 'cardPrice', '' as 'refNo', '' as 'tranNo', '' as 'source' , responeTime as 'dateCreated' FROM [portal].[dbo].a_smsplus a INNER JOIN [portal].[dbo].user b ON a.targetUser=b.username WHERE amount > 0";
                if (!string.IsNullOrEmpty(username))
                {
                    sql += " and b.username like '%" + username + "%' ";
                }
            }

            sql += " ORDER BY dateCreated DESC OFFSET @skip ROWS FETCH NEXT @take ROWS ONLY";

            var conn      = new SqlConnection(Constants.DBConnection);
            var myCommand = new SqlCommand(sql, conn);

            myCommand.Parameters.AddWithValue("skip", currentRecord);
            myCommand.Parameters.AddWithValue("take", numberRecord);
            conn.Open();
            var MyReader = myCommand.ExecuteReader();
            var stt      = 1;

            while (MyReader.Read())
            {
                var item1 = new ChargeItem
                {
                    Stt        = stt,
                    uid        = MyReader.GetInt64(MyReader.GetOrdinal("user_id")),
                    username   = MyReader.GetString(MyReader.GetOrdinal("username")),
                    fullname   = MyReader.GetString(MyReader.GetOrdinal("fullname")),
                    type       = MyReader.GetString(MyReader.GetOrdinal("type")),
                    cardNumber = MyReader.GetString(MyReader.GetOrdinal("cardNumber")),
                    cardSerial = MyReader.GetString(MyReader.GetOrdinal("cardSerial")),
                    telco      = MyReader.GetString(MyReader.GetOrdinal("cp")),
                    Price      = MyReader.GetInt64(MyReader.GetOrdinal("cardPrice")),
                    refNo      = MyReader.GetString(MyReader.GetOrdinal("refNo")),
                    tranNo     = MyReader.GetString(MyReader.GetOrdinal("tranNo")),
                    source     = MyReader.GetString(MyReader.GetOrdinal("source")),
                    time       = MyReader.GetDateTime(MyReader.GetOrdinal("dateCreated"))
                };
                item1.timeString = item1.time.ToString("dd-MM-yyyy");

                data.Add(item1);
                stt++;
            }
            MyReader.Close();
            sql = "Select count(*) as totalRecord from [portal].[dbo].a_paycard where cardPrice > 0";
            if (!String.IsNullOrEmpty(username))
            {
                sql += " and username like '%" + username + "%' ";
            }
            myCommand = new SqlCommand(sql, conn);
            MyReader  = myCommand.ExecuteReader();
            while (MyReader.Read())
            {
                totalRecord += MyReader.GetInt32(MyReader.GetOrdinal("totalRecord"));
            }
            MyReader.Close();
            sql = "Select count(*) as totalRecord from [portal].[dbo].a_smsplus WHERE amount > 0";
            if (!String.IsNullOrEmpty(username))
            {
                sql += " and targetUser like '%" + username + "%' ";
            }
            myCommand = new SqlCommand(sql, conn);
            MyReader  = myCommand.ExecuteReader();
            while (MyReader.Read())
            {
                totalRecord += MyReader.GetInt32(MyReader.GetOrdinal("totalRecord"));
            }
            MyReader.Close();
            conn.Close();
            rs.data        = data;
            rs.totalRecord = totalRecord;
            return(rs);
        }
Example #23
0
        /// <summary>
        /// Deserialize JSON into a FHIR ChargeItem
        /// </summary>
        public static void DeserializeJsonProperty(this ChargeItem current, ref Utf8JsonReader reader, JsonSerializerOptions options, string propertyName)
        {
            switch (propertyName)
            {
            case "identifier":
                if ((reader.TokenType != JsonTokenType.StartArray) || (!reader.Read()))
                {
                    throw new JsonException($"ChargeItem error reading 'identifier' expected StartArray, found {reader.TokenType}! depth: {reader.CurrentDepth}, pos: {reader.BytesConsumed}");
                }

                current.Identifier = new List <Identifier>();

                while (reader.TokenType != JsonTokenType.EndArray)
                {
                    Hl7.Fhir.Model.Identifier v_Identifier = new Hl7.Fhir.Model.Identifier();
                    v_Identifier.DeserializeJson(ref reader, options);
                    current.Identifier.Add(v_Identifier);

                    if (!reader.Read())
                    {
                        throw new JsonException($"ChargeItem error reading 'identifier' array, read failed! depth: {reader.CurrentDepth}, pos: {reader.BytesConsumed}");
                    }
                    if (reader.TokenType == JsonTokenType.EndObject)
                    {
                        reader.Read();
                    }
                }

                if (current.Identifier.Count == 0)
                {
                    current.Identifier = null;
                }
                break;

            case "definitionUri":
                if ((reader.TokenType != JsonTokenType.StartArray) || (!reader.Read()))
                {
                    throw new JsonException($"ChargeItem error reading 'definitionUri' expected StartArray, found {reader.TokenType}! depth: {reader.CurrentDepth}, pos: {reader.BytesConsumed}");
                }

                current.DefinitionUriElement = new List <FhirUri>();

                while (reader.TokenType != JsonTokenType.EndArray)
                {
                    if (reader.TokenType == JsonTokenType.Null)
                    {
                        current.DefinitionUriElement.Add(new FhirUri());
                        reader.Skip();
                    }
                    else
                    {
                        current.DefinitionUriElement.Add(new FhirUri(reader.GetString()));
                    }

                    if (!reader.Read())
                    {
                        throw new JsonException($"ChargeItem error reading 'definitionUri' array, read failed! depth: {reader.CurrentDepth}, pos: {reader.BytesConsumed}");
                    }
                    if (reader.TokenType == JsonTokenType.EndObject)
                    {
                        reader.Read();
                    }
                }

                if (current.DefinitionUriElement.Count == 0)
                {
                    current.DefinitionUriElement = null;
                }
                break;

            case "_definitionUri":
                if ((reader.TokenType != JsonTokenType.StartArray) || (!reader.Read()))
                {
                    throw new JsonException($"ChargeItem error reading 'definitionUri' expected StartArray, found {reader.TokenType}! depth: {reader.CurrentDepth}, pos: {reader.BytesConsumed}");
                }

                int i_definitionUri = 0;

                while (reader.TokenType != JsonTokenType.EndArray)
                {
                    if (i_definitionUri >= current.DefinitionUriElement.Count)
                    {
                        current.DefinitionUriElement.Add(new FhirUri());
                    }
                    if (reader.TokenType == JsonTokenType.Null)
                    {
                        reader.Skip();
                    }
                    else
                    {
                        ((Hl7.Fhir.Model.Element)current.DefinitionUriElement[i_definitionUri++]).DeserializeJson(ref reader, options);
                    }

                    if (!reader.Read())
                    {
                        throw new JsonException($"ChargeItem error reading 'definitionUri' array, read failed! depth: {reader.CurrentDepth}, pos: {reader.BytesConsumed}");
                    }
                    if (reader.TokenType == JsonTokenType.EndObject)
                    {
                        reader.Read();
                    }
                }
                break;

            case "definitionCanonical":
                if ((reader.TokenType != JsonTokenType.StartArray) || (!reader.Read()))
                {
                    throw new JsonException($"ChargeItem error reading 'definitionCanonical' expected StartArray, found {reader.TokenType}! depth: {reader.CurrentDepth}, pos: {reader.BytesConsumed}");
                }

                current.DefinitionCanonicalElement = new List <Canonical>();

                while (reader.TokenType != JsonTokenType.EndArray)
                {
                    if (reader.TokenType == JsonTokenType.Null)
                    {
                        current.DefinitionCanonicalElement.Add(new Canonical());
                        reader.Skip();
                    }
                    else
                    {
                        current.DefinitionCanonicalElement.Add(new Canonical(reader.GetString()));
                    }

                    if (!reader.Read())
                    {
                        throw new JsonException($"ChargeItem error reading 'definitionCanonical' array, read failed! depth: {reader.CurrentDepth}, pos: {reader.BytesConsumed}");
                    }
                    if (reader.TokenType == JsonTokenType.EndObject)
                    {
                        reader.Read();
                    }
                }

                if (current.DefinitionCanonicalElement.Count == 0)
                {
                    current.DefinitionCanonicalElement = null;
                }
                break;

            case "_definitionCanonical":
                if ((reader.TokenType != JsonTokenType.StartArray) || (!reader.Read()))
                {
                    throw new JsonException($"ChargeItem error reading 'definitionCanonical' expected StartArray, found {reader.TokenType}! depth: {reader.CurrentDepth}, pos: {reader.BytesConsumed}");
                }

                int i_definitionCanonical = 0;

                while (reader.TokenType != JsonTokenType.EndArray)
                {
                    if (i_definitionCanonical >= current.DefinitionCanonicalElement.Count)
                    {
                        current.DefinitionCanonicalElement.Add(new Canonical());
                    }
                    if (reader.TokenType == JsonTokenType.Null)
                    {
                        reader.Skip();
                    }
                    else
                    {
                        ((Hl7.Fhir.Model.Element)current.DefinitionCanonicalElement[i_definitionCanonical++]).DeserializeJson(ref reader, options);
                    }

                    if (!reader.Read())
                    {
                        throw new JsonException($"ChargeItem error reading 'definitionCanonical' array, read failed! depth: {reader.CurrentDepth}, pos: {reader.BytesConsumed}");
                    }
                    if (reader.TokenType == JsonTokenType.EndObject)
                    {
                        reader.Read();
                    }
                }
                break;

            case "status":
                if (reader.TokenType == JsonTokenType.Null)
                {
                    current.StatusElement = new Code <Hl7.Fhir.Model.ChargeItem.ChargeItemStatus>();
                    reader.Skip();
                }
                else
                {
                    current.StatusElement = new Code <Hl7.Fhir.Model.ChargeItem.ChargeItemStatus>(Hl7.Fhir.Utility.EnumUtility.ParseLiteral <Hl7.Fhir.Model.ChargeItem.ChargeItemStatus>(reader.GetString()));
                }
                break;

            case "_status":
                if (current.StatusElement == null)
                {
                    current.StatusElement = new Code <Hl7.Fhir.Model.ChargeItem.ChargeItemStatus>();
                }
                ((Hl7.Fhir.Model.Element)current.StatusElement).DeserializeJson(ref reader, options);
                break;

            case "partOf":
                if ((reader.TokenType != JsonTokenType.StartArray) || (!reader.Read()))
                {
                    throw new JsonException($"ChargeItem error reading 'partOf' expected StartArray, found {reader.TokenType}! depth: {reader.CurrentDepth}, pos: {reader.BytesConsumed}");
                }

                current.PartOf = new List <ResourceReference>();

                while (reader.TokenType != JsonTokenType.EndArray)
                {
                    Hl7.Fhir.Model.ResourceReference v_PartOf = new Hl7.Fhir.Model.ResourceReference();
                    v_PartOf.DeserializeJson(ref reader, options);
                    current.PartOf.Add(v_PartOf);

                    if (!reader.Read())
                    {
                        throw new JsonException($"ChargeItem error reading 'partOf' array, read failed! depth: {reader.CurrentDepth}, pos: {reader.BytesConsumed}");
                    }
                    if (reader.TokenType == JsonTokenType.EndObject)
                    {
                        reader.Read();
                    }
                }

                if (current.PartOf.Count == 0)
                {
                    current.PartOf = null;
                }
                break;

            case "code":
                current.Code = new Hl7.Fhir.Model.CodeableConcept();
                ((Hl7.Fhir.Model.CodeableConcept)current.Code).DeserializeJson(ref reader, options);
                break;

            case "subject":
                current.Subject = new Hl7.Fhir.Model.ResourceReference();
                ((Hl7.Fhir.Model.ResourceReference)current.Subject).DeserializeJson(ref reader, options);
                break;

            case "context":
                current.Context = new Hl7.Fhir.Model.ResourceReference();
                ((Hl7.Fhir.Model.ResourceReference)current.Context).DeserializeJson(ref reader, options);
                break;

            case "occurrenceDateTime":
                if (reader.TokenType == JsonTokenType.Null)
                {
                    current.Occurrence = new FhirDateTime();
                    reader.Skip();
                }
                else
                {
                    current.Occurrence = new FhirDateTime(reader.GetString());
                }
                break;

            case "_occurrenceDateTime":
                if (current.Occurrence == null)
                {
                    current.Occurrence = new FhirDateTime();
                }
                ((Hl7.Fhir.Model.Element)current.Occurrence).DeserializeJson(ref reader, options);
                break;

            case "occurrencePeriod":
                current.Occurrence = new Hl7.Fhir.Model.Period();
                ((Hl7.Fhir.Model.Period)current.Occurrence).DeserializeJson(ref reader, options);
                break;

            case "occurrenceTiming":
                current.Occurrence = new Hl7.Fhir.Model.Timing();
                ((Hl7.Fhir.Model.Timing)current.Occurrence).DeserializeJson(ref reader, options);
                break;

            case "performer":
                if ((reader.TokenType != JsonTokenType.StartArray) || (!reader.Read()))
                {
                    throw new JsonException($"ChargeItem error reading 'performer' expected StartArray, found {reader.TokenType}! depth: {reader.CurrentDepth}, pos: {reader.BytesConsumed}");
                }

                current.Performer = new List <ChargeItem.PerformerComponent>();

                while (reader.TokenType != JsonTokenType.EndArray)
                {
                    Hl7.Fhir.Model.ChargeItem.PerformerComponent v_Performer = new Hl7.Fhir.Model.ChargeItem.PerformerComponent();
                    v_Performer.DeserializeJson(ref reader, options);
                    current.Performer.Add(v_Performer);

                    if (!reader.Read())
                    {
                        throw new JsonException($"ChargeItem error reading 'performer' array, read failed! depth: {reader.CurrentDepth}, pos: {reader.BytesConsumed}");
                    }
                    if (reader.TokenType == JsonTokenType.EndObject)
                    {
                        reader.Read();
                    }
                }

                if (current.Performer.Count == 0)
                {
                    current.Performer = null;
                }
                break;

            case "performingOrganization":
                current.PerformingOrganization = new Hl7.Fhir.Model.ResourceReference();
                ((Hl7.Fhir.Model.ResourceReference)current.PerformingOrganization).DeserializeJson(ref reader, options);
                break;

            case "requestingOrganization":
                current.RequestingOrganization = new Hl7.Fhir.Model.ResourceReference();
                ((Hl7.Fhir.Model.ResourceReference)current.RequestingOrganization).DeserializeJson(ref reader, options);
                break;

            case "costCenter":
                current.CostCenter = new Hl7.Fhir.Model.ResourceReference();
                ((Hl7.Fhir.Model.ResourceReference)current.CostCenter).DeserializeJson(ref reader, options);
                break;

            case "quantity":
                current.Quantity = new Hl7.Fhir.Model.Quantity();
                ((Hl7.Fhir.Model.Quantity)current.Quantity).DeserializeJson(ref reader, options);
                break;

            case "bodysite":
                if ((reader.TokenType != JsonTokenType.StartArray) || (!reader.Read()))
                {
                    throw new JsonException($"ChargeItem error reading 'bodysite' expected StartArray, found {reader.TokenType}! depth: {reader.CurrentDepth}, pos: {reader.BytesConsumed}");
                }

                current.Bodysite = new List <CodeableConcept>();

                while (reader.TokenType != JsonTokenType.EndArray)
                {
                    Hl7.Fhir.Model.CodeableConcept v_Bodysite = new Hl7.Fhir.Model.CodeableConcept();
                    v_Bodysite.DeserializeJson(ref reader, options);
                    current.Bodysite.Add(v_Bodysite);

                    if (!reader.Read())
                    {
                        throw new JsonException($"ChargeItem error reading 'bodysite' array, read failed! depth: {reader.CurrentDepth}, pos: {reader.BytesConsumed}");
                    }
                    if (reader.TokenType == JsonTokenType.EndObject)
                    {
                        reader.Read();
                    }
                }

                if (current.Bodysite.Count == 0)
                {
                    current.Bodysite = null;
                }
                break;

            case "factorOverride":
                if (reader.TokenType == JsonTokenType.Null)
                {
                    current.FactorOverrideElement = new FhirDecimal();
                    reader.Skip();
                }
                else
                {
                    current.FactorOverrideElement = new FhirDecimal(reader.GetDecimal());
                }
                break;

            case "_factorOverride":
                if (current.FactorOverrideElement == null)
                {
                    current.FactorOverrideElement = new FhirDecimal();
                }
                ((Hl7.Fhir.Model.Element)current.FactorOverrideElement).DeserializeJson(ref reader, options);
                break;

            case "priceOverride":
                current.PriceOverride = new Hl7.Fhir.Model.Money();
                ((Hl7.Fhir.Model.Money)current.PriceOverride).DeserializeJson(ref reader, options);
                break;

            case "overrideReason":
                if (reader.TokenType == JsonTokenType.Null)
                {
                    current.OverrideReasonElement = new FhirString();
                    reader.Skip();
                }
                else
                {
                    current.OverrideReasonElement = new FhirString(reader.GetString());
                }
                break;

            case "_overrideReason":
                if (current.OverrideReasonElement == null)
                {
                    current.OverrideReasonElement = new FhirString();
                }
                ((Hl7.Fhir.Model.Element)current.OverrideReasonElement).DeserializeJson(ref reader, options);
                break;

            case "enterer":
                current.Enterer = new Hl7.Fhir.Model.ResourceReference();
                ((Hl7.Fhir.Model.ResourceReference)current.Enterer).DeserializeJson(ref reader, options);
                break;

            case "enteredDate":
                if (reader.TokenType == JsonTokenType.Null)
                {
                    current.EnteredDateElement = new FhirDateTime();
                    reader.Skip();
                }
                else
                {
                    current.EnteredDateElement = new FhirDateTime(reader.GetString());
                }
                break;

            case "_enteredDate":
                if (current.EnteredDateElement == null)
                {
                    current.EnteredDateElement = new FhirDateTime();
                }
                ((Hl7.Fhir.Model.Element)current.EnteredDateElement).DeserializeJson(ref reader, options);
                break;

            case "reason":
                if ((reader.TokenType != JsonTokenType.StartArray) || (!reader.Read()))
                {
                    throw new JsonException($"ChargeItem error reading 'reason' expected StartArray, found {reader.TokenType}! depth: {reader.CurrentDepth}, pos: {reader.BytesConsumed}");
                }

                current.Reason = new List <CodeableConcept>();

                while (reader.TokenType != JsonTokenType.EndArray)
                {
                    Hl7.Fhir.Model.CodeableConcept v_Reason = new Hl7.Fhir.Model.CodeableConcept();
                    v_Reason.DeserializeJson(ref reader, options);
                    current.Reason.Add(v_Reason);

                    if (!reader.Read())
                    {
                        throw new JsonException($"ChargeItem error reading 'reason' array, read failed! depth: {reader.CurrentDepth}, pos: {reader.BytesConsumed}");
                    }
                    if (reader.TokenType == JsonTokenType.EndObject)
                    {
                        reader.Read();
                    }
                }

                if (current.Reason.Count == 0)
                {
                    current.Reason = null;
                }
                break;

            case "service":
                if ((reader.TokenType != JsonTokenType.StartArray) || (!reader.Read()))
                {
                    throw new JsonException($"ChargeItem error reading 'service' expected StartArray, found {reader.TokenType}! depth: {reader.CurrentDepth}, pos: {reader.BytesConsumed}");
                }

                current.Service = new List <ResourceReference>();

                while (reader.TokenType != JsonTokenType.EndArray)
                {
                    Hl7.Fhir.Model.ResourceReference v_Service = new Hl7.Fhir.Model.ResourceReference();
                    v_Service.DeserializeJson(ref reader, options);
                    current.Service.Add(v_Service);

                    if (!reader.Read())
                    {
                        throw new JsonException($"ChargeItem error reading 'service' array, read failed! depth: {reader.CurrentDepth}, pos: {reader.BytesConsumed}");
                    }
                    if (reader.TokenType == JsonTokenType.EndObject)
                    {
                        reader.Read();
                    }
                }

                if (current.Service.Count == 0)
                {
                    current.Service = null;
                }
                break;

            case "productReference":
                current.Product = new Hl7.Fhir.Model.ResourceReference();
                ((Hl7.Fhir.Model.ResourceReference)current.Product).DeserializeJson(ref reader, options);
                break;

            case "productCodeableConcept":
                current.Product = new Hl7.Fhir.Model.CodeableConcept();
                ((Hl7.Fhir.Model.CodeableConcept)current.Product).DeserializeJson(ref reader, options);
                break;

            case "account":
                if ((reader.TokenType != JsonTokenType.StartArray) || (!reader.Read()))
                {
                    throw new JsonException($"ChargeItem error reading 'account' expected StartArray, found {reader.TokenType}! depth: {reader.CurrentDepth}, pos: {reader.BytesConsumed}");
                }

                current.Account = new List <ResourceReference>();

                while (reader.TokenType != JsonTokenType.EndArray)
                {
                    Hl7.Fhir.Model.ResourceReference v_Account = new Hl7.Fhir.Model.ResourceReference();
                    v_Account.DeserializeJson(ref reader, options);
                    current.Account.Add(v_Account);

                    if (!reader.Read())
                    {
                        throw new JsonException($"ChargeItem error reading 'account' array, read failed! depth: {reader.CurrentDepth}, pos: {reader.BytesConsumed}");
                    }
                    if (reader.TokenType == JsonTokenType.EndObject)
                    {
                        reader.Read();
                    }
                }

                if (current.Account.Count == 0)
                {
                    current.Account = null;
                }
                break;

            case "note":
                if ((reader.TokenType != JsonTokenType.StartArray) || (!reader.Read()))
                {
                    throw new JsonException($"ChargeItem error reading 'note' expected StartArray, found {reader.TokenType}! depth: {reader.CurrentDepth}, pos: {reader.BytesConsumed}");
                }

                current.Note = new List <Annotation>();

                while (reader.TokenType != JsonTokenType.EndArray)
                {
                    Hl7.Fhir.Model.Annotation v_Note = new Hl7.Fhir.Model.Annotation();
                    v_Note.DeserializeJson(ref reader, options);
                    current.Note.Add(v_Note);

                    if (!reader.Read())
                    {
                        throw new JsonException($"ChargeItem error reading 'note' array, read failed! depth: {reader.CurrentDepth}, pos: {reader.BytesConsumed}");
                    }
                    if (reader.TokenType == JsonTokenType.EndObject)
                    {
                        reader.Read();
                    }
                }

                if (current.Note.Count == 0)
                {
                    current.Note = null;
                }
                break;

            case "supportingInformation":
                if ((reader.TokenType != JsonTokenType.StartArray) || (!reader.Read()))
                {
                    throw new JsonException($"ChargeItem error reading 'supportingInformation' expected StartArray, found {reader.TokenType}! depth: {reader.CurrentDepth}, pos: {reader.BytesConsumed}");
                }

                current.SupportingInformation = new List <ResourceReference>();

                while (reader.TokenType != JsonTokenType.EndArray)
                {
                    Hl7.Fhir.Model.ResourceReference v_SupportingInformation = new Hl7.Fhir.Model.ResourceReference();
                    v_SupportingInformation.DeserializeJson(ref reader, options);
                    current.SupportingInformation.Add(v_SupportingInformation);

                    if (!reader.Read())
                    {
                        throw new JsonException($"ChargeItem error reading 'supportingInformation' array, read failed! depth: {reader.CurrentDepth}, pos: {reader.BytesConsumed}");
                    }
                    if (reader.TokenType == JsonTokenType.EndObject)
                    {
                        reader.Read();
                    }
                }

                if (current.SupportingInformation.Count == 0)
                {
                    current.SupportingInformation = null;
                }
                break;

            // Complex: ChargeItem, Export: ChargeItem, Base: DomainResource
            default:
                ((Hl7.Fhir.Model.DomainResource)current).DeserializeJsonProperty(ref reader, options, propertyName);
                break;
            }
        }
Example #24
0
        /// <summary>
        /// Serialize a FHIR ChargeItem into JSON
        /// </summary>
        public static void SerializeJson(this ChargeItem current, Utf8JsonWriter writer, JsonSerializerOptions options, bool includeStartObject = true)
        {
            if (includeStartObject)
            {
                writer.WriteStartObject();
            }
            writer.WriteString("resourceType", "ChargeItem");
            // Complex: ChargeItem, Export: ChargeItem, Base: DomainResource (DomainResource)
            ((Hl7.Fhir.Model.DomainResource)current).SerializeJson(writer, options, false);

            if ((current.Identifier != null) && (current.Identifier.Count != 0))
            {
                writer.WritePropertyName("identifier");
                writer.WriteStartArray();
                foreach (Identifier val in current.Identifier)
                {
                    val.SerializeJson(writer, options, true);
                }
                writer.WriteEndArray();
            }

            if ((current.DefinitionUriElement != null) && (current.DefinitionUriElement.Count != 0))
            {
                int valueCount     = 0;
                int extensionCount = 0;
                foreach (FhirUri val in current.DefinitionUriElement)
                {
                    if (!string.IsNullOrEmpty(val.Value))
                    {
                        valueCount++;
                    }
                    if (val.HasExtensions())
                    {
                        extensionCount++;
                    }
                }

                if (valueCount > 0)
                {
                    writer.WritePropertyName("definitionUri");
                    writer.WriteStartArray();
                    foreach (FhirUri val in current.DefinitionUriElement)
                    {
                        if (string.IsNullOrEmpty(val.Value))
                        {
                            writer.WriteNullValue();
                        }
                        else
                        {
                            writer.WriteStringValue(val.Value);
                        }
                    }

                    writer.WriteEndArray();
                }

                if (extensionCount > 0)
                {
                    writer.WritePropertyName("_definitionUri");
                    writer.WriteStartArray();
                    foreach (FhirUri val in current.DefinitionUriElement)
                    {
                        if (val.HasExtensions() || (!string.IsNullOrEmpty(val.ElementId)))
                        {
                            JsonStreamUtilities.SerializeExtensionList(writer, options, string.Empty, true, val.Extension, val.ElementId);
                        }
                        else
                        {
                            writer.WriteNullValue();
                        }
                    }

                    writer.WriteEndArray();
                }
            }

            if ((current.DefinitionCanonicalElement != null) && (current.DefinitionCanonicalElement.Count != 0))
            {
                int valueCount     = 0;
                int extensionCount = 0;
                foreach (Canonical val in current.DefinitionCanonicalElement)
                {
                    if (!string.IsNullOrEmpty(val.Value))
                    {
                        valueCount++;
                    }
                    if (val.HasExtensions())
                    {
                        extensionCount++;
                    }
                }

                if (valueCount > 0)
                {
                    writer.WritePropertyName("definitionCanonical");
                    writer.WriteStartArray();
                    foreach (Canonical val in current.DefinitionCanonicalElement)
                    {
                        if (string.IsNullOrEmpty(val.Value))
                        {
                            writer.WriteNullValue();
                        }
                        else
                        {
                            writer.WriteStringValue(val.Value);
                        }
                    }

                    writer.WriteEndArray();
                }

                if (extensionCount > 0)
                {
                    writer.WritePropertyName("_definitionCanonical");
                    writer.WriteStartArray();
                    foreach (Canonical val in current.DefinitionCanonicalElement)
                    {
                        if (val.HasExtensions() || (!string.IsNullOrEmpty(val.ElementId)))
                        {
                            JsonStreamUtilities.SerializeExtensionList(writer, options, string.Empty, true, val.Extension, val.ElementId);
                        }
                        else
                        {
                            writer.WriteNullValue();
                        }
                    }

                    writer.WriteEndArray();
                }
            }

            writer.WriteString("status", Hl7.Fhir.Utility.EnumUtility.GetLiteral(current.StatusElement.Value));

            if ((current.PartOf != null) && (current.PartOf.Count != 0))
            {
                writer.WritePropertyName("partOf");
                writer.WriteStartArray();
                foreach (ResourceReference val in current.PartOf)
                {
                    val.SerializeJson(writer, options, true);
                }
                writer.WriteEndArray();
            }

            writer.WritePropertyName("code");
            current.Code.SerializeJson(writer, options);

            writer.WritePropertyName("subject");
            current.Subject.SerializeJson(writer, options);

            if (current.Context != null)
            {
                writer.WritePropertyName("context");
                current.Context.SerializeJson(writer, options);
            }

            if (current.Occurrence != null)
            {
                switch (current.Occurrence)
                {
                case FhirDateTime v_FhirDateTime:
                    if (v_FhirDateTime != null)
                    {
                        if (!string.IsNullOrEmpty(v_FhirDateTime.Value))
                        {
                            writer.WriteString("occurrenceDateTime", v_FhirDateTime.Value);
                        }
                        if (v_FhirDateTime.HasExtensions() || (!string.IsNullOrEmpty(v_FhirDateTime.ElementId)))
                        {
                            JsonStreamUtilities.SerializeExtensionList(writer, options, "_occurrenceDateTime", false, v_FhirDateTime.Extension, v_FhirDateTime.ElementId);
                        }
                    }
                    break;

                case Period v_Period:
                    writer.WritePropertyName("occurrencePeriod");
                    v_Period.SerializeJson(writer, options);
                    break;

                case Timing v_Timing:
                    writer.WritePropertyName("occurrenceTiming");
                    v_Timing.SerializeJson(writer, options);
                    break;
                }
            }
            if ((current.Performer != null) && (current.Performer.Count != 0))
            {
                writer.WritePropertyName("performer");
                writer.WriteStartArray();
                foreach (ChargeItem.PerformerComponent val in current.Performer)
                {
                    val.SerializeJson(writer, options, true);
                }
                writer.WriteEndArray();
            }

            if (current.PerformingOrganization != null)
            {
                writer.WritePropertyName("performingOrganization");
                current.PerformingOrganization.SerializeJson(writer, options);
            }

            if (current.RequestingOrganization != null)
            {
                writer.WritePropertyName("requestingOrganization");
                current.RequestingOrganization.SerializeJson(writer, options);
            }

            if (current.CostCenter != null)
            {
                writer.WritePropertyName("costCenter");
                current.CostCenter.SerializeJson(writer, options);
            }

            if (current.Quantity != null)
            {
                writer.WritePropertyName("quantity");
                current.Quantity.SerializeJson(writer, options);
            }

            if ((current.Bodysite != null) && (current.Bodysite.Count != 0))
            {
                writer.WritePropertyName("bodysite");
                writer.WriteStartArray();
                foreach (CodeableConcept val in current.Bodysite)
                {
                    val.SerializeJson(writer, options, true);
                }
                writer.WriteEndArray();
            }

            if (current.FactorOverrideElement != null)
            {
                if (current.FactorOverrideElement.Value != null)
                {
                    writer.WriteNumber("factorOverride", (decimal)current.FactorOverrideElement.Value);
                }
                if (current.FactorOverrideElement.HasExtensions() || (!string.IsNullOrEmpty(current.FactorOverrideElement.ElementId)))
                {
                    JsonStreamUtilities.SerializeExtensionList(writer, options, "_factorOverride", false, current.FactorOverrideElement.Extension, current.FactorOverrideElement.ElementId);
                }
            }

            if (current.PriceOverride != null)
            {
                writer.WritePropertyName("priceOverride");
                current.PriceOverride.SerializeJson(writer, options);
            }

            if (current.OverrideReasonElement != null)
            {
                if (!string.IsNullOrEmpty(current.OverrideReasonElement.Value))
                {
                    writer.WriteString("overrideReason", current.OverrideReasonElement.Value);
                }
                if (current.OverrideReasonElement.HasExtensions() || (!string.IsNullOrEmpty(current.OverrideReasonElement.ElementId)))
                {
                    JsonStreamUtilities.SerializeExtensionList(writer, options, "_overrideReason", false, current.OverrideReasonElement.Extension, current.OverrideReasonElement.ElementId);
                }
            }

            if (current.Enterer != null)
            {
                writer.WritePropertyName("enterer");
                current.Enterer.SerializeJson(writer, options);
            }

            if (current.EnteredDateElement != null)
            {
                if (!string.IsNullOrEmpty(current.EnteredDateElement.Value))
                {
                    writer.WriteString("enteredDate", current.EnteredDateElement.Value);
                }
                if (current.EnteredDateElement.HasExtensions() || (!string.IsNullOrEmpty(current.EnteredDateElement.ElementId)))
                {
                    JsonStreamUtilities.SerializeExtensionList(writer, options, "_enteredDate", false, current.EnteredDateElement.Extension, current.EnteredDateElement.ElementId);
                }
            }

            if ((current.Reason != null) && (current.Reason.Count != 0))
            {
                writer.WritePropertyName("reason");
                writer.WriteStartArray();
                foreach (CodeableConcept val in current.Reason)
                {
                    val.SerializeJson(writer, options, true);
                }
                writer.WriteEndArray();
            }

            if ((current.Service != null) && (current.Service.Count != 0))
            {
                writer.WritePropertyName("service");
                writer.WriteStartArray();
                foreach (ResourceReference val in current.Service)
                {
                    val.SerializeJson(writer, options, true);
                }
                writer.WriteEndArray();
            }

            if (current.Product != null)
            {
                switch (current.Product)
                {
                case ResourceReference v_ResourceReference:
                    writer.WritePropertyName("productReference");
                    v_ResourceReference.SerializeJson(writer, options);
                    break;

                case CodeableConcept v_CodeableConcept:
                    writer.WritePropertyName("productCodeableConcept");
                    v_CodeableConcept.SerializeJson(writer, options);
                    break;
                }
            }
            if ((current.Account != null) && (current.Account.Count != 0))
            {
                writer.WritePropertyName("account");
                writer.WriteStartArray();
                foreach (ResourceReference val in current.Account)
                {
                    val.SerializeJson(writer, options, true);
                }
                writer.WriteEndArray();
            }

            if ((current.Note != null) && (current.Note.Count != 0))
            {
                writer.WritePropertyName("note");
                writer.WriteStartArray();
                foreach (Annotation val in current.Note)
                {
                    val.SerializeJson(writer, options, true);
                }
                writer.WriteEndArray();
            }

            if ((current.SupportingInformation != null) && (current.SupportingInformation.Count != 0))
            {
                writer.WritePropertyName("supportingInformation");
                writer.WriteStartArray();
                foreach (ResourceReference val in current.SupportingInformation)
                {
                    val.SerializeJson(writer, options, true);
                }
                writer.WriteEndArray();
            }

            if (includeStartObject)
            {
                writer.WriteEndObject();
            }
        }