コード例 #1
0
        /// <summary>
        /// Create and configure the organization service proxy.
        /// Initiate the method to create any data that this sample requires.
        /// Create a careplan.
        /// </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 careplan = new Entity("msemr_careplan");

                    careplan["msemr_careplanidentifier"] = "CP25741";
                    careplan["msemr_title"]      = "Dieting Care Plan";
                    careplan["msemr_planstatus"] = new OptionSetValue(935000003);

                    // Setting Context Type
                    careplan["msemr_contexttype"] = new OptionSetValue(935000000); //Encounter
                    Guid EncounterId = Encounter.GetEncounterId(_serviceProxy, "E23556");
                    if (EncounterId != Guid.Empty)
                    {
                        careplan["msemr_encounteridentifier"] = new EntityReference("msemr_encounter", EncounterId);
                    }

                    // Setting Subject Type
                    careplan["msemr_subjecttype"] = new OptionSetValue(935000000); //Patient
                    Guid PatientId = SDKFunctions.GetContactId(_serviceProxy, "James Kirk", 935000000);
                    if (PatientId != Guid.Empty)
                    {
                        careplan["msemr_patientidentifier"] = new EntityReference("contact", PatientId);
                    }

                    careplan["msemr_plandescription"] = "this plan is very specific for this type of case";
                    careplan["msemr_planintent"]      = new OptionSetValue(935000001);
                    careplan["msemr_planstartdate"]   = DateTime.Now;
                    careplan["msemr_planenddate"]     = DateTime.Now;

                    Guid CarePlanId = _serviceProxy.Create(careplan);

                    // Verify that the record has been created.
                    if (CarePlanId != Guid.Empty)
                    {
                        Console.WriteLine("Succesfully created {0}.", CarePlanId);
                    }
                }
            }
            // 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;
            }
        }
コード例 #2
0
        /// <summary>
        /// Create and configure the organization service proxy.
        /// Initiate the method to create any data that this sample requires.
        /// Create a medication administration.
        /// </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 medicationadministration = new Entity("msemr_medicationadministration");

                    medicationadministration["msemr_medicationadministrationnumber"] = "1234-abc";
                    medicationadministration["msemr_status"]     = new OptionSetValue(935000000);
                    medicationadministration["msemr_dosagetext"] = "--";
                    medicationadministration["msemr_notgiven"]   = true;
                    medicationadministration["msemr_dosagedose"] = 1;

                    //Setting Effective Type as DateTime
                    medicationadministration["msemr_effectivetype"]     = new OptionSetValue(935000000);//DateTime
                    medicationadministration["msemr_effectivedatetime"] = DateTime.Now;

                    //Setting Subject Type as Patient
                    medicationadministration["msemr_subjecttype"] = new OptionSetValue(935000000);
                    Guid SubjectTypePatient = SDKFunctions.GetContactId(_serviceProxy, "James Kirk", 935000000);
                    if (SubjectTypePatient != Guid.Empty)
                    {
                        medicationadministration["msemr_subjecttypepatient"] = new EntityReference("contact", SubjectTypePatient);
                    }

                    //Setting Context Type as Encounter
                    medicationadministration["msemr_contexttype"] = new OptionSetValue(935000000); //Encounter
                    Guid ContextTypeEncounter = Encounter.GetEncounterId(_serviceProxy, "E23556");
                    if (ContextTypeEncounter != Guid.Empty)
                    {
                        medicationadministration["msemr_contexttypeencounter"] = new EntityReference("msemr_encounter", ContextTypeEncounter);
                    }


                    //Setting Medication Type as Reference
                    medicationadministration["msemr_medicationtype"] = new OptionSetValue(935000001);//Refrence
                    Guid MedicationReference = Medication.GetProductId(_serviceProxy, "Panadol");
                    if (MedicationReference != Guid.Empty)
                    {
                        medicationadministration["msemr_medicationreference"] = new EntityReference("product", MedicationReference);
                    }

                    //Setting Dosage Rate Type as  Quantity
                    medicationadministration["msemr_dosageratetype"]     = new OptionSetValue(935000001);//Quantity
                    medicationadministration["msemr_dosageratequantity"] = 1;

                    Guid Category = SDKFunctions.GetCodeableConceptId(_serviceProxy, "Pain", 935000080);
                    if (Category != Guid.Empty)
                    {
                        medicationadministration["msemr_category"] = new EntityReference("msemr_codeableconcept", Category);
                    }
                    Guid Prescription = MedicationRequest.getMedicationRequestId(_serviceProxy, "MR-1234");
                    if (Prescription != Guid.Empty)
                    {
                        medicationadministration["msemr_prescription"] = new EntityReference("msemr_medicationrequest", Prescription);
                    }
                    Guid DosageSite = SDKFunctions.GetCodeableConceptId(_serviceProxy, "Route Code", 935000127);
                    if (DosageSite != Guid.Empty)
                    {
                        medicationadministration["msemr_dosagesite"] = new EntityReference("msemr_codeableconcept", DosageSite);
                    }

                    Guid DosageRoute = SDKFunctions.GetCodeableConceptId(_serviceProxy, "Route Code", 935000127);
                    if (DosageRoute != Guid.Empty)
                    {
                        medicationadministration["msemr_dosageroute"] = new EntityReference("msemr_codeableconcept", DosageRoute);
                    }
                    Guid DosageMethod = SDKFunctions.GetCodeableConceptId(_serviceProxy, "678-abc", 935000005);
                    if (DosageMethod != Guid.Empty)
                    {
                        medicationadministration["msemr_dosagemethod"] = new EntityReference("msemr_codeableconcept", DosageMethod);
                    }

                    Guid MedicationAdministrationId = _serviceProxy.Create(medicationadministration);

                    // Verify that the record has been created.
                    if (MedicationAdministrationId != Guid.Empty)
                    {
                        Console.WriteLine("Succesfully created {0}.", MedicationAdministrationId);
                    }
                }
            }
            // 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;
            }
        }
