internal static Medication GetMedication(DomainResource domainResource, Element medication) { switch (medication) { case ResourceReference medicationReference: return(domainResource.GetContainedResource <Medication>(medicationReference)); case CodeableConcept medicationCodeableConcept: return(ToMedication(medicationCodeableConcept)); default: throw new ArgumentOutOfRangeException(nameof(medication) , $"Allowed {nameof(ResourceReference)} or {nameof(CodeableConcept)} only"); } }