///<summary>Inserts one Intervention into the database.  Returns the new priKey.</summary>
 public static long Insert(Intervention intervention)
 {
     if (DataConnection.DBtype == DatabaseType.Oracle)
     {
         intervention.InterventionNum = DbHelper.GetNextOracleKey("intervention", "InterventionNum");
         int loopcount = 0;
         while (loopcount < 100)
         {
             try {
                 return(Insert(intervention, true));
             }
             catch (Oracle.DataAccess.Client.OracleException ex) {
                 if (ex.Number == 1 && ex.Message.ToLower().Contains("unique constraint") && ex.Message.ToLower().Contains("violated"))
                 {
                     intervention.InterventionNum++;
                     loopcount++;
                 }
                 else
                 {
                     throw ex;
                 }
             }
         }
         throw new ApplicationException("Insert failed.  Could not generate primary key.");
     }
     else
     {
         return(Insert(intervention, false));
     }
 }
Exemple #2
0
        private Intervention GetIntervention(Intervention request)
        {
            var          id    = request?.Id;
            Intervention ret   = null;
            var          query = DocQuery.ActiveQuery ?? Execute;

            DocPermissionFactory.SetVisibleFields <Intervention>(currentUser, "Intervention", request.VisibleFields);

            DocEntityIntervention entity = null;

            if (id.HasValue)
            {
                entity = DocEntityIntervention.GetIntervention(id.Value);
            }
            if (null == entity)
            {
                throw new HttpError(HttpStatusCode.NotFound, $"No Intervention found for Id {id.Value}");
            }

            if (!DocPermissionFactory.HasPermission(entity, currentUser, DocConstantPermission.VIEW))
            {
                throw new HttpError(HttpStatusCode.Forbidden, "You do not have VIEW permission for this route.");
            }

            ret = entity?.ToDto();
            return(ret);
        }
Exemple #3
0
        public void Insert(Intervention value)
        {
            using (var connection = new SqlConnection(_connectionString))
            {
                connection.Open();

                string query = @"
INSERT INTO [dbo].[Intervention]
           ([Title]
           ,[Type]
           ,[Notes]
           ,[Cost]
           ,[PhotoFolderUri]
           ,[BuidingSiteId])
     VALUES
           (@Title
           ,@Type
           ,@Notes
           ,@Cost
           ,@PhotoFolderUri
           ,@BuidingSiteId)";

                connection.Query(query, value);
            }
        }
        public ActionResult Interventions_Destroy([DataSourceRequest] DataSourceRequest request, [Bind(Prefix = "models")] IEnumerable <MentoratNetCore.ViewModels.InterventionsViewModel> interventions)
        {
            var entities = new List <Intervention>();

            if (ModelState.IsValid)
            {
                foreach (var intervention in interventions)
                {
                    var entity = new Intervention
                    {
                        No_Intervention          = intervention.No_Intervention,
                        Date_Intervention        = intervention.Date_Intervention,
                        No_Mentor_Intervention   = HttpContext.Session.GetString("intNoMentor").ToString(),   //No_Mentor_Intervention = Session["intNoMentor"].ToString(),
                        No_Mentore_Intervention  = intervention.No_Mentore_Intervention,
                        Duree_Intervention       = intervention.Duree_Intervention,
                        Description_Intervention = intervention.Description_Intervention
                    };

                    entities.Add(entity);
                    db.Interventions.Attach(entity);
                    db.Interventions.Remove(entity);
                }
                db.SaveChanges();
            }

            return(Json(entities.ToDataSourceResult(request, ModelState)));
        }
        public async Task <ActionResult <Intervention> > PostIntervention(Intervention intervention)
        {
            _context.interventions.Add(intervention);
            await _context.SaveChangesAsync();

            return(CreatedAtAction("GetIntervention", new { id = intervention.Id }, intervention));
        }
 public async Task <ActionResult <Intervention> > putIntervention(long ID, Intervention intervention)
 {
     if (ID != intervention.id)
     {
         return(null);
     }
     _context.Entry(intervention).State = EntityState.Modified;
     try
     {
         await _context.SaveChangesAsync();
     }
     catch (DbUpdateConcurrencyException)
     {
         if (ID != intervention.id)
         {
             return(NotFound());
         }
         else
         {
             throw;
         }
     }
     return(Content("The status of the intenvention ID: " + intervention.id +
                    " has been changed to: " + intervention.status + ". The start date is: "
                    + intervention.start_date + " and the end date is: " + intervention.end_date));
 }
        private void EnregistrerTempsRepartir(ObjRepartir resultat)
        {
            int tempsParPersonne = (int)(Math.Round((double)resultat.Duree / resultat.ChoixMentores.Length, MidpointRounding.AwayFromZero));
            //int tempsParPersonne = Convert.ToInt32((double) (resultat.Duree / resultat.ChoixMentores.Length));

            var entities = new List <Intervention>();

            if (tempsParPersonne > 0)
            {
                foreach (var iNoMentore in resultat.ChoixMentores)
                {
                    var entity = new Intervention
                    {
                        Date_Intervention        = resultat.Date,
                        No_Mentor_Intervention   = HttpContext.Session.GetString("intNoMentor").ToString(), //No_Mentor_Intervention =Session["intNoMentor"].ToString(),
                        No_Mentore_Intervention  = iNoMentore,
                        Duree_Intervention       = tempsParPersonne,
                        Description_Intervention = resultat.Commentaire,
                    };

                    db.Interventions.Add(entity);
                    entities.Add(entity);
                }
                db.SaveChanges();
            }
        }
        public void InterventionSetChiefComplaintTest()
        {
            Intervention a = new Intervention();

            a.setChiefComplaint("testcomplaint");
            Assert.AreEqual("testcomplaint", a.getChiefComplaint());
        }