コード例 #3
0
        /// <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;
            }
        }
コード例 #4
0
        /// <summary>
        /// Create and configure the organization service proxy.
        /// Initiate the method to create any data that this sample requires.
        /// Create a procedure.
        /// </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 procedure = new Entity("msemr_procedure");

                    procedure["msemr_datetime"]           = DateTime.Now;
                    procedure["msemr_performedstartdate"] = DateTime.Now;
                    procedure["msemr_performedenddate"]   = DateTime.Now;
                    Guid EpisodeofCare = EpisodeOfCare.GetEpisodeOfCareId(_serviceProxy, "EPC-153");
                    if (EpisodeofCare != Guid.Empty)
                    {
                        procedure["msemr_episodeofcare"] = new EntityReference("msemr_episodeofcare", EpisodeofCare);
                    }

                    Guid Code = Medication.GetProductId(_serviceProxy, "Panadol");
                    if (Code != Guid.Empty)
                    {
                        procedure["msemr_code"] = new EntityReference("product", Code);
                    }

                    Guid LocationId = SDKFunctions.GetLocationId(_serviceProxy, "Noble Hospital Center");
                    if (LocationId != Guid.Empty)
                    {
                        procedure["msemr_location"] = new EntityReference("msemr_location", LocationId);
                    }
                    Guid NotDoneReason = SDKFunctions.GetCodeableConceptId(_serviceProxy, "Blood pressure was high", 935000109);
                    if (NotDoneReason != Guid.Empty)
                    {
                        procedure["msemr_notdonereason"] = new EntityReference("msemr_codeableconcept", NotDoneReason);
                    }
                    Guid Category = SDKFunctions.GetCodeableConceptId(_serviceProxy, "xyz-123", 935000103);
                    if (Category != Guid.Empty)
                    {
                        procedure["msemr_category"] = new EntityReference("msemr_codeableconcept", NotDoneReason);
                    }
                    Guid EncounterId = Encounter.GetEncounterId(_serviceProxy, "E23556");
                    if (EncounterId != Guid.Empty)
                    {
                        procedure["msemr_encounter"] = new EntityReference("msemr_encounter", EncounterId);
                    }

                    //Setting Subject Type as Patient
                    procedure["msemr_subjecttype"] = new OptionSetValue(935000000);  //Patient
                    Guid Patient = SDKFunctions.GetContactId(_serviceProxy, "James Kirk", 935000000);
                    if (Patient != Guid.Empty)
                    {
                        procedure["msemr_patient"] = new EntityReference("contact", Patient);
                    }

                    Guid Outcome = SDKFunctions.GetCodeableConceptId(_serviceProxy, "mno-123", 935000107);
                    if (Outcome != Guid.Empty)
                    {
                        procedure["msemr_outcome"] = new EntityReference("msemr_codeableconcept", Outcome);
                    }
                    procedure["msemr_status"] = new OptionSetValue(935000000);
                    procedure["msemr_procedureidentifier"] = "mdf/xyz";
                    procedure["msemr_notdone"]             = true;


                    Guid ProcedureId = _serviceProxy.Create(procedure);

                    // Verify that the record has been created.
                    if (ProcedureId != Guid.Empty)
                    {
                        Console.WriteLine("Succesfully created {0}.", ProcedureId);
                    }
                }
            }
            // 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;
            }
        }
