Ejemplo n.º 1
0
        public async Task <ServiceResponse> AddSample(AddSampleCollectionRequest scData)
        {
            ServiceResponse sResponse = new ServiceResponse();

            try
            {
                if (string.IsNullOrEmpty(scData.babySubjectId))
                {
                    sResponse.Status  = "false";
                    sResponse.Message = "Baby subjectid is missing";
                    return(sResponse);
                }
                if (string.IsNullOrEmpty(scData.barcodeNo))
                {
                    sResponse.Status  = "false";
                    sResponse.Message = "Barcode is missing";
                    return(sResponse);
                }
                if (string.IsNullOrEmpty(scData.sampleCollectionDate))
                {
                    sResponse.Status  = "false";
                    sResponse.Message = "Sample collection date is missing";
                    return(sResponse);
                }
                if (string.IsNullOrEmpty(scData.sampleCollectionTime))
                {
                    sResponse.Status  = "false";
                    sResponse.Message = "Sample collection time is missing";
                    return(sResponse);
                }
                if (scData.hospitalId <= 0)
                {
                    sResponse.Status  = "false";
                    sResponse.Message = "Invalid hospitalId";
                    return(sResponse);
                }
                if (scData.collectedBy <= 0)
                {
                    sResponse.Status  = "false";
                    sResponse.Message = "Invalid collection by data";
                    return(sResponse);
                }

                var barcode = _sampleCollectionData.FetchBarcode(scData.barcodeNo);
                if (barcode.Count <= 0)
                {
                    var result = _sampleCollectionData.AddSample(scData);
                    sResponse.Status  = result.collectStatus.ToString();
                    sResponse.Message = result.msg;
                    return(sResponse);
                }
                else
                {
                    sResponse.Status  = "false";
                    sResponse.Message = $" This barcode no- {scData.barcodeNo} is already associated with another baby subject";
                    return(sResponse);
                }
            }
            catch (Exception e)
            {
                sResponse.Status  = "false";
                sResponse.Message = $"Unable to collect sample for this baby subjectid - {scData.babySubjectId} - {e.Message}";
                return(sResponse);
            }
        }
Ejemplo n.º 2
0
        public async Task <ServiceResponse> AddSample(AddSubjectSampleRequest ssData)
        {
            ServiceResponse sResponse = new ServiceResponse();

            try
            {
                if (string.IsNullOrEmpty(ssData.uniqueSubjectId))
                {
                    sResponse.Status  = "false";
                    sResponse.Message = "Uniquesubjectid is missing";
                    return(sResponse);
                }
                if (string.IsNullOrEmpty(ssData.barcodeNo))
                {
                    sResponse.Status  = "false";
                    sResponse.Message = "Barcode is missing";
                    return(sResponse);
                }
                if (string.IsNullOrEmpty(ssData.sampleCollectionDate))
                {
                    sResponse.Status  = "false";
                    sResponse.Message = "Sample collection date is missing";
                    return(sResponse);
                }
                if (string.IsNullOrEmpty(ssData.sampleCollectionTime))
                {
                    sResponse.Status  = "false";
                    sResponse.Message = "Sample collection time is missing";
                    return(sResponse);
                }
                if (ssData.collectionFrom <= 0)
                {
                    sResponse.Status  = "false";
                    sResponse.Message = "Invalid collection from data";
                    return(sResponse);
                }
                if (ssData.collectedBy <= 0)
                {
                    sResponse.Status  = "false";
                    sResponse.Message = "Invalid collection by data";
                    return(sResponse);
                }

                var barcode = _sampleCollectionData.FetchBarcode(ssData.barcodeNo);
                if (barcode.Count <= 0)
                {
                    var result = _sampleCollectionData.AddSample(ssData);
                    if (string.IsNullOrEmpty(result))
                    {
                        sResponse.Status  = "false";
                        sResponse.Message = $"Unable to collect sample for this uniquesubjectid - {ssData.uniqueSubjectId}";
                        return(sResponse);
                    }
                    else
                    {
                        var reason           = ssData.reason;
                        var smsSampleDetails = _sampleCollectionData.FetchSMSSamples(ssData.barcodeNo, ssData.uniqueSubjectId);
                        var barcodeNo        = smsSampleDetails.barcodeNo;
                        var subjectMobileNo  = smsSampleDetails.subjectMobileNo;
                        var subjectName      = smsSampleDetails.subjectName;
                        var anmName          = smsSampleDetails.anmName;
                        var anmMobileNo      = smsSampleDetails.anmMobileNo;

                        if (reason.ToUpper() == "FIRST TIME COLLECTION")
                        {
                            var smsURL     = _config.GetSection("RegistrationSamplingOdiyaSMStoSubject").GetSection("SMSNewSampleAPILink").Value;
                            var smsURLLink = smsURL.Replace("#MobileNo", subjectMobileNo).Replace("#SubjectName", subjectName).Replace("#SubjectId", ssData.uniqueSubjectId).Replace("#BarcodeNo", ssData.barcodeNo).Replace("#ANMName", anmName).Replace("#ANMMobile", anmMobileNo);
                            GetResponse(smsURLLink);
                        }
                        else
                        {
                            var smsURL     = _config.GetSection("RegistrationSamplingOdiyaSMStoSubject").GetSection("SMSNewSampleRecollectionAPILink").Value;
                            var smsURLLink = smsURL.Replace("#MobileNo", subjectMobileNo).Replace("#SubjectName", subjectName).Replace("#SubjectId", ssData.uniqueSubjectId).Replace("#BarcodeNo", ssData.barcodeNo).Replace("#ANMName", anmName).Replace("#ANMMobile", anmMobileNo);
                            GetResponse(smsURLLink);
                        }

                        sResponse.Status  = "true";
                        sResponse.Message = result;
                        return(sResponse);
                    }
                }
                else
                {
                    sResponse.Status  = "false";
                    sResponse.Message = $" This barcode no- {ssData.barcodeNo} is already associated with another subject";
                    return(sResponse);
                }
            }
            catch (Exception e)
            {
                sResponse.Status  = "false";
                sResponse.Message = $"Unable to collect sampele for this uniquesubjectid - {ssData.uniqueSubjectId} - {e.Message}";
                return(sResponse);
            }
        }