Пример #1
0
        public void UpdateCarePlan(CarePlan cp)
        {
            CarePlan ExistingCarePlan = this.GetCarePlan(cp.CarePlanID);

            Entities.Entry(ExistingCarePlan).CurrentValues.SetValues(cp);
            Entities.SaveChanges();
        }
Пример #2
0
 public ResourceExtensionsTests()
 {
     _carePlan = new CarePlan
     {
         BasedOn = new List <ResourceReference>
         {
             _carePlan1,
             _carePlan2,
         },
         Subject  = _patient1,
         Category = new List <CodeableConcept> {
             _codeableConcept1, _codeableConcept2
         },
         Activity = new List <CarePlan.ActivityComponent>
         {
             new CarePlan.ActivityComponent {
                 Reference = _deviceRequest1
             },
             new CarePlan.ActivityComponent
             {
                 OutcomeReference = new List <ResourceReference>
                 {
                     _encounter1,
                     _encounter2,
                 },
                 Detail = new CarePlan.DetailComponent
                 {
                     ReasonReference = new List <ResourceReference>
                     {
                         _condition1,
                     },
                     Product = _product1,
                 },
             },
             new CarePlan.ActivityComponent
             {
                 OutcomeCodeableConcept = new List <CodeableConcept> {
                     _codeableConcept3, _codeableConcept4
                 },
                 Detail = new CarePlan.DetailComponent
                 {
                     Product = _codeableConcept5,
                 },
             },
         },
         Intent      = CarePlan.CarePlanIntent.Proposal,
         Description = "test care plan",
     };
 }
Пример #3
0
        public async Task <ActionResult> Create(CarePlan carePlan)
        {
            try
            {
                CategoryCycleStatusHelper.User = User;
                if (HelperExtensions.isAllowedforEditingorAdd(carePlan.PatientId, CategoryCycleStatusHelper.GetPatientNewOrOldCycleByCategory(carePlan.PatientId, BillingCodeHelper.cmmBillingCatagoryid), User.Identity.GetUserId()) == false)
                {
                    return(RedirectToAction("Index", "CcmStatus", new { status = HelperExtensions.GetStatusRedirectionbyUser(User.Identity.GetUserId()), Message = "Cycle is locked." }));
                }
                var patient = await _db.Patients.FirstOrDefaultAsync(p => p.Id == carePlan.PatientId);

                if (patient != null && ModelState.IsValid)
                {
                    _db.Set <CarePlan>().AddOrUpdate(carePlan);

                    patient.UpdatedBy        = User.Identity.GetUserId();
                    patient.UpdatedOn        = DateTime.Now;
                    _db.Entry(patient).State = EntityState.Modified;
                    await _db.SaveChangesAsync();
                }

                var physician = await _db.Physicians.FindAsync(patient?.PhysicianId);

                ViewBag.PhysicianName = physician?.FirstName + ' ' + physician?.LastName;
                ViewBag.PatientName   = patient?.FirstName + ' ' + patient?.LastName;
                ViewBag.PatientId     = patient?.Id;
                ViewBag.CcmStatus     = patient?.CcmStatus;

                return(View(carePlan));
            }
            catch (Exception ex)
            {
                CarePlan carePlan1 = new CarePlan();
                ViewBag.PhysicianName = "Error";
                ViewBag.PatientName   = "Error";
                ViewBag.PatientId     = 0;
                ViewBag.CcmStatus     = "Error";
                log.Error(Environment.NewLine + User.Identity.GetUserName() + "-------" + User.Identity.GetUserId() + Environment.NewLine + ex.Message + "-----" + ex.StackTrace);
                return(View(carePlan1));
                /*return ex.Message + "------------------" + ex.StackTrace;*/
            }
        }
