public static string GetPrimaryCarePhysician(string personId) { DateTime todayDt = DateTime.Today; StringBuilder sb = new StringBuilder(); sb.Append("SELECT Prsnl_Person_Id, Person_Prsnl_R_Cd "); sb.Append("FROM BAR_PERSON_PRSNL_RELTN "); sb.Append("WHERE Person_Id = " + long.Parse(personId) + " "); sb.Append("AND Person_Prsnl_R_Cd = '1115' "); sb.Append("AND active_ind = '1' "); sb.Append("AND END_EFFECTIVE_DT_TM > '" + todayDt + "'"); DataTable dt = new DataTable(); using (var conn = new SqlConnection(GlobalSettings.SqlConnectionString())) using (var cmd = new SqlCommand(sb.ToString(), conn)) using (var da = new SqlDataAdapter(cmd)) { cmd.CommandType = CommandType.Text; da.Fill(dt); } string result = string.Empty; if (dt.Rows.Count > 0) { string physCode = EncntrPrsnlReltnDAL.GetAttendPhysician(dt.Rows[0]["Prsnl_Person_Id"].ToString()); result = CernerMapDAL.GetMap("CERNER_PROVIDER", physCode, "Z.CONVPROV"); } dt.Dispose(); return(result); }
public static string GetPrimaryCarePhysician(string personId) { if (personId.Contains(".0000") == false) { personId = personId + ".0000"; } string today = DateTime.Today.ToString("yyyy-MM-dd"); StringBuilder sb = new StringBuilder(); sb.Append("SELECT Prsnl_Person_Id, Person_Prsnl_R_Cd "); sb.Append("FROM PERSON_PRSNL_RELTN "); sb.Append("WHERE Person_Id = '" + personId + "' "); sb.Append("AND Person_Prsnl_R_Cd = '1115.0000' "); sb.Append("AND active_ind = '1.0000' "); //sb.Append("AND end_effective_dt_tm > '" + today + "' "); DataTable dt = new DataTable(); using (var conn = new SqlConnection(GlobalSettings.SqlConnectionString())) using (var cmd = new SqlCommand(sb.ToString(), conn)) using (var da = new SqlDataAdapter(cmd)) { cmd.CommandType = CommandType.Text; da.Fill(dt); } string result = string.Empty; if (dt.Rows.Count > 0) { string physCode = EncntrPrsnlReltnDAL.GetAttendPhysician(dt.Rows[0]["Prsnl_Person_Id"].ToString()); result = CernerMapDAL.GetMap("CERNER_PROVIDER", physCode, "Z.CONVPROV"); } return(result); }
private static Encounter LoadEncounter(DataRow row) { Encounter encounter = new Encounter(); encounter.Active_Ind = row["Active_Ind"].ToString(); string dischDisp = CernerCommon.StripDecimalsForMap(row["Disch_Disposition_Cd"].ToString()); encounter.Disch_Disposition_Cd = CernerMapDAL.GetMap("CERNER_DISCHARGE_DISPOSITION", dischDisp, dischDisp); encounter.Cerner_Disch_Disposition_Cd_Display = CodeValueDAL.GetCodeValueDisplay(dischDisp + ".0000"); encounter.Disch_Dt_Tm = row["Disch_Dt_Tm"].ToString(); encounter.Encntr_type_class_cd = row["Encntr_type_class_cd"].ToString(); encounter.Original_Encounter_Id = row["Encntr_Id"].ToString(); string encntrId = Encounter_AliasDAL.GetEncounterVisitNumber(row["Encntr_Id"].ToString()); encounter.Encounter_Id = encntrId; string encounterTypeCd = CernerCommon.StripDecimalsForMap(row["Encntr_Type_Cd"].ToString()); encounter.Cerner_Encoutner_Type_Cd = encounterTypeCd; //used for special logic in mpi conversion record 02 encounter.Cerner_Encounter_Type_Cd_Display = CodeValueDAL.GetCodeValueDisplay(encounterTypeCd + ".0000"); //for data sheet encounter.Encounter_Type_Cd = CernerMapDAL.GetMap("CERNER_REGTYPE", encounterTypeCd, encounterTypeCd); encounter.Inpatient_Admit_Dt_Tm = row["Inpatient_Admit_Dt_Tm"].ToString(); //From Encounter Table use field E_LOC_NURSE_UNIT_CD to retrieve the DISPLAY_KEY (col E) in CodeSet 220. //Use the DISPLAY_KEY to retrieve the Meditech location from the spreadsheet - "Approved locations" string loc = CodeValueDAL.GetCodeValueDisplay_Key(row["Loc_Nurse_Unit_Cd"].ToString()); encounter.Cerner_Loc_Nurse_Unit_Cd_Display = loc; //for data sheet encounter.Loc_Nurse_Unit_Cd = CernerMapDAL.GetMap("CERNER_LOCATION", loc, loc); string attendPhys = EncntrPrsnlReltnDAL.GetAttendPhysician(row["Encntr_Id"].ToString()); encounter.AttendPhysicianId = attendPhys; encounter.AttendPhysician = CernerMapDAL.GetMap("CERNER_PROVIDER", attendPhys, "Z.CONVPROV"); encounter.Person_Id = row["Person_Id"].ToString(); encounter.Reason_For_Visit = row["Reason_For_Visit"].ToString(); encounter.Reg_Dt_Tm = row["Reg_Dt_Tm"].ToString(); encounter.ConfidentialVisit = string.Empty; encounter.Organization_Id = row["organization_id"].ToString(); //DateTime? d = GMTtoTZ(encounter.Disch_Dt_Tm, "Mountain Standard Time"); //for BAR encounter.BAR_Encounter_Type_Cd = "OUT"; // CernerMapDAL.GetMap("CERNER_BAR_PATIENT_STATUS", encounterTypeCd, encounterTypeCd); encounter.Admit_Src_Cd = row["admit_src_cd"].ToString().Replace(".0000", ""); encounter.Admit_Type_Cd = row["admit_type_cd"].ToString().Replace(".0000", ""); return(encounter); }