Exemple #9
0
        public async Task <IActionResult> PutIntervention(long id, Intervention intervention)
        {
            if (id != intervention.id)
            {
                return(BadRequest());
            }

            Intervention interventionFound = await _context.interventions.FindAsync(id);

            interventionFound.status = intervention.status;
            interventionFound.start_date_intervention = DateTime.Now;

            try
            {
                await _context.SaveChangesAsync();
            }
            catch (DbUpdateConcurrencyException)
            {
                if (!InterventionExists(id))
                {
                    return(NotFound());
                }
                else
                {
                    throw;
                }
            }

            return(NoContent());
        }
Exemple #10
0
        public async Task <Intervention> UpdateAsync(Intervention intervention)
        {
            var query = new QuerySet();

            query.Include.Fields = new string[] { "customer", "way-of-entry", "building", "contact", "invoice", "origin", "technicians" };
            var existingIntervention = await _interventionDataProvider.GetByIdAsync(intervention.Id, query);

            if (intervention.Id != existingIntervention.Id)
            {
                throw new IllegalArgumentException("IllegalAttribute", "Intervention id cannot be updated.");
            }
            if (intervention.Date == null)
            {
                throw new IllegalArgumentException("IllegalAttribute", "Intervention-date is required.");
            }

            await EmbedRelations(intervention, existingIntervention);

            if (intervention.Invoice != null && intervention.Customer == null)
            {
                throw new IllegalArgumentException("IllegalAttribute", "Customer is required if an invoice is attached to the intervention.");
            }
            if (intervention.Contact != null && intervention.Contact.Customer != null && intervention.Contact.Customer.Id != intervention.Customer.Id)
            {
                throw new IllegalArgumentException("IllegalAttribute", $"Contact is not attached to customer {intervention.Contact.Id}.");
            }
            if (intervention.Building != null && intervention.Building.Customer != null && intervention.Building.Customer.Id != intervention.Customer.Id)
            {
                throw new IllegalArgumentException("IllegalAttribute", $"Building is not attached to customer {intervention.Customer.Id}.");
            }

            intervention = await _interventionDataProvider.UpdateAsync(intervention);

            return(intervention);
        }
Exemple #11
0
        //*****************************************************************************************************************
        void listerInterventionsTechnicienDate()
        {
            Intervention uneIntervention = new Intervention();

            uneIntervention.DebutIntervention = DateTime.Now.Date;
            uneIntervention.FkLoginT          = "tvsilvestre";
            try
            {
                using (InterventionManager interventionManager = new InterventionManager())
                {
                    List <Intervention> listIntervention = interventionManager.listeInterventionsTechnicien(uneIntervention);
                    foreach (Intervention chaqueIntervention in listIntervention)
                    {
                        Console.Write(chaqueIntervention.NomContact + "  " + chaqueIntervention.FkLoginT
                                      + "  " + chaqueIntervention.DebutIntervention.ToString()
                                      + "  " + chaqueIntervention.FinIntervention.ToString());
                        Console.WriteLine();
                    }
                }
            }
            catch (Exception ex)
            {
                Console.WriteLine(ex.Message);
            }
        }
Exemple #12
0
        public Intervention Add(Intervention intervention)
        {
            var newIntervention = _context.Interventions.Add(intervention);

            _context.SaveChanges();
            return(newIntervention.Entity);
        }
Exemple #13
0
        public Intervention mapInterventionData(String[] foundRecord, Intervention interv)
        {
            interv.Id               = Convert.ToInt32(foundRecord[0]);
            interv.doctor.ID        = Convert.ToInt32(foundRecord[1]);
            interv.doctor.FirstName = foundRecord[2];
            interv.doctor.LastName  = foundRecord[3];
            interv.PatientId        = Convert.ToInt32(foundRecord[4]);
            interv.PrescriptionId   = Convert.ToInt32(foundRecord[5]);
            interv.Start            = Convert.ToDateTime(foundRecord[6]);
            interv.End              = Convert.ToDateTime(foundRecord[7]);
            interv.Absence          = Convert.ToBoolean(foundRecord[8]);
            interv.Description      = foundRecord[9];
            if (foundRecord[10] == "surgery")
            {
                interv.Type = InterventionType.surgery;
            }
            else if (foundRecord[10] == "examination")
            {
                interv.Type = InterventionType.examination;
            }
            else
            {
                interv.Type = InterventionType.stationaryTreatment;
            }

            return(interv);
        }
Exemple #14
0
        public Intervention Post(Intervention request)
        {
            if (request == null)
            {
                throw new HttpError(HttpStatusCode.NotFound, "Request cannot be null.");
            }

            request.VisibleFields = request.VisibleFields ?? new List <string>();

            Intervention ret = null;

            using (Execute)
            {
                Execute.Run(ssn =>
                {
                    if (!DocPermissionFactory.HasPermissionTryAdd(currentUser, "Intervention"))
                    {
                        throw new HttpError(HttpStatusCode.Forbidden, "You do not have ADD permission for this route.");
                    }

                    ret = _AssignValues(request, DocConstantPermission.ADD, ssn);
                });
            }
            return(ret);
        }
