In FHIR, resources point at each other with references. A relative literal reference looks like:
Patient/123
Observation/abc-1/_history/4
ResourceType/id β points at the current version of a resource.ResourceType/id/_history/versionId β points at a specific version.This kata is the offline, deterministic version of Batch-1 Day 4, Assignment 2 (the .NET OpenMRS FHIR facade client): before you can follow a reference to another resource, you must be able to parse and build one.
Implement FhirReference with:
static FhirReference Parse(string reference) β parse a relative reference.string Type β the resource type, e.g. "Patient".string Id β the logical id, e.g. "123".string Version β the _history version id, or null when unversioned.bool IsVersioned β true when a version id is present.string Format() β reconstruct the canonical reference string.Type/id/_history/vid, and vid
must be non-empty."Patient", "Patient/", "/123",
"Patient/123/foo/4", "Patient/123/_history/") must throw
ArgumentException.Format() must round-trip: FhirReference.Parse(s).Format() == s for every valid s.Sign up to Exercism to learn and master FHIR with 9 exercises, and real human mentoring, all for free.