Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Refactor Medicine Module #591

Merged
merged 4 commits into from
May 26, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,7 @@ set(FAKER_SOURCES
src/modules/location/Location.cpp
src/modules/lorem/Lorem.cpp
src/modules/medicine/Medicine.cpp
src/modules/medicine/MedicineData.cpp
src/modules/movie/Movie.cpp
src/modules/movie/MovieData.cpp
src/modules/music/Music.cpp
Expand Down
8 changes: 4 additions & 4 deletions include/faker-cxx/Medicine.h
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
#pragma once

#include <string>
#include <string_view>

namespace faker
{
Expand All @@ -17,7 +17,7 @@ class Medicine
* Medicine::condition() // "AIDS"
* @endcode
*/
static std::string condition();
static std::string_view condition();

/**
* @brief Returns a random medical test
Expand All @@ -28,7 +28,7 @@ class Medicine
* Medicine::medicalTest() // "pulmonary auscultation"
* @endcode
*/
static std::string medicalTest();
static std::string_view medicalTest();

/**
* @brief Returns a random Medical specialty
Expand All @@ -40,6 +40,6 @@ class Medicine
* @endcode
*/

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

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

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

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

}
161 changes: 161 additions & 0 deletions src/modules/medicine/MedicineData.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,161 @@
#include "MedicineData.h"

namespace faker::medicine {
const std::array<std::string_view, 59> 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"
};

const std::array<std::string_view, 35> medicalTests = {
"HEENT examination",
"abdominal palpation",
"amniocentesis",
"ballistocardiogram",
"capsule endoscopy",
"cardiac auscultation",
"coloscopy",
"colposcopy",
"coronary catheterization",
"cystoscopy",
"digital rectal examination",
"echocardiography",
"electrocardiogram",
"electroencephalogram",
"electromyography",
"endoscopic retrograde cholangiopancreatography",
"esophageal motility study",
"esophageal pH monitoring",
"esophagogastroduodenoscopy",
"hearing test",
"hysteroscopy",
"laparoscopy",
"laryngoscopy",
"liver biopsy",
"mammography",
"neurological examination",
"neuropsychological tests",
"polysomnography",
"psychiatric assessment",
"pulmonary auscultation",
"pulmonary plethysmography",
"skin biopsy",
"thoracentesis",
"urodynamic testing",
"vaginal examination"
};

const std::array<std::string_view, 55> 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",
"Neurology",
"Neuropsychiatry",
"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"
};
}
10 changes: 10 additions & 0 deletions src/modules/medicine/MedicineData.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
#pragma once

#include <array>
#include <string_view>

namespace faker::medicine {
extern const std::array<std::string_view, 59> medicalConditions;
extern const std::array<std::string_view, 35> medicalTests;
extern const std::array<std::string_view, 55> specialties;
}
69 changes: 0 additions & 69 deletions src/modules/medicine/data/conditon.h

This file was deleted.

45 changes: 0 additions & 45 deletions src/modules/medicine/data/medicaltests.h

This file was deleted.

Loading
Loading