/// <summary> /// Create and configure the organization service proxy. /// Initiate the method to create any data that this sample requires. /// Create an episode of care. /// </summary> public void Run(ServerConnection.Configuration serverConfig, bool promptforDelete) { try { //<snippetMarketingAutomation1> // Connect to the Organization service. // The using statement assures that the service proxy will be properly disposed. using (_serviceProxy = new OrganizationServiceProxy(serverConfig.OrganizationUri, serverConfig.HomeRealmUri, serverConfig.Credentials, serverConfig.DeviceCredentials)) { // This statement is required to enable early-bound type support. _serviceProxy.EnableProxyTypes(); Entity episodeofcare = new Entity("msemr_episodeofcare"); episodeofcare["msemr_description"] = "Rehabilitation"; episodeofcare["msemr_startdatetime"] = DateTime.Now; episodeofcare["msemr_enddatetime"] = DateTime.Now; Guid caremanagerContactId = SDKFunctions.GetContactId(_serviceProxy, "James Kirk"); if (caremanagerContactId != Guid.Empty) { episodeofcare["msemr_caremanager"] = new EntityReference("contact", caremanagerContactId); } Guid patientContactId = SDKFunctions.GetContactId(_serviceProxy, "Daniel Atlas"); if (patientContactId != Guid.Empty) { episodeofcare["msemr_patient"] = new EntityReference("contact", patientContactId); } Guid organizationAccountId = Organization.GetAccountId(_serviceProxy, "Galaxy Corp"); if (organizationAccountId != Guid.Empty) { episodeofcare["msemr_organization"] = new EntityReference("account", organizationAccountId); } episodeofcare["msemr_status"] = new OptionSetValue(935000000); //Planned episodeofcare["msemr_identifier"] = "EPC-153"; Guid episodeofcareId = _serviceProxy.Create(episodeofcare); // Verify that the record has been created. if (episodeofcareId != Guid.Empty) { Console.WriteLine("Succesfully created {0}.", episodeofcareId); } } } // Catch any service fault exceptions that Microsoft Dynamics CRM throws. catch (FaultException <Microsoft.Xrm.Sdk.OrganizationServiceFault> ) { // You can handle an exception here or pass it back to the calling method. throw; } }
/// <summary> /// Create and configure the organization service proxy. /// Initiate the method to create any data that this sample requires. /// Create a task. /// </summary> public void Run(ServerConnection.Configuration serverConfig, bool promptforDelete) { try { //<snippetMarketingAutomation1> // Connect to the Organization service. // The using statement assures that the service proxy will be properly disposed. using (_serviceProxy = new OrganizationServiceProxy(serverConfig.OrganizationUri, serverConfig.HomeRealmUri, serverConfig.Credentials, serverConfig.DeviceCredentials)) { // This statement is required to enable early-bound type support. _serviceProxy.EnableProxyTypes(); Entity task = new Entity("task"); task["subject"] = "Surgery"; Guid businessstatusCodeableConceptId = SDKFunctions.GetCodeableConceptId(_serviceProxy, "General Partnership", 935000149); if (businessstatusCodeableConceptId != Guid.Empty) { task["msemr_businessstatus"] = new EntityReference("msemr_codeableconcept", businessstatusCodeableConceptId); } Guid codeCodeableConceptId = SDKFunctions.GetCodeableConceptId(_serviceProxy, "Code", 935000150); if (codeCodeableConceptId != Guid.Empty) { task["msemr_code"] = new EntityReference("msemr_codeableconcept", codeCodeableConceptId); } //Setting Context Type as Encounter task["msemr_contexttype"] = new OptionSetValue(935000000); //Encounter Guid contextencounterId = Encounter.GetEncounterId(_serviceProxy, "E23556"); if (contextencounterId != Guid.Empty) { task["msemr_contextencounter"] = new EntityReference("msemr_encounter", contextencounterId); } task["msemr_definitionuri"] = ""; task["msemr_descriptionfocus"] = ""; task["msemr_descriptionfor"] = ""; task["msemr_groupidentifier"] = ""; task["msemr_intent"] = new OptionSetValue(935000000); //Proposal //Setting performer owner type as practitioner task["msemr_performerownertype"] = new OptionSetValue(935000000); //Practitioner Guid performerownerpractitionerContacttId = SDKFunctions.GetContactId(_serviceProxy, "James Kirk"); if (performerownerpractitionerContacttId != Guid.Empty) { task["msemr_performerownerpractitioner"] = new EntityReference("contact", performerownerpractitionerContacttId); } Guid reasonCodeableConceptId = SDKFunctions.GetCodeableConceptId(_serviceProxy, "Reason", 935000154); if (reasonCodeableConceptId != Guid.Empty) { task["msemr_reason"] = new EntityReference("msemr_codeableconcept", reasonCodeableConceptId); } Guid referenceId = SDKFunctions.GetActivityDefinitionId(_serviceProxy, "Activity"); if (referenceId != Guid.Empty) { task["msemr_reference"] = new EntityReference("msemr_identifiesspecifictimeswhentheeventoccu", referenceId); } //Setting requestor agent as patient task["msemr_requesteragent"] = new OptionSetValue(935000002); //Patient Guid requesteragentpatientContactId = SDKFunctions.GetContactId(_serviceProxy, "James Kirk"); if (requesteragentpatientContactId != Guid.Empty) { task["msemr_requesteragentpatient"] = new EntityReference("contact", requesteragentpatientContactId); } Guid requesteronbehalfofAccountId = Organization.GetAccountId(_serviceProxy, "Galaxy Corp"); if (requesteronbehalfofAccountId != Guid.Empty) { task["msemr_requesteronbehalfof"] = new EntityReference("msemr_codeableconcept", requesteronbehalfofAccountId); } task["msemr_restrictionperiodstartdate"] = DateTime.Now; task["msemr_restrictionperiodenddate"] = DateTime.Now; task["msemr_restrictionrepetitions"] = 152; task["msemr_status"] = new OptionSetValue(935000000); //Draft Guid statusreasonCodeableConceptId = SDKFunctions.GetCodeableConceptId(_serviceProxy, "Status Reason", 935000155); if (statusreasonCodeableConceptId != Guid.Empty) { task["msemr_statusreason"] = new EntityReference("msemr_codeableconcept", statusreasonCodeableConceptId); } task["msemr_taskpriority"] = new OptionSetValue(935000002); //ASAP task["msemr_tasknumber"] = "T85746"; Guid taskId = _serviceProxy.Create(task); // Verify that the record has been created. if (taskId != Guid.Empty) { Console.WriteLine("Succesfully created {0}.", taskId); } } } // Catch any service fault exceptions that Microsoft Dynamics CRM throws. catch (FaultException <Microsoft.Xrm.Sdk.OrganizationServiceFault> ) { // You can handle an exception here or pass it back to the calling method. throw; } }
/// <summary> /// Create and configure the organization service proxy. /// Initiate the method to create any data that this sample requires. /// Create a medication request. /// </summary> public void Run(ServerConnection.Configuration serverConfig, bool promptforDelete) { try { //<snippetMarketingAutomation1> // Connect to the Organization service. // The using statement assures that the service proxy will be properly disposed. using (_serviceProxy = new OrganizationServiceProxy(serverConfig.OrganizationUri, serverConfig.HomeRealmUri, serverConfig.Credentials, serverConfig.DeviceCredentials)) { // This statement is required to enable early-bound type support. _serviceProxy.EnableProxyTypes(); Entity medicationrequest = new Entity("msemr_medicationrequest"); medicationrequest["msemr_identifier"] = "MR-1234"; medicationrequest["msemr_groupidentifier"] = "MRG-12345"; medicationrequest["msemr_priority"] = new OptionSetValue(935000000); medicationrequest["msemr_intent"] = new OptionSetValue(935000000); medicationrequest["msemr_status"] = new OptionSetValue(935000000); medicationrequest["msemr_dispenserequestvalidityperiodstartdate"] = DateTime.Now; medicationrequest["msemr_dispenserequestvalidityperiodenddate"] = DateTime.Now; medicationrequest["msemr_authoredon"] = DateTime.Now; medicationrequest["msemr_expectedsupplyduration"] = (decimal)3.5; // Setting Request Type as Organisation medicationrequest["msemr_requesteragenttype"] = new OptionSetValue(935000001); //Organisation Guid RequesteragentTypeOrganization = Organization.GetAccountId(_serviceProxy, "Galaxy Corp"); if (RequesteragentTypeOrganization != Guid.Empty) { medicationrequest["msemr_requesteragenttypeorganization"] = new EntityReference("account", RequesteragentTypeOrganization); } //Setting Medication Type as Medication Reference medicationrequest["msemr_medicationtype"] = new OptionSetValue(935000001); Guid MedicationTypeReference = Medication.GetProductId(_serviceProxy, "Panadol"); if (MedicationTypeReference != Guid.Empty) { medicationrequest["msemr_medicationtypereference"] = new EntityReference("product", MedicationTypeReference); } // Setting Subject Type as Patient medicationrequest["msemr_subjecttype"] = new OptionSetValue(935000000); Guid SubjectTypePatient = SDKFunctions.GetContactId(_serviceProxy, "James Kirk", 935000000); if (SubjectTypePatient != Guid.Empty) { medicationrequest["msemr_subjecttypepatient"] = new EntityReference("contact", SubjectTypePatient); } //Setting Context Type as Episode as Care medicationrequest["msemr_contexttype"] = new OptionSetValue(935000000); Guid ConextTypeEpisodeofCare = EpisodeOfCare.GetEpisodeOfCareId(_serviceProxy, "EPC-153"); if (ConextTypeEpisodeofCare != Guid.Empty) { medicationrequest["msemr_contexttypeepisodeofcare"] = new EntityReference("msemr_episodeofcare", ConextTypeEpisodeofCare); } Guid Recorder = SDKFunctions.GetContactId(_serviceProxy, "Emily Williams", 935000001); if (Recorder != Guid.Empty) { medicationrequest["msemr_recorder"] = new EntityReference("contact", Recorder); } Guid Category = SDKFunctions.GetCodeableConceptId(_serviceProxy, "Pain", 935000080); if (Category != Guid.Empty) { medicationrequest["msemr_category"] = new EntityReference("msemr_codeableconcept", Category); } Guid PriorPrescription = getMedicationRequestId(_serviceProxy, "MR-1234"); if (PriorPrescription != Guid.Empty) { medicationrequest["msemr_priorprescription"] = new EntityReference("msemr_medicationrequest", PriorPrescription); } Guid RequesterOnBehalfOf = Organization.GetAccountId(_serviceProxy, "Galaxy Corp"); if (RequesterOnBehalfOf != Guid.Empty) { medicationrequest["msemr_requesteronbehalfof"] = new EntityReference("account", RequesterOnBehalfOf); } Guid SubstitutionReason = SDKFunctions.GetCodeableConceptId(_serviceProxy, "Substitution Reason", 935000144); if (SubstitutionReason != Guid.Empty) { medicationrequest["msemr_substitutionreason"] = new EntityReference("msemr_codeableconcept", SubstitutionReason); } Guid DispenseRequestPerformer = Organization.GetAccountId(_serviceProxy, "Galaxy Corp"); if (DispenseRequestPerformer != Guid.Empty) { medicationrequest["msemr_dispenserequestperformer"] = new EntityReference("account", DispenseRequestPerformer); } medicationrequest["msemr_substitutionallowed"] = true; medicationrequest["msemr_dispenserequestquantity"] = 1; medicationrequest["msemr_dispenserequestnumberofrepeatsallowed"] = 1; medicationrequest["msemr_dispenserequestexpectedsupplyduration"] = 1; Guid MedicationRequestId = _serviceProxy.Create(medicationrequest); // Verify that the record has been created. if (MedicationRequestId != Guid.Empty) { Console.WriteLine("Succesfully created {0}.", MedicationRequestId); } } } // Catch any service fault exceptions that Microsoft Dynamics CRM throws. catch (FaultException <Microsoft.Xrm.Sdk.OrganizationServiceFault> ) { // You can handle an exception here or pass it back to the calling method. throw; } }
/// <summary> /// Create and configure the organization service proxy. /// Initiate the method to create any data that this sample requires. /// Create an encounter. /// </summary> public void Run(ServerConnection.Configuration serverConfig, bool promptforDelete) { try { //<snippetMarketingAutomation1> // Connect to the Organization service. // The using statement assures that the service proxy will be properly disposed. using (_serviceProxy = new OrganizationServiceProxy(serverConfig.OrganizationUri, serverConfig.HomeRealmUri, serverConfig.Credentials, serverConfig.DeviceCredentials)) { // This statement is required to enable early-bound type support. _serviceProxy.EnableProxyTypes(); Entity encounter = new Entity("msemr_encounter"); encounter["msemr_name"] = "Routine"; Guid subjectpatientContactId = SDKFunctions.GetContactId(_serviceProxy, "Daniel Atlas"); if (subjectpatientContactId != Guid.Empty) { encounter["msemr_subjectpatient"] = new EntityReference("contact", subjectpatientContactId); } encounter["msemr_class"] = new OptionSetValue(935000008); //short stay encounter["msemr_encounterstartdate"] = DateTime.Now; encounter["msemr_encounterenddate"] = DateTime.Now; encounter["msemr_encounterclass"] = new OptionSetValue(935000001); //outPatient encounter["msemr_encounterlength"] = (decimal)30.5; encounter["msemr_encounterstatus"] = new OptionSetValue(935000000); //Planned encounter["msemr_encounteridentifier"] = "Routine 25352"; Guid priorityCodeableConceptId = SDKFunctions.GetCodeableConceptId(_serviceProxy, "Urgent", 935000102); if (priorityCodeableConceptId != Guid.Empty) { encounter["msemr_encounterpriority"] = new EntityReference("msemr_codeableconcept", priorityCodeableConceptId); } Guid groupCodeableConceptId = SDKFunctions.GetCodeableConceptId(_serviceProxy, "Group Identifier", 935000063); if (groupCodeableConceptId != Guid.Empty) { encounter["msemr_encountergroupidentifier"] = new EntityReference("msemr_codeableconcept", groupCodeableConceptId); } Guid parentEncountertId = GetEncounterId(_serviceProxy, "E23556"); if (parentEncountertId != Guid.Empty) { encounter["msemr_encounterparentencounteridentifier"] = new EntityReference("msemr_encounter", parentEncountertId); } Guid patientIdentifier = SDKFunctions.GetContactId(_serviceProxy, "James Kirk"); if (patientIdentifier != Guid.Empty) { encounter["msemr_encounterpatientidentifier"] = new EntityReference("contact", patientIdentifier); } encounter["msemr_periodstart"] = DateTime.Now; encounter["msemr_periodend"] = DateTime.Now; encounter["msemr_duration"] = 30; encounter["msemr_priority"] = new OptionSetValue(935000000); //ASAP encounter["msemr_hospitalizationpreadmissionnumber"] = "25352"; Guid destinationLocationId = SDKFunctions.GetLocationId(_serviceProxy, "Noble Hospital Center"); if (destinationLocationId != Guid.Empty) { encounter["msemr_hospitalizationdestination"] = new EntityReference("msemr_location", destinationLocationId); } Guid dischargedispositionCodeableConceptId = SDKFunctions.GetCodeableConceptId(_serviceProxy, "Discharge Disposition", 935000042); if (dischargedispositionCodeableConceptId != Guid.Empty) { encounter["msemr_hospitalizationdischargedisposition"] = new EntityReference("msemr_codeableconcept", dischargedispositionCodeableConceptId); } Guid admitsourceCodeableConceptId = SDKFunctions.GetCodeableConceptId(_serviceProxy, "Admit Source", 935000007); if (admitsourceCodeableConceptId != Guid.Empty) { encounter["msemr_hospitalizationadmitsource"] = new EntityReference("msemr_codeableconcept", admitsourceCodeableConceptId); } Guid readmissionCodeableConceptId = SDKFunctions.GetCodeableConceptId(_serviceProxy, "Re-admission", 935000114); if (readmissionCodeableConceptId != Guid.Empty) { encounter["msemr_hospitalizationreadmission"] = new EntityReference("msemr_codeableconcept", readmissionCodeableConceptId); } Guid originLocationId = SDKFunctions.GetLocationId(_serviceProxy, "Alpine"); if (originLocationId != Guid.Empty) { encounter["msemr_hospitalizationorigin"] = new EntityReference("msemr_location", originLocationId); } Guid accountId = Organization.GetAccountId(_serviceProxy, "Galaxy Corp"); if (accountId != Guid.Empty) { encounter["msemr_onbehalfof"] = new EntityReference("account", accountId); } Guid encounterId = _serviceProxy.Create(encounter); // Verify that the record has been created. if (encounterId != Guid.Empty) { Console.WriteLine("Succesfully created {0}.", encounterId); } } } // Catch any service fault exceptions that Microsoft Dynamics CRM throws. catch (FaultException <Microsoft.Xrm.Sdk.OrganizationServiceFault> ) { // You can handle an exception here or pass it back to the calling method. throw; } }
/// <summary> /// Create and configure the organization service proxy. /// Initiate the method to create any data that this sample requires. /// Create a location. /// </summary> public void Run(ServerConnection.Configuration serverConfig, bool promptforDelete) { try { //<snippetMarketingAutomation1> // Connect to the Organization service. // The using statement assures that the service proxy will be properly disposed. using (_serviceProxy = new OrganizationServiceProxy(serverConfig.OrganizationUri, serverConfig.HomeRealmUri, serverConfig.Credentials, serverConfig.DeviceCredentials)) { // This statement is required to enable early-bound type support. _serviceProxy.EnableProxyTypes(); Entity location = new Entity("msemr_location"); location["msemr_name"] = "Noble Hospital Center"; location["msemr_addresstype"] = new OptionSetValue(935000001); //Physical location["msemr_addressuse"] = new OptionSetValue(935000001); //Work location["msemr_addresscity"] = "Albuquerque"; location["msemr_addresscountry"] = "US"; location["msemr_addressline1"] = "1770"; location["msemr_addressline2"] = "Byrd"; location["msemr_addressline3"] = "Lane"; location["msemr_addresspostalcode"] = "87107"; location["msemr_addressstate"] = "New Mexico"; location["msemr_addresstext"] = "Primary Location"; location["msemr_addressperiodend"] = DateTime.Now; location["msemr_addressperiodstart"] = DateTime.Now.AddDays(20); Guid accountId = Organization.GetAccountId(_serviceProxy, "Galaxy Corp"); if (accountId != Guid.Empty) { location["msemr_managingorganization"] = new EntityReference("account", accountId); } Guid partOfLocationId = SDKFunctions.GetLocationId(_serviceProxy, "FHIR Organizational Unit"); if (partOfLocationId != Guid.Empty) { location["msemr_partof"] = new EntityReference("msemr_location", partOfLocationId); } Guid physicaltypeCodeableConceptId = SDKFunctions.GetCodeableConceptId(_serviceProxy, "si", 935000072); if (physicaltypeCodeableConceptId != Guid.Empty) { location["msemr_physicaltype"] = new EntityReference("msemr_codeableconcept", physicaltypeCodeableConceptId); } Guid typeCodeableConceptId = SDKFunctions.GetCodeableConceptId(_serviceProxy, "Dx", 935000131); if (typeCodeableConceptId != Guid.Empty) { location["msemr_type"] = new EntityReference("msemr_codeableconcept", typeCodeableConceptId); } location["msemr_mode"] = new OptionSetValue(935000001); //Kind location["msemr_status"] = new OptionSetValue(935000000); //Active location["msemr_operationalstatus"] = new OptionSetValue(935000004); //Occupied location["msemr_description"] = "Primary Location"; location["msemr_locationnumber"] = "L442"; location["msemr_locationalias1"] = "General Hospital"; location["msemr_locationpositionaltitude"] = (decimal)18524.5265; location["msemr_locationpositionlatitude"] = (decimal)24.15; location["msemr_locationpositionlongitude"] = (decimal)841.12; Guid locationId = _serviceProxy.Create(location); // Verify that the record has been created. if (locationId != Guid.Empty) { Console.WriteLine("Succesfully created {0}.", locationId); } } } // Catch any service fault exceptions that Microsoft Dynamics CRM throws. catch (FaultException <Microsoft.Xrm.Sdk.OrganizationServiceFault> ) { // You can handle an exception here or pass it back to the calling method. throw; } }
/// <summary> /// Create and configure the organization service proxy. /// Initiate the method to create any data that this sample requires. /// Create a referral request. /// </summary> public void Run(ServerConnection.Configuration serverConfig, bool promptforDelete) { try { //<snippetMarketingAutomation1> // Connect to the Organization service. // The using statement assures that the service proxy will be properly disposed. using (_serviceProxy = new OrganizationServiceProxy(serverConfig.OrganizationUri, serverConfig.HomeRealmUri, serverConfig.Credentials, serverConfig.DeviceCredentials)) { // This statement is required to enable early-bound type support. _serviceProxy.EnableProxyTypes(); Practitioner practioner = new Practitioner(); Entity referralRequest = new Entity("msemr_referralrequest"); //Primary Field referralRequest["msemr_name"] = "Andrea Leonardo"; //Setting context type as encounter referralRequest["msemr_contexttype"] = new OptionSetValue(935000000); //Encounter Guid subjectcontextencounterId = Encounter.GetEncounterId(_serviceProxy, "E23556"); if (subjectcontextencounterId != Guid.Empty) { referralRequest["msemr_subjectcontextencounter"] = new EntityReference("msemr_encounter", subjectcontextencounterId); } Guid encounterId = Encounter.GetEncounterId(_serviceProxy, "E23556"); if (encounterId != Guid.Empty) { referralRequest["msemr_initiatingencounter"] = new EntityReference("msemr_encounter", encounterId); } //Setting requester agent as Practitioner referralRequest["msemr_requesteragent"] = new OptionSetValue(935000000); //Practitioner Guid requesteragentpractitionerContactId = SDKFunctions.GetContactId(_serviceProxy, "Daniel Atlas"); if (requesteragentpractitionerContactId != Guid.Empty) { referralRequest["msemr_requesteragentpractitioner"] = new EntityReference("contact", requesteragentpractitionerContactId); } Guid requesteronbehalfofAccountId = Organization.GetAccountId(_serviceProxy, "Galaxy Corp"); if (requesteronbehalfofAccountId != Guid.Empty) { referralRequest["msemr_requesteronbehalfof"] = new EntityReference("account", requesteronbehalfofAccountId); } Guid requestorContactId = SDKFunctions.GetContactId(_serviceProxy, "James Kirk"); if (requestorContactId != Guid.Empty) { referralRequest["msemr_requestor"] = new EntityReference("contact", requestorContactId); } referralRequest["msemr_occurenceperiodstartdate"] = DateTime.Now; referralRequest["msemr_occurenceperiodenddate"] = DateTime.Now; referralRequest["msemr_occurrencedate"] = DateTime.Now; referralRequest["msemr_occurrencetype"] = new OptionSetValue(935000000); //Date referralRequest["msemr_authoredon"] = DateTime.Now; Guid typeCodeableConceptId = SDKFunctions.GetCodeableConceptId(_serviceProxy, "Referral Request", 935000094); if (typeCodeableConceptId != Guid.Empty) { referralRequest["msemr_type"] = new EntityReference("msemr_codeableconcept", typeCodeableConceptId); } Guid basedonreferralId = SDKFunctions.GetReferralRequestId(_serviceProxy, "Ref452"); if (basedonreferralId != Guid.Empty) { referralRequest["msemr_basedonreferral"] = new EntityReference("msemr_referralrequest", basedonreferralId); } Guid practitionerspecialtyCodeableConceptId = SDKFunctions.GetCodeableConceptId(_serviceProxy, "Psychiatric", 935000101); if (practitionerspecialtyCodeableConceptId != Guid.Empty) { referralRequest["msemr_practitionerspecialty"] = new EntityReference("msemr_codeableconcept", practitionerspecialtyCodeableConceptId); } referralRequest["msemr_priority"] = new OptionSetValue(935000000); //Routine referralRequest["msemr_intent"] = new OptionSetValue(935000000); //Proposal referralRequest["msemr_subject"] = new OptionSetValue(935000000); //Patient Guid subjectpatientContactId = SDKFunctions.GetContactId(_serviceProxy, "Emily Williams"); if (subjectpatientContactId != Guid.Empty) { referralRequest["msemr_subjectpatient"] = new EntityReference("contact", subjectpatientContactId); } referralRequest["msemr_status"] = new OptionSetValue(935000000); //Draft referralRequest["msemr_description"] = ""; referralRequest["msemr_referralrequestnumber"] = "Ref452"; referralRequest["msemr_groupidentifier"] = ""; Guid referralRequestId = _serviceProxy.Create(referralRequest); // Verify that the record has been created. if (referralRequestId != Guid.Empty) { Console.WriteLine("Succesfully created {0}.", referralRequestId); } } } // Catch any service fault exceptions that Microsoft Dynamics CRM throws. catch (FaultException <Microsoft.Xrm.Sdk.OrganizationServiceFault> ) { // You can handle an exception here or pass it back to the calling method. throw; } }
/// <summary> /// Create and configure the organization service proxy. /// Initiate the method to create any data that this sample requires. /// Create a healthcare service. /// </summary> public void Run(ServerConnection.Configuration serverConfig, bool promptforDelete) { try { //<snippetMarketingAutomation1> // Connect to the Organization service. // The using statement assures that the service proxy will be properly disposed. using (_serviceProxy = new OrganizationServiceProxy(serverConfig.OrganizationUri, serverConfig.HomeRealmUri, serverConfig.Credentials, serverConfig.DeviceCredentials)) { // This statement is required to enable early-bound type support. _serviceProxy.EnableProxyTypes(); Entity healthcareService = new Entity("msemr_healthcareservice"); healthcareService["msemr_name"] = "Surgical Treatment"; healthcareService["msemr_appointmentrequired"] = true; healthcareService["msemr_availabilityexceptions"] = "Public holiday availability"; healthcareService["msemr_comment"] = "More details"; healthcareService["msemr_healthcareservice"] = "Healthcare Service"; healthcareService["msemr_extradetails"] = "Extra Details"; healthcareService["msemr_notavailableduringenddatetime"] = DateTime.Now; healthcareService["msemr_notavailableduringstartdatetime"] = DateTime.Now; healthcareService["msemr_notavailabledescription"] = "Machine failure"; healthcareService["msemr_eligibilitynote"] = "Eligibility Note"; Guid eligibilityCodeableConceptId = SDKFunctions.GetCodeableConceptId(_serviceProxy, "Eligibile", 935000132); if (eligibilityCodeableConceptId != Guid.Empty) { healthcareService["msemr_eligibility"] = new EntityReference("msemr_codeableconcept", eligibilityCodeableConceptId); } Guid providedbyAccountId = Organization.GetAccountId(_serviceProxy, "Galaxy Corp"); if (providedbyAccountId != Guid.Empty) { healthcareService["msemr_providedby"] = new EntityReference("account", providedbyAccountId); } Guid categoryCodeableConceptId = SDKFunctions.GetCodeableConceptId(_serviceProxy, "Category", 935000129); if (categoryCodeableConceptId != Guid.Empty) { healthcareService["msemr_category"] = new EntityReference("msemr_codeableconcept", categoryCodeableConceptId); } Guid healthcareServiceId = _serviceProxy.Create(healthcareService); // Verify that the record has been created. if (healthcareServiceId != Guid.Empty) { Console.WriteLine("Succesfully created {0}.", healthcareServiceId); } } } // Catch any service fault exceptions that Microsoft Dynamics CRM throws. catch (FaultException <Microsoft.Xrm.Sdk.OrganizationServiceFault> ) { // You can handle an exception here or pass it back to the calling method. throw; } }