
250 P.3d 592 (2009)
The PEOPLE of the State of Colorado, Plaintiff-Appellant,
v.
Robert PENA, Defendant-Appellee.
No. 08CA0200.
Colorado Court of Appeals, Div. VI.
September 17, 2009.
As Modified on Denial of Rehearing February 18, 2010.
*593 John R. Newsome, District Attorney, Doyle Baker, Deputy District Attorney, Colorado Springs, Colorado, for Plaintiff-Appellant.
Douglas K. Wilson, Colorado State Public Defender, Alan Kratz, Deputy State Public Defender, Denver, Colorado, for Defendant-Appellee.
Opinion by Judge HAWTHORNE.
Pursuant to section 16-12-102(1), C.R.S. 2009, and C.A.R. 4(b)(2), the People appeal the trial court's order dismissing the class six felony charge of driving after revocation prohibited against defendant, Robert Pena, because defendant did not receive a timely preliminary hearing. We reverse the order and remand for the trial court to reinstate the charge.


*594 I. Facts and Procedural Background
Defendant was arrested and charged in this El Paso County case on April 17, 2007, and on April 18, he posted bond and was released. The record does not indicate whether defendant appeared before the court on April 18 before posting bond.
On April 23, defendant was sentenced, taken into custody, and began serving a one-year jail sentence on a separate case in Pueblo County. Because he was incarcerated in Pueblo County and the prosecution did not obtain a writ for his appearance, defendant failed to appear for the April 25 advisement hearing in this case. The court revoked his bond and issued a warrant for his arrest.
After the warrant in this case was served on defendant in the Pueblo County Jail, he was booked into the El Paso County Jail and appeared before the court in this case on May 24. The court reset bond and initially advised defendant.
Defendant again appeared before the El Paso County court in this case, for the purpose of a "first appearance," on a writ of habeas corpus issued on June 12, and at that time, he requested a preliminary hearing. The El Paso County court set a preliminary hearing in this case for July 10. Defendant failed to appear for that hearing because he was still in Pueblo County's custody while serving his sentence there.
Defendant next appeared before the El Paso County court on December 3, after an arrest warrant was served on him in the Pueblo County Jail because he had failed to appear at the July 10 preliminary hearing. The court set another preliminary hearing for December 19. Defendant appeared at that hearing, on another writ of habeas corpus, and the court, after argument, determined that defendant's right to a preliminary hearing had been violated because "he hadn't been writted here" by the court for a preliminary hearing within thirty days of his June 12 request. The court dismissed the felony charge against him.
The People now appeal.

II. Jurisdiction
We first address defendant's contention that, because the People's appeal is untimely, we lack jurisdiction to consider it. We disagree.
Defendant relies on C.A.R. 4(b)(3) and 4.1 in support of his proposition that the People had ten days from the trial court's dismissal of the felony charge to file a notice of appeal. However, C.A.R. 4(b)(3) and 4.1 apply in cases where a trial court has dismissed one or more but less than all counts of a charging document. See People v. Severin, 122 P.3d 1073, 1074 (Colo.App.2005).
Severin is distinguishable. There, the trial court had reduced the felony charge against the defendant, but had not dismissed the charge or the case itself.
Thirty-two days later and on the eve of trial, the prosecution successfully moved to dismiss the remaining misdemeanor charge, and then six days later appealed to this court. Id. The division concluded that the prosecution's appeal should have been brought within ten days of the trial court's order reducing the charge because the order effectively dismissed one, but not all, of the charges against the defendant. Id. at 1074-75 (citing C.A.R. 4(b)(3) and 4.1).
Here, the trial court dismissed count one, the felony charge, and after a brief oral objection requesting the court to reconsider the dismissal, the People moved to dismiss count two, the traffic offense. The trial court then dismissed count two, thus effectively dismissing the case in its entirety. Because the trial court dismissed all charges, the people properly proceeded under C.A.R. 4(b)(2) by filing a notice of appeal within forty-five days of the court's order. See id. at 1074.
Therefore, we conclude that we have jurisdiction to consider the appeal.

III. Right to Preliminary Hearing
The People contend that "defendant was never entitled to a preliminary hearing in this case because he was not in custody for the class six felony when he requested the preliminary hearing." Defendant concedes that he was in Pueblo County's custody when *595 he requested the preliminary hearing, but he contends that he was concurrently in El Paso County's custody. We agree with the People.
Because the trial court here dismissed the felony charge based on a legal conclusion, we review its decision de novo. People v. Beck, 187 P.3d 1125, 1127 (Colo.App.2008).

A. Law Regarding Preliminary Hearings
In Colorado, "[a] preliminary hearing is held for the limited purpose of determining if probable cause exists to believe that the crime or crimes charged were committed by the defendant." People ex rel. Farina v. District Court, 184 Colo. 406, 409, 521 P.2d 778, 779 (1974). "The preliminary hearing was created as a screening device to afford the defendant an opportunity to challenge the sufficiency of the prosecution's evidence to establish probable cause before an impartial judge." Id.; accord People v. Taylor, 104 P.3d 269, 270 (Colo.App.2004).
A person charged with a class four, five, or six felony is not entitled to a preliminary hearing unless the felony charged requires mandatory sentencing, is a crime of violence, or is a sexual offense. See § 16-5-301(1)(a), (1)(b)(I), C.R.S.2009; Crim. P. 5(a)(4), 7(h)(1). None of these exceptions is applicable in defendant's case.
However, section 16-5-301(1)(b)(II), C.R.S. 2009, allows a defendant charged with a class four, five, or six felony, who is not otherwise entitled to a preliminary hearing, to demand one if the defendant is "in custody for the offense for which the preliminary hearing is requested." See also Crim. P. 5(a)(4), 7(h)(1). "The purpose of this provision is to ensure that persons held in custody on charges for which no probable cause exists will be released swiftly." Taylor, 104 P.3d at 271 (citing Gerstein v. Pugh, 420 U.S. 103, 95 S.Ct. 854, 43 L.Ed.2d 54 (1975); People v. Abbott, 638 P.2d 781 (Colo.1981)).