Exemple #15
0
        public void Delete(Intervention request)
        {
            using (Execute)
            {
                Execute.Run(ssn =>
                {
                    if (!(request?.Id > 0))
                    {
                        throw new HttpError(HttpStatusCode.NotFound, $"No Id provided for delete.");
                    }

                    var en = DocEntityIntervention.GetIntervention(request?.Id);
                    if (null == en)
                    {
                        throw new HttpError(HttpStatusCode.NotFound, $"No Intervention could be found for Id {request?.Id}.");
                    }
                    if (en.IsRemoved)
                    {
                        return;
                    }

                    if (!DocPermissionFactory.HasPermission(en, currentUser, DocConstantPermission.DELETE))
                    {
                        throw new HttpError(HttpStatusCode.Forbidden, "You do not have DELETE permission for this route.");
                    }

                    en.Remove();

                    DocCacheClient.RemoveSearch(DocConstantModelName.INTERVENTION);
                    DocCacheClient.RemoveById(request.Id);
                });
            }
        }
Exemple #16
0
        public async Task <Intervention> Update(string interventionId, Intervention intervention)
        {
            var odsApi = await _odsApiClientProvider.NewResourcesClient();

            var interventionv3 = intervention.MapToInterventionModelv3();

            interventionv3.Id = null;

            var response = await odsApi.Put($"interventions/{interventionId}", interventionv3);

            await odsApi.HandleHttpResponse(response);

            var updatedInterventionv2 = interventionv3.MapToInterventionV2();

            updatedInterventionv2.Id = interventionId;

            var cachedInterventions = await _cache.GetOrDefault <IList <Intervention> >(CacheKeys.Interventions);

            if (cachedInterventions != null)
            {
                cachedInterventions = cachedInterventions
                                      .Where(i => i.Id != interventionId)
                                      .ToList();

                cachedInterventions.Add(updatedInterventionv2);

                await _cache.TrySet(CacheKeys.Interventions, cachedInterventions);
            }

            return(updatedInterventionv2);
        }
Exemple #17
0
        public void InterventionSetGenderTest()
        {
            Intervention a = new Intervention();

            a.setGender("m");
            Assert.AreEqual("m", a.getGender());
        }
Exemple #18
0
        public async Task <Intervention> CreateAsync(Intervention intervention)
        {
            if (intervention.Id != 0)
            {
                throw new IllegalArgumentException("IllegalAttribute", "Intervention cannot have an id on create.");
            }
            if (intervention.Date == null)
            {
                throw new IllegalArgumentException("IllegalAttribute", "Intervention-date is required.");
            }
            if (intervention.Invoice != null)
            {
                var message = "Invoice cannot be added to an intervention on creation.";
                _logger.LogDebug(message);
                throw new IllegalArgumentException("IllegalAttribute", message);
            }

            await EmbedRelations(intervention);

            if (intervention.Contact != null && intervention.Contact.Customer.Id != intervention.Customer.Id)
            {
                throw new IllegalArgumentException("IllegalAttribute", $"Contact is not attached to customer {intervention.Contact.Id}.");
            }
            if (intervention.Building != null && intervention.Building.Customer.Id != intervention.Customer.Id)
            {
                throw new IllegalArgumentException("IllegalAttribute", $"Building is not attached to customer {intervention.Customer.Id}.");
            }

            return(await _interventionDataProvider.CreateAsync(intervention));
        }
Exemple #19
0
        public void InterventionSetAgeTest()
        {
            Intervention a = new Intervention();

            a.setAge("21");
            Assert.AreEqual("21", a.getAge());
        }
        ///<summary>Inserts one Intervention into the database.  Provides option to use the existing priKey.</summary>
        public static long Insert(Intervention intervention, bool useExistingPK)
        {
            if (!useExistingPK && PrefC.RandomKeys)
            {
                intervention.InterventionNum = ReplicationServers.GetKey("intervention", "InterventionNum");
            }
            string command = "INSERT INTO intervention (";

            if (useExistingPK || PrefC.RandomKeys)
            {
                command += "InterventionNum,";
            }
            command += "PatNum,ProvNum,CodeValue,CodeSystem,Note,DateEntry,CodeSet) VALUES(";
            if (useExistingPK || PrefC.RandomKeys)
            {
                command += POut.Long(intervention.InterventionNum) + ",";
            }
            command +=
                POut.Long(intervention.PatNum) + ","
                + POut.Long(intervention.ProvNum) + ","
                + "'" + POut.String(intervention.CodeValue) + "',"
                + "'" + POut.String(intervention.CodeSystem) + "',"
                + "'" + POut.String(intervention.Note) + "',"
                + POut.Date(intervention.DateEntry) + ","
                + POut.Int((int)intervention.CodeSet) + ")";
            if (useExistingPK || PrefC.RandomKeys)
            {
                Db.NonQ(command);
            }
            else
            {
                intervention.InterventionNum = Db.NonQ(command, true);
            }
            return(intervention.InterventionNum);
        }
Exemple #21
0
        public async Task <object> Create(Intervention intervention)
        {
            var odsApi = await _odsApiClientProvider.NewResourcesClient();

            var interventionv3 = intervention.MapToInterventionModelv3();

            interventionv3.Id = null;

            var response = await odsApi.Post("interventions", interventionv3);

            var createdInterventionId = await odsApi.HandleHttpResponseGetCreatedResourceId(response);

            var createdInterventionv3 = await odsApi.Get <InterventionModelv3>($"interventions/{createdInterventionId}");

            var createdInterventionv2 = createdInterventionv3.MapToInterventionV2();

            var cachedInterventions = await _cache.GetOrDefault <IList <Intervention> >(CacheKeys.Interventions);

            if (cachedInterventions != null)
            {
                cachedInterventions.Add(createdInterventionv2);
                await _cache.TrySet(CacheKeys.Interventions, cachedInterventions);
            }

            return(createdInterventionv2);
        }
