public override Guid WriteToCDS(OrganizationServiceProxy _serviceProxy) { Guid patientProcedureId = Guid.Empty; HealthCDM.msemr_procedure addProcedure = new HealthCDM.msemr_procedure(); addProcedure.msemr_Patient = new EntityReference(HealthCDM.Contact.EntityLogicalName, Guid.Parse((PatientId))); addProcedure.msemr_Status = new OptionSetValue(Status); addProcedure.msemr_DateTime = ProcedureDateTime; addProcedure.msemr_SubjectType = new OptionSetValue(SubjectType); addProcedure.msemr_description = Description; try { patientProcedureId = _serviceProxy.Create(addProcedure); if (patientProcedureId != Guid.Empty) { ProcedureId = patientProcedureId.ToString(); Console.WriteLine("Created Patient Procedure [" + ProcedureId + "] for Patient [" + PatientId + "]"); } else { throw new Exception("ProcedueId == null"); } } catch (Exception ex) { throw new Exception(ex.ToString()); } return(patientProcedureId); }
public override Guid WriteToCDS(string cdsUrl, string cdsUserName, string cdsPassword) { Guid patientProcedureId = 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_procedure addProcedure = new HealthCDM.msemr_procedure(); addProcedure.msemr_Patient = new EntityReference(HealthCDM.Contact.EntityLogicalName, Guid.Parse((PatientId))); addProcedure.msemr_Status = new OptionSetValue(Status); addProcedure.msemr_DateTime = ProcedureDateTime; addProcedure.msemr_SubjectType = new OptionSetValue(SubjectType); addProcedure.msemr_description = Description; try { patientProcedureId = _serviceProxy.Create(addProcedure); if (patientProcedureId != Guid.Empty) { ProcedureId = patientProcedureId.ToString(); Console.WriteLine("Created Patient Procedure [" + ProcedureId + "] for Patient [" + PatientId + "]"); } else { throw new Exception("ProcedueId == null"); } } catch (Exception ex) { throw new Exception(ex.ToString()); } } } catch (Exception ex) { throw new Exception(ex.ToString()); } return(patientProcedureId); }