public string GetMultiStatement(Observation observation) { var mConcept = GetMConcept(observation.MConceptId); if (null == mConcept) { Log.Debug($"No concept {observation.MConceptId} for mulit-statement"); return(string.Empty); } var iqConcept = mConcept.IQConcepts.FirstOrDefault(); if (null == iqConcept) { Log.Debug($"No iq-concept for {observation.MConceptId}"); return(string.Empty); } StringBuilder multi = new StringBuilder(); multi.AppendLine($@" DELETE FROM [{iqConcept.Tablename}] WHERE Ptn_pk=@ptnpk AND Visit_Pk=@visitipk AND LocationId=(select TOP 1 FacilityID from mst_Facility WHERE DeleteFlag = 0);" ); foreach (var choice in observation.GetMultipleChoices()) { multi.AppendLine($@" Insert into [{iqConcept.Tablename}] ( [ptn_pk], [Visit_Pk], [LocationID],[{iqConcept.Fieldname}],UserId, [CreateDate], DateField1, DateField2, NumericField) values ( @ptnpk,@visitipk,(select TOP 1 FacilityID from mst_Facility WHERE DeleteFlag = 0),{choice},{Patient.UserId},Getdate(),Getdate(), Getdate(), 0);"); } return(multi.ToString()); }