Exemplo n.º 1
0
            /// <summary>
            ///     Convert JSON Data
            /// </summary>
            /// <param name="jsondata">JSON Object</param>
            /// <returns>MDR Text Data</returns>
            /// <remarks></remarks>
            public static List <DeviceEventMdrTextData> CnvJsonDataToList(JArray jsondata)
            {
                var result = new List <DeviceEventMdrTextData>();

                foreach (var obj in jsondata)
                {
                    var tmp = new DeviceEventMdrTextData();

                    tmp.PatientSequenceNumber = Utilities.GetJTokenString(obj, "patient_sequence_number");
                    tmp.TextTypeCode          = Utilities.GetJTokenString(obj, "text_type_code");
                    tmp.Text         = Utilities.GetJTokenString(obj, "text");
                    tmp.MdrTextKey   = Utilities.GetJTokenString(obj, "mdr_text_key");
                    tmp.DateReceived = Utilities.GetJTokenString(obj, "date_received");

                    result.Add(tmp);
                }

                return(result);
            }
            /// <summary>
            ///     Convert JSON Data
            /// </summary>
            /// <param name="jsondata">JSON Object</param>
            /// <returns>MDR Text Data</returns>
            /// <remarks></remarks>
            public static List<DeviceEventMdrTextData> CnvJsonDataToList(JArray jsondata)
            {
                var result = new List<DeviceEventMdrTextData>();

                foreach (var obj in jsondata)
                {
                    var tmp = new DeviceEventMdrTextData();

                    tmp.PatientSequenceNumber = Utilities.GetJTokenString(obj, "patient_sequence_number");
                    tmp.TextTypeCode = Utilities.GetJTokenString(obj, "text_type_code");
                    tmp.Text = Utilities.GetJTokenString(obj, "text");
                    tmp.MdrTextKey = Utilities.GetJTokenString(obj, "mdr_text_key");
                    tmp.DateReceived = Utilities.GetJTokenString(obj, "date_received");

                    result.Add(tmp);
                }

                return result;
            }
            /// <summary>
            ///     Convert JSON Data
            /// </summary>
            /// <param name="jsondata">JSON Object</param>
            /// <returns>List of Adverse Device Events</returns>
            /// <remarks></remarks>
            public static List <AdverseDeviceEvent> CnvJsonDataToList(JObject jsondata)
            {
                var result = new List <AdverseDeviceEvent>();

                //jsondata.dump("In")
                foreach (var obj in jsondata.GetValue("results"))
                {
                    //obj.Dump("Obj")
                    var tmp = new AdverseDeviceEvent();

                    tmp.AdverseEventFlag      = Utilities.GetJTokenString(obj, "adverse_event_flag");
                    tmp.ProductProblemFlag    = Utilities.GetJTokenString(obj, "product_problem_flag");
                    tmp.DateOfEvent           = Utilities.GetJTokenString(obj, "date_of_event");
                    tmp.DateReport            = Utilities.GetJTokenString(obj, "date_report");
                    tmp.DateReceived          = Utilities.GetJTokenString(obj, "date_received");
                    tmp.NumberDevicesInEvent  = Utilities.GetJTokenString(obj, "number_devices_in_event");
                    tmp.NumberPatientsInEvent = Utilities.GetJTokenString(obj, "number_patients_in_event");
                    //Source
                    tmp.ReportSourceCode         = Utilities.GetJTokenString(obj, "report_source_code");
                    tmp.HealthProfessional       = Utilities.GetJTokenString(obj, "health_professional");
                    tmp.ReporterOccupationCode   = Utilities.GetJTokenString(obj, "reporter_occupation_code");
                    tmp.InitialReportToFda       = Utilities.GetJTokenString(obj, "initial_report_to_fda");
                    tmp.ReprocessedAndReusedFlag = Utilities.GetJTokenString(obj, "reprocessed_and_reused_flag");

                    var reportTypes = obj.Value <JArray>("type_of_report");

                    if (reportTypes != null)
                    {
                        foreach (var itm in reportTypes)
                        {
                            tmp.TypeOfReport.Add((itm).ToString());
                        }
                    }

                    // Not an array
                    //var remedialAction = obj.Value<JArray>("remedial_action");

                    //if (remedialAction != null)
                    //{
                    //    foreach (var itm in remedialAction)
                    //    {
                    //        tmp.RemedialAction.Add((itm).ToString());
                    //    }
                    //}

                    var sourceType = obj.Value <JArray>("source_type");

                    if (sourceType != null)
                    {
                        foreach (var itm in sourceType)
                        {
                            tmp.SourceType.Add((itm).ToString());
                        }
                    }

                    tmp.DateFacilityAware        = Utilities.GetJTokenString(obj, "date_facility_aware");
                    tmp.ReportDate               = Utilities.GetJTokenString(obj, "report_date");
                    tmp.ReportToFda              = Utilities.GetJTokenString(obj, "report_to_fda");
                    tmp.DateReportToFda          = Utilities.GetJTokenString(obj, "date_report_to_fda");
                    tmp.ReportToManufacturer     = Utilities.GetJTokenString(obj, "report_to_manufacturer");
                    tmp.DateReportToManufacturer = Utilities.GetJTokenString(obj, "date_report_to_manufacturer");
                    tmp.EventLocation            = Utilities.GetJTokenString(obj, "event_location");

                    tmp.DistributorName       = Utilities.GetJTokenString(obj, "distributor_name");
                    tmp.DistributorAddress1   = Utilities.GetJTokenString(obj, "distributor_address_1");
                    tmp.DistributorAddress2   = Utilities.GetJTokenString(obj, "distributor_address_2");
                    tmp.DistributorCity       = Utilities.GetJTokenString(obj, "distributor_city");
                    tmp.DistributorState      = Utilities.GetJTokenString(obj, "distributor_state");
                    tmp.DistributorZipCode    = Utilities.GetJTokenString(obj, "distributor_zip_code");
                    tmp.DistributorZipCodeExt = Utilities.GetJTokenString(obj, "distributor_zip_code_ext");

                    tmp.ManufacturerName       = Utilities.GetJTokenString(obj, "manufacturer_name");
                    tmp.ManufacturerAddress1   = Utilities.GetJTokenString(obj, "manufacturer_address_1");
                    tmp.ManufacturerAddress2   = Utilities.GetJTokenString(obj, "manufacturer_address_2");
                    tmp.ManufacturerCity       = Utilities.GetJTokenString(obj, "manufacturer_city");
                    tmp.ManufacturerState      = Utilities.GetJTokenString(obj, "manufacturer_state");
                    tmp.ManufacturerZipCode    = Utilities.GetJTokenString(obj, "manufacturer_zip_code");
                    tmp.ManufacturerZipCodeExt = Utilities.GetJTokenString(obj, "manufacturer_zip_code_ext");
                    tmp.ManufacturerCountry    = Utilities.GetJTokenString(obj, "manufacturer_country");
                    tmp.ManufacturerPostalCode = Utilities.GetJTokenString(obj, "manufacturer_postal_code");

                    tmp.EventType = Utilities.GetJTokenString(obj, "event_type");
                    tmp.DeviceDateOfManufacture = Utilities.GetJTokenString(obj, "device_date_of_manufacture");
                    tmp.SingleUseFlag           = Utilities.GetJTokenString(obj, "single_use_flag");
                    tmp.PreviousUseCode         = Utilities.GetJTokenString(obj, "previous_use_code");

                    tmp.RemovalCorrectionNumber = Utilities.GetJTokenString(obj, "removal_correction_number");

                    tmp.ManufactureContactNameTitle = Utilities.GetJTokenString(obj, "manufacturer_contact_t_name");
                    tmp.ManufactureContactNameFirst = Utilities.GetJTokenString(obj, "manufacturer_contact_f_name");
                    tmp.ManufactureContactNameLast  = Utilities.GetJTokenString(obj, "manufacturer_contact_l_name");

                    tmp.ManufactureContactStreet1    = Utilities.GetJTokenString(obj, "manufacturer_contact_street_1");
                    tmp.ManufactureContactStreet2    = Utilities.GetJTokenString(obj, "manufacturer_contact_street_2");
                    tmp.ManufactureContactCity       = Utilities.GetJTokenString(obj, "manufacturer_contact_city");
                    tmp.ManufactureContactState      = Utilities.GetJTokenString(obj, "manufacturer_contact_state");
                    tmp.ManufactureContactZipCode    = Utilities.GetJTokenString(obj, "manufacturer_contact_zip_code");
                    tmp.ManufactureContactZipCodeExt = Utilities.GetJTokenString(obj, "manufacturer_contact_zip_ext");
                    tmp.ManufactureContactPostal     = Utilities.GetJTokenString(obj, "manufacturer_contact_postal");
                    tmp.ManufactureContactCountry    = Utilities.GetJTokenString(obj, "manufacturer_contact_country");

                    tmp.ManufactureContactPhoneCountry   = Utilities.GetJTokenString(obj, "manufacturer_contact_pcountry");
                    tmp.ManufactureContactPhoneAreaCode  = Utilities.GetJTokenString(obj, "manufacturer_contact_area_code");
                    tmp.ManufactureContactPhoneExchange  = Utilities.GetJTokenString(obj, "manufacturer_contact_exchange");
                    tmp.ManufactureContactPhoneExtension = Utilities.GetJTokenString(obj, "manufacturer_contact_extension");
                    tmp.ManufactureContactPhoneCity      = Utilities.GetJTokenString(obj, "manufacturer_contact_pcity");
                    tmp.ManufactureContactPhoneNumber    = Utilities.GetJTokenString(obj, "manufacturer_contact_phone_number");
                    tmp.ManufactureContactLocal          = Utilities.GetJTokenString(obj, "manufacturer_contact_plocal");

                    tmp.ManufactureName          = Utilities.GetJTokenString(obj, "manufacturer_g1_name");
                    tmp.ManufactureStreet1       = Utilities.GetJTokenString(obj, "manufacturer_g1_street_1");
                    tmp.ManufactureStreet2       = Utilities.GetJTokenString(obj, "manufacturer_g1_street_2");
                    tmp.ManufactureCity          = Utilities.GetJTokenString(obj, "manufacturer_g1_city");
                    tmp.ManufactureState         = Utilities.GetJTokenString(obj, "manufacturer_g1_state");
                    tmp.ManufactureZipCode       = Utilities.GetJTokenString(obj, "manufacturer_g1_zip_code");
                    tmp.ManufactureZipCodeExt    = Utilities.GetJTokenString(obj, "manufacturer_g1_zip_ext");
                    tmp.ManufacturePostalCode    = Utilities.GetJTokenString(obj, "manufacturer_g1_postal_code");
                    tmp.ManufactureCountry       = Utilities.GetJTokenString(obj, "manufacturer_g1_country");
                    tmp.DateManufacturerReceived = Utilities.GetJTokenString(obj, "date_manufacturer_received");

                    tmp.EventKey             = Utilities.GetJTokenString(obj, "event_key");
                    tmp.MdrReportKey         = Utilities.GetJTokenString(obj, "mdr_report_key");
                    tmp.ManufacturerLinkFlag = Utilities.GetJTokenString(obj, "manufacturer_link_flag_");

                    tmp.Device  = DeviceEventDeviceData.CnvJsonDataToList((JArray)Utilities.GetJTokenObject(obj, "device"));
                    tmp.Patient = DeviceEventPatientData.CnvJsonDataToList((JArray)Utilities.GetJTokenObject(obj, "patient"));
                    tmp.MdrText = DeviceEventMdrTextData.CnvJsonDataToList((JArray)Utilities.GetJTokenObject(obj, "mdr_text"));

                    result.Add(tmp);
                }

                return(result);
            }