Exemple #22
0
        public ActionResult Interventions_Create([DataSourceRequest] DataSourceRequest request, [Bind(Prefix = "models")] IEnumerable <MentoratNetCore.ViewModels.InterventionsViewModel> interventions)
        {
            var          entities      = new List <Intervention>();
            List <Error> currentErrors = new List <Error>();

            if (interventions != null && ModelState.IsValid)
            {
                ValiderGrid(interventions, currentErrors);
                if (currentErrors.Count > 0)
                {
                    return(Json(new { Errors = currentErrors }));
                }
                else
                {
                    foreach (var intervention in interventions)
                    {
                        var entity = new Intervention
                        {
                            Date_Intervention        = intervention.Date_Intervention,
                            No_Mentor_Intervention   = HttpContext.Session.GetString("intNoMentor").ToString(), //No_Mentor_Intervention = Session["intNoMentor"].ToString(),
                            No_Mentore_Intervention  = intervention.No_Mentore_Intervention,
                            Duree_Intervention       = intervention.Duree_Intervention,
                            Description_Intervention = intervention.Description_Intervention
                        };

                        db.Interventions.Add(entity);
                        entities.Add(entity);
                    }
                    db.SaveChanges();
                }
            }
            return(Json(interventions));
            //return Json(interventions.ToDataSourceResult(request, ModelState));
            //return Json(entities.ToDataSourceResult(request, ModelState));
        }
Exemple #23
0
        private List <Intervention> ConvertToList(DataTable dataTable)
        {
            List <Intervention> interventions = new List <Intervention>();

            int rowsCount = dataTable.Rows.Count;

            if (rowsCount > 0)
            {
                for (int i = 0; i < rowsCount; i++)
                {
                    if (dataTable.Rows[i]["ApprovedBy"] == DBNull.Value)
                    {
                        dataTable.Rows[i]["ApprovedBy"]  = -1;
                        dataTable.Rows[i]["Approved By"] = "";
                    }
                    State state;
                    State.TryParse((string)dataTable.Rows[i]["State"], out state);
                    Intervention intervention = new Intervention();
                    intervention.InterventionId = (int)dataTable.Rows[i]["InterventionId"];
                    intervention.ApprovedBy     = new User
                    {
                        UserId = (int)dataTable.Rows[i]["ApprovedBy"],
                        Name   = (string)dataTable.Rows[i]["Approved By"]
                    };
                    intervention.ProposedBy = new SiteEngineer
                    {
                        SiteEngineerId = (int)dataTable.Rows[i]["ProposedBy"],
                        Name           = (string)dataTable.Rows[i]["Proposed By"],
                        District       = (string)dataTable.Rows[i]["District"]
                    };
                    intervention.Client = new Client
                    {
                        ClientId = (int)dataTable.Rows[i]["ClientId"],
                        Name     = (string)dataTable.Rows[i]["Client"]
                    };
                    intervention.Cost             = (decimal)dataTable.Rows[i]["Cost"];
                    intervention.DateToPerform    = (string)dataTable.Rows[i]["DateToPerform"];
                    intervention.InterventionType = new InterventionType
                    {
                        InterventionTypeId = (int)dataTable.Rows[i]["InterventionTypeId"],
                        Name = (string)dataTable.Rows[i]["Intervention Type"]
                    };
                    intervention.LabourHours         = (int)dataTable.Rows[i]["LabourHours"];
                    intervention.MostRecentVisitDate = (string)dataTable.Rows[i]["MostRecentVisitDate"];
                    intervention.Note  = (string)dataTable.Rows[i]["Note"];
                    intervention.State = state;
                    if (dataTable.Rows[i]["Life"] == DBNull.Value)
                    {
                        intervention.Life = -1;
                    }
                    else
                    {
                        intervention.Life = (double)dataTable.Rows[i]["Life"];
                    }
                    interventions.Add(intervention);
                }
            }

            return(interventions);
        }
Exemple #24
0
 //------------------------------------------------------
 public double CalculeTonCoutPuisqueTuNeCalculePasAPartirDesSourcesDeCout(bool bCoutReel)
 {
     if (bCoutReel)
     {
         if (FractionIntervention != null)
         {
             if (Duree != null)
             {
                 if (FractionIntervention.Intervention != null)
                 {
                     return(Duree.Value * FractionIntervention.Intervention.GetCoutHeureMainOeuvre());
                 }
             }
         }
         return(0);
     }
     else
     {
         if (Intervention != null)
         {
             if (Duree != null)
             {
                 return(Duree.Value * Intervention.GetCoutHeureMainOeuvre());
             }
             if (TypeOperation != null)
             {
                 return(TypeOperation.DureeStandardHeures * Intervention.GetCoutHeureMainOeuvre());
             }
         }
     }
     return(0);
 }
