PRIMARY OBJECTIVES:
I. Evaluate the safety, maximum tolerated dose (MTD), and the recommended phase II dose (RP2D) of afatinib dimaleate (afatinib) in combination with capecitabine in patients with advanced solid tumors (phase I) and pancreatico-biliary cancers (phase Ib). (Phase I/Ib)
SECONDARY OBJECTIVES:
I. Evaluate biomarkers of response from tumor biopsies, including markers related to the epidermal growth factor receptor (EGFR) and human epidermal growth factor receptor 2 (HER2) pathways via OncoPlex or other equivalent gene sequencing assay. (Phase I/Ib)
II. Evaluate rates of response and stable disease, duration of response, time to progression, progression-free and overall survival. (Phase I/Ib)
OUTLINE: This is a phase I, dose-escalation study of afatinib dimaleate followed by a phase Ib study.
Patients receive afatinib dimaleate orally (PO) once daily (QD) on days 1-21 and capecitabine PO twice daily (BID) on days 1-14. Courses repeat every 21 days in the absence of disease progression or unacceptable toxicity.
After completion of study treatment, patients are followed up every 3 months for 3 years.
Inclusion Criteria:
PHASE I:
* PHASE I: Histologically confirmed solid tumor malignancy
* PHASE I: Life expectancy \>= 12 weeks
* PHASE I: No limit on the number of prior systemic therapies for metastatic disease
* PHASE I: Prior treatment with erlotinib, gefitinib or EGFR-blocking monoclonal antibodies (cetuximab and panitumumab) is allowed
* PHASE I: Signed informed consent
* PHASE I: Eastern Cooperative Oncology Group (ECOG) performance status (PS) of 0-2
* PHASE I: Measurable disease according to Response Evaluation Criteria in Solid Tumors (RECIST) version (v)1.1
* PHASE I: Must be willing to provide tumor tissue biopsy samples (may be fresh or archival paraffin embedded) at baseline
* PHASE I: In order to perform a retrospective biomarker analysis with the next generation gene sequencing UW-OncoPlex assay; fresh tumor biopsies from metastatic or primary tumor lesion will be done if considered safe and feasible by treating physician and radiologist; Patients who already have OncoPlex or other equivalent gene sequencing assay (eg Foundation One, Perthera, Caris etc) test results available from prior tumor biopsy are eligible to participate, without the needed of a repeat tumor biopsy, but the test results need to be provided to the study principal investigator
* PHASE I: Females of childbearing potential must use an effective method of contraception (barrier method of birth control or abstinence) from the time of consent until at least 180 days following discontinuation of protocol therapy; females of childbearing potential must have a negative pregnancy test within 3 days prior to registration for protocol therapy; patients are considered not of child bearing potential if they are surgically sterile (they have undergone a hysterectomy, bilateral tubal ligation, or bilateral oophorectomy) or they are naturally postmenopausal for at least 12 consecutive months; females must not be pregnant or breastfeeding; in rare cases of an endocrine-secreting tumor, human chorionic gonadotropin (hCG) levels may be above normal limits (falsely-positive) but with no pregnancy in the patient; in these cases, there should be a repeat serum hCG test (with a non-rising result) to rule out pregnancy; upon confirmation of results and discussion with the Sponsor-Investigator, these patients may enter the study
* PHASE I: Sexually active male subjects must use an effective method of contraception (barrier method of birth control or abstinence) from the time of consent until at least 180 days following discontinuation of protocol therapy
* PHASE I: Absolute neutrophil count \>= 1500/uL
* PHASE I: Platelet count \>= 100,000/uL
* PHASE I: Hemoglobin \>= 9 gm/dL
* PHASE I: Total bilirubin =\< 1.5 times upper limit of normal (ULN)
* PHASE I: Transaminases (aspartate aminotransferase \[AST\] and/or alanine aminotransferase \[ALT\]) =\< 2.5 x ULN
* PHASE I: Prothrombin time (PT) (or international normalized ratio \[INR\]) and partial thromboplastin time (PTT) =\< 1.5 x ULN
* PHASE I: Calculated creatinine clearance (CrCl) \>= 60 mL/min calculated by Cockcroft-Gault formula
PHASE IB:
* PHASE IB: Histologically confirmed refractory locally-advanced unresectable or metastatic pancreatic or biliary cancer
* PHASE IB: Life expectancy \>= 12 weeks
* PHASE IB: =\< 2 lines of prior systemic therapy for metastatic disease (if patients have metastatic disease)
* PHASE IB: =\< 2 lines of prior systemic therapy for patients with progressive locally-advanced disease
* PHASE IB: No prior treatment with erlotinib is allowed for pancreatic cancer patients
* PHASE IB: ECOG PS 0-1
* PHASE IB: Signed informed consent
* PHASE IB: Measurable disease according to RECIST v1.1
* PHASE IB: Must be willing to provide tumor tissue biopsy samples (may be fresh or archival paraffin embedded) at baseline
* PHASE IB: Fresh tumor biopsies from metastatic or primary tumor lesions will be done only if considered safe and feasible by treating physician and radiologist; patients who already have OncoPlex or other equivalent gene sequencing assay (eg Foundation One, Perthera, Caris etc) test results available from prior tumor biopsy are eligible to participate, without the needed of a repeat tumor biopsy, but the test results need to be available to the study principal investigator
* PHASE IB: Females of childbearing potential must use an effective method of contraception (barrier method of birth control or abstinence) from the time of consent until at least 180 days following discontinuation of protocol therapy; females of childbearing potential must have a negative pregnancy test within 3 days prior to registration for protocol therapy; patients are considered not of child bearing potential if they are surgically sterile (they have undergone a hysterectomy, bilateral tubal ligation, or bilateral oophorectomy) or they are naturally postmenopausal for at least 12 consecutive months; females must not be pregnant or breastfeeding; in rare cases of an endocrine-secreting tumor, hCG levels may be above normal limits (falsely-positive) but with no pregnancy in the patient; in these cases, there should be a repeat serum hCG test (with a non-rising result) to rule out pregnancy; upon confirmation of results and discussion with the sponsor-investigator, these patients may enter the study
* PHASE IB: Sexually active male subjects must use an effective method of contraception (barrier method of birth control or abstinence) from the time of consent until at least 180 days following discontinuation of protocol therapy
* PHASE IB: Patients in the expansion cohort must have a measurable site of disease according to RECIST (v 1.1) that has not been previously irradiated, or evidence of at least 20% progression in a previously irradiated lesion, and assessed by imaging within 28 days prior to registration for protocol therapy
* PHASE IB: Absolute neutrophil count \>= 1500/uL
* PHASE IB: Platelet count \>= 100,000/uL
* PHASE IB: Hemoglobin \>= 9 gm/dL
* PHASE IB: Total bilirubin =\< 1.5 times upper limit of normal (ULN)
* PHASE IB: Transaminases (AST and/or ALT) =\< 2.5 x ULN
* PHASE IB: PT (or INR) and PTT =\< 1.5 x ULN
* PHASE IB: Calculated creatinine clearance (CrCl) \>= 60 mL/min calculated by Cockcroft-Gault formula
Exclusion Criteria:
* Prior treatment with afatinib
* Untreated or symptomatic brain metastases requiring corticosteroid therapy (no corticosteroid use for this purpose in the preceding 4 weeks)
* Diagnosis with any of the following in the 12 months prior to registration: severe/unstable angina, myocardial infarction, uncontrolled cardiac arrhythmia, congestive heart failure, cerebrovascular accident or transient ischemic attack
* Active venous thrombosis with contraindication for anticoagulation
* Patients taking warfarin; if anticoagulation is required, the patient must be on a stable dose of a Food and Drug Administration (FDA) approved anticoagulant other than warfarin (e.g. enoxaparin, dalteparin, fondaparinux, apixaban, rivaroxaban) for at least 30 days
* Any history of or concomitant condition that, in the opinion of the investigator, would compromise the patient?s ability to comply with the study or interfere with the evaluation of the efficacy and safety of the test drug
* Gastrointestinal tract disease or any other reasons resulting in an inability to take oral medication or a requirement for intravenous (IV) alimentation, prior surgical procedures affecting absorption, active peptic ulcer disease or chronic diarrhea
* History of bone marrow transplant and stem cell rescue
* Receipt of any chemotherapy, biological therapy or investigational agents within 3 weeks prior to study registration
* Radiotherapy within 4 weeks prior to therapy except palliative radiation to target organs other than primary tumor may be allowed up to 2 weeks prior to registration
* Major surgery within 4 weeks before starting study treatment or scheduled for surgery during the projected course of the study
* Known pre-existing interstitial lung disease
* Any history or presence of poorly controlled gastrointestinal disorders that could affect the absorption of the study drug (e.g. Crohn?s disease, ulcerative colitis, chronic diarrhea, malabsorption)
* Known active hepatitis B infection (defined as presence of hepatitis B \[HepB\] surface antigen \[sAg\] and/or Hep B deoxyribonucleic acid \[DNA\]), known active hepatitis C infection (defined as presence of hepatitis C \[Hep C\] ribonucleic acid \[RNA\]) and/or known human immunodeficiency virus (HIV) carrier