コード例 #5
0
        /// <summary>
        /// Create and configure the organization service proxy.
        /// Initiate the method to create any data that this sample requires.
        /// Create a risk assessment.
        /// </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 riskAssessment = new Entity("msemr_riskassessment");

                    riskAssessment["msemr_name"] = "Operational Risk";

                    //Setting context type as encounter
                    riskAssessment["msemr_contexttype"] = new OptionSetValue(935000000); //Encounter
                    Guid encounterId = Encounter.GetEncounterId(_serviceProxy, "E23556");
                    if (encounterId != Guid.Empty)
                    {
                        riskAssessment["msemr_contextencounter"] = new EntityReference("msemr_encounter", encounterId);
                    }

                    //Setting performer type as practitioner
                    riskAssessment["msemr_performertype"] = new OptionSetValue(935000000); //Practitioner
                    Guid performerpractitionerContactId = SDKFunctions.GetContactId(_serviceProxy, "James Kirk");
                    if (performerpractitionerContactId != Guid.Empty)
                    {
                        riskAssessment["msemr_performerpractitioner"] = new EntityReference("contact", performerpractitionerContactId);
                    }

                    //Setting reason type as codeable concept
                    riskAssessment["msemr_reasontype"] = new OptionSetValue(935000000); //Codeable concept
                    Guid reasonconceptCodeableConceptId = SDKFunctions.GetCodeableConceptId(_serviceProxy, "Risk Assessment Reason Code", 935000126);
                    if (reasonconceptCodeableConceptId != Guid.Empty)
                    {
                        riskAssessment["msemr_reasonconcept"] = new EntityReference("msemr_codeableconcept", reasonconceptCodeableConceptId);
                    }

                    //Setting subject type as codeable patient
                    riskAssessment["msemr_subjecttype"] = new OptionSetValue(935000000); //Patient
                    Guid subjectpatientContactId = SDKFunctions.GetContactId(_serviceProxy, "James Kirk");
                    if (subjectpatientContactId != Guid.Empty)
                    {
                        riskAssessment["msemr_subjectpatient"] = new EntityReference("contact", subjectpatientContactId);
                    }
                    riskAssessment["msemr_occurrencetype"]      = new OptionSetValue(935000000); //Time
                    riskAssessment["msemr_occurrencestartdate"] = DateTime.Now;
                    riskAssessment["msemr_occurrenceenddate"]   = DateTime.Now;
                    riskAssessment["msemr_occurrencedatetime"]  = DateTime.Now;

                    Guid conditionId = SDKFunctions.GetConditionId(_serviceProxy, "Tooth loss");
                    if (conditionId != Guid.Empty)
                    {
                        riskAssessment["msemr_condition"] = new EntityReference("msemr_condition", conditionId);
                    }

                    Guid methodCodeableConceptId = SDKFunctions.GetCodeableConceptId(_serviceProxy, "Method", 935000124);
                    if (methodCodeableConceptId != Guid.Empty)
                    {
                        riskAssessment["msemr_method"] = new EntityReference("msemr_codeableconcept", methodCodeableConceptId);
                    }

                    Guid codeCodeableConceptId = SDKFunctions.GetCodeableConceptId(_serviceProxy, "Code", 935000123);
                    if (codeCodeableConceptId != Guid.Empty)
                    {
                        riskAssessment["msemr_code"] = new EntityReference("msemr_codeableconcept", codeCodeableConceptId);
                    }

                    riskAssessment["msemr_basedon"] = "";

                    riskAssessment["msemr_parent"] = "";

                    riskAssessment["msemr_basis"] = "";

                    riskAssessment["msemr_status"] = new OptionSetValue(935000000); //Registered

                    riskAssessment["msemr_comment"] = "";

                    riskAssessment["msemr_mitigation"] = "";

                    riskAssessment["msemr_riskassessmentnumber"] = "RAN865";

                    Guid riskAssessmentId = _serviceProxy.Create(riskAssessment);

                    // Verify that the record has been created.
                    if (riskAssessmentId != Guid.Empty)
                    {
                        Console.WriteLine("Succesfully created {0}.", riskAssessmentId);
                    }
                }
            }
            // 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;
            }
        }
コード例 #6
0
        /// <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;
            }
        }
