Is sensitivity or specificity a function of prevalence? Standard teaching says that sensitivity and specificity are properties of the test and are independent of prevalence. But isn't this just an assumption?
Harrison's principles of internal medicine 19th ed says

It has long been asserted that sensitivity and specificity are prevalence-independent parameters of test accuracy, and many texts still make this statement. This statistically useful assumption, however, is clinically simplistic. ...test sensitivity will likely be higher in hospitalised patients, and test specificity higher in outpatients.

(Prevalence is typically higher in inpatients than in outpatients)
Is there a mathematical or an approximate graphical relation between these parameters?
Even this link calls it an 'simplification'. Why?
Edit: I know how sensitivity is defined. There is no term of prevalence involved, as mentioned in the answers. I myself have maintained that these are properties of the test unaffected by the population used, in until I came across this statement, hence the question. But I assume, this confusion is arising not due to definition but practical calculation of these values. Specificity and sensitivity are calculated using 2x2 tables, does the prevalence of the reference population here matter? Is that what they are referring to? If it does, what's the function?
 A: As already said by others, sensitivity and specificity don't depend on prevalence. Sensitivity is the proportion of true positives among all positives and specificity is proportion of true negatives among all negatives. So if sensitivity is 90%, then the test will be correct for 90% of the cases that are positive. Obviously 90% of something smaller and 90% of something larger is still 90%... 
So given the tabular data that you mention,
$$
\begin{array}{cc} 
 & \substack{\text{positive} \\ \text{condition}} & \substack{\text{negative} \\ \text{condition}}\\ 
 \substack{\text{positive} \\ \text{test}}  & a & c \\ 
 \substack{\text{negative} \\ \text{test}}  & b & d \\ 
\end{array}
$$
sensitivity is $\tfrac{a}{a+b+c+d} \,/\, \tfrac{a+b}{a+b+c+d} = \tfrac{a}{a+b}$ (from the definition of conditional probability $p(Y \mid X) = \tfrac{p(Y \cap X)}{p(X)}$) and specifity is $\tfrac{d}{a+b+c+d} \,/\, \tfrac{c+d}{a+b+c+d} = \tfrac{d}{c+d}$. For each of the metrics, you look only at one of the columns at the time, so the prevalence (relative sizes of the columns) does not matter for those metrics. The prevalence does not come into the equations. Also it would be rather strange if the "practical" sensitivity was defined differently then theoretically and led to different conclusions.
But the quote seems also to be saying something else

test sensitivity will likely be higher in hospitalized patients, and
  test specificity higher in outpatients

so authors say that sensitivity differs in different groups. I guess that inpatients and outpatients may differ in many aspects, not only in prevalence alone, so some other factors may influence the sensitivity. So I agree that they may change between different datasets, that differ in prevalence, but the change will not be a function of the prevalence itself (as shown by @gung in his answer).
On another hand, if I had to guess, maybe the authors are confusing sensitivity with posterior probability. Sensitivity is $p(\text{positive test}\mid\text{condition})$, while the posterior probability is
$$
p(\text{condition}\mid\text{positive test}) \propto p(\text{positive test}\mid\text{condition})\times p(\text{condition})
$$
and in many cases this is the probability the people are interested in ("how likely is a patient with a positive test result to actually have the disease?") and it depends on the prevalence. Notice that also your link discusses the impact of prevalence on Positive Predictive Value, i.e. the posterior probability, not on sensitivity.
A: See my answer here on true/false positive/negative rates.
Sensitivity is just another name for the true positive rate, and specificity is the same as the true negative rate. Both sensitivity and specificity are conditional probabilities; they condition on the disease status of the patient. Thus the prevalence of the disease (i.e. the a priori probability that a patient has the disease) is irrelevant, since you are assuming a particular disease state.
I can't comment on why the textbook author claims that sensitivity and specificity depend on the clinical context. Are these empirical observations?
A: I cannot, of course, speak to the author's intentions, but here would be my reasoning for that statement:
Consider clinical context as a diagnostic test itself. One with very poor sensitivity and specificity, but a test none the less. If you're in the hospital, you're likely to be sick. If you're not in the hospital, you're not likely to be sick.
From this perspective, the actual diagnostic test you perform is actually the second part of two tests done in serial.
A: This must be a mistake. I think perhaps the author is trying to suggest that positive and negative predictive value (PPV and NPV) are dependent on the prevalence (as well as sensitivity and specificity). These are often discussed with diagnostic tests and, to a clinician, perhaps more valuable than raw interpretation of sensitivity and specificity.
This graph demonstrates the relationship between the PPV and NPV with prevalence, for a test with 95% sensitivity and 85% specificity.

From Mausner JS, Kramer S: Mausner and Bahn Epidemiology: An Introductory Text. Philadelphia, WB Saunders, 1985, p. 221.
A: @Satwik, @gung and @Tim have already provided a lot of detail, but I'll try and add a small example of how the case of underlying  factors may cause such an effect. 
A Key Principle: Bias
Sensitivity/Specificity and ALL statistical tests share the same caveat: it applies only to repeating the same sampling procedure as before in an unbiased manner. 
Hospitals are functioning organisations designed to perform biased sampling, using admissions policies to filter the general population down into those requiring admission and treatment. This is very antithesis of scientific procedure. If you want to know how a test performs in different populations it needs to be tested in different populations.
The latent effect: Correlation
It is rare (or impossible in the real world if you want to be strict) for a diagnostic to be independent/orthogonal to all other risk factors for a disease, so there is some degree of correlation. 
If the screen for admission to hospital is positively correlated with the diagnostic then what you will find is that people who pass the admissions test are favourably predisposed for positive results by the diagnostic, proportional to the correlation. Thus true positives are enriched and false negatives are reduced by amounts proportional to the correlation. 
This then makes sensitivity appear larger. 
The explanation of the phenomenon
An observation that sensitivity may be higher in a hospital based context is therefore not unrealistic. In fact if the admissions policy is well thought out and fit for purpose one would expect this to occur.
It is not evidence of a breakdown in the assumption that sensitivity and specificity are prevalence independent, rather it is evidence of a biased sampling based on the hospital admission policy. 
Which, given a hospital is there to treat people and not to do scientific experiments, is definitely a good thing. 
But it does give scientists a headache.
A: Stochastic13 has answered beautifully - could I add to this by suggesting the clarification to the oversimplification that is being discussed:
Sensitivity and specificity doesn't change with prevalence provided the cumulative probability function of the test within both those with the disease and those without the disease is the same as the population from which the sensitivity and specificty has been calculated.
A: Sensitivity and specificity are not properties of the the test.  They are properties of the test and the patient as shown empirically here whenever the disease is not all-or-nothing.    In the example given in the link, older patients have more advanced coronary disease that is easier to detect, hence sensitivity of an exercise ECG test must (and does) increase with age.  So if age is your "prevalence factor" sensitivity increases with prevalence.  On the whole, sensitivity and specificity, which were appropriated from radio and radar operating characteristics, are far less useful in medicine than they seem, and we would do well to introduce probabilistic diagnosis through logistic regression models as done in the linked chapter.  In that way one can handle

*

*tests with non-binary outputs

*non-binary diagnostic status

*multiple correlated tests

*multiple disease stages/severities (using ordinal logistic regression)