Пример #4
0
        public ActionResult Assessments(Guid carddlType, Guid carddlStatus, DateTime carDate, string carRemarks, string CarePlanId, int carPatient)
        {
            if (checkDropdowns(carddlType, 6) && checkDropdowns(carddlStatus, 7) && IsDate(carDate) && IsValidText(carRemarks))
            {
                CarePlan cp = new CarePlan()
                {
                    CarePlanDate = carDate, CarePlanRemarks = carRemarks, CarePlanStatus = carddlStatus, CarePlanType = carddlType, PatientId_fk = carPatient
                };
                //if completely new
                if (CarePlanId == null || CarePlanId.Equals(""))
                {
                    cp.CarePlanID = Guid.NewGuid();
                    new BusinessLayer.CarePlanBL().AddCarePlan(cp);
                }
                else
                { //if update
                    try
                    {
                        cp.CarePlanID = new Guid(CarePlanId);
                        new BusinessLayer.CarePlanBL().UpdateCarePlan(cp);
                    }
                    catch (FormatException)
                    {
                        cp.CarePlanID           = Guid.Empty;
                        TempData["InvalidData"] = true;
                        return(RedirectToAction("Index", "Assessments"));
                    }
                }
            }
            else
            {
                ViewBag.Message = "Invalid data sent!";
            }

            return(RedirectToAction("Index", "Assessments"));
            //return RedirectToAction("Index", "Assessments", new { prodid = aid, qty = pqty });
        }
Пример #5
0
 public void UpdateCarePlan(CarePlan cp)
 {
     new CarePlanHandler().UpdateCarePlan(cp);
 }
Пример #6
0
 public void AddCarePlan(CarePlan cp)
 {
     new DataLayer.CarePlanHandler().AddCarePlan(cp);
 }
Пример #7
0
        /// <summary>
        /// Update the care plan given that a new act exists
        /// </summary>
        public void UpdateCarePlan(Act act)
        {
            try
            {
                List <Object> warehousePlan    = new List <object>();
                var           warehouseService = ApplicationContext.Current.GetService <IAdHocDatawarehouseService>();
                var           careplanService  = ApplicationContext.Current.GetService <ICarePlanService>();

                CarePlan carePlan = null;

                // First step, we delete all acts in the warehouse for the specified patient in the protocol
                var patientId = act.Participations.FirstOrDefault(o => o.ParticipationRoleKey == ActParticipationKey.RecordTarget)?.PlayerEntityKey;
                if (patientId == null)
                {
                    this.m_tracer.TraceWarning("Cannot update care plan for act as it seems to have no RecordTarget");
                    return;
                }

                var patient = ApplicationContext.Current.GetService <IDataPersistenceService <Patient> >().Get(patientId.Value);

                // Is there a protocol for this act?
                if (act.Protocols.Count() == 0)
                {
                    // Need to re-calculate the entire care plan
                    this.m_tracer.TraceWarning("Will need to calculate the entire care plan for patient {0}", patientId);

                    this.m_tracer.TraceVerbose("Calculating care plan for {0}", patient.Key);

                    // First, we clear the warehouse
                    warehouseService.Delete(this.m_dataMart.Id, new { patient_id = patient.Key.Value });

                    // Now calculate
                    carePlan = careplanService.CreateCarePlan(patient, false, this.m_parameters);

                    // Remove for all on this patient
                    lock (this.m_lock)
                        this.m_actCarePlanPromise.RemoveAll(i => i is Act && (i as Act).Participations.Any(p => p.PlayerEntityKey == patient.Key.Value || i is Patient && (i as Patient).Key == patient.Key.Value));
                }
                else
                {
                    warehouseService.Delete(this.m_dataMart.Id, new
                    {
                        patient_id  = patientId.Value,
                        protocol_id = act.Protocols.FirstOrDefault()?.ProtocolKey
                    });

                    carePlan = careplanService.CreateCarePlan(patient, false, this.m_parameters, act.Protocols.FirstOrDefault().ProtocolKey);

                    // Remove for all on this patient
                    lock (this.m_lock)
                        this.m_actCarePlanPromise.RemoveAll(i => i is Act && (i as Act).Participations.Any(p => p.PlayerEntityKey == patient.Key.Value || i is Patient && (i as Patient).Key == patient.Key.Value) && (i as Act).Protocols.FirstOrDefault()?.ProtocolKey == act.Protocols.FirstOrDefault()?.ProtocolKey);
                }

                /// Create a plan for the warehouse
                warehousePlan.AddRange(carePlan.Action.Select(o => new
                {
                    creation_date = DateTime.Now,
                    patient_id    = patient.Key.Value,
                    location_id   = patient.Relationships.FirstOrDefault(r => r.RelationshipTypeKey == EntityRelationshipTypeKeys.DedicatedServiceDeliveryLocation || r.RelationshipType?.Mnemonic == "DedicatedServiceDeliveryLocation")?.TargetEntityKey.Value,
                    act_id        = o.Key.Value,
                    protocol_id   = o.Protocols.FirstOrDefault().ProtocolKey,
                    class_id      = o.ClassConceptKey.Value,
                    type_id       = o.TypeConceptKey.Value,
                    min_date      = o.StartTime?.Date,
                    max_date      = o.StopTime?.Date,
                    act_date      = o.ActTime.Date,
                    product_id    = o.Participations?.FirstOrDefault(r => r.ParticipationRoleKey == ActParticipationKey.Product || r.ParticipationRole?.Mnemonic == "Product")?.PlayerEntityKey.Value,
                    sequence_id   = o.Protocols.FirstOrDefault()?.Sequence,
                    dose_seq      = (o as SubstanceAdministration)?.SequenceId
                }));


                // Insert plans
                warehouseService.Add(this.m_dataMart.Id, warehousePlan);
            }
            catch (Exception ex)
            {
                this.m_tracer.TraceError("Could not update care plan based on Act {0}: {1}", act, ex);
            }
        }
