예제 #1
0
        public async void ShouldSuccessfullyCreateANewBilling()
        {
            var newBillingEntity = new BillingEntity
            {
                Id = Guid.NewGuid()
            };
            var newCreatedBillingEntity = await _service.CreateBillingAsync(newBillingEntity);

            Assert.NotNull(newCreatedBillingEntity);
        }
예제 #2
0
            public async void Should_AddAsync_Valid()
            {
                await using var context = new TestContext(ContextOptions);
                var repository = new BillingsRepository(
                    new Mock <ILogger <AbstractRepository <BillingsContext, BillingEntity> > >().Object,
                    context
                    );
                var newEntity = new BillingEntity();
                var result    = await repository.AddAsync(newEntity);

                Assert.NotNull(result);
            }
예제 #3
0
 public Task <int> SubmitForm <TDto>(BillingEntity entity, TDto dto) where TDto : class
 {
     if (!string.IsNullOrEmpty(entity.F_Id))
     {
         entity.Modify(entity.F_Id);
         entity.F_LastModifyUserId = _usersService?.GetCurrentUserId();
         return(_service.UpdateAsync(entity, dto));
     }
     else
     {
         entity.Create();
         entity.F_CreatorUserId = _usersService?.GetCurrentUserId();
         return(_service.InsertAsync(entity));
     }
 }
예제 #4
0
            public async void Should_GetOneByParameterAsync_Valid()
            {
                await using var context = new TestContext(ContextOptions);
                var repository = new BillingsRepository(
                    new Mock <ILogger <AbstractRepository <BillingsContext, BillingEntity> > >().Object,
                    context
                    );
                var newEntity = new BillingEntity {
                    Version = 99
                };
                var _ = await repository.AddAsync(newEntity);

                var result = await repository.GetOneByParameterAsync(
                    e => e.Version == 99
                    );

                Assert.NotNull(result);
            }
        public static TModel ToTransactionModel <TModel>(
            this BillingEntity billingEntity,
            ITransactionModel transactionModel
            )
            where TModel : class, ITransactionModel, new()
        {
            return(new TModel
            {
                Id = transactionModel.Id,
                Version = transactionModel.Version,
                Timestamp = transactionModel.Timestamp,

                AccountId = transactionModel.AccountId,
                ProfileId = transactionModel.ProfileId,

                Amount = transactionModel.Amount,
                Info = transactionModel.Info,

                Approved = billingEntity.Approved,
                Pending = billingEntity.Pending,

                SequentialNumber = transactionModel.SequentialNumber
            });
        }
예제 #6
0
 public Task <BillingEntity?> UpdateBillingAsync(BillingEntity billingEntity)
 {
     throw new NotImplementedException();
 }
예제 #7
0
 public Task <BillingEntity?> CreateBillingAsync(BillingEntity billingEntity)
 {
     return(_billingsRepository.AddAsync(billingEntity) !);
 }
예제 #8
0
 public Task <int> UpdateForm(BillingEntity entity)
 {
     return(_service.UpdatePartialAsync(entity));
 }
예제 #9
0
        public async Task <IActionResult> AddFee([FromBody] AddFeeInput input)
        {
            var patient = await _patientApp.GetForm(input.PatientId);

            if (patient == null)
            {
                return(BadRequest("患者Id有误!"));
            }
            var drugDict   = _drugsApp;
            var materials  = _materialApp;
            var treatments = _treatmentApp;
            var user       = await _usersService.GetCurrentUserAsync();

            var billingDateTime = DateTime.Now;
            var totalCosts      = 0f;
            var list            = new List <BillingEntity>();

            foreach (var item in input.Items.FindAll(t => t.Amount > 0 && (t.BillType == 1 || t.BillType == 2 || t.BillType == 3)))
            {
                var entity = new BillingEntity
                {
                    F_Id              = Common.GuId(),
                    F_Pid             = input.PatientId,
                    F_DialylisNo      = patient.F_DialysisNo,
                    F_PName           = patient.F_Name,
                    F_PGender         = patient.F_Gender,
                    F_BillingDateTime = billingDateTime,
                    F_BillingPersonId = user.F_Id,
                    F_BillingPerson   = user.F_RealName,
                    F_CreatorTime     = DateTime.Now,
                    F_CreatorUserId   = user.F_Id,
                    F_EnabledMark     = true
                };
                switch (item.BillType)
                {
                case 1:
                    entity.F_ItemClass = "药品";
                    var findDrug = await drugDict.GetForm(item.ItemId);

                    if (findDrug != null)
                    {
                        entity.F_ItemId   = item.ItemId;
                        entity.F_ItemCode = findDrug.F_DrugCode;
                        entity.F_ItemName = findDrug.F_DrugName;
                        entity.F_ItemSpec = findDrug.F_DrugSpec;
                        entity.F_ItemUnit = findDrug.F_DrugUnit;
                        entity.F_Amount   = item.Amount;
                        entity.F_Charges  = entity.F_Costs = item.Amount * findDrug.F_Charges;
                        entity.F_Supplier = findDrug.F_DrugSupplier;
                        list.Add(entity);
                    }
                    break;

                case 2:
                    entity.F_ItemClass = "耗材";
                    var findMaterials = await materials.GetForm(item.ItemId);

                    if (findMaterials != null)
                    {
                        entity.F_ItemId   = item.ItemId;
                        entity.F_ItemCode = findMaterials.F_MaterialCode;
                        entity.F_ItemName = findMaterials.F_MaterialName;
                        entity.F_ItemSpec = findMaterials.F_MaterialSpec;
                        entity.F_ItemUnit = findMaterials.F_MaterialUnit;
                        entity.F_Amount   = item.Amount;
                        entity.F_Charges  = entity.F_Costs = item.Amount * findMaterials.F_Charges;
                        entity.F_Supplier = findMaterials.F_MaterialSupplier;
                        list.Add(entity);
                    }
                    break;

                case 3:
                    entity.F_ItemClass = "诊疗";
                    var treatmentEntity = await treatments.GetForm(item.ItemId);

                    if (treatmentEntity != null)
                    {
                        entity.F_ItemId   = item.ItemId;
                        entity.F_ItemCode = treatmentEntity.F_TreatmentCode;
                        entity.F_ItemName = treatmentEntity.F_TreatmentName;
                        entity.F_ItemSpec = treatmentEntity.F_TreatmentSpec;
                        entity.F_ItemUnit = treatmentEntity.F_TreatmentUnit;
                        entity.F_Amount   = item.Amount;
                        entity.F_Charges  = entity.F_Costs = item.Amount * treatmentEntity.F_Charges;
                        //entity.F_Supplier = findtreatments;
                        list.Add(entity);
                    }
                    break;
                }
            }
            await _billingApp.InsertList(list);

            totalCosts = list.Sum(t => t.F_Costs).ToFloat(2);
            var data = new
            {
                totalCosts
            };

            return(Ok(data));
        }