Exemple #25
0
        public async Task <IActionResult> Edit(int id, [Bind("InterventionID,PreInterventionScore,PostInterventionScore,Antecedence,Behaviours,Consequence,Treatment")] Intervention intervention)
        {
            if (id != intervention.InterventionID)
            {
                return(NotFound());
            }

            if (ModelState.IsValid)
            {
                try
                {
                    _context.Update(intervention);
                    await _context.SaveChangesAsync();
                }
                catch (DbUpdateConcurrencyException)
                {
                    if (!InterventionExists(intervention.InterventionID))
                    {
                        return(NotFound());
                    }
                    else
                    {
                        throw;
                    }
                }
                return(RedirectToAction(nameof(Index)));
            }
            return(View(intervention));
        }
Exemple #26
0
        private List <Intervention> accConvertToList(DataTable dataTable)
        {
            List <Intervention> interventions = new List <Intervention>();

            int rowsCount = dataTable.Rows.Count;

            if (rowsCount > 0)
            {
                for (int i = 0; i < rowsCount; i++)
                {
                    State        state        = (State)Enum.Parse(typeof(State), dataTable.Rows[i]["State"].ToString());
                    Intervention intervention = new Intervention();
                    intervention.District      = (string)dataTable.Rows[i]["InterventionDistrict"];
                    intervention.DateToPerform = (string)dataTable.Rows[i]["DateToPerform"];
                    intervention.ProposedBy    = new SiteEngineer
                    {
                        SiteEngineerId = (int)dataTable.Rows[i]["ProposedBy"],
                        Name           = (string)dataTable.Rows[i]["Name"],
                    };
                    intervention.LabourHours = (int)dataTable.Rows[i]["LabourHours"];
                    intervention.Cost        = (decimal)dataTable.Rows[i]["Cost"];
                    intervention.State       = state;
                    interventions.Add(intervention);
                }
            }

            return(interventions);
        }
        public static InterventionDTO MapToDto(this Intervention a)
        {
            // TODO Map missing fields

            return(new InterventionDTO
            {
                //AppropriateGradeLevels = a.AppropriateGradeLevels,
                //AppropriateSexes = a.AppropriateSexes,
                BeginDate = a.BeginDate,
                ClassType = a.ClassType,
                DeliveryMethodType = a.DeliveryMethodType,
                //Diagnoses = a.Diagnoses,
                //EducationContents = a.EducationContents,
                //EducationOrganizationReference = a.EducationOrganizationReference,
                EndDate = a.EndDate,
                Id = a.Id,
                IdentificationCode = a.IdentificationCode,
                //InterventionPrescriptions = a.InterventionPrescriptions,
                //LearningResourceMetadataURIs = a.LearningResourceMetadataURIs,
                //MeetingTimes = a.MeetingTimes,
                //PopulationServeds = a.PopulationServeds,
                //Staffs = a.Staffs,
                //Uris = a.Uris,
                _Etag = a._etag,
            });
        }
 public static InterventionModelv3 MapToInterventionModelv3(this Intervention a)
 {
     return(new InterventionModelv3
     {
         AppropriateGradeLevels = a.AppropriateGradeLevels?.Select(b => b.MapToGradeLevelDescriptorV3()),
         AppropriateSexes = a.AppropriateSexes?.Select(b => b.MapToSexDescriptorV3()),
         BeginDate = a.BeginDate.ToString("yyyy-MM-dd"),
         EndDate = a.EndDate?.ToString("yyyy-MM-dd"),
         DeliveryMethodDescriptor = a.DeliveryMethodType?.MapToDeliveryMethodDescriptorV3(),
         Diagnoses = a.Diagnoses?.Select(b => b.MapToDiagnosisDescriptorV3()),
         EducationContents = a.EducationContents?.Select(b => b.MapToEducationContentV3()),
         EducationOrganizationReference = a.EducationOrganizationReference?.MapToEducationOrganizationReferencev3(),
         Id = a.Id,
         InterventionClassDescriptor = a.ClassType?.MapToInterventionClassDescriptorTypeV3(),
         InterventionIdentificationCode = a.IdentificationCode,
         InterventionPrescriptions = a.InterventionPrescriptions?.Select(b => b.MapToInterventionPrescriptionv3()),
         LearningResourceMetadataURIs = a.LearningResourceMetadataURIs?.Select(b => b.MapToLearningResourceMetadataURIv3()),
         //MaxDosage = -1, // TODO Check
         //MinDosage = -1, // TODO Check
         MeetingTimes = a.MeetingTimes?.Select(b => b.MapToMeetingTimev3()),
         PopulationServeds = a.PopulationServeds?.Select(b => b.MapToPopulationServedDescriptorv3()),
         Staffs = a.Staffs?.Select(b => b.MapToStaffItemv3()),
         Uris = a.Uris?.Select(b => b.MapToUriv3()),
         _etag = a._etag,
     });
 }
Exemple #29
0
        /// <summary>
        /// Update the recent visit date of an intervention
        /// </summary>
        /// <param name="interventionId">The guid of an intervention</param>
        /// <param name="lastVisitDate">The date update to</param>
        /// <returns>True if success, false if fail</returns>
        public bool updateInterventionLastVisitDate(Guid interventionId, DateTime lastVisitDate)
        {
            Intervention intervention = getInterventionsById(interventionId);

            intervention.DateRecentVisit = lastVisitDate;
            return(Interventions.update(intervention));
        }
