Table of Contents

Health Data Science

Personalized Message

Assuming, you have 100 total OPD attendance each day and you are to send a personalized message for every patient after taking their vitals. It will be tedious if you are to send it personally but using for loop and if statement in R markdown makes it easier to create and send personalized messages to clients or patients who visit the Hospital based on some medical conditions. The process is automated so, once you meet a setting condition you get your preferred personalized message.

Datasets

DATAFRAME FOR CREATING A PERSONALIZED MESSAGE FOR PATIENTS

bp <- data.frame(
  Name = c("Alice", "Selina", "Rose", "Hibiscus", "Sunflower", "Tolu", "Mary", "Lola", "Sandra", "Margaret", "Celine", "Colen"),
  Age = c(25, 30, 35, 45, 19, 22, 45, 34, 23, 26, 33, 32),
  Systolic = c(126, 167, 170, 230, 102, 134, 155, 254, 112, 130, 144, 150),
  Diastolic = c(76, 110, 120, 91, 76, 69, 102, 189, 64, 78, 89, 103),
  Protein_in_urine = c("NO", "YES", "YES", "YES", "NO", "NO", "YES", "YES", "NO", "NO", "YES", "YES")
)

Personalized Messages Codes

CODES FOR CREATING PERSONALIZED MESSAGE FOR PATIENTS

Note With the codes below indentation is a key.

for (i in 1:nrow(bp)){
  if(bp$Systolic[i] >=140 | bp$Diastolic[i] >=90){
    print(paste(bp$name[i],"has high blood pressure. Please consult a doctor!"))
  }else if(bp$Systolic[i] >=120){
    print(paste(bp$Name[i],"has elevated blood pressure. Monitor closely and adopt a healthy lifestyle"))
  }else{
    print(paste(bp$name[i],"has normal blood pressure. Keep up the good habits!"))
  }
}
## [1] "Alice has elevated blood pressure. Monitor closely and adopt a healthy lifestyle"
## [1] " has high blood pressure. Please consult a doctor!"
## [1] " has high blood pressure. Please consult a doctor!"
## [1] " has high blood pressure. Please consult a doctor!"
## [1] " has normal blood pressure. Keep up the good habits!"
## [1] "Tolu has elevated blood pressure. Monitor closely and adopt a healthy lifestyle"
## [1] " has high blood pressure. Please consult a doctor!"
## [1] " has high blood pressure. Please consult a doctor!"
## [1] " has normal blood pressure. Keep up the good habits!"
## [1] "Margaret has elevated blood pressure. Monitor closely and adopt a healthy lifestyle"
## [1] " has high blood pressure. Please consult a doctor!"
## [1] " has high blood pressure. Please consult a doctor!"