Example #1
0
        private Element GetValue(entitystorematerialised_CoreResult1 result)
        {
            if (int.TryParse(result.Observationvalue, out int intValue))
            {
                Quantity valueQuantity = new Quantity();

                valueQuantity.Code  = result.Unitscode;
                valueQuantity.Value = Convert.ToDecimal(intValue);
                valueQuantity.Unit  = result.Unitstext;

                return(valueQuantity);
            }
            else if (bool.TryParse(result.Observationvalue, out bool boolValue))
            {
                return(new FhirBoolean(Convert.ToBoolean(boolValue)));
            }
            else if (decimal.TryParse(result.Observationvalue, out decimal decimalValue))
            {
                Quantity valueQuantity = new Quantity();

                valueQuantity.Code  = result.Unitscode;
                valueQuantity.Value = Convert.ToDecimal(decimalValue);
                valueQuantity.Unit  = result.Unitstext;

                return(valueQuantity);
            }
            else
            {
                return(new FhirString(result.Observationvalue));
            }
        }
Example #2
0
 private FhirDateTime GetEffective(entitystorematerialised_CoreResult1 coreObservationResult)
 {
     if (coreObservationResult.Observationdatetime.HasValue)
     {
         var elem = new FhirDateTime(coreObservationResult.Observationdatetime.Value);
         elem.ElementId = "effectiveDateTime";
         return(elem);
     }
     return(null);
 }
Example #3
0
        private Meta GetMeta(entitystorematerialised_CoreResult1 src)
        {
            if (src.IsNull() || !src.Createdtimestamp.HasValue)
            {
                return(null);
            }

            return(new Meta
            {
                VersionId = $"{src.Sequenceid}",
                LastUpdated = src.Createdtimestamp
            });
        }
Example #4
0
        private List <Identifier> GetResultIdentifiers(entitystorematerialised_CoreResult1 coreObservationResult)
        {
            var identifiers = new List <Identifier>();

            Identifier id = new Identifier
            {
                Value = coreObservationResult.Contextkey
            };

            identifiers.Add(id);

            return(identifiers);
        }
Example #5
0
        private CodeableConcept GetResultCode(entitystorematerialised_CoreResult1 coreObservationResult)
        {
            var obsCodes = new CodeableConcept();

            Coding obsCode = new Coding();

            obsCode.Code    = coreObservationResult.Observationidentifiercode;
            obsCode.Display = coreObservationResult.Observationidentifiertext;

            obsCodes.Coding.Add(obsCode);

            return(obsCodes);
        }
Example #6
0
        private List <ResourceReference> GetPerformer(entitystorematerialised_CoreResult1 src, Observation obs)
        {
            var referenceResources = new List <ResourceReference>();

            if (obs.Performer.IsCollectionValid())
            {
                obs.Performer.Each(per => referenceResources.Add(per));
            }

            ResourceReference performer = new ResourceReference
            {
                Reference = "Practitioner",
                Display   = src.Author
            };

            referenceResources.Add(performer);
            return(referenceResources);
        }
Example #7
0
        private List <CodeableConcept> GetInterpretation(entitystorematerialised_CoreResult1 result)
        {
            var interpretations = new List <CodeableConcept>();

            CodeableConcept code = new CodeableConcept();

            if (result.Abnormalflag.IsEmpty())
            {
                return(interpretations);
            }

            if (result.Abnormalflag.ToLower() == "true")
            {
                code.Text = "Abnormal";
            }
            else
            {
                code.Text = "Normal";
            }
            interpretations.Add(code);
            return(interpretations);
        }
Example #8
0
        private ObservationStatus GetStatus(entitystorematerialised_CoreResult1 coreObservationResult)
        {
            if (coreObservationResult.Observationresultstatus.IsEmpty())
            {
                return(default(ObservationStatus));
            }

            switch (coreObservationResult.Observationresultstatus.ToLower())
            {
            case "amended":
                return(ObservationStatus.Amended);

            case "cancelled":
                return(ObservationStatus.Cancelled);

            case "corrected":
                return(ObservationStatus.Corrected);

            case "enteredinerror":
                return(ObservationStatus.EnteredInError);

            case "final":
                return(ObservationStatus.Final);

            case "preliminary":
                return(ObservationStatus.Preliminary);

            case "registered":
                return(ObservationStatus.Registered);

            default:
                return(ObservationStatus.Unknown);
            }

            return(default(ObservationStatus));;
        }
Example #9
0
        private List <Observation.ReferenceRangeComponent> GetReferenceRange(entitystorematerialised_CoreResult1 result, Observation obs)
        {
            var referenceRanges = new List <Observation.ReferenceRangeComponent>();

            if (obs.ReferenceRange.IsCollectionValid())
            {
                obs.ReferenceRange.Each(refRange => referenceRanges.Add(refRange));
            }

            Observation.ReferenceRangeComponent referenceRange = new Observation.ReferenceRangeComponent();

            referenceRange.Low = new SimpleQuantity
            {
                Value = Decimal.TryParse(result.Referencerangelow, out Decimal refLow) ? refLow : default(decimal?)
            };

            referenceRange.High = new SimpleQuantity
            {
                Value = Decimal.TryParse(result.Referencerangehigh, out Decimal refHigh) ? refHigh : default(decimal?)
            };

            referenceRanges.Add(referenceRange);
            return(referenceRanges);
        }