示例#1
0
 public Policy CreatePolicyFromOffer(PolicyHolder policyHolder, Offer offer)
 {
     return(CreatePolicy(policyHolder, offer));
 }
示例#2
0
        public override IDeepCopyable CopyTo(IDeepCopyable other)
        {
            var dest = other as Coverage;

            if (dest == null)
            {
                throw new ArgumentException("Can only copy to an object of the same type", "other");
            }

            base.CopyTo(dest);
            if (Identifier != null)
            {
                dest.Identifier = new List <Hl7.Fhir.Model.Identifier>(Identifier.DeepCopy());
            }
            if (StatusElement != null)
            {
                dest.StatusElement = (Code <Hl7.Fhir.Model.FinancialResourceStatusCodes>)StatusElement.DeepCopy();
            }
            if (Type != null)
            {
                dest.Type = (Hl7.Fhir.Model.CodeableConcept)Type.DeepCopy();
            }
            if (PolicyHolder != null)
            {
                dest.PolicyHolder = (Hl7.Fhir.Model.ResourceReference)PolicyHolder.DeepCopy();
            }
            if (Subscriber != null)
            {
                dest.Subscriber = (Hl7.Fhir.Model.ResourceReference)Subscriber.DeepCopy();
            }
            if (SubscriberIdElement != null)
            {
                dest.SubscriberIdElement = (Hl7.Fhir.Model.FhirString)SubscriberIdElement.DeepCopy();
            }
            if (Beneficiary != null)
            {
                dest.Beneficiary = (Hl7.Fhir.Model.ResourceReference)Beneficiary.DeepCopy();
            }
            if (DependentElement != null)
            {
                dest.DependentElement = (Hl7.Fhir.Model.FhirString)DependentElement.DeepCopy();
            }
            if (Relationship != null)
            {
                dest.Relationship = (Hl7.Fhir.Model.CodeableConcept)Relationship.DeepCopy();
            }
            if (Period != null)
            {
                dest.Period = (Hl7.Fhir.Model.Period)Period.DeepCopy();
            }
            if (Payor != null)
            {
                dest.Payor = new List <Hl7.Fhir.Model.ResourceReference>(Payor.DeepCopy());
            }
            if (Class != null)
            {
                dest.Class = new List <Hl7.Fhir.Model.Coverage.ClassComponent>(Class.DeepCopy());
            }
            if (OrderElement != null)
            {
                dest.OrderElement = (Hl7.Fhir.Model.PositiveInt)OrderElement.DeepCopy();
            }
            if (NetworkElement != null)
            {
                dest.NetworkElement = (Hl7.Fhir.Model.FhirString)NetworkElement.DeepCopy();
            }
            if (CostToBeneficiary != null)
            {
                dest.CostToBeneficiary = new List <Hl7.Fhir.Model.Coverage.CostToBeneficiaryComponent>(CostToBeneficiary.DeepCopy());
            }
            if (SubrogationElement != null)
            {
                dest.SubrogationElement = (Hl7.Fhir.Model.FhirBoolean)SubrogationElement.DeepCopy();
            }
            if (Contract != null)
            {
                dest.Contract = new List <Hl7.Fhir.Model.ResourceReference>(Contract.DeepCopy());
            }
            return(dest);
        }
示例#3
0
        // GET: PTransactions/Details/5
        public async Task <IActionResult> Process(int?id)
        {
            if (id == null)
            {
                return(NotFound());
            }

            Subtransaction subtransaction = await _transactionContext.Subtransactions.FirstAsync(s => s.Id == id);

            PTransaction transaction = await _transactionContext.PTransactions.FirstAsync(m => m.Id == subtransaction.PTransactionId);

            PolicyHolder policyHolder = await _policyHolderContext.PolicyHolders.FirstAsync(p => p.Id == transaction.HolderId);

            Policy policy = await _policyContext.Policies.FirstAsync(p => p.Id == policyHolder.Id);

            Drug drug = await _drugContext.Drugs.FirstAsync(d => d.Id == subtransaction.DrugId);

            IQueryable <PolicyDrug> coveredDrugs = _policyDrugContext.PolicyDrugs.Where(pd => pd.PolicyId == policy.Id);

            PolicyDrug pd = coveredDrugs.FirstOrDefault(cd => cd.DrugId == drug.Id);

            bool inDate   = policyHolder.StartDate < DateTime.Now && DateTime.Now < policyHolder.EndDate;
            bool inPolicy = pd != null;

            if (!inDate)
            {
                subtransaction.Accepted = -2;
            }
            else if (!inPolicy)
            {
                subtransaction.Accepted = -1;
            }
            else
            {
                subtransaction.Accepted = 1;
            }

            transaction.Processed = isTransactionProcessed(transaction, subtransaction);

            if (subtransaction.Accepted == 1)
            {
                subtransaction.AmountPaid    = getTotalCost(drug, policy, policyHolder, subtransaction);
                policyHolder.AmountPaid     += subtransaction.AmountPaid;
                policyHolder.AmountRemaining = policy.MaxCoverage - policyHolder.AmountPaid;

                _policyHolderContext.PolicyHolders.Update(policyHolder);
                _policyHolderContext.SaveChanges();
            }
            _transactionContext.PTransactions.Update(transaction);
            _transactionContext.Subtransactions.Update(subtransaction);
            _transactionContext.SaveChanges();

            // Send response to pharmacy
            SendResponse(subtransaction);

            string holderName = "";

            if (policyHolder.Name == HttpContext.Session.GetString(HomeController.HolderName))
            {
                holderName = policyHolder.Name;
            }

            bool includeProcessed = false;

            if (!string.IsNullOrEmpty(HttpContext.Session.GetString(HomeController.IncludeProcessed)))
            {
                includeProcessed = bool.Parse(HttpContext.Session.GetString(HomeController.IncludeProcessed));
            }

            return(RedirectToAction("Details", new { id = transaction.Id }));
        }
