module CLostProblems
	use SimulationVariables
	implicit none    
	public 
    contains
    subroutine LostProblemsToJson(parent)

        type(json_value),pointer :: parent
        type(json_core) :: json
        type(json_value),pointer :: p

        ! 1. create new node
        call json%create_object(p,'Configuration')
        
        ! 2. add member of data type to new node
        call ProblemToJson(p,"LostCirculation",data%problems%LostProblems%LostCirculation)
        call json%add(p,"FlowRate",data%problems%LostProblems%FlowRate)

        ! 3. add new node to parent
        call json%add(parent,p)
    end subroutine

    subroutine ProcessLostProblemsDueTime(time)
        implicit none
        integer :: time
        if(data%problems%LostProblems%LostCirculation%ProblemType == Time_ProblemType) call ProcessDueTime(data%problems%LostProblems%LostCirculation, ChangeLostCirculation, time)
    end subroutine
    
    subroutine ProcessLostProblemsDuePumpStrokes(strokes)
        implicit none
        integer :: strokes
        
        if(data%problems%LostProblems%LostCirculation%ProblemType == PumpStrokes_ProblemType) call ProcessDuePumpStrokes(data%problems%LostProblems%LostCirculation, ChangeLostCirculation, strokes)
        
    end subroutine
    
    subroutine ProcessLostProblemsDueVolumePumped(volume)
        implicit none
        real(8) :: volume
        
        if(data%problems%LostProblems%LostCirculation%ProblemType == VolumePumped_ProblemType) call ProcessDueVolumePumped(data%problems%LostProblems%LostCirculation, ChangeLostCirculation, volume)
        
    end subroutine
    
    subroutine ProcessLostProblemsDueDistanceDrilled(distance)
        implicit none
        real(8) :: distance
        
        if(data%problems%LostProblems%LostCirculation%ProblemType == DistanceDrilled_ProblemType) call ProcessDueDistanceDrilled(data%problems%LostProblems%LostCirculation, ChangeLostCirculation, distance)
        
    end subroutine
    
    
    
    
    subroutine ChangeLostCirculation(status)
        implicit none
        integer, intent (in) :: status
        ! if(associated(LostCirculationPtr)) call LostCirculationPtr(status)
        !if(status == Clear_StatusType) print*,'On_LostCirculation_Clear'
        !if(status == Executed_StatusType) print*,'On_LostCirculation_Execute'
    endsubroutine
        
    
end module CLostProblems