Ejemplo n.º 1
0
        static Template MediaFHIRToTemplate(Resource fhirMessage)
        {
            Template converted = null;

            try
            {
                Media biometricFHIR = (Media)fhirMessage;

                Extension       organizationExtension = null;
                Extension       captureSiteExtension  = null;
                uint            n = 0;
                TemplateBuilder templateBuilder = new TemplateBuilder();
                foreach (Extension extension in biometricFHIR.Extension)
                {
                    if (n == 0)
                    {
                        organizationExtension = extension;
                    }
                    else if (n == 1)
                    {
                        captureSiteExtension = extension;
                    }
                    else
                    {
                        TemplateBuilder.Minutia minutia = new TemplateBuilder.Minutia();
                        List <Extension>        ext     = extension.Value.Extension;

                        minutia.Position.X = Int32.Parse(ext[0].Value.ToString());
                        minutia.Position.Y = Int32.Parse(ext[1].Value.ToString());
                        minutia.Direction  = Byte.Parse(ext[2].Value.ToString());
                        minutia.Type       = ConvertStringToMinutiaType(ext[3].Value.ToString());
                        templateBuilder.Minutiae.Add(minutia);
                    }
                    n += 1;
                }
                if (organizationExtension != null && captureSiteExtension != null && templateBuilder.Minutiae.Count > 0)
                {
                    templateBuilder.OriginalDpi    = Int32.Parse(captureSiteExtension.Value.Extension[5].Value.ToString());
                    templateBuilder.OriginalHeight = Int32.Parse(captureSiteExtension.Value.Extension[6].Value.ToString());
                    templateBuilder.OriginalWidth  = Int32.Parse(captureSiteExtension.Value.Extension[7].Value.ToString());
                    converted = new Template(templateBuilder);
                }
                string captureSiteCode = biometricFHIR.Extension[1].Value.Extension[1].Value.ToString();
                string lateralityCode  = biometricFHIR.Extension[1].Value.Extension[2].Value.ToString();

                converted.NoID = FHIRToNoID(fhirMessage); //Gets the NoID Identifiers
                converted.NoID.CaptureSiteSnoMedCode = FHIRUtilities.SnoMedCaptureSiteNameToCode(captureSiteCode);
                converted.NoID.LateralitySnoMedCode  = UInt32.Parse(lateralityCode);
            }
            catch (Exception ex)
            {
                throw ex;
            }
            return(converted);
        }