John Calvin said it beautifully, “There is no time in which God does not invite us to Himself," which is the main sentiment in James 5:13-14
James 5:13-14 Is anyone among you suffering? Let him pray. Is anyone cheerful? Let him sing praise. Is anyone among you sick? Let him call for the elders of the church, and let them pray over him, anointing him with oil in the name of the Lord.
Very simply, there are three occasions that should prompt prayer:
1. If you are suffering
2. If you are cheerful
3. If you are sick
These three occasions make up our common experience as human beings. So, in other words- pray at all times! We go through times of suffering or general hardship, times of cheerfulness, and times of sickness. No matter where you find yourself, God invites you to Himself through prayer. Jesus encourages prayer at all times (Luke 18:1) and Paul says to do so without ceasing (1 Thes. 5:17). Paul most closely mirrors the thoughts of James when he writes:
Ephesians 6:18 praying at all times in the Spirit, with all prayer and supplication. To that end keep alert with all perseverance, making supplication for all the saints...
James, like Paul, doesn't only encourage private prayer, it is to be a community event also. Yes we are called to pray privately, just as Jesus did from time to time, but we are also to enlist others in prayer for us and for God's glory.
James says to pray when we are suffering, which is reference to hardship and trials we undergo. If you find yourself in such a hardship, bring it to God in prayer. Have others pray for you also. James says to "praise" when you are cheerful. Praising God is a prayer acknowledging the greatness and goodness of God, among other attributes. Such times of cheerfulness are usually in relationship to a time of peace and clear blessing from God. We can tend to forget praise in such seasons. Praising God during times of cheer isn't just for you, it's so others who may be in times of suffering can witness the blessings of God upon you and rejoice with you in the midst of their trial. Finally, when we are sick, and most likely seriously sick, we should call for the elders to come and pray and anoint us with oil for healing. Obviously it is not always God's will to heal us of our sickness (see Paul and Timothy), further, no one will escape final sickness, however bodily frailty and God's healing (immediate or gradual) is a constant reminder of our need to depend on God, to seek His strength, and to pray.
So James bids us to pray every circumstances which serves as an acknowledgement of the sufficiency of God in our lives.