B. Custody of Prisoners
The sheriff of a county has "charge and custody of the jails of the county, and of the prisoners." § 30-10-511, C.R.S. 2009; see also § 16-11-308, C.R.S. 2009 (provides a similar custodial grant to the executive director of the Department of Corrections). However, district courts have the power to issue writs of habeas corpus to bring any person confined in any jail before them to testify. § 13-45-119, C.R.S. 2009. Upon completion of the purpose of the writ, the court must return the prisoner to the original place of custody. Id.
Prisoners transferred on a writ of habeas corpus from one jurisdiction to another for a limited purpose are in the temporary custody of the demanding jurisdiction, and remain in the primary custody of the sending jurisdiction. See United States v. Mauro, 436 U.S. 340, 362, 98 S.Ct. 1834, 1848, 56 L.Ed.2d 329 (1978) (when the government presents prison authorities in sending state with writ of habeas corpus ad prosequendum demanding prisoner's presence in federal court, it obtains temporary custody of prisoner); People v. Lucero, 654 P.2d 835, 836-37 (Colo.1982) (under former section 17-20-118, now codified at section 17-22.5-103, C.R.S. 2009, an offender who is temporarily released from a correctional facility "is not completely free of custody until he is discharged, which occurs only after he `has remained the full term for which he was sentenced'"); Higgins v. Colorado Dep't of Corr., 876 P.2d 124, 126 (Colo.App.1994) (statutory framework governing prisoners incarcerated in DOC facilities contemplates that state prisoners may temporarily be incarcerated in county and city jails when transferred pursuant to "legal writ").

C. Analysis
We conclude that defendant was in custody in Pueblo County for his conviction there and that El Paso County obtained only temporary custody for defendant's court appearance and did not hold him for the offense charged in that county. Accordingly, we conclude that defendant was not entitled to a preliminary hearing under section 16-5-301(1)(b)(II).
On June 12, when defendant requested a preliminary hearing, he was in El Paso County's temporary custody only to enable his appearance there. He had been transferred *596 from Pueblo County's primary custody pursuant to a writ of habeas corpus ordering "the El Paso County Sheriff to transfer and retain custody of [defendant] for [proceedings before the court], and afterwards to return [defendant] to the custodian."
On December 19, when the court dismissed the felony charge against defendant, and on each previous date when defendant appeared before the court, he was still serving his Pueblo County sentence. Except for his initial arrest and booking on April 17 and 18, nothing in the record indicates that the offense charged in this case was ever the primary basis for defendant's custodial status. And on April 18, defendant posted bond and was released from custody for the offense at issue here. Therefore, after he initially posted bond and was released, defendant was only temporarily in El Paso County's custody with respect to this offense.
We conclude that such temporary custody under the circumstances here does not constitute "custody for the offense for which the preliminary hearing is requested" for the purposes of section 16-5-301(1)(b)(II). See Taylor, 104 P.3d at 272 (court erred in granting defendant's request for preliminary hearing on class five felony because the defendant remained in the primary custody of another judicial district).
The purpose of granting a preliminary hearing based on section 16-5-301(1)(b)(II) is to "ensure that persons held in custody on charges for which no probable cause exists will be released swiftly." Id. at 271. Here, that purpose would not be served because defendant was not deprived of his liberty based on the pending El Paso County charge, but rather was in custody based on the Pueblo County sentence he was serving. Therefore, a probable cause hearing would have served no purpose in these circumstances. Cf. Moody v. Daggett, 429 U.S. 78, 86 n. 7, 97 S.Ct. 274, 278, 50 L.Ed.2d 236 (1976) (in parole revocation context, parolee was not entitled to a preliminary hearing when imprisoned at time of revocation proceedings on charges for another crime committed while on parole).
Finally, we reject defendant's assertion that the Taylor division's interpretation of section 16-5-301(1)(b)(II) presents a "potential" constitutional infirmity. The fact that a defendant may be entitled to a preliminary hearing in the case for which he is in custody does not cause a constitutional deprivation in other cases for which he might be, but is not, in custody. See J.T. v. O'Rourke, 651 P.2d 407, 412 (Colo.1982) (citing Gerstein v. Pugh, 420 U.S. at 125 n. 26, 95 S.Ct. at 869) (a probable cause determination is not a constitutional prerequisite to a charging decision and is required only for suspects who suffer actual restraints on their liberty).

IV. Felony Charge Dismissal
At the December 19 hearing, the trial court concluded that defendant had not received a timely preliminary hearing and dismissed the felony charge against him. Because defendant was not in El Paso County's custody on June 12, as contemplated by section 16-5-301(1)(b)(II), and therefore not legally entitled to a preliminary hearing, the court was without authority to dismiss the felony charge on that basis. See Taylor, 104 P.3d at 272-73.
Therefore, the order dismissing the class six felony aggravated driving after revocation prohibited charge is reversed, and the case is remanded for the court to reinstate the charge.
Judge CARPARELLI and Judge TERRY concur.
