/// <summary> /// Parse PrescriptionAdministrationRequestComponent /// </summary> public static Prescription.PrescriptionAdministrationRequestComponent ParsePrescriptionAdministrationRequestComponent(IFhirReader reader, ErrorList errors, Prescription.PrescriptionAdministrationRequestComponent existingInstance = null) { Prescription.PrescriptionAdministrationRequestComponent result = existingInstance != null ? existingInstance : new Prescription.PrescriptionAdministrationRequestComponent(); try { string currentElementName = reader.CurrentElementName; reader.EnterElement(); while (reader.HasMoreElements()) { // Parse element extension if (ParserUtils.IsAtFhirElement(reader, "extension")) { result.Extension = new List <Extension>(); reader.EnterArray(); while (ParserUtils.IsAtArrayElement(reader, "extension")) { result.Extension.Add(ExtensionParser.ParseExtension(reader, errors)); } reader.LeaveArray(); } // Parse element internalId else if (reader.IsAtRefIdElement()) { result.InternalId = Id.Parse(reader.ReadRefIdContents()); } // Parse element description else if (ParserUtils.IsAtFhirElement(reader, "description")) { result.Description = FhirStringParser.ParseFhirString(reader, errors); } // Parse element totalPeriodicDose else if (ParserUtils.IsAtFhirElement(reader, "totalPeriodicDose")) { result.TotalPeriodicDose = RatioParser.ParseRatio(reader, errors); } // Parse element start else if (ParserUtils.IsAtFhirElement(reader, "start")) { result.Start = FhirDateTimeParser.ParseFhirDateTime(reader, errors); } // Parse element end else if (ParserUtils.IsAtFhirElement(reader, "end")) { result.End = FhirDateTimeParser.ParseFhirDateTime(reader, errors); } // Parse element duration else if (ParserUtils.IsAtFhirElement(reader, "duration")) { result.Duration = QuantityParser.ParseQuantity(reader, errors); } // Parse element numberOfAdministrations else if (ParserUtils.IsAtFhirElement(reader, "numberOfAdministrations")) { result.NumberOfAdministrations = IntegerParser.ParseInteger(reader, errors); } // Parse element dosageInstruction else if (ParserUtils.IsAtFhirElement(reader, "dosageInstruction")) { result.DosageInstruction = new List <Prescription.PrescriptionAdministrationRequestDosageInstructionComponent>(); reader.EnterArray(); while (ParserUtils.IsAtArrayElement(reader, "dosageInstruction")) { result.DosageInstruction.Add(PrescriptionParser.ParsePrescriptionAdministrationRequestDosageInstructionComponent(reader, errors)); } reader.LeaveArray(); } else { errors.Add(String.Format("Encountered unknown element {0} while parsing {1}", reader.CurrentElementName, currentElementName), reader); reader.SkipSubElementsFor(currentElementName); result = null; } } reader.LeaveElement(); } catch (Exception ex) { errors.Add(ex.Message, reader); } return(result); }
public static void SerializePrescriptionAdministrationRequestComponent(Prescription.PrescriptionAdministrationRequestComponent value, IFhirWriter writer) { writer.WriteStartComplexContent(); // Serialize element's localId attribute if (value.InternalId != null && !String.IsNullOrEmpty(value.InternalId.Contents)) { writer.WriteRefIdContents(value.InternalId.Contents); } // Serialize element extension if (value.Extension != null && value.Extension.Count > 0) { writer.WriteStartArrayElement("extension"); foreach (var item in value.Extension) { writer.WriteStartArrayMember("extension"); ExtensionSerializer.SerializeExtension(item, writer); writer.WriteEndArrayMember(); } writer.WriteEndArrayElement(); } // Serialize element description if (value.Description != null) { writer.WriteStartElement("description"); FhirStringSerializer.SerializeFhirString(value.Description, writer); writer.WriteEndElement(); } // Serialize element totalPeriodicDose if (value.TotalPeriodicDose != null) { writer.WriteStartElement("totalPeriodicDose"); RatioSerializer.SerializeRatio(value.TotalPeriodicDose, writer); writer.WriteEndElement(); } // Serialize element start if (value.Start != null) { writer.WriteStartElement("start"); FhirDateTimeSerializer.SerializeFhirDateTime(value.Start, writer); writer.WriteEndElement(); } // Serialize element end if (value.End != null) { writer.WriteStartElement("end"); FhirDateTimeSerializer.SerializeFhirDateTime(value.End, writer); writer.WriteEndElement(); } // Serialize element duration if (value.Duration != null) { writer.WriteStartElement("duration"); QuantitySerializer.SerializeQuantity(value.Duration, writer); writer.WriteEndElement(); } // Serialize element numberOfAdministrations if (value.NumberOfAdministrations != null) { writer.WriteStartElement("numberOfAdministrations"); IntegerSerializer.SerializeInteger(value.NumberOfAdministrations, writer); writer.WriteEndElement(); } // Serialize element dosageInstruction if (value.DosageInstruction != null && value.DosageInstruction.Count > 0) { writer.WriteStartArrayElement("dosageInstruction"); foreach (var item in value.DosageInstruction) { writer.WriteStartArrayMember("dosageInstruction"); PrescriptionSerializer.SerializePrescriptionAdministrationRequestDosageInstructionComponent(item, writer); writer.WriteEndArrayMember(); } writer.WriteEndArrayElement(); } writer.WriteEndComplexContent(); }