Exemple #30
0
        /// <summary>
        /// Update the approve by property of an intervention
        /// </summary>
        /// <param name="interventionId">The guid of an intervention </param>
        /// <param name="user">The user instance which updated the intervention</param>s
        /// <returns></returns>
        public bool updateIntervetionApprovedBy(Guid interventionId, User user)
        {
            Intervention intervention = getInterventionsById(interventionId);

            intervention.ApprovedBy = user.Id;
            return(Interventions.update(intervention));
        }
 public InterventionDetailWindow (Intervention intervention, Gtk.Window parent) : base(Gtk.WindowType.Toplevel)
 {
     this.Build ();
     this.Modal = true;
     this.TransientFor = parent;
     show.Intervention = intervention;
     show.IsEditable = false;
     show.HideActionButtons ();
 }
 public InterventionDetailWindow (Intervention intervention, EventHandler OnSave, Gtk.Window parent) : base(Gtk.WindowType.Toplevel)
 {
     this.Build ();
     this.Modal = true;
     this.OnSaved = OnSave;
     this.TransientFor = parent;
     show.Intervention = intervention;
     show.IsEditable = false;
 }
Exemple #33
0
    public Intervention AddIntervention()
    {
        Intervention item = new Intervention();
        item.id_intervention = GetFreeIdIntervention();
        interventions.Add(item);
        System.Comparison<Intervention> cmp = new System.Comparison<Intervention>(Intervention.CompareId);
        interventions.Sort(cmp);

        return item;
    }
 public InterventionDetailWindow (Case c, EventHandler OnSave, Gtk.Window parent) : base(Gtk.WindowType.Toplevel)
 {
     this.Build ();
     this.Modal = true;
     this.OnSaved = OnSave;
     this.TransientFor = parent;
     Intervention i = new Intervention ();
     i.Case = c;
     show.Intervention = i;
     show.IsEditable = true;
 }
Exemple #35
0
		///<summary>Converts a DataTable to a list of objects.</summary>
		public static List<Intervention> TableToList(DataTable table){
			List<Intervention> retVal=new List<Intervention>();
			Intervention intervention;
			for(int i=0;i<table.Rows.Count;i++) {
				intervention=new Intervention();
				intervention.InterventionNum= PIn.Long  (table.Rows[i]["InterventionNum"].ToString());
				intervention.PatNum         = PIn.Long  (table.Rows[i]["PatNum"].ToString());
				intervention.ProvNum        = PIn.Long  (table.Rows[i]["ProvNum"].ToString());
				intervention.CodeValue      = PIn.String(table.Rows[i]["CodeValue"].ToString());
				intervention.CodeSystem     = PIn.String(table.Rows[i]["CodeSystem"].ToString());
				intervention.Note           = PIn.String(table.Rows[i]["Note"].ToString());
				intervention.DateEntry      = PIn.Date  (table.Rows[i]["DateEntry"].ToString());
				intervention.CodeSet        = (OpenDentBusiness.InterventionCodeSet)PIn.Int(table.Rows[i]["CodeSet"].ToString());
				retVal.Add(intervention);
			}
			return retVal;
		}
Exemple #36
0
		///<summary>Inserts one Intervention into the database.  Returns the new priKey.</summary>
		public static long Insert(Intervention intervention){
			if(DataConnection.DBtype==DatabaseType.Oracle) {
				intervention.InterventionNum=DbHelper.GetNextOracleKey("intervention","InterventionNum");
				int loopcount=0;
				while(loopcount<100){
					try {
						return Insert(intervention,true);
					}
					catch(Oracle.DataAccess.Client.OracleException ex){
						if(ex.Number==1 && ex.Message.ToLower().Contains("unique constraint") && ex.Message.ToLower().Contains("violated")){
							intervention.InterventionNum++;
							loopcount++;
						}
						else{
							throw ex;
						}
					}
				}
				throw new ApplicationException("Insert failed.  Could not generate primary key.");
			}
			else {
				return Insert(intervention,false);
			}
		}
Exemple #37
0
		///<summary>Updates one Intervention in the database.</summary>
		public static void Update(Intervention intervention){
			string command="UPDATE intervention SET "
				+"PatNum         =  "+POut.Long  (intervention.PatNum)+", "
				+"ProvNum        =  "+POut.Long  (intervention.ProvNum)+", "
				+"CodeValue      = '"+POut.String(intervention.CodeValue)+"', "
				+"CodeSystem     = '"+POut.String(intervention.CodeSystem)+"', "
				+"Note           = '"+POut.String(intervention.Note)+"', "
				+"DateEntry      =  "+POut.Date  (intervention.DateEntry)+", "
				+"CodeSet        =  "+POut.Int   ((int)intervention.CodeSet)+" "
				+"WHERE InterventionNum = "+POut.Long(intervention.InterventionNum);
			Db.NonQ(command);
		}
