Skip to content

Commit

Permalink
Feature/medicine module (#205)
Browse files Browse the repository at this point in the history
* add Medicine module

* fix/missing-pragma-once

* add medicine module as source

* add test for Medicine module
  • Loading branch information
sandeshkhadka authored Oct 14, 2023
1 parent e838ce6 commit 2b8d28f
Show file tree
Hide file tree
Showing 7 changed files with 292 additions and 0 deletions.
2 changes: 2 additions & 0 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,7 @@ set(FAKER_SOURCES
src/modules/hacker/Hacker.cpp
src/modules/sport/Sport.cpp
src/modules/videoGame/VideoGame.cpp
src/modules/medicine/Medicine.cpp
)

set(FAKER_UT_SOURCES
Expand Down Expand Up @@ -74,6 +75,7 @@ set(FAKER_UT_SOURCES
src/modules/hacker/HackerTest.cpp
src/modules/sport/SportTest.cpp
src/modules/videoGame/VideoGameTest.cpp
src/modules/medicine/MedicineTest.cpp
)

add_library(${LIBRARY_NAME} ${FAKER_SOURCES})
Expand Down
47 changes: 47 additions & 0 deletions include/faker-cxx/Medicine.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,47 @@
#pragma once

#include <string>

namespace faker
{
class Medicine
{

public:
/**
* @brief Returns a random medical condition.
*
* @returns Medical condition.
*
* @code
* Medicine::condition() // "AIDS"
* @endcode
*
*/
static std::string condition();

/**
* @brief Returns a random medical test
*
* @returns Medical test.
*
* @code
* Medicine::medicalTest() // "pulmonary auscultation"
* @endcode
*
*/
static std::string medicalTest();

/**
* @brief Returns a random Medical specialty
*
* @returns Medical specialty.
* @code
* Medicine::specialty() // "Cardiology"
* @endcode
*
*/

static std::string specialty();
};
}
24 changes: 24 additions & 0 deletions src/modules/medicine/Medicine.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
#include "faker-cxx/Medicine.h"

#include "data/conditon.h"
#include "data/medicaltests.h"
#include "data/specialty.h"
#include "faker-cxx/Helper.h"

namespace faker
{
std::string Medicine::condition()
{
return Helper::arrayElement<std::string>(medicalConditions);
}

std::string Medicine::medicalTest()
{
return Helper::arrayElement<std::string>(medicalTests);
}
std::string Medicine::specialty()
{
return Helper::arrayElement<std::string>(specialties);
}

}
40 changes: 40 additions & 0 deletions src/modules/medicine/MedicineTest.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,40 @@

#include <algorithm>
#include <faker-cxx/Medicine.h>
#include <gtest/gtest.h>

#include "data/conditon.h"
#include "data/medicaltests.h"
#include "data/specialty.h"

using namespace ::testing;
using namespace faker;

class MedicineTest : public Test
{
public:
};

TEST_F(MedicineTest, shouldGenerateMedicalCondition)
{
const auto generatedMedicalCondition = Medicine::condition();

ASSERT_TRUE(std::ranges::any_of(medicalConditions, [generatedMedicalCondition](const std::string& medicalCondition)
{ return medicalCondition == generatedMedicalCondition; }));
}

TEST_F(MedicineTest, shouldGenerateMedicalTest)
{
const auto generatedMedicalTest = Medicine::medicalTest();

ASSERT_TRUE(std::ranges::any_of(medicalTests, [generatedMedicalTest](const std::string& medicalTest)
{ return medicalTest == generatedMedicalTest; }));
}

TEST_F(MedicineTest, shouldGenerateSpecialty)
{
const auto generatedSpecialty = Medicine::specialty();

ASSERT_TRUE(std::ranges::any_of(specialties, [generatedSpecialty](const std::string& specialty)
{ return specialty == generatedSpecialty; }));
}
69 changes: 69 additions & 0 deletions src/modules/medicine/data/conditon.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,69 @@
#pragma once

#include <string>
#include <vector>

namespace faker
{
const std::vector<std::string> medicalConditions = {
"AIDS",
"Anorexia Nervosa",
"Arthritis, Juvenile Rheumatoid",
"Asthma, Moderate or Severe Persistent",
"Bronchiolitis",
"Bulimia",
"Cancer",
"Cardiorespiratory Diseases",
"Celiac Disease",
"Cerebral Palsy",
"Cleft Lip or Palate",
"Crohn’s Disease",
"Cystic Fibrosis",
"Depression",
"Developmental, Sensory, or Motor Disabilities",
"Diabetes Mellitus",
"Down syndrome",
"Elevated Blood Lead Level",
"Epilepsy",
"Failure to Thrive",
"Fetal Alcohol Syndrome",
"Gall Bladder Disease",
"Gastro Esophageal Reflux Disease",
"Gastrointestinal Abnormalities",
"HIV Infection",
"Heart Disease",
"Hepatitis",
"Hypertension, Chronic/Prehypertension",
"Hypertension, Pregnancy-induced",
"Hyperthyroidism",
"Hypoglycemia",
"Hypothyroidism",
"Inborn Errors of Metabolism",
"Inflammatory Bowel Disease (IBD)",
"Lactose Intolerance",
"Large for Gestational Age",
"Liver Disease",
"Lupus Erythematosus",
"Major Surgery, Burns, or Trauma",
"Malabsorption Syndromes",
"Meningitis",
"Multiple Sclerosis",
"Muscular Dystrophy",
"Neonatal Abstinence Syndrome",
"Neural Tube Defect (Spina Bifida)",
"Nutrient Deficiency Diseases",
"Pancreatitis",
"Parasitic Infection",
"Parkinson’s disease",
"Pneumonia",
"Prediabetes",
"Renal Disease",
"Sickle Cell Anemia",
"Small Bowel Enterocolitis and syndrome",
"Small for Gestational Age (SGA)",
"Thalassemia Major",
"Tuberculosis",
"Ulcerative Colitis",
"Ulcers, Stomach or Intestinal",
};
}
45 changes: 45 additions & 0 deletions src/modules/medicine/data/medicaltests.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,45 @@
#pragma once

#include <string>
#include <vector>

namespace faker
{
const std::vector<std::string> medicalTests = {
"abdominal palpation",
"cardiac auscultation",
"HEENT examination",
"digital rectal examination",
"neurological examination",
"psychiatric assessment",
"pulmonary auscultation",
"vaginal examination",
"coronary catheterization",
"echocardiography",
"electrocardiogram",
"ballistocardiogram",
"skin biopsy",
"hearing test",
"laryngoscopy",
"capsule endoscopy",
"coloscopy",
"endoscopic retrograde cholangiopancreatography",
"esophagogastroduodenoscopy",
"esophageal motility study",
"esophageal pH monitoring",
"liver biopsy",
"electroencephalogram",
"electromyography",
"neuropsychological tests",
"amniocentesis",
"colposcopy",
"mammography",
"hysteroscopy",
"laparoscopy",
"polysomnography",
"pulmonary plethysmography",
"thoracentesis",
"cystoscopy",
"urodynamic testing",
};
}
65 changes: 65 additions & 0 deletions src/modules/medicine/data/specialty.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,65 @@
#pragma once

#include <string>
#include <vector>

namespace faker
{
const std::vector<std::string> specialties = {
"Accident and emergency medicine",
"Allergist",
"Anaesthetics",
"Cardiology",
"Child psychiatry",
"Clinical biology",
"Clinical chemistry",
"Clinical microbiology",
"Clinical neurophysiology",
"Craniofacial surgery",
"Dermatology",
"Endocrinology",
"Family and General Medicine",
"Gastroenterologic surgery",
"Gastroenterology",
"General Practice",
"General surgery",
"Geriatrics",
"Hematology",
"Immunology",
"Infectious diseases",
"Internal medicine",
"Laboratory medicine",
"Nephrology",
"Neuropsychiatry",
"Neurology",
"Neurosurgery",
"Nuclear medicine",
"Obstetrics and gynaecology",
"Occupational medicine",
"Oncology",
"Ophthalmology",
"Oral and maxillofacial surgery",
"Orthopaedics",
"Otorhinolaryngology",
"Paediatric surgery",
"Paediatrics",
"Pathology",
"Pharmacology",
"Physical medicine and rehabilitation",
"Plastic surgery",
"Podiatric surgery",
"Preventive medicine",
"Psychiatry",
"Public health",
"Radiation Oncology",
"Radiology",
"Respiratory medicine",
"Rheumatology",
"Stomatology",
"Thoracic surgery",
"Tropical medicine",
"Urology",
"Vascular surgery",
"Venereology",
};
}

0 comments on commit 2b8d28f

Please sign in to comment.