public HttpResponseMessage Read(int observationId, string _format = "application/xml+FHIR", bool _summary = false) { HttpResponseMessage message = new HttpResponseMessage(); Observation observation = db.Observations.Find(observationId); if (observation == null) { message.StatusCode = HttpStatusCode.NotFound; message.Content = new StringContent("observation with id " + observationId + " not found!", Encoding.UTF8, "text/html"); return(message); } Hl7.Fhir.Model.Observation fhirObservation = ObservationMapper.MapModel(observation); string fixedFormat = ControllerUtils.FixMimeString(_format); string payload = ControllerUtils.Serialize(fhirObservation, fixedFormat, _summary); message.Content = new StringContent(payload, Encoding.UTF8, fixedFormat); return(message); }
public HttpResponseMessage Read(int deviceId, string _format = "application/xml+FHIR", bool _summary = false) { HttpResponseMessage message = new HttpResponseMessage(); Device device = db.Devices.Find(deviceId); if (device == null) { message.StatusCode = HttpStatusCode.NotFound; message.Content = new StringContent("Device with id " + deviceId + " not found!", Encoding.UTF8, "text/html"); return(message); } Hl7.Fhir.Model.Device fhirDevice = DeviceMapper.MapModel(device); string fixedFormat = ControllerUtils.FixMimeString(_format); string payload = ControllerUtils.Serialize(fhirDevice, fixedFormat, _summary); message.Content = new StringContent(payload, Encoding.UTF8, fixedFormat); return(message); }