コード例 #7
0
        /// <summary>
        /// Create and configure the organization service proxy.
        /// Initiate the method to create any data that this sample requires.
        /// Create an observation.
        /// </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 observation = new Entity("msemr_observation");

                    observation["msemr_identifier"]  = "OBS-123";
                    observation["msemr_comment"]     = "following Schedule";
                    observation["msemr_description"] = "Recovery is good";
                    observation["msemr_status"]      = new OptionSetValue(935000000);

                    //Setting Context Type as Encounter
                    observation["msemr_contexttype"] = new OptionSetValue(935000001); //Encounter
                    Guid EncounterId = Encounter.GetEncounterId(_serviceProxy, "E23556");
                    if (EncounterId != Guid.Empty)
                    {
                        observation["msemr_conexttypeencounter"] = new EntityReference("msemr_encounter", EncounterId);
                    }

                    //Setting Device Type as Device Metric
                    observation["msemr_devicetype"] = new OptionSetValue(935000001);
                    Guid DeviceMetricId = SDKFunctions.GetDeviceMetricId(_serviceProxy, "Device Metric");
                    if (DeviceMetricId != Guid.Empty)
                    {
                        observation["msemr_devicetypedevicemetric"] = new EntityReference("msemr_device", DeviceMetricId);
                    }

                    //Setting Effictive as DateTime
                    observation["msemr_effectivetype"]         = new OptionSetValue(935000000); //DateTime
                    observation["msemr_effectivetypedatetime"] = DateTime.Now;

                    //Setting Subject Type as Device
                    observation["msemr_subjecttype"] = new OptionSetValue(935000002);//Device
                    Guid SubjectTypeDevice = Device.GetDeviceId(_serviceProxy, "Pacemaker");
                    if (SubjectTypeDevice != Guid.Empty)
                    {
                        observation["msemr_subjecttypedevice"] = new EntityReference("msemr_device", SubjectTypeDevice);
                    }


                    //Setting Value Type as Range
                    observation["msemr_valuetype"]           = new OptionSetValue(935000004); //Range
                    observation["msemr_valuerangehighlimit"] = 10;
                    observation["msemr_valuerangelowlimit"]  = 1;


                    Guid BodySite = SDKFunctions.GetCodeableConceptId(_serviceProxy, "Body Site", 100000000);
                    if (BodySite != Guid.Empty)
                    {
                        observation["msemr_bodysite"] = new EntityReference("msemr_codeableconcept", BodySite);
                    }
                    Guid Code = SDKFunctions.GetCodeableConceptId(_serviceProxy, "Observation Name", 935000073);
                    if (Code != Guid.Empty)
                    {
                        observation["msemr_code"] = new EntityReference("msemr_codeableconcept", Code);
                    }

                    Guid EpisodeOfCareId = EpisodeOfCare.GetEpisodeOfCareId(_serviceProxy, "EPC-153");
                    if (EpisodeOfCareId != Guid.Empty)
                    {
                        observation["msemr_episodeofcare"] = new EntityReference("msemr_episodeofcare", EpisodeOfCareId);
                    }
                    Guid DataAbsentReason = SDKFunctions.GetCodeableConceptId(_serviceProxy, "Absent Reason", 935000090);
                    if (DataAbsentReason != Guid.Empty)
                    {
                        observation["msemr_dataabsentreason"] = new EntityReference("msemr_codeableconcept", DataAbsentReason);
                    }
                    Guid DeviceId = Device.GetDeviceId(_serviceProxy, "MAGNETOM Sola");
                    if (DeviceId != Guid.Empty)
                    {
                        observation["msemr_device"] = new EntityReference("msemr_device", DeviceId);
                    }
                    Guid Interpretation = SDKFunctions.GetCodeableConceptId(_serviceProxy, "Interpretation Code", 935000085);
                    if (Interpretation != Guid.Empty)
                    {
                        observation["msemr_interpretation"] = new EntityReference("msemr_codeableconcept", Interpretation);
                    }
                    observation["msemr_issueddate"] = DateTime.Now;
                    Guid Method = SDKFunctions.GetCodeableConceptId(_serviceProxy, "Interpretation Code", 935000086);
                    if (Method != Guid.Empty)
                    {
                        observation["msemr_method"] = new EntityReference("msemr_codeableconcept", Method);
                    }
                    observation["msemr_observationnumber"] = "OBS-123";
                    Guid SpecimenId = SDKFunctions.GetSpecimenId(_serviceProxy, "SP-1234");
                    if (SpecimenId != Guid.Empty)
                    {
                        observation["msemr_specimen"] = new EntityReference("msemr_specimen", SpecimenId);
                    }


                    Guid ObservationId = _serviceProxy.Create(observation);

                    // Verify that the record has been created.
                    if (ObservationId != Guid.Empty)
                    {
                        Console.WriteLine("Succesfully created {0}.", ObservationId);
                    }
                }
            }
            // 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;
            }
        }