static DB() { Patient = new PatientData(); Companion = new CompanionData(); Employee = new EmployeeData(); Breeds = new BreedsData(); Species = new SpeciesData(); Operation = new OperationData(); Disease = new DiseaseData(); Drug = new DrugData(); Prescription = new PrescriptionData(); }
/// <summary> /// Convert JSON Date /// </summary> /// <param name="jToken">Token</param> /// <returns>Patient Data Object</returns> /// <remarks></remarks> public static PatientData ConvertJsonDate(JToken jToken) { var data = new PatientData(); if (Utilities.IsJTokenValid(jToken)) { data.PatientOnSetAge = (jToken["patientonsetage"]).ToString(); data.PatientOnSetAgeUnit = (jToken["patientonsetageunit"]).ToString(); // patient.patientonsetageunit() //string //The unit of measurement for the patient.patientonsetage field. //800 = Decade //801 = Year //802 = Month //803 = Week //804 = Day //805 = Hour var patientSex = (int)data.PatientSex; int.TryParse((jToken["patientsex"]).ToString(), out patientSex); data.PatientSex = (PatientSex)patientSex; //data.patientsex = jToken("patientsex") // patient.patientsex() //string //The sex of the patient. //0 = Unknown //1 = Male //2 = Female data.PatientWeight = Utilities.GetJTokenString(jToken, "patientweight"); // KiloGrams if (Utilities.IsJTokenValid(Utilities.GetJTokenString(jToken, "patientdeath"))) { //data.PatientDeathDate = ConvertDateStringToDate(jToken("patientdeath")("patientdeathdate"), "yyyyMMdd") data.PatientDeathDate = DateTime.ParseExact((jToken["patientdeath"]["patientdeathdate"]).ToString(), "yyyyMMdd", CultureInfo.InvariantCulture); } data.Drug = DrugData.ConvertJsonData(jToken["drug"]); data.Reaction = ReactionData.ConvertJsonData(jToken["reaction"]); } return(data); }
public async Task OnGetAsync(int?id, int?categoryID) { DrugD = new DrugData(); DrugD.Drugs = await _context.Drug .Include(b => b.Partner) .Include(b => b.DrugCategories) .ThenInclude(b => b.Category) .AsNoTracking() .OrderBy(b => b.Name) .ToListAsync(); if (id != null) { DrugID = id.Value; Drug drug = DrugD.Drugs .Where(i => i.ID == id.Value).Single(); DrugD.Categories = drug.DrugCategories.Select(s => s.Category); } }
/// <summary> /// Convert JSON Data /// </summary> /// <param name="jToken">Token</param> /// <returns>List of Drug Data</returns> /// <remarks></remarks> public static List<DrugData> ConvertJsonData(JToken jToken) { var data = new List<DrugData>(); if (Utilities.IsJTokenValid(jToken)) { foreach (var drug in jToken) { var obj = new DrugData(); var actionDrug = (int) obj.ActionDrug; var drugRecurreAdministraton = (int) obj.DrugRecurreAdministration; var drugIntervalDosageDefinition = (int) obj.DrugIntervalDosageDefinition; var drugTreatmentDurationUnit = (int) obj.DrugTreatmentDurationUnit; var drugCumulativeDosageUnit = (int) obj.DrugCumulativeDosageUnit; var drugCharacterization = (int) obj.DrugCharacterization; int.TryParse((Utilities.GetJTokenString(drug, "actiondrug")), out actionDrug); obj.ActionDrug = (ActionDrug) actionDrug; int.TryParse((Utilities.GetJTokenString(drug, "drugrecurreadministration")), out drugRecurreAdministraton); obj.DrugRecurreAdministration = (DrugRecurreAdministration) drugRecurreAdministraton; obj.DrugIntervalDosageUnitNumb = (Utilities.GetJTokenString(drug, "drugintervaldosageunitnumb")); int.TryParse((Utilities.GetJTokenString(drug, "drugintervaldosagedefinition")), out drugIntervalDosageDefinition); obj.DrugIntervalDosageDefinition = (DrugIntervalDosageDefinition) drugIntervalDosageDefinition; obj.DrugTreatmentDuration = (Utilities.GetJTokenString(drug, "drugtreatmentduration")); int.TryParse((Utilities.GetJTokenString(drug, "drugtreatmentdurationunit")), out drugTreatmentDurationUnit); obj.DrugTreatmentDurationUnit = (DrugTreatmentDurationUnit) drugTreatmentDurationUnit; obj.DrugCumulativeDosageNumb = (Utilities.GetJTokenString(drug, "drugcumulativedosagenumb")); int.TryParse((Utilities.GetJTokenString(drug, "drugcumulativedosageunit")), out drugCumulativeDosageUnit); obj.DrugCumulativeDosageUnit = (DrugCumulativeDosageUnit) drugCumulativeDosageUnit; int.TryParse((Utilities.GetJTokenString(drug, "drugcharacterization")), out drugCharacterization); obj.DrugCharacterization = (DrugCharacterization) drugCharacterization; obj.DrugAdditional = (Utilities.GetJTokenString(drug, "drugadditional")); obj.DrugAuthorizationNumb = (Utilities.GetJTokenString(drug, "drugauthorizationnumb")); obj.DrugIndication = (Utilities.GetJTokenString(drug, "drugindication")); obj.MedicinalProduct = (Utilities.GetJTokenString(drug, "medicinalproduct")); obj.Drugadministrationroute = (Utilities.GetJTokenString(drug, "drugadministrationroute")); obj.DrugDosageText = (Utilities.GetJTokenString(drug, "drugdosagetext")); obj.DrugStartDate = (Utilities.GetJTokenString(drug, "drugstartdate")); obj.DrugStartDateFormat = (Utilities.GetJTokenString(drug, "drugstartdateformat")); obj.DrugEndDate = (Utilities.GetJTokenString(drug, "drugenddate")); obj.DrugEndDateFormat = (Utilities.GetJTokenString(drug, "drugenddateformat")); obj.DrugDosageForm = (Utilities.GetJTokenString(drug, "drugdosageform")); obj.OpenFDA = OpenFdaData.ConvertJsonData((JObject) Utilities.GetJTokenObject(drug, "openfda")); data.Add(obj); } } return data; }
/// <summary> /// Convert JSON Data /// </summary> /// <param name="jToken">Token</param> /// <returns>List of Drug Data</returns> /// <remarks></remarks> public static List <DrugData> ConvertJsonData(JToken jToken) { var data = new List <DrugData>(); if (Utilities.IsJTokenValid(jToken)) { foreach (var drug in jToken) { var obj = new DrugData(); var actionDrug = (int)obj.ActionDrug; var drugRecurreAdministraton = (int)obj.DrugRecurreAdministration; var drugIntervalDosageDefinition = (int)obj.DrugIntervalDosageDefinition; var drugTreatmentDurationUnit = (int)obj.DrugTreatmentDurationUnit; var drugCumulativeDosageUnit = (int)obj.DrugCumulativeDosageUnit; var drugCharacterization = (int)obj.DrugCharacterization; int.TryParse((Utilities.GetJTokenString(drug, "actiondrug")), out actionDrug); obj.ActionDrug = (ActionDrug)actionDrug; int.TryParse((Utilities.GetJTokenString(drug, "drugrecurreadministration")), out drugRecurreAdministraton); obj.DrugRecurreAdministration = (DrugRecurreAdministration)drugRecurreAdministraton; obj.DrugIntervalDosageUnitNumb = (Utilities.GetJTokenString(drug, "drugintervaldosageunitnumb")); int.TryParse((Utilities.GetJTokenString(drug, "drugintervaldosagedefinition")), out drugIntervalDosageDefinition); obj.DrugIntervalDosageDefinition = (DrugIntervalDosageDefinition)drugIntervalDosageDefinition; obj.DrugTreatmentDuration = (Utilities.GetJTokenString(drug, "drugtreatmentduration")); int.TryParse((Utilities.GetJTokenString(drug, "drugtreatmentdurationunit")), out drugTreatmentDurationUnit); obj.DrugTreatmentDurationUnit = (DrugTreatmentDurationUnit)drugTreatmentDurationUnit; obj.DrugCumulativeDosageNumb = (Utilities.GetJTokenString(drug, "drugcumulativedosagenumb")); int.TryParse((Utilities.GetJTokenString(drug, "drugcumulativedosageunit")), out drugCumulativeDosageUnit); obj.DrugCumulativeDosageUnit = (DrugCumulativeDosageUnit)drugCumulativeDosageUnit; int.TryParse((Utilities.GetJTokenString(drug, "drugcharacterization")), out drugCharacterization); obj.DrugCharacterization = (DrugCharacterization)drugCharacterization; obj.DrugAdditional = (Utilities.GetJTokenString(drug, "drugadditional")); obj.DrugAuthorizationNumb = (Utilities.GetJTokenString(drug, "drugauthorizationnumb")); obj.DrugIndication = (Utilities.GetJTokenString(drug, "drugindication")); obj.MedicinalProduct = (Utilities.GetJTokenString(drug, "medicinalproduct")); obj.Drugadministrationroute = (Utilities.GetJTokenString(drug, "drugadministrationroute")); obj.DrugDosageText = (Utilities.GetJTokenString(drug, "drugdosagetext")); obj.DrugStartDate = (Utilities.GetJTokenString(drug, "drugstartdate")); obj.DrugStartDateFormat = (Utilities.GetJTokenString(drug, "drugstartdateformat")); obj.DrugEndDate = (Utilities.GetJTokenString(drug, "drugenddate")); obj.DrugEndDateFormat = (Utilities.GetJTokenString(drug, "drugenddateformat")); obj.DrugDosageForm = (Utilities.GetJTokenString(drug, "drugdosageform")); obj.OpenFDA = OpenFdaData.ConvertJsonData((JObject)Utilities.GetJTokenObject(drug, "openfda")); data.Add(obj); } } return(data); }