Scientists have developed a probe that for the first time goes inside the lung to find bacterial infections.
Currently, this is done by sending samples to a laboratory and waiting several days for the results.
The new approach was inspired by the 1960s film Fantastic Voyage, in which a submarine shrinks to microscopic size to enter a human body. It is even called Proteus after that sci-fi sub.
The project has been unveiled at a US science meeting in Texas.
In the film, the team enters the body of an important scientist to save him from a blood clot in his brain.
Drawing on this theme, a group of doctors and scientists from Edinburgh, Bath and Heriot-Watt Universities in the UK developed a system for sending a probe inside a patient's lung.
I watched the procedure. I could see the probe journeying through the tiny airways from its on board camera until it came across bacteria.
The inside of the patient's lung had been sprayed earlier with a chemical that makes the bacteria visible when light from the probe is shone on them.
The Proteus probe enables doctors to see infection inside the human body for the very first time, according to Prof Kevin Dhaliwal of Edinburgh University, who leads the project.
"The real advantage is that we are actually imaging and detecting where the disease is in the patient's lungs and we are giving a diagnosis and a decision-making power within minutes or seconds. That's a big difference."
Currently, samples need to be taken from patients and analysed in labs. The process can take days and can often give unreliable results.
The team is using its technology to test if critically ill people are developing pneumonia.
Patients in intensive care are given broad-spectrum antibiotics just in case they have the infection. But there is a huge downside. Complications can develop as the antibiotics interact with the patient's other medication and clinical studies indicate that as a result tens of thousands of people worldwide die.
The use of antibiotics in this way also increases the risk of antibiotic-resistant strains emerging. The Proteus system can identify the precise strain of the bacteria and therefore enable doctors to prescribe the appropriate antibiotic, according to Dr Anya Bruce, who is a project manager for the Proteus initiative.
"There is a huge over-use of antibiotics," she told BBC News. "Clinicians do not have the answers at their fingertips when administering broad-spectrum antibiotics but this technology could give them the information about what they are trying to treat."
In principle, the technique could be used to detect many other conditions inside the body, such as fungi and cancer, according to Prof Dhaliwal.
"Our team is making rapid progress in bringing together many technologies to help us develop entirely new approaches to diagnose and treat disease at the bedside."
Prof Dhaliwal is collaborating with Prof Gerard Cote at Texas A&M University in College Station to use the same technique to develop cheap, portable tests for a range of diseases, including diabetes and coronary heart disease.
Prof Cote has also developed a system to detect malaria by shining light on a blood sample. Aid workers in the field can see straight away if a patient is infected and provide appropriate medication.
Currently, this can only be done by sending blood samples to a large hospital where each one has to be checked by eye under a microscope. Each sample can take several hours to analyse.
Prof Cote aims to have his system incorporated into a tablet device or smartphone so that immediate diagnoses can be made in poor and remote areas.
"The main global need is to diagnose malaria in the field. And it will have a huge impact, particularly for infants and the elderly who are dying at a tremendous rate in these underserved areas of the world," Prof Cote said.
Details of the new system were given at the annual meeting of the American Association for the Advancement of Science in Austin, Texas.
Prof Philip Nelson, chief executive of the UK Engineering and Physical Sciences Research Council (EPSRC), which funded the research, commented: "This new technology developed by the Proteus team is a clear example of how scientists, engineers and medics can collaborate internationally to produce life-saving techniques for diagnosis and treatment."
Proteus has also received funding from the Medical Research Council, the Wellcome Trust, and CARB-X, the world's largest public-private partnership devoted to antibacterial early development research.