Пример #8
0
        public override List <ImportExport.Result> XmlImport(System.Xml.XmlNode objectNode)
        {
            List <ImportExport.Result> response = base.XmlImport(objectNode);


            try {
                foreach (System.Xml.XmlNode currentNode in objectNode.ChildNodes)
                {
                    switch (currentNode.Name)
                    {
                    case "Properties":

                        foreach (System.Xml.XmlNode currentPropertyNode in currentNode.ChildNodes)
                        {
                            switch (currentPropertyNode.Attributes["Name"].InnerText)
                            {
                            case "ProblemDomainName":

                                problemDomainName = currentPropertyNode.InnerText;

                                problemDomainId = application.CoreObjectGetIdByName("ProblemDomain", problemDomainName);

                                break;

                            case "DefiningCharacteristics": DefiningCharacteristics = currentPropertyNode.InnerText; break;

                            case "RelatedFactors": RelatedFactors = currentPropertyNode.InnerText; break;

                            default: break;
                            }
                        }

                        break;

                    case "ProblemClass":

                        // USES THE DOMAIN ID CAPTURED UNDER PROPERTIES

                        problemClassName = currentNode.Attributes["Name"].InnerText;

                        ProblemClass problemClass = application.ProblemClassGetByName(problemDomainId, problemClassName);

                        if (problemClass == null)
                        {
                            // DOES NOT EXIST, CREATE NEW FROM IMPORT

                            problemClass = new ProblemClass(application);

                            response.AddRange(problemClass.XmlImport(currentNode));

                            problemDomainId = problemClass.ProblemDomainId;

                            problemClassId = problemClass.Id;


                            if (problemClassId == 0)
                            {
                                throw new ApplicationException("Unable to import Care Measure Class: " + currentNode.Attributes["Name"].InnerText + ".");
                            }
                        }

                        break;

                    case "CarePlan":

                        CarePlan defaultCarePlan = application.CarePlanGet(currentNode.Attributes["Name"].InnerText);

                        if (defaultCarePlan == null)
                        {
                            // DOES NOT EXIST, CREATE NEW FROM IMPORT

                            defaultCarePlan = new CarePlan(application);

                            response.AddRange(defaultCarePlan.XmlImport(currentNode));
                        }

                        if (defaultCarePlan != null)
                        {
                            defaultCarePlanId = defaultCarePlan.Id;
                        }

                        break;
                    } // switch (currentNode.Attributes["Name"].InnerText) {
                }     // foreach (System.Xml.XmlNode currentNode in objectNode.ChildNodes) {


                // SAVE IMPORTED CLASS

                if (!Save())
                {
                    throw new ApplicationException("Unable to save " + ObjectType + ": " + Name + ".");
                }
            }

            catch (Exception importException) {
                response.Add(new ImportExport.Result(ObjectType, Name, importException));
            }

            return(response);
        }