Beispiel #1
0
        public override async Task ProcessAsync(ILookupTemplate <IFhirTemplate> config, IMeasurementGroup data, Func <Exception, IMeasurementGroup, Task <bool> > errorConsumer = null)
        {
            // Get required ids
            var ids = await ResourceIdentityService.ResolveResourceIdentitiesAsync(data).ConfigureAwait(false);

            var grps = _fhirTemplateProcessor.CreateObservationGroups(config, data);

            foreach (var grp in grps)
            {
                _ = await SaveObservationAsync(config, grp, ids).ConfigureAwait(false);
            }
        }
Beispiel #2
0
        protected virtual void ProcessNormalizedEvent(Measurement normalizedEvent, ILookupTemplate <IFhirTemplate> fhirTemplate, DeviceResult validationResult)
        {
            var measurementGroup = new MeasurementGroup
            {
                MeasureType   = normalizedEvent.Type,
                CorrelationId = normalizedEvent.CorrelationId,
                DeviceId      = normalizedEvent.DeviceId,
                EncounterId   = normalizedEvent.EncounterId,
                PatientId     = normalizedEvent.PatientId,
                Data          = new List <Measurement>()
                {
                    normalizedEvent
                },
            };

            try
            {
                // Convert Measurement to Observation Group
                var observationGroup = _fhirTemplateProcessor.CreateObservationGroups(fhirTemplate, measurementGroup).First();

                // Build HL7 Observation
                validationResult.Observations.Add(_fhirTemplateProcessor.CreateObservation(fhirTemplate, observationGroup));
            }
            catch (TemplateNotFoundException e)
            {
                validationResult.CaptureError(
                    $"No Fhir Template exists with the type name [{e.Message}]. Ensure that all Fhir Template type names match Device Mapping type names (including casing)",
                    ErrorLevel.ERROR,
                    ValidationCategory.FHIRTRANSFORMATION,
                    LineInfo.Default);
            }
            catch (Exception e)
            {
                validationResult.CaptureException(e, ValidationCategory.FHIRTRANSFORMATION);
            }
        }