/// <summary>
        /// Process a response message doing query continuation if needed
        /// </summary>
        private void PushPatientsAsync(Object state)
        {
            Int32 childId = (Int32)state;

            // Get the child record
            try
            {
                GIIS.DataLayer.Child child = GIIS.DataLayer.Child.GetChildById(childId);


                // Determine if this is an update to information (A08) or registration (A04)
                using (var dao = new SyncData())
                {
                    ADT_A01 request = this.CreateADT(child, dao);

                    ActionType action = ActionType.Create;
                    String     ecid   = dao.GetPatientEcid(childId);
                    if (ecid == null) // no ECID = Register
                    {
                        this.UpdateMSH(request.MSH, "ADT_A01", "ADT", "A04");
                    }
                    else
                    {
                        this.UpdateMSH(request.MSH, "ADT_A01", "ADT", "A08");
                        action = ActionType.Update;
                    }

                    // Send the message
                    var response = this.m_sender.SendAndReceive(request) as NHapi.Model.V231.Message.ACK;
                    AuditUtil.SendPIXAudit(request, response);
                    if (response == null || !response.MSA.AcknowledgementCode.Value.EndsWith("A"))
                    {
                        Trace.TraceError("{0}: Error registering the child in HIE (child id#{1})", this.m_context.JobId, childId);
                        foreach (var err in response.ERR.GetErrorCodeAndLocation())
                        {
                            Trace.TraceError("{0}: CR ERR: {1} ({2})", this.m_context.JobId, err.CodeIdentifyingError.Text, err.CodeIdentifyingError.AlternateText);
                        }
                        // Kill!
                        Trace.TraceError("Stopping sync");
                        this.m_errorState = true;
                        return;
                    }

                    // Get the ECID if not already got
                    if (action == ActionType.Create)
                    {
                        var pixSearch   = this.CreatePIXSearch(child.Id, ConfigurationManager.AppSettings["giis_child_id_oid"], ConfigurationManager.AppSettings["ecid"]);
                        var pixResponse = this.m_sender.SendAndReceive(pixSearch) as RSP_K23;
                        AuditUtil.SendPIXAudit(pixSearch, pixResponse);
                        // Is the response success?
                        if (pixResponse == null || pixResponse.QAK.QueryResponseStatus.Value != "OK")
                        {
                            Trace.TraceError("{0}: Error retrieving the ECID for created patient", this.m_context.JobId);
                            foreach (var err in pixResponse.ERR.GetErrorCodeAndLocation())
                            {
                                Trace.TraceError("{0}: CR ERR: {1} ({2})", this.m_context.JobId, err.CodeIdentifyingError.Text, err.CodeIdentifyingError.AlternateText);
                            }
                            // Kill!
                            Trace.TraceError("Stopping sync");
                            this.m_errorState = true;
                            return;
                        }
                        else
                        {
                            var cx = pixResponse.QUERY_RESPONSE.PID.GetPatientIdentifierList(0);
                            // Sanity check
                            if (cx.AssigningAuthority.UniversalID.Value.Equals(ConfigurationManager.AppSettings["ecid"]))
                            {
                                ecid = cx.IDNumber.Value;
                            }
                            else
                            {
                                Trace.TraceError("{0}: Should not be here! CX.4 indicates ECID OID is {1} but configuration is {2}?", this.m_context.JobId, cx.AssigningAuthority.UniversalID.Value, ConfigurationManager.AppSettings["ecid"]);
                                this.m_errorState = true;
                                return;
                            }
                        }
                    }

                    // Update
                    if (String.IsNullOrEmpty(child.TempId))
                    {
                        child.TempId = ecid;
                    }

                    child.ModifiedOn = DateTime.Now;
                    child.ModifiedBy = Int32.Parse(ConfigurationManager.AppSettings["giis_authority_user_id"]);
                    GIIS.DataLayer.Child.Update(child);

                    dao.RegisterPatientSync(childId, this.m_context.JobId, action, ecid);
                    dao.Commit();
                }
            }
            catch (Exception e)
            {
                Trace.TraceError(e.ToString());
                this.m_errorState = true;
            }
        }