' Copyright (C) 2025  P4pillon.org
'
' This program is free software: you can redistribute it and/or modify
' it under the terms of the GNU Affero General Public License as
' published by the Free Software Foundation, either version 3 of the
' License, or (at your option) any later version.
'
' This program is distributed in the hope that it will be useful,
' but WITHOUT ANY WARRANTY; without even the implied warranty of
' MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
' GNU Affero General Public License for more details.
'
' You should have received a copy of the GNU Affero General Public License
' along with this program.  If not, see <https://www.gnu.org/licenses/>.
Imports System.IO

Public Class jeux_d_essai_CAS_STANDARD
#Region "Cas Standard"


    Private Sub CAS_STANDARD_LinkLabel_LinkClicked(sender As Object, e As LinkLabelLinkClickedEventArgs) Handles CAS_STANDARD_LinkLabel.LinkClicked
        Dim file As String
        OpenFileDialog1.InitialDirectory = Application.StartupPath + "\technique\jeux d'essai"
        If OpenFileDialog1.ShowDialog() = Windows.Forms.DialogResult.Cancel Then
            Exit Sub
        End If
        file = OpenFileDialog1.FileName

        'Dim sr As New StreamReader(Application.StartupPath + "\technique\jeux d'essai\III.03 - CAS STANDARD.txt")
        Dim sr As New StreamReader(file)
        Dim série, Test, CV, Bénéficiaire, line, CVphysique As String 'InfosParticulières
        CVphysique = "xxxx"
        InfosParticulières_Label1.Text = "   "
        Dim Prestations(10) As String
        line = sr.ReadLine
        série = Mid(line, 1, InStr(line, " ") - 1)
        série_Label1.Text = série
        line = sr.ReadLine '1 50 0102 ALAIN 0 0101 03/05/2011 Cas standard 1
        While Not line Is Nothing
            COMPTOIR_MAIN.Visible = True
            Test = Mid(line, 1, InStr(line, " ") - 1)
            Test_Label1.Text = Test
            line = Mid(line, InStr(line, " ") + 1) '50 0102 ALAIN 0 0101 03/05/2011 Cas standard 1
            line = Mid(line, InStr(line, " ") + 1) '0102 ALAIN 0 0101 03/05/2011 Cas standard 1
            CV = Mid(line, 1, InStr(line, " ") - 1)
            CV_Label1.Text = CV
            line = Mid(line, InStr(line, " ") + 1) 'ALAIN 0 0101 03/05/2011 Cas standard 1
            Bénéficiaire = Mid(line, 1, InStr(line, " ") - 1)
            Bénéficiaire_Label1.Text = Bénéficiaire
            If InStr(line, "Soins en rapport avec ALD") <> 0 Then
                InfosParticulières_Label1.Text = "ALD"
            Else
                line = sr.ReadLine
                If InStr(line, "Soins en rapport avec ALD") = 1 Then
                    InfosParticulières_Label1.Text = "ALD"
                ElseIf InStr(line, "Soins li") = 1 And InStr(line, "AVP du") <> 0 Then
                    InfosParticulières_Label1.Text = "AVP"
                Else
                    InfosParticulières_Label1.Text = "   "
                End If
            End If
            Application.DoEvents()
            ReDim Prestations(10)
            While line <> "03/05/2011"
                line = sr.ReadLine
            End While
            While line = "03/05/2011"
                line = sr.ReadLine
            End While
            Dim num_prestation As Integer = 0
            While InStr(line, "%") = 0
                Prestations(num_prestation) = Mid(line, 1, InStr(line, " ") - 1)
                num_prestation = num_prestation + 1
                line = sr.ReadLine
            End While
            While InStr(line, "FSE en TP AMO") = 0 And InStr(line, "CAS NON PASSANT") = 0
                line = sr.ReadLine
            End While

            If InStr(line, "FSE en TP AMO") = 1 Then
                '------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
                'CV
                Jeux_d_essai2.SetCle(Config.SesamIni, "TESTSSV", "NomFichierVitale1", CV + ".IN")

                Dim lineCV, carte_phys, carte_virt As String
                Using srCV As New StreamReader("C:\ProgramData\santesocial\fsv\1.40.9\adm\Phys-Virt.txt")
                    lineCV = srCV.ReadLine

                    Do
                        carte_phys = Mid(lineCV, 1, InStr(lineCV, ";") - 1)
                        lineCV = Mid(lineCV, InStr(lineCV, ";") + 1)
                        carte_virt = Mid(lineCV, 1, InStr(lineCV, ";") - 1)
                        If carte_virt = CV Then
                            If CVphysique <> carte_phys Then
                                CVphysique = carte_phys
                                CVphysique_Label1.Text = carte_phys
                                Beep()
                                MyMsg_Box.Presentation("Officine", "carte physique: " + carte_phys, False, "", False, "", True, "OK")
                                MyMsg_Box.ShowDialog()
                            End If
                        End If
                        lineCV = srCV.ReadLine
                    Loop Until lineCV Is Nothing Or lineCV = ""
                End Using

                COMPTOIR_MAIN.LECTURE_VITALE.PerformClick()

                '------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
                'PRESCRIPTEUR
                If série_Label1.Text = "III.03.04_01" And Test_Label1.Text = "5" Then
                    COMPTOIR_MAIN.PrescripteurMyCombobox.Text = "SNCF"
                Else
                    COMPTOIR_MAIN.PrescripteurMyCombobox.Text = "pr"
                End If
                COMPTOIR_MAIN.recherche_prescripteur()
                '------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
                'LIGNES
                For r = 0 To 10
                    If Prestations(r) <> "" Then
                        COMPTOIR_MAIN.Vente.Rows.Add()
                    End If
                Next
                For r = 0 To 10
                    If Prestations(r) <> "" Then
                        COMPTOIR_MAIN.Vente.CurrentCell = COMPTOIR_MAIN.Vente.Item(COMPTOIR_MAIN.Vente_produits.Index, r)
                        Select Case Prestations(r)
                            Case "PH1"
                                COMPTOIR_MAIN.Vente.Item(COMPTOIR_MAIN.Vente_produits.Index, r).Value = "3614369"
                            Case "PH7"
                                COMPTOIR_MAIN.Vente.Item(COMPTOIR_MAIN.Vente_produits.Index, r).Value = "3261020"
                            Case "PH4"
                                COMPTOIR_MAIN.Vente.Item(COMPTOIR_MAIN.Vente_produits.Index, r).Value = "3302210"
                            Case "PH2"
                                COMPTOIR_MAIN.Vente.Item(COMPTOIR_MAIN.Vente_produits.Index, r).Value = "3284618"
                            Case "PHN"
                                COMPTOIR_MAIN.Vente.Item(COMPTOIR_MAIN.Vente_produits.Index, r).Value = "3575327"
                            Case "AAR"
                                COMPTOIR_MAIN.Vente.Item(COMPTOIR_MAIN.Vente_produits.Index, r).Value = "1136581"
                            Case "AAD"
                                COMPTOIR_MAIN.Vente.Item(COMPTOIR_MAIN.Vente_produits.Index, r).Value = "1202473"
                            Case "POC"
                                COMPTOIR_MAIN.Vente.Item(COMPTOIR_MAIN.Vente_produits.Index, r).Value = "2540338"
                            Case "MAC"
                                COMPTOIR_MAIN.Vente.Item(COMPTOIR_MAIN.Vente_produits.Index, r).Value = "1387426"
                            Case "PA"
                                COMPTOIR_MAIN.Vente.Item(COMPTOIR_MAIN.Vente_produits.Index, r).Value = "Genouillère"
                            Case "PAN"
                                COMPTOIR_MAIN.Vente.Item(COMPTOIR_MAIN.Vente_produits.Index, r).Value = "1378462"
                            Case "CPH"
                                COMPTOIR_MAIN.Vente.Item(COMPTOIR_MAIN.Vente_produits.Index, r).Value = "COPIE ORDONNANCE 0.23"
                            Case "UPH"
                                COMPTOIR_MAIN.Vente.Item(COMPTOIR_MAIN.Vente_produits.Index, r).Value = "urgence test cas standard"
                            Case "B"
                                COMPTOIR_MAIN.Vente.Item(COMPTOIR_MAIN.Vente_produits.Index, r).Value = "Analyse d’urine"
                            Case "PMH"
                                COMPTOIR_MAIN.Vente.Item(COMPTOIR_MAIN.Vente_produits.Index, r).Value = "Test cas standards PMH"
                            Case "PM4"
                                COMPTOIR_MAIN.Vente.Item(COMPTOIR_MAIN.Vente_produits.Index, r).Value = "Test cas standards PM4"
                            Case "PM2"
                                COMPTOIR_MAIN.Vente.Item(COMPTOIR_MAIN.Vente_produits.Index, r).Value = "Test cas standards PM2"
                        End Select

                        COMPTOIR_MAIN.Vente.CurrentCell = COMPTOIR_MAIN.Vente.Item(COMPTOIR_MAIN.VenteQuantité.Index, r)

                        If Prestations(r) = "B" Then
                            COMPTOIR_MAIN.Vente.Item(COMPTOIR_MAIN.VenteQuantité.Index, r).Value = "10"
                        Else
                            COMPTOIR_MAIN.Vente.Item(COMPTOIR_MAIN.VenteQuantité.Index, r).Value = "1"
                        End If

                        COMPTOIR_MAIN.Vente.CurrentCell = COMPTOIR_MAIN.Vente.Item(COMPTOIR_MAIN.VentePrix.Index, r)
                        COMPTOIR_MAIN.Vente.CurrentCell = COMPTOIR_MAIN.Vente.Item(COMPTOIR_MAIN.VentePrix.Index + 1, r)


                    End If
                Next
                If InfosParticulières_Label1.Text = "ALD" Then
                    For r = 0 To COMPTOIR_MAIN.Vente.RowCount - 2
                        COMPTOIR_MAIN.Vente.Item(COMPTOIR_MAIN.VenteType.Index, r).Value = "ALD"
                    Next
                End If
                COMPTOIR_MAIN.CheckBox_Facturation_AMC.Checked = False
                COMPTOIR_MAIN.Button_Facturation_Click(Nothing, Nothing)

                CurrentBenéficiaire.clear()
                COMPTOIR_MAIN.ResetForm()

                COMPTOIR_MAIN.Close()

            End If
                line = sr.ReadLine
        End While




        sr.Close()

    End Sub

#End Region
End Class