static public TestAmbCase BuildAmbCaseFromDataBaseData(string guid, string idlpu, string mis, string patientId) { if ((guid != string.Empty) && (idlpu != string.Empty) && (mis != string.Empty) && (patientId != string.Empty)) { string caseId = TestCaseBase.GetCaseId(guid, idlpu, mis, patientId); if (caseId != null) { CaseAmb ca = new CaseAmb(); using (SqlConnection connection = Global.GetSqlConnection()) { string findCase = "SELECT TOP(1) * FROM AmbCase WHERE IdCase = '" + caseId + "'"; SqlCommand caseCommand = new SqlCommand(findCase, connection); using (SqlDataReader caseReader = caseCommand.ExecuteReader()) { while (caseReader.Read()) { if (caseReader["IdCasePurpose"].ToString() != "") { ca.IdCasePurpose = Convert.ToByte(caseReader["IdCasePurpose"]); } if (caseReader["IdAmbResult"].ToString() != "") { ca.IdAmbResult = Convert.ToByte(caseReader["IdAmbResult"]); } if (caseReader["IsActive"].ToString() != "") { ca.IsActive = Convert.ToBoolean(caseReader["IsActive"]); } TestAmbCase ambcase = new TestAmbCase(guid, ca); ambcase.caseBase = TestCaseBase.BuildBaseCaseFromDataBaseData(guid, idlpu, mis, patientId); ambcase.ambSteps = TestAmbStep.BuildAmbTestStepsFromDataBase(caseId, ca.IdLpu); List <TestStepBase> st = TestStepBase.BuildTestStepsFromDataBase(caseId, ca.IdLpu); if (st != null) { foreach (TestStepBase i in st) { if (Global.IsEqual(i.step.IdStepMis, null)) { ambcase.defaultStep = i; } } if (!Global.IsEqual(ambcase.defaultStep, null)) { ambcase.records = new List <TestMedRecord>(); List <TestService> ser = TestService.BuildServiseFromDataBaseData(ambcase.defaultStep.idStep); if (!Global.IsEqual(ser, null)) { ambcase.records.AddRange(ser); } TestTfomsInfo forms = TestTfomsInfo.BuildTfomsInfoFromDataBaseDate(ambcase.defaultStep.idStep); if (!Global.IsEqual(forms, null)) { ambcase.records.Add(forms); } TestDeathInfo tdi = TestDeathInfo.BuildDeathInfoFromDataBaseDate(ambcase.defaultStep.idStep); if (!Global.IsEqual(tdi, null)) { ambcase.records.Add(tdi); } List <TestDiagnosis> td = TestDiagnosis.BuildDiagnosisFromDataBaseDate(ambcase.defaultStep.idStep); if (!Global.IsEqual(td, null)) { ambcase.records.AddRange(td); } TestClinicMainDiagnosis acdm = TestClinicMainDiagnosis.BuildTestClinicMainDiagnosisFromDataBaseDate(ambcase.defaultStep.idStep); if (!Global.IsEqual(acdm, null)) { ambcase.records.Add(acdm); } List <TestReferral> trl = TestReferral.BuildReferralFromDataBaseData(ambcase.defaultStep.idStep); if (!Global.IsEqual(trl, null)) { ambcase.records.AddRange(trl); } List <TestSickList> tsl = TestSickList.BuildSickListFromDataBaseData(ambcase.defaultStep.idStep, patientId); if (!Global.IsEqual(tsl, null)) { ambcase.records.AddRange(tsl); } TestDischargeSummary tds = TestDischargeSummary.BuildSickListFromDataBaseData(ambcase.defaultStep.idStep); if (!Global.IsEqual(tds, null)) { ambcase.records.Add(tds); } List <TestLaboratoryReport> tlr = TestLaboratoryReport.BuildLaboratoryReportFromDataBaseData(ambcase.defaultStep.idStep); if (!Global.IsEqual(tlr, null)) { ambcase.records.AddRange(tlr); } TestConsultNote tcn = TestConsultNote.BuildSickListFromDataBaseData(ambcase.defaultStep.idStep); if (!Global.IsEqual(tcn, null)) { ambcase.records.Add(tcn); } TestDispensaryOne d1 = TestDispensaryOne.BuildSickListFromDataBaseData(ambcase.defaultStep.idStep); if (!Global.IsEqual(d1, null)) { ambcase.records.Add(d1); } List <TestAppointedMedication> ap = TestAppointedMedication.BuildAppointedMedicationFromDataBaseDate(ambcase.defaultStep.idStep); if (!Global.IsEqual(ap, null)) { ambcase.records.AddRange(ap); } if (ambcase.records.Count == 0) { ambcase.records = null; } } } return(ambcase); } } } } } return(null); }
public static TestMasterCase BuildTestMasterCase(string guid, string idlpu, string patientIdmis, string mis = "") { if ((guid != string.Empty) && (idlpu != string.Empty) && (patientIdmis != string.Empty)) { string patientId = TestPerson.GetPersonId(guid, idlpu, patientIdmis); string caseId = TestCaseBase.GetCaseId(guid, idlpu, mis, patientId); if (caseId != null) { TestMasterCase mcase = new TestMasterCase(); mcase.caseBase = TestCaseBase.BuildBaseCaseFromDataBaseData(guid, idlpu, mis, patientId); List <TestStepBase> st = TestStepBase.BuildTestStepsFromDataBase(caseId, idlpu); if (st != null) { foreach (TestStepBase i in st) { if (Global.IsEqual(i.doctor, null)) { mcase.defaultStep = i; } } if (!Global.IsEqual(mcase.defaultStep, null)) { mcase.records = new List <TestMedRecord>(); List <TestService> serv = TestService.BuildServiseFromDataBaseData(mcase.defaultStep.idStep); if (!Global.IsEqual(serv, null)) { mcase.records.AddRange(serv); } TestTfomsInfo forms = TestTfomsInfo.BuildTfomsInfoFromDataBaseDate(mcase.defaultStep.idStep); if (!Global.IsEqual(forms, null)) { mcase.records.Add(forms); } TestDeathInfo tdi = TestDeathInfo.BuildDeathInfoFromDataBaseDate(mcase.defaultStep.idStep); if (!Global.IsEqual(tdi, null)) { mcase.records.Add(tdi); } List <TestDiagnosis> td = TestDiagnosis.BuildDiagnosisFromDataBaseDate(mcase.defaultStep.idStep); if (!Global.IsEqual(td, null)) { mcase.records.AddRange(td); } TestClinicMainDiagnosis acdm = TestClinicMainDiagnosis.BuildTestClinicMainDiagnosisFromDataBaseDate(mcase.defaultStep.idStep); if (!Global.IsEqual(acdm, null)) { mcase.records.Add(acdm); } List <TestReferral> trl = TestReferral.BuildReferralFromDataBaseData(mcase.defaultStep.idStep); if (!Global.IsEqual(trl, null)) { mcase.records.AddRange(trl); } List <TestSickList> tsl = TestSickList.BuildSickListFromDataBaseData(mcase.defaultStep.idStep, patientId); if (!Global.IsEqual(tsl, null)) { mcase.records.AddRange(tsl); } TestDischargeSummary tds = TestDischargeSummary.BuildSickListFromDataBaseData(mcase.defaultStep.idStep); if (!Global.IsEqual(tds, null)) { mcase.records.Add(tds); } List <TestLaboratoryReport> tlr = TestLaboratoryReport.BuildLaboratoryReportFromDataBaseData(mcase.defaultStep.idStep); if (!Global.IsEqual(tlr, null)) { mcase.records.AddRange(tlr); } TestConsultNote tcn = TestConsultNote.BuildSickListFromDataBaseData(mcase.defaultStep.idStep); if (!Global.IsEqual(tcn, null)) { mcase.records.Add(tcn); } TestDispensaryOne d1 = TestDispensaryOne.BuildSickListFromDataBaseData(mcase.defaultStep.idStep); if (!Global.IsEqual(d1, null)) { mcase.records.Add(d1); } List <TestAppointedMedication> ap = TestAppointedMedication.BuildAppointedMedicationFromDataBaseDate(mcase.defaultStep.idStep); if (!Global.IsEqual(ap, null)) { mcase.records.AddRange(ap); } List <TestForm027U> form = TestForm027U.BuildForm027UFromDataBaseData(mcase.defaultStep.idStep); if (!Global.IsEqual(form, null)) { mcase.records.AddRange(form); } } } return(mcase); } } return(null); }
static public TestStatCase BuildAmbCaseFromDataBaseData(string guid, string idlpu, string mis, string patientId) { if ((guid != string.Empty) && (idlpu != string.Empty) && (mis != string.Empty)) { string caseId = TestCaseBase.GetCaseId(guid, idlpu, mis, patientId); if (caseId != null) { CaseStat ca = new CaseStat(); using (SqlConnection connection = Global.GetSqlConnection()) { string findCase = "SELECT TOP(1) * FROM HospCase WHERE IdCase = '" + caseId + "'"; SqlCommand caseCommand = new SqlCommand(findCase, connection); using (SqlDataReader caseReader = caseCommand.ExecuteReader()) { while (caseReader.Read()) { if (caseReader["DeliveredCode"].ToString() != "") { ca.DeliveryCode = Convert.ToString(caseReader["DeliveredCode"]); } if (caseReader["IdIntoxicationType"].ToString() != "") { ca.IdIntoxicationType = Convert.ToByte(caseReader["IdIntoxicationType"]); } if (caseReader["IdPatientConditionOnAdmission"].ToString() != "") { ca.IdPatientConditionOnAdmission = Convert.ToByte(caseReader["IdPatientConditionOnAdmission"]); } if (caseReader["IdTypeFromDiseaseStart"].ToString() != "") { ca.IdTypeFromDiseaseStart = Convert.ToByte(caseReader["IdTypeFromDiseaseStart"]); } if (caseReader["IdTransportIntern"].ToString() != "") { ca.IdTransportIntern = Convert.ToByte(caseReader["IdTransportIntern"]); } if (caseReader["IdHospChannel"].ToString() != "") { ca.IdHospChannel = Convert.ToByte(caseReader["IdHospChannel"]); } if (caseReader["RW1Mark"].ToString() != "") { ca.RW1Mark = Convert.ToBoolean(caseReader["RW1Mark"]); } if (caseReader["AIDSMark"].ToString() != "") { ca.AIDSMark = Convert.ToBoolean(caseReader["AIDSMark"]); } TestStatCase statcase = new TestStatCase(guid, ca); statcase.caseBase = TestCaseBase.BuildBaseCaseFromDataBaseData(guid, idlpu, mis, patientId); statcase.statSteps = TestStatStep.BuildStatStepsFromDataBase(caseId, ca.IdLpu); List <TestStepBase> st = TestStepBase.BuildTestStepsFromDataBase(caseId, ca.IdLpu); if (st != null) { foreach (TestStepBase i in st) { if (Global.IsEqual(i.doctor, null)) { statcase.defaultStep = i; } } if (!Global.IsEqual(statcase.defaultStep, null)) { statcase.records = new List <TestMedRecord>(); List <TestService> serv = TestService.BuildServiseFromDataBaseData(statcase.defaultStep.idStep); if (!Global.IsEqual(serv, null)) { statcase.records.AddRange(serv); } TestTfomsInfo forms = TestTfomsInfo.BuildTfomsInfoFromDataBaseDate(statcase.defaultStep.idStep); if (!Global.IsEqual(forms, null)) { statcase.records.Add(forms); } TestDeathInfo tdi = TestDeathInfo.BuildDeathInfoFromDataBaseDate(statcase.defaultStep.idStep); if (!Global.IsEqual(tdi, null)) { statcase.records.Add(tdi); } List <TestDiagnosis> td = TestDiagnosis.BuildDiagnosisFromDataBaseDate(statcase.defaultStep.idStep); if (!Global.IsEqual(td, null)) { statcase.records.AddRange(td); } TestClinicMainDiagnosis acdm = TestClinicMainDiagnosis.BuildTestClinicMainDiagnosisFromDataBaseDate(statcase.defaultStep.idStep); if (!Global.IsEqual(acdm, null)) { statcase.records.Add(acdm); } List <TestReferral> trl = TestReferral.BuildReferralFromDataBaseData(statcase.defaultStep.idStep); if (!Global.IsEqual(trl, null)) { statcase.records.AddRange(trl); } List <TestSickList> tsl = TestSickList.BuildSickListFromDataBaseData(statcase.defaultStep.idStep, patientId); if (!Global.IsEqual(tsl, null)) { statcase.records.AddRange(tsl); } TestDischargeSummary tds = TestDischargeSummary.BuildSickListFromDataBaseData(statcase.defaultStep.idStep); if (!Global.IsEqual(tds, null)) { statcase.records.Add(tds); } List <TestLaboratoryReport> tlr = TestLaboratoryReport.BuildLaboratoryReportFromDataBaseData(statcase.defaultStep.idStep); if (!Global.IsEqual(tlr, null)) { statcase.records.AddRange(tlr); } TestConsultNote tcn = TestConsultNote.BuildSickListFromDataBaseData(statcase.defaultStep.idStep); if (!Global.IsEqual(tcn, null)) { statcase.records.Add(tcn); } List <TestAppointedMedication> ap = TestAppointedMedication.BuildAppointedMedicationFromDataBaseDate(statcase.defaultStep.idStep); if (!Global.IsEqual(ap, null)) { statcase.records.AddRange(ap); } List <TestForm027U> form = TestForm027U.BuildForm027UFromDataBaseData(statcase.defaultStep.idStep); if (!Global.IsEqual(form, null)) { statcase.records.AddRange(form); } if (statcase.records.Count == 0) { statcase.records = null; } } } return(statcase); } } } } } return(null); }