예제 #1
0
        /// <summary>
        /// Deserialize JSON into a FHIR MessageHeader#Response
        /// </summary>
        public static void DeserializeJson(this MessageHeader.ResponseComponent current, ref Utf8JsonReader reader, JsonSerializerOptions options)
        {
            string propertyName;

            while (reader.Read())
            {
                if (reader.TokenType == JsonTokenType.EndObject)
                {
                    return;
                }

                if (reader.TokenType == JsonTokenType.PropertyName)
                {
                    propertyName = reader.GetString();
                    if (Hl7.Fhir.Serialization.FhirSerializerOptions.Debug)
                    {
                        Console.WriteLine($"MessageHeader.ResponseComponent >>> MessageHeader#Response.{propertyName}, depth: {reader.CurrentDepth}, pos: {reader.BytesConsumed}");
                    }
                    reader.Read();
                    current.DeserializeJsonProperty(ref reader, options, propertyName);
                }
            }

            throw new JsonException($"MessageHeader.ResponseComponent: invalid state! depth: {reader.CurrentDepth}, pos: {reader.BytesConsumed}");
        }
예제 #2
0
 /// <summary>Constructor that creates an acknowledgement for the specified message.</summary>
 /// <param name="messageId">the id of the message to create an acknowledgement for.</param>
 /// <param name="destination">the endpoint identifier that the ack message will be sent to.</param>
 /// <param name="source">the endpoint identifier that the ack message will be sent from.</param>
 public AckMessage(string messageId, string destination, string source = "http://nchs.cdc.gov/vrdr_submission") : base("http://nchs.cdc.gov/vrdr_acknowledgement")
 {
     Header.Source.Endpoint  = source;
     this.MessageDestination = destination;
     MessageHeader.ResponseComponent resp = new MessageHeader.ResponseComponent();
     resp.Identifier = messageId;
     resp.Code       = MessageHeader.ResponseType.Ok;
     Header.Response = resp;
 }
예제 #3
0
        /// <summary>
        /// Deserialize JSON into a FHIR MessageHeader#Response
        /// </summary>
        public static void DeserializeJsonProperty(this MessageHeader.ResponseComponent current, ref Utf8JsonReader reader, JsonSerializerOptions options, string propertyName)
        {
            switch (propertyName)
            {
            case "identifier":
                if (reader.TokenType == JsonTokenType.Null)
                {
                    current.IdentifierElement = new Id();
                    reader.Skip();
                }
                else
                {
                    current.IdentifierElement = new Id(reader.GetString());
                }
                break;

            case "_identifier":
                if (current.IdentifierElement == null)
                {
                    current.IdentifierElement = new Id();
                }
                ((Hl7.Fhir.Model.Element)current.IdentifierElement).DeserializeJson(ref reader, options);
                break;

            case "code":
                if (reader.TokenType == JsonTokenType.Null)
                {
                    current.CodeElement = new Code <Hl7.Fhir.Model.MessageHeader.ResponseType>();
                    reader.Skip();
                }
                else
                {
                    current.CodeElement = new Code <Hl7.Fhir.Model.MessageHeader.ResponseType>(Hl7.Fhir.Utility.EnumUtility.ParseLiteral <Hl7.Fhir.Model.MessageHeader.ResponseType>(reader.GetString()));
                }
                break;

            case "_code":
                if (current.CodeElement == null)
                {
                    current.CodeElement = new Code <Hl7.Fhir.Model.MessageHeader.ResponseType>();
                }
                ((Hl7.Fhir.Model.Element)current.CodeElement).DeserializeJson(ref reader, options);
                break;

            case "details":
                current.Details = new Hl7.Fhir.Model.ResourceReference();
                ((Hl7.Fhir.Model.ResourceReference)current.Details).DeserializeJson(ref reader, options);
                break;

            // Complex: response, Export: ResponseComponent, Base: BackboneElement
            default:
                ((Hl7.Fhir.Model.BackboneElement)current).DeserializeJsonProperty(ref reader, options, propertyName);
                break;
            }
        }
        /// <summary>Constructor that creates an extraction error message for the specified message.</summary>
        /// <param name="messageId">the id of the message to create an extraction error for.</param>
        /// <param name="destination">the endpoint identifier that the extraction error message will be sent to.</param>
        /// <param name="source">the endpoint identifier that the extraction error message will be sent from.</param>
        public ExtractionErrorMessage(string messageId, string destination, string source = "http://nchs.cdc.gov/vrdr_submission") : base("http://nchs.cdc.gov/vrdr_extraction_error")
        {
            Header.Source.Endpoint  = source;
            this.MessageDestination = destination;
            MessageHeader.ResponseComponent resp = new MessageHeader.ResponseComponent();
            resp.Identifier = messageId;
            resp.Code       = MessageHeader.ResponseType.FatalError;
            Header.Response = resp;

            this.details    = new OperationOutcome();
            this.details.Id = Guid.NewGuid().ToString();
            MessageBundle.AddResourceEntry(this.details, "urn:uuid:" + this.details.Id);
            Header.Response.Details = new ResourceReference("urn:uuid:" + this.details.Id);
        }
예제 #5
0
        /// <summary>
        /// Serialize a FHIR MessageHeader#Response into JSON
        /// </summary>
        public static void SerializeJson(this MessageHeader.ResponseComponent current, Utf8JsonWriter writer, JsonSerializerOptions options, bool includeStartObject = true)
        {
            if (includeStartObject)
            {
                writer.WriteStartObject();
            }
            // Component: MessageHeader#Response, Export: ResponseComponent, Base: BackboneElement (BackboneElement)
            ((Hl7.Fhir.Model.BackboneElement)current).SerializeJson(writer, options, false);

            writer.WriteString("identifier", current.IdentifierElement.Value);

            writer.WriteString("code", Hl7.Fhir.Utility.EnumUtility.GetLiteral(current.CodeElement.Value));

            if (current.Details != null)
            {
                writer.WritePropertyName("details");
                current.Details.SerializeJson(writer, options);
            }

            if (includeStartObject)
            {
                writer.WriteEndObject();
            }
        }