'Sequential dependent markdown parameters

I would like to create a parameterized markdown document with two parameters where available options for the second input are dependent on the first. In my case I am dealing with a database of patients and visit dates, so the first input would be the patient ID, then code with generate a list of dates for that patient and the second input would be the index of the available. So something like:

---
title: "Dependent Inputs"
output: html_document
params: 
  MRN: "Medical Record in Database to Assess"
  D_idx: "The Date index from list for this subject"
---

# First get MRN:
params$MRN

# After user input MRN then filter and list possible dates
DB %>% filter(ID == MRN)  %>% select(Dates)

# Now enter date index for this MRN
params#D_idx

# Do the rest of the analysis using MRN and Date to get desired dataset ...

The interaction between the two doesn't seem possible. Tried using some shiny widgets as well but I am only interested in getting the user input to run the rest of the script, not rendering shiny outputs.



Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source