Exemple #38
0
		///<summary>Updates one Intervention in the database.  Uses an old object to compare to, and only alters changed fields.  This prevents collisions and concurrency problems in heavily used tables.  Returns true if an update occurred.</summary>
		public static bool Update(Intervention intervention,Intervention oldIntervention){
			string command="";
			if(intervention.PatNum != oldIntervention.PatNum) {
				if(command!=""){ command+=",";}
				command+="PatNum = "+POut.Long(intervention.PatNum)+"";
			}
			if(intervention.ProvNum != oldIntervention.ProvNum) {
				if(command!=""){ command+=",";}
				command+="ProvNum = "+POut.Long(intervention.ProvNum)+"";
			}
			if(intervention.CodeValue != oldIntervention.CodeValue) {
				if(command!=""){ command+=",";}
				command+="CodeValue = '"+POut.String(intervention.CodeValue)+"'";
			}
			if(intervention.CodeSystem != oldIntervention.CodeSystem) {
				if(command!=""){ command+=",";}
				command+="CodeSystem = '"+POut.String(intervention.CodeSystem)+"'";
			}
			if(intervention.Note != oldIntervention.Note) {
				if(command!=""){ command+=",";}
				command+="Note = '"+POut.String(intervention.Note)+"'";
			}
			if(intervention.DateEntry != oldIntervention.DateEntry) {
				if(command!=""){ command+=",";}
				command+="DateEntry = "+POut.Date(intervention.DateEntry)+"";
			}
			if(intervention.CodeSet != oldIntervention.CodeSet) {
				if(command!=""){ command+=",";}
				command+="CodeSet = "+POut.Int   ((int)intervention.CodeSet)+"";
			}
			if(command==""){
				return false;
			}
			command="UPDATE intervention SET "+command
				+" WHERE InterventionNum = "+POut.Long(intervention.InterventionNum);
			Db.NonQ(command);
			return true;
		}
