public static string GetXml(NotesModel notes, bool acceptDefaults, Dictionary<string, string> dict) { dict = (dict == null) ? new Dictionary<string, string>() : dict; StringWriter stringWriter = new StringWriter(); XmlWriterSettings settings = new XmlWriterSettings(); settings.CheckCharacters = false; XmlWriter xmlWriter = XmlWriter.Create(stringWriter, settings); xmlWriter.WriteProcessingInstruction("xml", "version=\"1.0\" encoding=\"UTF-8\" standalone=\"yes\""); xmlWriter.WriteStartElement("patient"); //getting the properties from the model PropertyInfo[] notesFields = notes.GetType().GetProperties(); Field field; foreach (var pi in notesFields) { if (pi.PropertyType == typeof(Field)) { field = (Field)pi.GetValue(notes); if (field == null) { field = new Field() { Name = pi.Name, Value = String.Empty, ColourType = (int)PosConstants.ColourType.Normal }; } if (field.Value == null) field.Value = String.Empty; if (dict.ContainsKey(field.Name) && dict[field.Name] != field.Value.Trim()) { field.ColourType = (int)PosConstants.ColourType.Correct; } else if (acceptDefaults) { field.ColourType = (int)PosConstants.ColourType.Normal; } xmlWriter.WriteStartElement(field.Name); xmlWriter.WriteAttributeString("CustomColourType", field.ColourType.ToString()); xmlWriter.WriteCData(field.Value.Trim()); xmlWriter.WriteEndElement(); } } xmlWriter.WriteEndElement(); xmlWriter.Flush(); xmlWriter.Close(); stringWriter.Flush(); string xml = stringWriter.ToString(); stringWriter.Dispose(); return xml; }
public static void ExamDataSave(int examID, int patientID, NotesModel notes) { PropertyInfo[] notesFields = notes.GetType().GetProperties(); Field field; PropertyInfo pi; Dictionary<string, string> dicJson; ExamData data = new ExamData(); using(var db = new PosEntities()) { var dataConfigurationQuery = from dbConfig in db.ExamDataConfigurations select dbConfig; foreach(var config in dataConfigurationQuery) { dicJson = new Dictionary<string, string>(); if (config.FieldDataType == (int)PosConstants.FieldDataType.Json) { string[] examFields = config.Field.Replace(" ", "") .Split(','); foreach(string examField in examFields) { pi = notesFields.First(f => f.Name == examField); field = (Field) pi.GetValue(notes); dicJson.Add(field.Name, field.Value); } data = new ExamData() { PatientID = patientID, ExamID = examID, ExamDataConfigurationID = config.ExamDataConfigurationID, FieldName = config.Name, FieldValue = JsonConvert.SerializeObject(dicJson), FieldDataType = (int)PosConstants.FieldDataType.Json }; } db.ExamDatas.Add(data); } //finally saving db.SaveChanges(); } }
private void SetPropertyValue(NotesModel notes, PropertyInfo pi, string fieldValue, int colourType) { if (pi == null) return; Field field = (Field)pi.GetValue(notes); if (field == null) { field = new Field(); field.Name = pi.Name; pi.SetValue(notes, field); } field.Value = fieldValue; field.ColourType = colourType; if (notes.NotesType == PosConstants.NotesType.New) { if (fieldValue != "" && fieldValue != "OU") field.ColourType = (int)PosConstants.ColourType.New; } }
private void SetProperty(NotesModel notes, PropertyInfo pi, string fieldName, string fieldValue, int colourType, List<SelectListItem> examLookUp) { if (pi != null && pi.PropertyType == typeof(Field)) { Field field = new Field() { Name = fieldName }; //setting the colour type //setting the loopup var lookupItem = examLookUp.FirstOrDefault(m => m.Text.Trim() == fieldName.Trim()); if (lookupItem != null) { field.LookUpFieldName = lookupItem.Value; } if(patientFields.Contains(fieldName)) { field.FieldType = (int) PosConstants.FieldType.Patient; } else { field.FieldType = (int) PosConstants.FieldType.Notes; } pi.SetValue(notes, field); SetPropertyValue(notes, pi, fieldValue, colourType); } }
private void SetPriorValues(NotesModel notes) { SetFieldValue(notes.LastManRfxOD1, notes.ManRfxOD1.Value); SetFieldValue(notes.LastManRfxOD2, notes.ManRfxOD2.Value); SetFieldValue(notes.LastManVAOD1, notes.ManVAOD1.Value); SetFieldValue(notes.LastManVAOD2, notes.ManVAOD2.Value); SetFieldValue(notes.LastCycRfxOD, notes.CycRfxOD.Value); SetFieldValue(notes.LastCycVAOD3, notes.CycVAOD3.Value); SetFieldValue(notes.LastCycVAOD4, notes.CycVAOD4.Value); SetFieldValue(notes.LastManRfxOS1, notes.ManRfxOS1.Value); SetFieldValue(notes.LastManRfxOS2, notes.ManRfxOS2.Value); SetFieldValue(notes.LastManVSOS1, notes.ManVSOS1.Value); SetFieldValue(notes.LastManVSOS2, notes.ManVSOS2.Value); SetFieldValue(notes.LastCycRfxOS, notes.CycRfxOS.Value); SetFieldValue(notes.LastCycVSOS1, notes.CycVSOS1.Value); SetFieldValue(notes.LastCycVSOS2, notes.CycVSOS2.Value); //setting the original values to blank SetFieldValue(notes.ManRfxOD1, ""); SetFieldValue(notes.ManRfxOD2, ""); SetFieldValue(notes.ManVAOD1, ""); SetFieldValue(notes.ManVAOD2, ""); SetFieldValue(notes.CycRfxOD, ""); SetFieldValue(notes.CycVAOD3, ""); SetFieldValue(notes.CycVAOD4, ""); SetFieldValue(notes.ManRfxOS1, ""); SetFieldValue(notes.ManRfxOS2, ""); SetFieldValue(notes.ManVSOS1, ""); SetFieldValue(notes.ManVSOS2, ""); SetFieldValue(notes.CycRfxOS, ""); SetFieldValue(notes.CycVSOS1, ""); SetFieldValue(notes.CycVSOS2, ""); }
private void SetPatientInfo(PatientModel patient, NotesModel notes) { SetPatientField(notes.patientID, patient.PatientID.ToString()); SetPatientField(notes.hdnPatientID, patient.PatientID.ToString()); SetPatientField(notes.PatientNumber, patient.PatientNumber.ToString()); SetPatientField(notes.Greeting, patient.Greeting); SetPatientField(notes.FirstName, patient.FirstName); SetPatientField(notes.MiddleName, patient.MiddleName); SetPatientField(notes.LastName, patient.LastName); SetPatientField(notes.NickName, patient.NickName); SetPatientField(notes.PatientName, patient.FirstName + " " + patient.LastName); SetPatientField(notes.DOB, patient.DateOfBirth.Value.ToShortDateString()); SetPatientField(notes.Sex, patient.Sex); SetPatientField(notes.PrematureBirth, patient.PrematureBirth == null ? false.ToString() : patient.PrematureBirth.Value.ToString()); SetPatientField(notes.HxFrom, patient.HxFrom); SetPatientField(notes.RefDoctor, patient.ReferredDoctor); SetPatientField(notes.Refd, patient.ReferredFrom); SetPatientField(notes.Allergies, patient.Allergies); SetPatientField(notes.Occupation, patient.Occupation); notes.tbAge.ColourType = (int)PosConstants.ColourType.Normal; }
private void SetIdDates(ExamModel exam, NotesModel notes, int patientID) { if (notes.NotesType == PosConstants.NotesType.New) exam.ExamID = 0; notes.hdnPatientID = new Field() { Name = "hdnPatientID", Value = patientID.ToString() }; if (exam.ExamID > 0) { notes.ExamDate = new Field() { Name = "ExamDate", Value = exam.ExamDate.ToShortDateString() }; notes.hdnExamID = new Field() { Name = "hdnExamID", Value = exam.ExamID.ToString() }; } else { notes.ExamDate = new Field() { Name = "ExamDate", Value = DateTime.Now.ToShortDateString() }; notes.LastExam = new Field() { Name = "LastExam", Value = exam.ExamDate != DateTime.MinValue ? exam.ExamDate.ToShortDateString() : null }; notes.hdnExamID = null; } //setting ExamDate & Correct Date if (notes.NotesType == PosConstants.NotesType.Correct && exam.CorrectExamID != null) { notes.ExamCorrectDate = new Field() { Name = "ExamCorrectDate", Value = exam.ExamCorrectDate.Value.ToShortDateString() }; } else { notes.ExamCorrectDate = null; } if (notes.NotesType == PosConstants.NotesType.Saved) { notes.ExamSaveDate = new Field() { Name = "ExamSaveDate", Value = exam.LastUpdatedDate.ToString() }; } else { notes.ExamSaveDate = null; } }
private void GetNotesFromXml(NotesModel notes, string examText) { PropertyInfo[] notesFields = notes.GetType().GetProperties(); //looping through the xml and setting the Notes StringReader stringReader = new StringReader(examText); XmlReaderSettings settings = new XmlReaderSettings(); settings.CheckCharacters = false; XmlReader reader = XmlReader.Create(stringReader, settings); string fieldName = ""; string fieldValue = ""; string fieldAttr = ""; while (reader.Read()) { switch (reader.NodeType) { case XmlNodeType.Element: fieldName = reader.Name; fieldAttr = reader.GetAttribute("CustomColourType"); fieldAttr = fieldAttr == "" ? "0" : fieldAttr; break; case XmlNodeType.Text: fieldValue = reader.Value; break; case XmlNodeType.CDATA: fieldValue = reader.Value; break; case XmlNodeType.EndElement: if (fieldName != "") { //SetControlValue(fieldName, fieldValue, fieldAttr); PropertyInfo pi = notesFields.FirstOrDefault(p => p.Name == fieldName); SetPropertyValue(notes, pi, fieldValue, Convert.ToInt32(fieldAttr)); fieldName = ""; fieldValue = ""; fieldAttr = ""; } break; } } reader.Close(); stringReader.Close(); stringReader.Dispose(); }
private NotesModel GetNotesFromXml(string examText) { NotesModel notes = new NotesModel(); GetNotesFromXml(notes, examText); return notes; }
private NotesViewModel GetBlankNotes(string userName) { NotesViewModel notesVM = new NotesViewModel(); NotesModel notes = new NotesModel() { NotesType = PosConstants.NotesType.New }; notesVM.Notes = notes; notesVM.Doctors = PosRepository.DoctorsGet(); notesVM.AutoComplete = PosRepository.AutoCorrectGet(userName); List<SelectListItem> examLookUp = PosRepository.ExamLookUpGet(); PropertyInfo[] notesFields = notes.GetType().GetProperties(); foreach (var pi in notesFields) { SetProperty(notes, pi, pi.Name, "", (int)PosConstants.ColourType.Normal, examLookUp); } return notesVM; }
public string Save(PosConstants.NotesSaveType saveType, NotesModel model) { string message = String.Empty; ExamModel exam = new ExamModel() { ExamID = model.hdnExamID != null ? Convert.ToInt32(model.hdnExamID.Value) : 0, ExamDate = Convert.ToDateTime(model.ExamDate.Value), PatientID = Convert.ToInt32(model.hdnPatientID.Value), UserName = model.User.Value, SaveInd = 0, LastUpdatedDate = DateTime.Now, ExamCorrectDate = DateTime.Now, CorrectExamID = null, }; switch (saveType) { case PosConstants.NotesSaveType.Save: message = PosMessage.NotesSaveSuccessful; exam.ExamText = WebUtil.GetXml(model, false, null); exam.SaveInd = 1; break; case PosConstants.NotesSaveType.SignOff: message = PosMessage.NotesSignOffSuccessful; exam.ExamText = WebUtil.GetXml(model, true, null); break; case PosConstants.NotesSaveType.Correct: message = PosMessage.NotesCorrectSuccessful; exam.CorrectExamID = exam.ExamID; exam.ExamID = 0; //getting the original exam ExamModel orginalExam = PatientRepository.ExamGet(exam.PatientID, exam.CorrectExamID); Dictionary<string, string> dict = WebUtil.GetDictionary(orginalExam.ExamText, false); exam.ExamText = WebUtil.GetXml(model, true, dict); break; default: message = String.Empty; break; } PatientRepository.ExamSave(exam); //removing & creating print queue if (saveType == PosConstants.NotesSaveType.Correct) { PosRepository.PrintQueueRemove(exam.CorrectExamID.Value); } if(saveType == PosConstants.NotesSaveType.SignOff || saveType == PosConstants.NotesSaveType.Correct) { //saving additional data PatientRepository.ExamDataSave(exam.ExamID, exam.PatientID, model); if(model.cbPrintQueue.Value == true.ToString()) PosRepository.PrintQueueAdd(new PrintQueueItem() { ExamID = exam.ExamID, UserName = exam.UserName, PrintExamNote = null }); if(model.ExamNoteTo.Value != "") PosRepository.PrintQueueAdd(new PrintQueueItem() { ExamID = exam.ExamID, UserName = exam.UserName, PrintExamNote = true }); } return message; }