Inspiration
Meet Nasreen, a 31 year old woman who lives in Lahore and has five children. Nasreen’s youngest daughter has fallen from the stairs and needs a CT scan. Nasreen tries to go to a nearby hospital suggested by a friend, but is turned away because it does not have the facilities she requires. Nasreen has no one else to turn to for advice and it takes her going back and forth between seven hospitals before she can get a CT scan for her daughter. Even then, she has to pay Rs. 6000 for the scan, not realizing that a public hospital nearby could have done it for free. Nasreen is not alone: this is a problem that is faced by millions of Pakistanis.
Due to a lack of centralized platform that contains publicly available data about hospitals, Pakistanis primarily rely on word-of-mouth to find the right hospital to go to, or may avoid seeking healthcare entirely. This compounds the stress and adds to the confusion that patients experience, as well as delay timely healthcare delivery. This problem is experienced particularly by those with limited access to the internet, especially low to middle income families, but can be felt by individuals across Pakistan. It is most acute during medical emergencies, where diagnostic delays can directly affect survival; however, patients experience this routinely when seeking healthcare. Existing public healthcare platforms are built primarily for internal administration or strictly medical related purposes; most patient-facing platforms focus on specialist books (such as Marham or Oladoc), not on hospital level facilities and with little to no focus on disclosing hospital quality or any comparison based tool.
What it does
This project aims to solve this problem by leveraging artificial intelligence to achieve four primary goals to deliver reliable information about 45 hospitals in Lahore, as a small proof of concept project to show the benefits of a patient-facing centralized healthcare platform.
Firstly, my project analyzes the negative Google Reviews (1-3 stars) online of each hospital, and groups them into themes of complaints using BERTopic AI. There are approximately 4000 after processing. I also display department specific feedback, such as complaints about the Gynecology department, for example. This allows users to quickly see what previous patients with negative experiences have to say about the hospital. Since at times Google Reviews can be biased, I also display a representative review from each theme to allow the user viewing it to come to their own conclusions about the hospital.
Secondly, my project provides users with information on each hospital. I synthesize multiple sources of data to create the app, including public databases and official hospital websites. Where information was not publicly available, I called the hospital's front desk to confirm details. This previously scattered data is hence hosted on one centralized platform, allowing for ease of access to hospital data.
Thirdly, users can use this data to compare up to three hospitals to one another using the website. The website calculates average benchmarks for the % of themes and negative reviews across the city, and displays an evaluation of whether each hospital is above, below or at average. This helps users make more informed decisions when choosing between hospitals.
Fourth, a helpful AI chatbot on the page can summarize the information present to users who feel overwhelmed by the statistics or just need help in making a decision, thereby making information access easier. The bot can respond in both Urdu and English for accessibility on the compare page and the hospital informaton pages.
Finally, users can see the hospitals closest to them in a specific range, allowing for ease of usage. This data is calculated using roads and traffic time, making the suggested time highly accurate. The website can also filter hospitals by the facilities, price range, positive review percentages, and whether it offers subsidized healthcare.
In summary, my project does the following:
- Analyze negative reviews and present major areas of negative complaint at each hospital
- Provide reliable data about each hospital, such as the beds and price
- Allow users to compare hospitals based on their statistics
- Let users see the hospitals closest to them in a specific range and based on specific features
- Help understand information through a small chatbot
How we built it
This website was built using Python and HTML. To conduct my analysis of negative reviews of each hospital, we leveraged Google Review data across 45 hospitals in Lahore. This number was chosen as it was the total general hospitals in the city with over a hundred reviews, to make for a solid analysis. I created a dataset of these reviews, filtered them by the number of stars and processed the dataset to get rid of spam and overly short reviews. I then used BERTopic to group each of the reviews into themes. I was left with a large number of themes, which were then grouped into larger, meta-themes. For example, categories with keywords such as bugs-cockroaches-bed and cleanliness-gloves-hygiene were grouped into the "Environment" category. I used BERTopic to also get two representative reviews from each theme, as mentioned above, to ensure that the user could read exactly what people were saying about each hospital.
The BERTopic pipeline I used for this project was very specialized for the data I was using and took a long time to get right. To measure the best pipeline, I calculated both Topic Coherence and Diversity of the topics created using Python. I used paraphrase-multilingual-mpnet-base-v2 for my embedding model, since I was dealing with multilingual data. I clustered these embeddings using HDBSCAN, setting the minimum cluster size to 10 documents, to allow for more granular topics. I filtered out various stop words to ensure I would not get nonsense topics (see more below in the Challenges section), and set the ngram_range to collect both unigrams (single words) and bigrams (phrases of 2 words). The keywords that were designed to represent each topic were found using KeyBERTInspired, which selects keywords whose embeddings closely match the overall topic vector, and Maximal Marginal Relevance (MMR), which also adds diversity into the words so that the topics don't contain redundant synonyms. This was all to make sure that the topics titles would be able to better encapsulate what each topic contained. I also used reduce_outliers() to ensure that the reviews which were left uncategorized would be kept in a category that they shared the most in common with.
To collect statistics about each hospital, I tried to find every publicly available, reliable source of data that I could. I began with government databases or websites that outlined which hospitals were government-affiliated or were teaching hospitals. Public hospitals usually had data on them collected by the Punjab Healthcare Commission or other regulatory bodies, so I did a lot of research to find as many sources of data on the number of beds and other facilities. Private hospitals, on the other hand, rarely collected this data in any sort of centralized way, so I went to their official websites online or called their front desks for any data I needed. Data on prices was taken from Marham, which lists the prices of different consultants. I used these prices to make a range the user might expect to spend, based on the price of the lowest and most expensive consultant. Furthermore, I used data from the Punjab Healthcare Commission on each hospital's compliance with MSDS standards and which services at each hospital were Sehat Sahulat Card Empaneled (The SSC is a subsidized healthcare program). All of the data I collected and synthesized was stored and managed on a spreadsheet on SQLite.
The comparison feature was made after I used Flask to create the website itself. Once the database had been imported into the project, I used it to calculate the average negative review ratio and percentage of each negative theme for the city; I would then compare each hospital to the city-wide averages, using simple JavaScript to display the color in red, yellow or green depending on its performance and making it easy for users to interpret the results. I created a table where users could pick up to 3 hospitals from the central map, and compare the statistics and the services offered at each side-by-side.
The AI chatbot feature was built with Gemini 3.5 Flash. When the user asks the question, the frontend sends the user's message, recent chat history and IDs of the hospital(s) they are currently viewing. The server uses a function to query the SQL database and fetch the raw data for those hospital(s). Then, I build a prompt to help the AI answer the user's questions. It combines the raw data with behavioral rules; for example, the AI must match the user's language (English, Urdu, or Roman Urdu), avoid giving medical advice and summarize raw data rather than dumping exact statistics. If multiple hospitals are selected, it prompts the AI to act as a comparison engine and highlight trade-offs. Once Gemini generates a response based only on the instructions, the code extracts the reply and sends it back to the frontend.
Finally, in order to implement the main page, where the hospitals are organized by distance, I used the GoogleMapsAPI. I allocated a search radius that the user could input manually; the API would calculate the distance using road lengths and organize each result in order of closeness by time, leveraging live traffic data. Although this feature is already present in Google Maps, I thought it was useful to incorporate into the website just to ensure ease of use and so that the user could keep distance in mind when choosing a hospital to go to. I also categorized the ease of access of each hospital by color; so hospitals beyond ~15 minutes were red, ~10 minutes were yellow and within ~5 minutes were green. For the filtering feature, the server sends the hospital data to the frontend as a complete list. When the user adjusts the sliders or checkboxes, a function sifts through the data to filter the hospitals that do not meet the specifications using simple JavaScript.
Challenges we ran into
I ran into a variety of challenges when making this project. Firstly, I didn't plan to use BERTopic for topic modeling. Initially, I tried three models, BERT, LDA and NMF. I tried experimenting with various different pipelines for these models but the topics that were being created were not very satisfactory (as an example, many of the topics were simply nonsensical, such as: ['dr', 'rude', 'mother', 'experience', 'surgery', 'child', 'khan', 'did', 'father', 'asked']) and I decided to go with BERTopic.
When creating the BERTopic pipeline, I found that my data had a lot of words in Urdu (both written in Roman Urdu and Nastaliq Script). I tried a lot to fix this, including using various translation tools on the data, but here I ran into another problem. To translate Urdu, I would first have to detect reviews with it. This is fairly easy to do with Nastaliq Urdu since it is written in another script and I could simply filter for reviews containing characters in a certain Unicode range. However, with Roman Urdu this becomes difficult as there is no agreed upon spelling and it is written in English. In fact, the alternative spellings of many Roman Urdu words such as "me" ("mein") can be read as English words. So, translation was an imperfect solution for Roman Urdu.
I was bit confused as to what to do, and eventually decided to use a multilingual model for the embeddings. This improved the quality of the topics marginally, but there were still a lot of nonsense words within the topics. I think this is for two reasons: firstly, Urdu is an under-resourced language in general and it makes sense that models would struggle with it due to a lack of data; secondly, as mentioned above, Roman Urdu specifically does not have a standardized spelling, so the same word can be spelling in different ways ("ap" or "aap"). Some topics also contained a lot of non-useful words, such as hospital-hospitals-patients`, and a lot of reviews got sorted into this blanket category. To solve both of these problems, I implemented a harsh stop word list manually with common Roman Urdu words (including alternative spellings) and vague words such as "good" or "patient". I also used a harsh cleaning technique by removing anything that wasn't an adjective, verb or noun from the reviews. This greatly improved the quality of the topics created.
Another issue I faced was during the data collection for the information on hospitals. I had not realized that a lot of data required digging through multiple different sources for what I needed. For private hospitals, there were little to no databases that I could consult, and hence the collection was done manually by hospital. Many times, as mentioned above, I was unable to find the information I needed, especially if the hospital didn't have a website. In that case, I would call their front desk and confirm what I needed - for example, one hospital had been listed as being empaneled with the Sehat Sahulat Card for dialysis treatment, but I knew from talking to a friend that it might not have been. The hospital had no website and it was difficult to find any digital presence of it online, and hence I tracked down their number and asked their front desk directly - it turned out they were not empaneled with the SSC anymore at all. A lot of the times, I found the data I needed in more unlikely sources. For example, a hospital's website would say that they had a certain number of beds, but the number of beds listed for a COVID-19 pandemic directory would suggest that they had a larger number. Hence, collecting the data itself was an arduous process that took a lot of double-checking and going back and forth between the most up to date sources.
Finally, a small issue I faced was present in the maps feature on my website. When the user would move the search radius bar, some hospitals would remain being listed despite being visually outside of the marked area. I went back to my code and found that when calculating the distance from the hospital, I was using the Haversine Formula instead of using Google's road distances, which were more accurate. I also faced a bit of difficulty with the prompting of the chatbot, and deciding the exact prompt to use took a lot of trial and error.
Accomplishments that we're proud of
I am really proud of this project and the work that I was able to accomplish. Firstly, Hospital Nama was created to address a problem that has no solution in Pakistan so far; a lack of centralized, patient-facing platform that could provide users with reliable information about hospitals. My project, although not perfect, is intended as a pilot example of something that could address the issue. The idea to use BERTopic to analyze Google Reviews was something I had not seen before in any project, and I was proud of having been able to collect the reviews and conduct successful topic modeling on it.
I was also quite proud of the work I did in collecting the data. It was quite a difficult task given that for many of the hospitals, I would have to search for each column of the dataset manually. As I mentioned earlier, suddenly stumbling upon a database which had the data I needed was a very gratifying task, and I am very happy to have, everything else aside, managed to create at least a centralized, and more importantly, public source of information on a few hospitals in Lahore. I think it could be of great use to other people who would like to carry out a similar project on a larger scale.
What we learned
I learnt a lot about NLP and programming in general using the project. Learning about how BERTopic worked and the multiple different ways the pipeline can be customized for my dataset was informative, and revealed the issues with working in under-resourced languages such as Urdu of which I was not aware of previously. Furthermore, learning about how to create a database using SQL, as well as how to collect data using primarily online sources that are difficult to find was a great experience; in the future, I think the work I did particularly on the data collection and processing will be very useful.
Another thing I've learnt is fullstack development project. Although I have worked with JavaScript/Python and HTML before, I have never integrated an SQL database within a project before. Navigating the experience of buying a domain, setting up Render, Cloudflare and Google Sites for my website was entirely new to me, and incredibly informative as someone who had previously focused on just the front or back-end of projects, never in tandem. Coding, deploying and managing a website was a new experience and I think it will be quite useful to me in my future projects to understanding fullstack development as a whole.
What's next for Hospital Nama
I plan to improve Hospital Nama in a variety of ways. Firstly, my idea is to increase the number of hospitals on there, extending to maternity and military hospitals, mental health clinics and other healthcare facilities. I also plan to add more hospitals, even if they do not have a lot of reviews, since just having details on their bed count, price, departments, and MSDS compliance etc. is quite useful. It also ensures that I have a broader range of hospitals on my website, so it is more reflective of the healthcare landscape in my city. This is relatively easy to carry out; however, I'd have to come up with new categories of data especially if. I choose to incorporate healthcare facilities that are not hospitals.
I'd also like it such that users can make accounts on HospitalNama and save the hospitals that they view the most, like a favorites bar that they can come back to whenever they need to check something.
Finally, I'd like to seek out recognition for this project and increase the number of users to get more feedback. For this project to achieve it's purpose on a larger scale and help people gain access to reliable healthcare information, I'd need to make sure people are comfortable using it in the first place. For this purpose, I'd like to contact key stakeholders or advertise the website more and incorporate suggestions into the website.
Key Takeaways
Overall, I am really happy with what I was able to do in this hackathon! This was the first project on this scale and using AI that I've done; I enjoyed it and I'm proud of the final product.
Below, I've attached GitHub repo links to both the code for the website & data analysis, as well as a working link to the project.
Log in or sign up for Devpost to join the conversation.