Exemple #39
0
		///<summary>Inserts one Intervention into the database.  Provides option to use the existing priKey.</summary>
		public static long Insert(Intervention intervention,bool useExistingPK){
			if(!useExistingPK && PrefC.RandomKeys) {
				intervention.InterventionNum=ReplicationServers.GetKey("intervention","InterventionNum");
			}
			string command="INSERT INTO intervention (";
			if(useExistingPK || PrefC.RandomKeys) {
				command+="InterventionNum,";
			}
			command+="PatNum,ProvNum,CodeValue,CodeSystem,Note,DateEntry,CodeSet) VALUES(";
			if(useExistingPK || PrefC.RandomKeys) {
				command+=POut.Long(intervention.InterventionNum)+",";
			}
			command+=
				     POut.Long  (intervention.PatNum)+","
				+    POut.Long  (intervention.ProvNum)+","
				+"'"+POut.String(intervention.CodeValue)+"',"
				+"'"+POut.String(intervention.CodeSystem)+"',"
				+"'"+POut.String(intervention.Note)+"',"
				+    POut.Date  (intervention.DateEntry)+","
				+    POut.Int   ((int)intervention.CodeSet)+")";
			if(useExistingPK || PrefC.RandomKeys) {
				Db.NonQ(command);
			}
			else {
				intervention.InterventionNum=Db.NonQ(command,true);
			}
			return intervention.InterventionNum;
		}
 void AddIntervention()
 {
     selectedIntervention = database.AddIntervention();
     Refocus();
 }
    void OnGUI()
    {
        if (database == null) database = (DialogDatabase)AssetDatabase.LoadAssetAtPath("Assets/Binaries/Databases/dialogDB.asset", typeof(DialogDatabase));
        if (database == null) return;
        if (database.questions == null) database.questions = new System.Collections.Generic.List<Question>();
        if (database.answers == null) database.answers = new System.Collections.Generic.List<Answer>();
        if (database.interventions == null) database.interventions = new System.Collections.Generic.List<Intervention>();

        EditorGUILayout.BeginHorizontal();

        EditorGUILayout.BeginVertical("Box", GUILayout.Width(256));
        scrollPos = EditorGUILayout.BeginScrollView(scrollPos);

        if (GUILayout.Button("Export to JSON"))
        {
            database.Export();
        }
        if (GUILayout.Button("Import from JSON"))
        {
            database.Import();
        }

        EditorGUILayout.LabelField("Interventions");
        GUI.SetNextControlName("Add");
        if (GUILayout.Button("Add New Intervention"))
        {
            AddIntervention();
        }

        for (int i = 0; i < database.interventions.Count; i++)
        {
            EditorGUILayout.BeginHorizontal();
            GUILayout.Space(10);
            Intervention item = database.interventions[i];
            string id_string = "ID " + item.id_intervention;
            if (item == selectedIntervention)
            {
                GUILayout.Label(id_string);
            }
            else
            {
                if (GUILayout.Button(id_string))
                {
                    selectedAnswer = null;
                    selectedQuestion = null;
                    selectedIntervention = item;
                    Refocus();
                }
            }

            if (GUILayout.Button("X", GUILayout.MaxWidth(24)))
            {
                selectedIntervention = null;
                database.interventions.Remove(item);
            }
            EditorGUILayout.EndHorizontal();
        }

        EditorGUILayout.LabelField("Questions");
        GUI.SetNextControlName("AddQ");
        if (GUILayout.Button("Add New Question"))
        {
            AddQuestion();
        }

        for (int i = 0; i < database.questions.Count; i++)
        {
            EditorGUILayout.BeginHorizontal();
            GUILayout.Space(10);
            Question item = database.questions[i];
            string id_string = "ID " + item.id_dialog;
            if (item == selectedQuestion)
            {
                GUILayout.Label(id_string);
            }
            else
            {
                if (GUILayout.Button(id_string))
                {
                    selectedIntervention = null;
                    selectedAnswer = null;
                    selectedQuestion = item;
                    Refocus();
                }
            }

            if (GUILayout.Button("X", GUILayout.MaxWidth(24)))
            {
                selectedQuestion = null;
                database.questions.Remove(item);
            }
            EditorGUILayout.EndHorizontal();
        }


        EditorGUILayout.LabelField("Answers");
        GUI.SetNextControlName("AddA");
        if (GUILayout.Button("Add New Answer"))
        {
            AddAnswer();
        }

        for (int i = 0; i < database.answers.Count; i++)
        {
            EditorGUILayout.BeginHorizontal();
            GUILayout.Space(10);
            Answer item = database.answers[i];
            string id_string = "ID " + item.id_dialog;
            if (item == selectedAnswer)
            {
                GUILayout.Label(id_string);
            }
            else
            {
                if (GUILayout.Button(id_string))
                {
                    selectedIntervention = null;
                    selectedAnswer = item;
                    selectedQuestion = null;
                    Refocus();
                }
            }

            if (GUILayout.Button("X", GUILayout.MaxWidth(24)))
            {
                selectedAnswer = null;
                database.answers.Remove(item);
            }
            EditorGUILayout.EndHorizontal();
        }

        GUILayout.FlexibleSpace();
        EditorGUILayout.EndScrollView();
        EditorGUILayout.EndVertical();
        scrollPos2 = EditorGUILayout.BeginScrollView(scrollPos2);
        EditorGUILayout.BeginVertical("Box");

        if (selectedIntervention != null)
        {
            EditorGUILayout.BeginHorizontal();
            EditorGUILayout.LabelField("Unique ID", GUILayout.Width(128));
            EditorGUILayout.LabelField(selectedIntervention.id_intervention.ToString(), GUILayout.Width(256));
            EditorGUILayout.EndHorizontal();
            EditorGUILayout.LabelField("Questions:");
            for (int q = 0; q < selectedIntervention.questions_ids.Count; q++)
            {
                EditorGUILayout.BeginHorizontal();
                EditorGUILayout.LabelField("ID " + selectedIntervention.questions_ids[q]);
                if (GUILayout.Button("X"))
                { selectedIntervention.questions_ids.RemoveAt(q); break; }
                EditorGUILayout.EndHorizontal();
            }
            EditorGUILayout.BeginHorizontal();
            tempInt = EditorGUILayout.IntField(tempInt);
            if (GUILayout.Button("Add Question ID")) {
                selectedIntervention.questions_ids.Add(tempInt);
            }
            EditorGUILayout.EndHorizontal();

            EditorGUILayout.LabelField("Answer Scores:");
            for (int s = 0; s < selectedIntervention.scores.Count; s++)
            {
                EditorGUILayout.BeginHorizontal();
                EditorGUILayout.LabelField("ID " + s);
                selectedIntervention.scores[s] = EditorGUILayout.IntField(selectedIntervention.scores[s]);
                EditorGUILayout.EndHorizontal();
            }
            
            if (GUI.changed) EditorUtility.SetDirty(database);
            GUILayout.FlexibleSpace();
        }
        else if (selectedQuestion != null)
        {
            EditorGUILayout.BeginHorizontal();
            EditorGUILayout.LabelField("Unique ID", GUILayout.Width(128));
            EditorGUILayout.LabelField(selectedQuestion.id_dialog.ToString(), GUILayout.Width(256));
            EditorGUILayout.EndHorizontal();
            EditorGUILayout.BeginHorizontal();
            EditorGUILayout.LabelField("Character ID", GUILayout.Width(128));
            selectedQuestion.id_character = (Dialog.CHARACTER) EditorGUILayout.EnumPopup(selectedQuestion.id_character);
            EditorGUILayout.EndHorizontal();
            EditorGUILayout.BeginHorizontal();
            EditorGUILayout.LabelField("Text", GUILayout.Width(128));
            selectedQuestion.text = EditorGUILayout.TextField(selectedQuestion.text);
            EditorGUILayout.EndHorizontal();
            
            if (GUI.changed) EditorUtility.SetDirty(database);
            GUILayout.FlexibleSpace();
        }
        else if (selectedAnswer != null)
        {
            EditorGUILayout.BeginHorizontal();
            EditorGUILayout.LabelField("Unique ID", GUILayout.Width(128));
            EditorGUILayout.LabelField(selectedAnswer.id_dialog.ToString(), GUILayout.Width(256));
            EditorGUILayout.EndHorizontal();
            EditorGUILayout.BeginHorizontal();
            EditorGUILayout.LabelField("Character ID", GUILayout.Width(128));
            selectedAnswer.id_character = (Dialog.CHARACTER)EditorGUILayout.EnumPopup(selectedAnswer.id_character);
            EditorGUILayout.EndHorizontal();
            EditorGUILayout.BeginHorizontal();
            EditorGUILayout.LabelField("Text", GUILayout.Width(128));
            selectedAnswer.text = EditorGUILayout.TextField(selectedAnswer.text);
            EditorGUILayout.EndHorizontal();
            EditorGUILayout.BeginHorizontal();
            EditorGUILayout.LabelField("Short Answer", GUILayout.Width(128));
            selectedAnswer.shortAnswer = EditorGUILayout.TextField(selectedAnswer.shortAnswer);
            EditorGUILayout.EndHorizontal();

            if (GUI.changed) EditorUtility.SetDirty(database);
            GUILayout.FlexibleSpace();
        }
        else 
        {
            EditorGUILayout.BeginHorizontal();
            EditorGUILayout.LabelField("Select an item");
            EditorGUILayout.EndHorizontal();

        }
        EditorGUILayout.EndVertical();
        EditorGUILayout.EndScrollView();


        EditorGUILayout.EndHorizontal();
    }
Exemple #42
0
 public static int CompareId(Intervention c1, Intervention c2)
 {
     return c1.id_intervention.CompareTo(c2.id_intervention);
 }