// this will overwrite the current patient information with the value from the FHIR repo // if the patient is deleted, the patient will be reactivated public static void update_fhir_patient(FHIR_Patient fp) { using (var dal = new Company.ClinicalDAL.ClinicalDAL(context)) { var pat = dal.GetPatient_External_Id_Source(fp.External_id, fp.External_source); if (pat != null) { pat.LastName = fp.LastName; pat.FirstName = fp.FirstName; pat.Sex = !string.IsNullOrEmpty(fp.Gender) ? fp.Gender.Substring(0, 1) : "U"; pat.DateOfBirth = !string.IsNullOrEmpty(fp.Birthdate) ? DateTime.Parse(fp.Birthdate) : (DateTime?)null; pat.AddressLine1 = fp.Address; pat.City = fp.City; pat.State = fp.State; pat.Zip = fp.Zip; pat.HomePhone = fp.Phone; pat.Active = true; dal.UpdatePatient(pat); UserAction ua = new UserAction { User = GlobalVariables.Instance.ClinicalUser, Action_id = UserActionCode.External_Patient_Updated.ToString(), Action_desc = UserActionDesc[UserActionCode.External_Patient_Updated], Action_date = DateTime.Now, Patient_id = pat.id, External_id = pat.External_id, External_source = pat.External_source }; dal.AddUserAction(ua); } } }
// this is just to validate if an MRN exist. If used to query patient will need to be logged. public static ClinicalDAL.Patient GetPatient_External_Id_Source(FHIR_Patient fp) { using (var dal = new Company.ClinicalDAL.ClinicalDAL(context)) { return(dal.GetPatient_External_Id_Source(fp.External_id, fp.External_source)); } }