示例#1
0
    public static void DeleteExercise()
    {
        int IdExercicio = GlobalController.instance.exercise.idExercicio;

        List <PontosRotuloPaciente> allPrps = PontosRotuloPaciente.Read();


        foreach (var prp in allPrps)
        {
            if (prp.idExercicio == IdExercicio)
            {
                PontosRotuloPaciente.DeleteValue(prp.idRotuloPaciente);
            }
        }

        string pathEx = string.Format("{0}/Exercicios/{1}", Application.dataPath, GlobalController.instance.exercise.pontosExercicio);

        if (File.Exists(pathEx))
        {
            File.Delete(pathEx);
        }

        Exercicio.DeleteValue(IdExercicio);
        Flow.StaticExercisesToReview();
    }
    public static void DeleteMovement()
    {
        int IdMovimento = GlobalController.instance.movement.idMovimento;

        List <Exercicio> allExercises             = Exercicio.Read();
        List <PontosRotuloFisioterapeuta> allPrfs = PontosRotuloFisioterapeuta.Read();
        List <PontosRotuloPaciente>       allPrps = PontosRotuloPaciente.Read();
        List <MovimentoMusculo>           mm      = MovimentoMusculo.Read();

        foreach (var prf in allPrfs)
        {
            if (prf.idMovimento == IdMovimento)
            {
                PontosRotuloFisioterapeuta.DeleteValue(prf.idRotuloFisioterapeuta);
            }
        }


        foreach (var ex in allExercises)
        {
            if (ex.idMovimento == IdMovimento)
            {
                foreach (var prp in allPrps)
                {
                    if (prp.idExercicio == ex.idExercicio)
                    {
                        PontosRotuloPaciente.DeleteValue(prp.idRotuloPaciente);
                    }
                }
                string pathEx = string.Format("{0}/Exercicios/{1}", Application.dataPath, ex.pontosExercicio);
                if (File.Exists(pathEx))
                {
                    File.Delete(pathEx);
                }
                Exercicio.DeleteValue(ex.idExercicio);
            }
        }

        foreach (var m in mm)
        {
            if (m.idMovimento == IdMovimento)
            {
                MovimentoMusculo.DeleteValue(m.idMovimento, m.idMusculo);
            }
        }

        string pathMov = string.Format("{0}/Movimentos/{1}", Application.dataPath, GlobalController.instance.movement.pontosMovimento);

        if (File.Exists(pathMov))
        {
            File.Delete(pathMov);
        }

        Movimento.DeleteValue(IdMovimento);


        Flow.StaticMovements();
    }
    public static void DeletePatient()
    {
        int IdPaciente = GlobalController.instance.user.idPaciente;
        int IdPessoa   = GlobalController.instance.user.persona.idPessoa;

        string nomePessoa = (GlobalController.instance.user.persona.nomePessoa).Replace(' ', '_');
        string nomePasta  = string.Format("Assets/Exercicios/{1}-{2}", Application.dataPath, IdPessoa, nomePessoa);

        List <Sessao>               allSessions  = Sessao.Read();
        List <Exercicio>            allExercises = Exercicio.Read();
        List <PontosRotuloPaciente> allPrps      = PontosRotuloPaciente.Read();

        foreach (var exercise in allExercises)
        {
            if (exercise.idPaciente == IdPaciente)
            {
                foreach (var prp in allPrps)
                {
                    if (prp.idExercicio == exercise.idExercicio)
                    {
                        PontosRotuloPaciente.DeleteValue(prp.idRotuloPaciente);
                    }
                }

                Exercicio.DeleteValue(exercise.idExercicio);
            }
        }

        foreach (var session in allSessions)
        {
            if (session.idPaciente == IdPaciente)
            {
                Sessao.DeleteValue(session.idSessao);
            }
        }

        Paciente.DeleteValue(IdPaciente);
        Pessoa.DeleteValue(IdPessoa);
        if (Directory.Exists(nomePasta))
        {
            Directory.Delete(nomePasta, true);
        }

        Flow.StaticNewPatient();
    }
    public static void DeleteLabelPatient()
    {
        int IdPRP = GlobalController.instance.prp.idRotuloPaciente;

        PontosRotuloPaciente.DeleteValue(IdPRP);

        GameObject[] labels = GameObject.FindGameObjectsWithTag("labelpaciente");

        foreach (var l in labels)
        {
            var scripto = l.GetComponentInChildren <SetLabelPatient>();
            var idPrp   = scripto.Prp.idRotuloPaciente;

            if (idPrp == IdPRP)
            {
                Destroy(l.gameObject);
                PontosRotuloPaciente.DeleteValue(idPrp);
            }
        }
    }
        public static void TestPatientLabelPointsDeleteValue()
        {
            using (var conn = new SqliteConnection(GlobalController.path))
            {
                conn.Open();

                Pessoa.Insert("patient name1", "m", "1995-01-01", "6198732711", null);
                Pessoa.Insert("patient name2", "m", "1995-01-02", "6198732712", null);
                Pessoa.Insert("patient name3", "m", "1995-01-03", "6198732713", null);
                Pessoa.Insert("physio name1", "m", "1995-01-04", "6198732714", null);
                Pessoa.Insert("physio name2", "m", "1995-01-05", "6198732715", null);
                Pessoa.Insert("physio name3", "m", "1995-01-06", "6198732716", null);

                Fisioterapeuta.Insert(4, "abracadabra1", "demais1", null, null);
                Fisioterapeuta.Insert(5, "abracadabra2", "demais2", null, null);
                Fisioterapeuta.Insert(6, "abracadabra3", "demais3", null, null);

                Paciente.Insert(1, null);
                Paciente.Insert(2, null);
                Paciente.Insert(3, null);

                Movimento.Insert(1, "Movimento1", "Musculo Redondo Maior", null);
                Movimento.Insert(2, "Movimento2", "Musculo Redondo Maior", "Dificuldade nesse local");
                Movimento.Insert(3, "Movimento3", "Musculo Redondo Maior", "Dificuldade nesse local");

                Sessao.Insert(1, 1, "2018-03-01", null);
                Sessao.Insert(2, 2, "2018-03-02", "procedimento2");
                Sessao.Insert(3, 3, "2018-03-03", "procedimento3");

                Exercicio.Insert(1, 1, 1, "caminhopaciente1.ponto", null);
                Exercicio.Insert(1, 2, 1, "caminhopaciente2.ponto", "levantou mt coisa1");
                Exercicio.Insert(2, 1, 2, "caminhopaciente3.ponto", null);
                Exercicio.Insert(2, 2, 2, "caminhopaciente4.ponto", "levantou mt coisa2");
                Exercicio.Insert(3, 1, 3, "caminhopaciente5.ponto", null);
                Exercicio.Insert(3, 2, 3, "caminhopaciente6.ponto", "levantou mt coisa3");

                PontosRotuloPaciente.Insert(1, "Aperfeicoando1", 05.00f, 06.00f);
                PontosRotuloPaciente.Insert(2, "Aperfeicoando2", 06.00f, 07.00f);
                PontosRotuloPaciente.Insert(3, "Aperfeicoando3", 07.00f, 08.00f);

                var check = "SELECT EXISTS(SELECT 1 FROM 'PONTOSROTULOPACIENTE' WHERE \"idRotuloPaciente\" = \"1\" LIMIT 1)";

                var result = 0;
                using (var cmd = new SqliteCommand(check, conn))
                {
                    using (IDataReader reader = cmd.ExecuteReader())
                    {
                        try
                        {
                            while (reader.Read())
                            {
                                if (!reader.IsDBNull(0))
                                {
                                    result = reader.GetInt32(0);
                                }
                            }
                        }
                        finally
                        {
                            reader.Dispose();
                            reader.Close();
                        }
                    }
                    cmd.Dispose();
                }

                Assert.AreEqual(result, 1);
                PontosRotuloPaciente.DeleteValue(1);

                result = 0;
                using (var cmd = new SqliteCommand(check, conn))
                {
                    using (IDataReader reader = cmd.ExecuteReader())
                    {
                        try
                        {
                            while (reader.Read())
                            {
                                if (!reader.IsDBNull(0))
                                {
                                    result = reader.GetInt32(0);
                                }
                            }
                        }
                        finally
                        {
                            reader.Dispose();
                            reader.Close();
                        }
                    }
                    cmd.Dispose();
                }

                Assert.AreEqual(result, 0);

                conn.Dispose();
                conn.Close();
            }
            return;
        }