Beispiel #1
0
        public async Task <ReactiveResponse> GetPrescriptionBarcodeDetailesByPrescriptionId(long prescriptionId)
        {
            var response = new ReactiveResponse();

            try
            {
                var result = await _prescriptionBarcodeDetailesRepository.GetWhere(a => a.PrescriptionBarcode.PrescriptionId == prescriptionId);

                response.ItemsInfo = new List <PrescriptionBarcodeDetailesResponse>();
                PrescriptionBarcodeDetailesResponse prescriptionBarcodeDetailesResponse;
                foreach (var item in result)
                {
                    prescriptionBarcodeDetailesResponse = new PrescriptionBarcodeDetailesResponse();
                    result.CopyPropertiesTo(prescriptionBarcodeDetailesResponse);
                    response.ItemsInfo.Add(prescriptionBarcodeDetailesResponse);
                }
                return(response.ToSuccess <ReactiveResponse>());
            }
            catch (Exception ex)
            {
                throw new Exception(ex.Message);
            }
        }
Beispiel #2
0
        public async Task <ReactiveResponse> ReActivePrescriptionId(long PrescriptionId)
        {
            var response = new ReactiveResponse();

            response.ItemsInfo = new List <PrescriptionBarcodeDetailesResponse>();
            var prescriptionBarcodeDetailes         = new PrescriptionBarcodeDetailes();
            var prescriptionBarcodeDetailesResponse = new PrescriptionBarcodeDetailesResponse();

            try
            {
                if (PrescriptionId == 0)
                {
                    return(response.ToIncompleteInput <ReactiveResponse>());
                }
                TTAC tTAC   = new TTAC(_serviceProvider);
                var  result = await _prescriptionBarcodeDetailesRepository.GetWhere(a => a.PrescriptionBarcode.PrescriptionId == PrescriptionId &&
                                                                                    a.Status == 0);

                if (result == null)
                {
                    return(response.ToRowNotFound <ReactiveResponse>());
                }
                if (result.Count == 0)
                {
                    return(response.ToRowNotFound <ReactiveResponse>());
                }
                foreach (var item in result)
                {
                    TTACReactiveRequest  tTACReactiveRequest  = new TTACReactiveRequest();
                    TTACReactiveResponse tTACReactiveResponse = new TTACReactiveResponse();

                    var prescriptionBarcode = await _prescriptionBarcodeRepository.FirstOrDefault(a => a.Id == item.PrescriptionBarcodeId);

                    var prescription = await _prescriptionRepository.FirstOrDefault(a => a.Id == prescriptionBarcode.PrescriptionId);

                    tTACReactiveRequest.Amount       = prescriptionBarcode.Amount;
                    tTACReactiveRequest.TrackingCode = (int)item.TrackingCode;
                    tTACReactiveRequest.BarcodeUid   = item.BarcodeUid;
                    tTACReactiveRequest.PharmacyGln  = prescription.PharmacyGln;
                    tTACReactiveRequest.Username     = Constants.TTAC_UserName;
                    tTACReactiveRequest.Password     = Constants.TTAC_Password;

                    tTACReactiveResponse = await tTAC.CallReactiveApi(tTACReactiveRequest);

                    response.ErrorCode    = tTACReactiveResponse.ErrorCode;
                    response.ErrorMessage = tTACReactiveResponse.ErrorMessage;
                    foreach (var resultItem in tTACReactiveResponse.ItemsInfo)
                    {
                        prescriptionBarcodeDetailes = new PrescriptionBarcodeDetailes();
                        prescriptionBarcodeDetailes.PrescriptionBarcodeId = item.PrescriptionBarcodeId;
                        prescriptionBarcodeDetailes.PrescriptionBarcodeDetailesTypesId = (int)PrescriptionBarcodeDetailesTypeEnum.ReActiveBarcodeItems;
                        resultItem.CopyPropertiesTo(prescriptionBarcodeDetailes);
                        resultItem.CopyPropertiesTo(prescriptionBarcodeDetailesResponse);
                        response.ItemsInfo.Add(prescriptionBarcodeDetailesResponse);

                        if (tTACReactiveResponse.ErrorCode == 0 && (resultItem.Status == 100 || resultItem.Status == 111))
                        {
                            prescriptionBarcode.PrescriptionBarcodeStatusId = (int)PrescriptionBarcodeStatusEnum.ReActiveRequest;
                            await _prescriptionBarcodeRepository.Update(prescriptionBarcode);
                        }
                        await _prescriptionBarcodeDetailesRepository.Add(prescriptionBarcodeDetailes);
                    }
                }
                response.HasError = false;
                return(response);
            }
            catch (Exception e)
            {
                response.ToApiError <ReactiveResponse>();
                _logService.LogText(e.StackTrace);
                throw new Exception(e.Message);
            }
        }