Ejemplo n.º 1
0
        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;
        }
Ejemplo n.º 2
0
        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;
            }
        }
Ejemplo n.º 3
0
 private void SetPatientField(Field field, string value)
 {
     field.Value = value;
     field.ColourType = (int) PosConstants.ColourType.Normal;
     field.FieldType = (int)PosConstants.FieldType.Patient;
 }
Ejemplo n.º 4
0
        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);
            }
        }
Ejemplo n.º 5
0
 private void SetFieldValue(Field field, string value)
 {
     field.Value = value;
     field.ColourType = (int)PosConstants.ColourType.Normal;
 }