public override Guid WriteToCDS(OrganizationServiceProxy _serviceProxy) { Guid patientConditionId = Guid.Empty; HealthCDM.msemr_condition addCondition = new HealthCDM.msemr_condition(); addCondition.msemr_SubjectTypePatient = new EntityReference(HealthCDM.Contact.EntityLogicalName, Guid.Parse((PatientId))); addCondition.msemr_Practitioner = new EntityReference(HealthCDM.Contact.EntityLogicalName, Guid.Parse((PractitionerId))); addCondition.msemr_SubjectType = new OptionSetValue(SubjectType); addCondition.msemr_OnsetDate = OnsetDate; addCondition.msemr_name = Description; addCondition.msemr_VerificationStatus = new OptionSetValue(VerificationStatus); try { patientConditionId = _serviceProxy.Create(addCondition); if (patientConditionId != Guid.Empty) { ConditionId = patientConditionId.ToString(); Console.WriteLine("Created Condition [" + ConditionId + "] for Patient [" + PatientId + "]"); } else { throw new Exception("ConditionId == null"); } } catch (Exception ex) { throw new Exception(ex.ToString()); } return(patientConditionId); }
public override Guid WriteToCDS(string cdsUrl, string cdsUserName, string cdsPassword) { Guid patientConditionId = Guid.Empty; try { #region Get our Login Information // setup the variables OrganizationServiceProxy _serviceProxy; // homeRealmUri will stay null for now Uri homeRealmUri = null; // setup credentials from whatever is in the app.config ClientCredentials credentials; // same for organizationuri comes from app.config Uri organizationUri; // set the organization uri from what was in the app.config organizationUri = new Uri(cdsUrl); credentials = new ClientCredentials(); credentials.UserName.UserName = cdsUserName; credentials.UserName.Password = cdsPassword; #endregion ServicePointManager.SecurityProtocol = SecurityProtocolType.Tls12; using (_serviceProxy = new OrganizationServiceProxy(organizationUri, homeRealmUri, credentials, null)) { // To impersonate set the GUID of CRM user here (which I merely took from CRM itself // would need not to use this caller id in the future (as it will change per instance of CRM) //_serviceProxy.CallerId = new Guid("14D40CB7-81D5-E311-93F5-00155D00330C"); _serviceProxy.ServiceConfiguration.CurrentServiceEndpoint.Behaviors.Add(new ProxyTypesBehavior()); //enable using proxy types _serviceProxy.EnableProxyTypes(); HealthCDM.msemr_condition addCondition = new HealthCDM.msemr_condition(); patientConditionId = WriteToCDS(_serviceProxy); } } catch (Exception ex) { throw new Exception(ex.ToString()); } return(patientConditionId); }
public override Guid WriteToCDS(string cdsUrl, string cdsUserName, string cdsPassword) { Guid patientConditionId = Guid.Empty; try { #region Get our Login Information // setup the variables OrganizationServiceProxy _serviceProxy; // homeRealmUri will stay null for now Uri homeRealmUri = null; // setup credentials from whatever is in the app.config ClientCredentials credentials; // same for organizationuri comes from app.config Uri organizationUri; // set the organization uri from what was in the app.config organizationUri = new Uri(cdsUrl); credentials = new ClientCredentials(); credentials.UserName.UserName = cdsUserName; credentials.UserName.Password = cdsPassword; #endregion ServicePointManager.SecurityProtocol = SecurityProtocolType.Tls12; using (_serviceProxy = new OrganizationServiceProxy(organizationUri, homeRealmUri, credentials, null)) { // To impersonate set the GUID of CRM user here (which I merely took from CRM itself // would need not to use this caller id in the future (as it will change per instance of CRM) //_serviceProxy.CallerId = new Guid("14D40CB7-81D5-E311-93F5-00155D00330C"); _serviceProxy.ServiceConfiguration.CurrentServiceEndpoint.Behaviors.Add(new ProxyTypesBehavior()); //enable using proxy types _serviceProxy.EnableProxyTypes(); HealthCDM.msemr_condition addCondition = new HealthCDM.msemr_condition(); addCondition.msemr_SubjectTypePatient = new EntityReference(HealthCDM.Contact.EntityLogicalName, Guid.Parse((PatientId))); addCondition.msemr_Practitioner = new EntityReference(HealthCDM.Contact.EntityLogicalName, Guid.Parse((PractitionerId))); addCondition.msemr_SubjectType = new OptionSetValue(SubjectType); addCondition.msemr_OnsetDate = OnsetDate; addCondition.msemr_name = Description; addCondition.msemr_VerificationStatus = new OptionSetValue(VerificationStatus); try { patientConditionId = _serviceProxy.Create(addCondition); if (patientConditionId != Guid.Empty) { ConditionId = patientConditionId.ToString(); Console.WriteLine("Created Condition [" + ConditionId + "] for Patient [" + PatientId + "]"); } else { throw new Exception("ConditionId == null"); } } catch (Exception ex) { throw new Exception(ex.ToString()); } } } catch (Exception ex) { throw new Exception(ex.ToString()); } return(patientConditionId); }