示例#4
0
 public Policy Buy(Offer offer, PolicyHolder customer)
 {
     return(CreatePolicyFromOffer(customer, offer));
 }
示例#5
0
        /// <summary>
        /// Serialize to a JSON object
        /// </summary>
        public new void SerializeJson(Utf8JsonWriter writer, JsonSerializerOptions options, bool includeStartObject = true)
        {
            if (includeStartObject)
            {
                writer.WriteStartObject();
            }
            if (!string.IsNullOrEmpty(ResourceType))
            {
                writer.WriteString("resourceType", (string)ResourceType !);
            }


            ((fhirCsR4.Models.DomainResource) this).SerializeJson(writer, options, false);

            if ((Identifier != null) && (Identifier.Count != 0))
            {
                writer.WritePropertyName("identifier");
                writer.WriteStartArray();

                foreach (Identifier valIdentifier in Identifier)
                {
                    valIdentifier.SerializeJson(writer, options, true);
                }

                writer.WriteEndArray();
            }

            if (!string.IsNullOrEmpty(Status))
            {
                writer.WriteString("status", (string)Status !);
            }

            if (_Status != null)
            {
                writer.WritePropertyName("_status");
                _Status.SerializeJson(writer, options);
            }

            if (Type != null)
            {
                writer.WritePropertyName("type");
                Type.SerializeJson(writer, options);
            }

            if (PolicyHolder != null)
            {
                writer.WritePropertyName("policyHolder");
                PolicyHolder.SerializeJson(writer, options);
            }

            if (Subscriber != null)
            {
                writer.WritePropertyName("subscriber");
                Subscriber.SerializeJson(writer, options);
            }

            if (!string.IsNullOrEmpty(SubscriberId))
            {
                writer.WriteString("subscriberId", (string)SubscriberId !);
            }

            if (_SubscriberId != null)
            {
                writer.WritePropertyName("_subscriberId");
                _SubscriberId.SerializeJson(writer, options);
            }

            if (Beneficiary != null)
            {
                writer.WritePropertyName("beneficiary");
                Beneficiary.SerializeJson(writer, options);
            }

            if (!string.IsNullOrEmpty(Dependent))
            {
                writer.WriteString("dependent", (string)Dependent !);
            }

            if (_Dependent != null)
            {
                writer.WritePropertyName("_dependent");
                _Dependent.SerializeJson(writer, options);
            }

            if (Relationship != null)
            {
                writer.WritePropertyName("relationship");
                Relationship.SerializeJson(writer, options);
            }

            if (Period != null)
            {
                writer.WritePropertyName("period");
                Period.SerializeJson(writer, options);
            }

            if ((Payor != null) && (Payor.Count != 0))
            {
                writer.WritePropertyName("payor");
                writer.WriteStartArray();

                foreach (Reference valPayor in Payor)
                {
                    valPayor.SerializeJson(writer, options, true);
                }

                writer.WriteEndArray();
            }

            if ((Class != null) && (Class.Count != 0))
            {
                writer.WritePropertyName("class");
                writer.WriteStartArray();

                foreach (CoverageClass valClass in Class)
                {
                    valClass.SerializeJson(writer, options, true);
                }

                writer.WriteEndArray();
            }

            if (Order != null)
            {
                writer.WriteNumber("order", (uint)Order !);
            }

            if (!string.IsNullOrEmpty(Network))
            {
                writer.WriteString("network", (string)Network !);
            }

            if (_Network != null)
            {
                writer.WritePropertyName("_network");
                _Network.SerializeJson(writer, options);
            }

            if ((CostToBeneficiary != null) && (CostToBeneficiary.Count != 0))
            {
                writer.WritePropertyName("costToBeneficiary");
                writer.WriteStartArray();

                foreach (CoverageCostToBeneficiary valCostToBeneficiary in CostToBeneficiary)
                {
                    valCostToBeneficiary.SerializeJson(writer, options, true);
                }

                writer.WriteEndArray();
            }

            if (Subrogation != null)
            {
                writer.WriteBoolean("subrogation", (bool)Subrogation !);
            }

            if ((Contract != null) && (Contract.Count != 0))
            {
                writer.WritePropertyName("contract");
                writer.WriteStartArray();

                foreach (Reference valContract in Contract)
                {
                    valContract.SerializeJson(writer, options, true);
                }

                writer.WriteEndArray();
            }

            if (includeStartObject)
            {
                writer.WriteEndObject();
            }
        }
 public void Archive(PolicyHolder model)
 {
     _PolicyHolderRepository.Delete(model);
     _datacontext.SaveChanges();
 }
 public void Update(PolicyHolder model)
 {
     _PolicyHolderRepository.Update(model);
     _datacontext.SaveChanges();
 }
 public void Insert(PolicyHolder model)
 {
     _PolicyHolderRepository.Insert(model);
     _datacontext.SaveChanges();
 }
 public CatalogController(PolicyHolder policyHolder, IHttpClientFactory httpClientFactory)
 {
     _httpClientFactory = httpClientFactory;
     _policyHolder      = policyHolder;
 }