public IEnumerable <Model.Person> LoadPeople(Model.OrderSection section, Model.ProphSubsection subsection) { string sql = SectionizeQuery(Queries.SELECT_PEOPLE, section, subsection); sql = RecoursizeQuery(sql); return(aPerson.Load(connectionMain, LocalizeQuery(sql))); }
public IEnumerable <Model.Recourse> LoadRecourses(Model.InvoiceRecord irec, Model.OrderSection section, Model.ProphSubsection subsection) { // Query is cached if (section != lastRecoursesSection || lastRecourceSubsection != subsection) { selectRecourses = null; lastRecoursesSection = section; lastRecourceSubsection = subsection; } if (selectRecourses == null) { string sql = LocalizeQuery(Queries.SELECT_RECOURSES); sql = RecoursizeQuery(sql); selectRecourses = connectionAlt.CreateCommand(); selectRecourses.CommandText = SectionizeQuery(sql, section, subsection); AddStringParameters(selectRecourses, SELECT_RECOURSE_CASES_PARAMS); } string id = string.Format("{0,6}", irec.Person.Identity); selectRecourses.Parameters[0].Value = id; List <RecourseAux> rs = aRecourse.Load(selectRecourses).ToList(); foreach (RecourseAux ra in rs) { Model.Recourse rec = ra.ToRecourse(); invox.Dict.ResultOutcome.Instance.Repair(rec); rec.Events = LoadEvents(rec, ra, section); yield return(rec); } }
public decimal Total(Model.OrderSection section, Model.ProphSubsection subsection) { string sql = SectionizeQuery(Queries.SELECT_TOTAL, section, subsection); object result = ExecuteScalar(connectionMain, LocalizeQuery(sql)); return(result != null && result != DBNull.Value ? (decimal)result : 0); }
/// <summary> /// Подставить в запрос коды отделений в соответствие разделу приложения Д к приказу /// </summary> string SectionizeQuery(string sql, Model.OrderSection section, Model.ProphSubsection subsection) { switch (section) { case Model.OrderSection.D1: return(sql.Replace(APPENDIX_SECTION_MARKER, D1_SELECTION)); case Model.OrderSection.D2: return(sql.Replace(APPENDIX_SECTION_MARKER, D2_SELECTION)); case Model.OrderSection.D3: switch (subsection) { case Model.ProphSubsection.Stage1: return(sql.Replace(APPENDIX_SECTION_MARKER, D3_SELECTION_STAGE1)); case Model.ProphSubsection.Stage2: return(sql.Replace(APPENDIX_SECTION_MARKER, D3_SELECTION_STAGE2)); case Model.ProphSubsection.Prophylaxis: return(sql.Replace(APPENDIX_SECTION_MARKER, D3_SELECTION_PROF)); default: throw new NotImplementedException(); } case Model.OrderSection.D4: return(sql.Replace(APPENDIX_SECTION_MARKER, D4_SELECTION)); } return(sql); }
/// <summary> /// Ctor /// </summary> /// <param name="location">Каталог Релакс</param> /// <param name="lpuCode">Код ЛПУ (релаксовский)</param> /// <param name="period">Каталог текущего периода (от корневого каталога Релакс)</param> public Pool(string location, string lpuCode, string period, SQL.Medialog medialog) { this.period = period; this.lpuCode = lpuCode; lastRecourceSubsection = Model.ProphSubsection.None; this.medialog = medialog; aStrings = new AdapterStrings(); aPerson = new AdapterPerson(medialog); aInvoice = new AdapterInvoice(); aRecourse = new AdapterRecourseAux(); aService = new AdapterServiceAux(); aConcomitantDisease = new AdapterConcomitantDisease(); aOncologyDirection = new AdapterOncoDirection(); string cs = string.Format(CONNECTION_STRING, location); connectionMain = new OleDbConnection(cs); connectionAlt = new OleDbConnection(cs); selectServicesTreatment = connectionAlt.CreateCommand(); selectServicesTreatment.CommandText = LocalizeQuery(Queries.SELECT_SERVICES); AddStringParameters(selectServicesTreatment, SELECT_SERVICES_TREATMENT); selectServicesByDate = connectionAlt.CreateCommand(); selectServicesByDate.CommandText = LocalizeQuery(Queries.SELECT_SERVICES + SERVICES_BY_DATE_CRITERION); AddStringParameters(selectServicesByDate, SELECT_SERVICES_BY_DATE); selectServicesStage1 = connectionAlt.CreateCommand(); selectServicesStage1.CommandText = LocalizeQuery(Queries.SELECT_SERVICES + "and (" + D3_SELECTION_STAGE1 + ")"); AddStringParameters(selectServicesStage1, SELECT_SERVICES_TREATMENT); selectServicesStage2 = connectionAlt.CreateCommand(); selectServicesStage2.CommandText = LocalizeQuery(Queries.SELECT_SERVICES + "and (" + D3_SELECTION_STAGE2 + ")"); AddStringParameters(selectServicesStage2, SELECT_SERVICES_TREATMENT); selectServicesProf = connectionAlt.CreateCommand(); selectServicesProf.CommandText = LocalizeQuery(Queries.SELECT_SERVICES + "and (" + D3_SELECTION_PROF + ")"); AddStringParameters(selectServicesProf, SELECT_SERVICES_TREATMENT); selectConcomDiseases = connectionAlt.CreateCommand(); selectConcomDiseases.CommandText = LocalizeQuery(Queries.SELECT_CONCOMITANT_DISEASES); AddStringParameters(selectConcomDiseases, SELECT_CONCOM_DISEASES); selectDispDirections = connectionAlt.CreateCommand(); selectDispDirections.CommandText = LocalizeQuery(Queries.SELECT_DISP_ASSIGNMENTS); AddStringParameters(selectDispDirections, PARAMETER_EVENT_RECID); selectOnkologyDirections = connectionAlt.CreateCommand(); selectOnkologyDirections.CommandText = LocalizeQuery(Queries.SELECT_ONCO_DIRECTIONS); AddStringParameters(selectOnkologyDirections, PARAMETER_EVENT_RECID); selectOnkologyTreat = connectionAlt.CreateCommand(); selectOnkologyTreat.CommandText = LocalizeQuery(Queries.SELECT_ONKO_TREAT); AddStringParameters(selectOnkologyTreat, PARAMETER_EVENT_RECID); }
public int GetInvoiceRecordsCount(Model.OrderSection section, Model.ProphSubsection subsection) { string sql = SectionizeQuery(Queries.SELECT_INVOICE_RECORDS_COUNT, section, subsection); sql = RecoursizeQuery(sql); object result = ExecuteScalar(connectionMain, LocalizeQuery(sql)); return(result != null && result != DBNull.Value ? (int)(decimal)result : 0); }
public IEnumerable <Model.InvoiceRecord> LoadInvoiceRecords(Model.OrderSection section, Model.ProphSubsection subsection) { string sql = SectionizeQuery(Queries.SELECT_INVOICE_PEOPLE, section, subsection); sql = RecoursizeQuery(sql); return(aInvoice.Load(connectionMain, LocalizeQuery(sql))); }
public static InvoiceFilename ToAssuranceCompany(string lpuCode, string assuranceCompanyCode, int year, int month, int packetNumber, Model.OrderSection orderSection, Model.ProphSubsection subSection) { StringBuilder sb = new StringBuilder(); // Source sb.Append('M'); sb.Append(lpuCode); // Destination sb.Append('S'); sb.Append(assuranceCompanyCode); sb.Append('_'); sb.Append(year % 100); sb.Append(month.ToString("D2")); sb.Append((packetNumber % 100).ToString("D2")); string bulk = sb.ToString(); string invoice = null; string persons = null; switch (orderSection) { case Model.OrderSection.D1: invoice = "H" + bulk; persons = "L" + bulk; break; case Model.OrderSection.D2: invoice = "T" + bulk; persons = "LT" + bulk; break; case Model.OrderSection.D3: bulk = Model.ProphSubsectionHelper.GetCode(subSection) + bulk; invoice = "D" + bulk; persons = "L" + bulk; break; case Model.OrderSection.D4: invoice = "C" + bulk; persons = "LC" + bulk; break; } return(new InvoiceFilename(persons, invoice) { clinicCode = lpuCode, smoCode = assuranceCompanyCode, section = orderSection, subsection = subSection, year = year, month = month, code = (year % 100) * 10000 + month * 100 + (packetNumber % 100) }); }
/// <summary> /// Save invoice record to XML /// </summary> /// <param name="xml">XML exporter to use</param> /// <param name="onRecourse">Callback to call on each recourse</param> /// <param name="pool">Datapool</param> /// <param name="section">Order #59 section</param> public void Write(Lib.XmlExporter xml, Action onRecourse, Data.IInvoice pool, OrderSection section, Model.ProphSubsection subsection) { foreach (Recourse recourse in pool.LoadRecourses(this, section, subsection)) { ++Identity; xml.Writer.WriteStartElement("ZAP"); xml.Writer.WriteElementString("N_ZAP", Identity.ToString()); xml.WriteBool("PR_NOV", Revised); Person.Write(xml, section); recourse.Write(xml, pool, section, this); xml.Writer.WriteEndElement(); onRecourse(); } }