public static Entity Map(this PatientPerson patient, IOrganizationService organizationService, Logger logger, VeisConfig config) { Entity ent = null; if (patient != null) { ent = new Entity("crme_person"); ent.Id = new Guid(); ent.Attributes.Add("crme_ssn", patient.SocialSecurityNumber); ent.Attributes.Add("crme_primaryphone", patient.PhoneNumber); ent.Attributes.Add("crme_branchofservice", patient.BranchOfService); ent.Attributes.Add("crme_recordsource", patient.RecordSource); ent.Attributes.Add("crme_gender", patient.GenderCode); ent.Attributes.Add("crme_deceaseddate", patient.DeceasedDate); ent.Attributes.Add("crme_identitytheft", patient.IdentifyTheft); ent.Attributes.Add("crme_url", "&select=*&$filter=crme_patientmviidentifier eq '" + patient.Identifier + "' and crme_searchtype eq 'SelectedPersonSearch'"); ent.Attributes.Add("crme_dobstring", patient.BirthDate); if (patient.NameList != null) { var legalName = patient.NameList.GetName("Legal", true); if (legalName != null) { ent.Attributes.AddRange(legalName.Map()); } } if (patient.Address != null) { ent.Attributes.AddRange(patient.Address.Map()); if (!ent.Attributes.Contains("crme_fulladdress")) { ent.Attributes.Add("crme_fulladdress", patient.FullAddress); } } } TryGetMviQueryParams(patient, ent, logger); TryGetCorpInfo(patient, ent, logger); ent.Attributes.Add("crme_veteransensitivitylevel", patient.VeteranSensitivityLevel); ent.Attributes.Add("crme_edipi", patient.EdiPi); string empty = string.Empty; if (config.GetSensitiveInfo) { List <string> strs = new List <string>(); strs.Add(TryGetICN(patient, logger)); string url = getKVPSetting("sensitive_endpoint", organizationService); List <string> list2 = new List <string>(); list2.Add(TryGetICN(patient, logger)); string keys = config.VeisConfiguration.SvcConfigInfo.ApimSubscriptionKey; NonVetResponse nvResponse = getVHAVeteranEmployeeFlags(String.Format("{0}{1}", config.VeisConfiguration.SvcConfigInfo.SvcBaseUrl, config.EmployeeEndpoint), keys, strs, logger); List <VeteranEmployeeFlag> vHAVeteranEmployeeFlags = new List <VeteranEmployeeFlag>(); foreach (NVDatum datum in nvResponse.Data) { if (datum.NationalId == null) { vHAVeteranEmployeeFlags.Add(new VeteranEmployeeFlag() { NationalId = "", Value = "NO" }); } else if (!(datum.Veteran == null || datum.Veteran == "" ? false : !(datum.Veteran.ToUpper() == "YES"))) { vHAVeteranEmployeeFlags.Add(new VeteranEmployeeFlag() { NationalId = datum.NationalId, Value = "NO" }); } else if (!(!(datum.Veteran.ToUpper() == "NO") || datum.NewPersonIndicator == null ? true : !(datum.NewPersonIndicator.ToUpper() == "YES"))) { vHAVeteranEmployeeFlags.Add(new VeteranEmployeeFlag() { NationalId = datum.NationalId, Value = "YES" }); } else if ((!(datum.Veteran.ToUpper() == "NO") || datum.PrimaryEligibilityCode == null ? false : datum.PrimaryEligibilityCode.ToUpper() == "EMPLOYEE")) { vHAVeteranEmployeeFlags.Add(new VeteranEmployeeFlag() { NationalId = datum.NationalId, Value = "YES" }); } } string isEmp = string.Empty; if (vHAVeteranEmployeeFlags.Count > 0) { isEmp = isEmployee(ent["crme_icn"].ToString(), vHAVeteranEmployeeFlags); } HandleSensitivityMasking(config, patient, ent, isEmp); } return(ent); }
public static NonVetResponse getVHAVeteranEmployeeFlags(string url, string subKeys, List <string> list, Logger logger) { NonVetRequest request = new NonVetRequest() { ClientName = "VCCM", Format = "JSON", NationalIds = list.ToArray() }; string str = JsonHelper.Serialize(request); HttpWebRequest httpWebRequest = (HttpWebRequest)WebRequest.Create(url); if (subKeys.Length > 0) { string[] headers = subKeys.Split('|'); for (int i = 0; i < headers.Length; i = i + 2) { httpWebRequest.Headers.Add(headers[i], headers[i + 1]); } } httpWebRequest.ContentType = "application/json"; httpWebRequest.Method = "POST"; using (StreamWriter streamWriter = new StreamWriter(httpWebRequest.GetRequestStream())) { streamWriter.Write(str); } WebResponse webResponse = httpWebRequest.GetResponse(); Stream webStream = webResponse.GetResponseStream(); StreamReader responseReader = new StreamReader(webStream); string responseString = responseReader.ReadToEnd(); responseReader.Close(); NonVetResponse nvResponse = JsonHelper.Deserialize <NonVetResponse>(responseString); /* * List<KeyValuePair<string, string>> keyValuePairs = new List<KeyValuePair<string, string>>(); * try * { * foreach (NVDatum datum in nvResponse.Data) * { * if (datum.NationalId == null) * { * // no nationalid * keyValuePairs.Add(new KeyValuePair<string, string>("", "NO")); * } * else if (!(datum.Veteran == null || datum.Veteran == "" ? false : !(datum.Veteran.ToUpper() == "YES"))) * { * keyValuePairs.Add(new KeyValuePair<string, string>(datum.NationalId, "NO")); * } * else if (!(!(datum.Veteran.ToUpper() == "NO") || datum.NewPersonIndicator == null ? true : !(datum.NewPersonIndicator.ToUpper() == "YES"))) * { * keyValuePairs.Add(new KeyValuePair<string, string>(datum.NationalId, "YES")); * } * else if ((!(datum.Veteran.ToUpper() == "NO") || datum.PrimaryEligibilityCode == null ? false : datum.PrimaryEligibilityCode.ToUpper() == "EMPLOYEE")) * { * keyValuePairs.Add(new KeyValuePair<string, string>(datum.NationalId, "YES")); * } * } * } * catch (Exception ex) * { * //Exception exception = ex; * //base.Logger.WriteDebugMessage(string.Concat("ERROR::Error pulling NonVet info from HDR with the supplied ICNs.", exception.Message)); * } * return keyValuePairs;*/ return(nvResponse); }