Esempio n. 1
0
        /// <summary>
        /// Create and configure the organization service proxy.
        /// Initiate the method to create any data that this sample requires.
        /// Create a practitioner.
        /// </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 practitioner = new Entity("contact");

                    //Setting contact type as practioner
                    practitioner["msemr_contacttype"] = new OptionSetValue(935000001);
                    practitioner["firstname"]         = "John";
                    practitioner["lastname"]          = "Smith";

                    Guid GeneralPractioner = SDKFunctions.GetContactId(_serviceProxy, "Emily Williams", 935000001);
                    if (GeneralPractioner != Guid.Empty)
                    {
                        practitioner["msemr_generalpractioner"] = new EntityReference("contact", GeneralPractioner);
                    }

                    practitioner["emailaddress1"] = "*****@*****.**";
                    practitioner["telephone2"]    = "1-888-751-4083";
                    practitioner["mobilephone"]   = "555-555-1234";
                    practitioner["telephone1"]    = "653-123-1234";
                    practitioner["preferredcontactmethodcode"] = new OptionSetValue(3); //Phone
                    practitioner["gendercode"]               = new OptionSetValue(1);   //Male
                    practitioner["familystatuscode"]         = new OptionSetValue(2);   //Married
                    practitioner["anniversary"]              = DateTime.Now.AddYears(-20);
                    practitioner["spousesname"]              = "Crista Smith";
                    practitioner["address1_line1"]           = "3386";
                    practitioner["address1_line2"]           = "Gateway Avenue";
                    practitioner["address1_city"]            = "Lancaster";
                    practitioner["address1_stateorprovince"] = "CA";
                    practitioner["address1_postalcode"]      = "93534";
                    practitioner["address1_country"]         = "US";

                    practitioner["birthdate"] = DateTime.Now.AddYears(-50);

                    Guid PractionerId = _serviceProxy.Create(practitioner);

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

                    organization["name"] = "Galaxy Corp";

                    organization["msemr_address1periodstartdate"] = DateTime.Now;
                    organization["msemr_address1periodenddate"]   = DateTime.Now;

                    organization["msemr_telecom1startdate"] = DateTime.Now;
                    organization["msemr_telecom1enddate"]   = DateTime.Now;
                    organization["msemr_telecom1system"]    = new OptionSetValue(935000001); //Email
                    organization["msemr_telecom1use"]       = new OptionSetValue(935000001); //Work
                    organization["msemr_telecom1rank"]      = 18;

                    organization["msemr_accounttype"] = new OptionSetValue(935000001); //Organization

                    organization["msemr_alias"] = "Galaxy";

                    Guid primaryContact = SDKFunctions.GetContactId(_serviceProxy, "James Kirk");
                    if (primaryContact != Guid.Empty)
                    {
                        organization["primarycontactid"] = new EntityReference("contact", primaryContact);
                    }
                    Guid contact1puroposeCodeableConceptId = SDKFunctions.GetCodeableConceptId(_serviceProxy, "BILL", 935000027);
                    if (contact1puroposeCodeableConceptId != Guid.Empty)
                    {
                        organization["msemr_contact1puropose"] = new EntityReference("msemr_codeableconcept", contact1puroposeCodeableConceptId);
                    }

                    Guid organizationId = _serviceProxy.Create(organization);

                    // Verify that the record has been created.
                    if (organizationId != Guid.Empty)
                    {
                        Console.WriteLine("Succesfully created {0}.", organizationId);
                    }
                }
            }
            // 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;
            }
        }
Esempio n. 3
0
        /// <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;
            }
        }
Esempio n. 4
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;
            }
        }
Esempio n. 5
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;
            }
        }
        /// <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 an appointment.
        /// </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 appointmentemr = new Entity("msemr_appointmentemr");

                    appointmentemr["subject"] = "Routine";

                    //Setting participant actor type as patient
                    appointmentemr["msemr_participantactortype"] = new OptionSetValue(935000000); //Patient
                    Guid actorpatientContactId = SDKFunctions.GetContactId(_serviceProxy, "Daniel Atlas");
                    if (actorpatientContactId != Guid.Empty)
                    {
                        appointmentemr["msemr_actorpatient"] = new EntityReference("contact", actorpatientContactId);
                    }

                    Guid particpanttypeCodeableConceptId = SDKFunctions.GetCodeableConceptId(_serviceProxy, "Participant Type", 935000092);
                    if (particpanttypeCodeableConceptId != Guid.Empty)
                    {
                        appointmentemr["msemr_particpanttype"] = new EntityReference("msemr_codeableconcept", particpanttypeCodeableConceptId);
                    }

                    appointmentemr["msemr_participantstatus"] = new OptionSetValue(935000000); //Accepted

                    appointmentemr["msemr_appointmentcreationdate"] = DateTime.Now;

                    Guid appointmentTypeId = SDKFunctions.GetAppointmentTypeId(_serviceProxy, "New");
                    if (appointmentTypeId != Guid.Empty)
                    {
                        appointmentemr["msemr_appointmenttype"] = new EntityReference("msdyn_workordertype", appointmentTypeId);
                    }

                    appointmentemr["msemr_comment"] = "";

                    appointmentemr["msemr_description"] = "General";

                    appointmentemr["msemr_starttime"]       = DateTime.Now;
                    appointmentemr["msemr_endtime"]         = DateTime.Now;
                    appointmentemr["msemr_minutesduration"] = 20;

                    appointmentemr["msemr_patientinstruction"] = "";

                    appointmentemr["msemr_priority"] = 1;

                    appointmentemr["msemr_required"] = new OptionSetValue(935000002); //Information Only

                    Guid servicecategoryCodeableConceptId = SDKFunctions.GetCodeableConceptId(_serviceProxy, "Category", 935000129);
                    if (servicecategoryCodeableConceptId != Guid.Empty)
                    {
                        appointmentemr["msemr_servicecategory"] = new EntityReference("msemr_codeableconcept", servicecategoryCodeableConceptId);
                    }

                    Guid bookingsStatusId = SDKFunctions.GetBookingStatusId(_serviceProxy, "Committed");
                    if (bookingsStatusId != Guid.Empty)
                    {
                        appointmentemr["msemr_status"] = new EntityReference("bookingstatus", bookingsStatusId);
                    }

                    appointmentemr["msemr_supportinginformation"] = "";

                    Guid appointmentemrId = _serviceProxy.Create(appointmentemr);

                    // Verify that the record has been created.
                    if (appointmentemrId != Guid.Empty)
                    {
                        Console.WriteLine("Succesfully created {0}.", appointmentemrId);
                    }
                }
            }
            // 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;
            }
        }
Esempio n. 8
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;
            }
        }
Esempio n. 9
0
        /// <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;
            }
        }
Esempio n. 10
0
        /// <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;
            }
        }
Esempio n. 14
0
        /// <summary>
        /// Create and configure the organization service proxy.
        /// Initiate the method to create any data that this sample requires.
        /// Create a medication.
        /// </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 product = new Entity("product");

                    product["name"] = "Paracetamol";

                    Guid medicationcodeCodeableConceptId = SDKFunctions.GetCodeableConceptId(_serviceProxy, "HCPCS", 935000076);
                    if (medicationcodeCodeableConceptId != Guid.Empty)
                    {
                        product["msemr_medicationcode"] = new EntityReference("msemr_codeableconcept", medicationcodeCodeableConceptId);
                    }

                    Guid formCodeableConceptId = SDKFunctions.GetCodeableConceptId(_serviceProxy, "1095-C", 935000058);
                    if (formCodeableConceptId != Guid.Empty)
                    {
                        product["msemr_form"] = new EntityReference("msemr_codeableconcept", formCodeableConceptId);
                    }

                    Guid packagecontainerCodeableConceptId = SDKFunctions.GetCodeableConceptId(_serviceProxy, "Blister pack", 935000077);
                    if (packagecontainerCodeableConceptId != Guid.Empty)
                    {
                        product["msemr_packagecontainer"] = new EntityReference("msemr_codeableconcept", packagecontainerCodeableConceptId);
                    }

                    Guid defaultUnitId = GetDefaultUnit(_serviceProxy, "Primary Unit");
                    if (defaultUnitId != Guid.Empty)
                    {
                        product["defaultuomid"] = new EntityReference("uom", defaultUnitId);
                    }

                    Guid unitGroupId = GetUnitGroup(_serviceProxy, "Default Unit");
                    if (unitGroupId != Guid.Empty)
                    {
                        product["defaultuomscheduleid"] = new EntityReference("uomschedule", unitGroupId);
                    }

                    product["msemr_isoverthecounter"] = true;

                    product["msemr_isbrand"] = true;

                    Guid productid = _serviceProxy.Create(product);

                    // Verify that the record has been created.
                    if (productid != Guid.Empty)
                    {
                        Console.WriteLine("Succesfully created {0}.", productid);
                    }
                }
            }
            // 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;
            }
        }
Esempio n. 15
0
        /// <summary>
        /// Create and configure the organization service proxy.
        /// Initiate the method to create any data that this sample requires.
        /// Create a device.
        /// </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 device = new Entity("msemr_device");

                    device["msemr_name"]             = "MAGNETOM Sola";
                    device["msemr_manufacturer"]     = "Siemens Healthineers";
                    device["msemr_manufacturerdate"] = DateTime.Now;
                    device["msemr_model"]            = "1.5T";
                    device["msemr_carrieraidc"]      = "abc-123-zxy";
                    device["msemr_devicenumber"]     = "dvc-00789";
                    device["msemr_devicestatus"]     = new OptionSetValue(935000000);
                    device["msemr_expirationdate"]   = DateTime.Now.AddYears(3);

                    Guid LocationId = SDKFunctions.GetLocationId(_serviceProxy, "Noble Hospital Center");
                    if (LocationId != Guid.Empty)
                    {
                        device["msemr_location"] = new EntityReference("msemr_location", LocationId);
                    }
                    device["msemr_lotnumber"] = "123456";


                    Guid PatientId = SDKFunctions.GetContactId(_serviceProxy, "James Kirk", 935000000);
                    if (PatientId != Guid.Empty)
                    {
                        device["msemr_patient"] = new EntityReference("contact", PatientId);
                    }

                    Guid CodeableConceptId = SDKFunctions.GetCodeableConceptId(_serviceProxy, "271003", 935000037);
                    if (CodeableConceptId != Guid.Empty)
                    {
                        device["msemr_type"] = new EntityReference("msemr_codeableconcept", CodeableConceptId);
                    }
                    device["msemr_udi"]             = "xyz-123";
                    device["msemr_udicarrierhrf"]   = "abc-987";
                    device["msemr_udientrytype"]    = new OptionSetValue(935000002);
                    device["msemr_udiissuer"]       = "GS1";
                    device["msemr_udijurisdiction"] = "http://hl7.org/fhir/NamingSystem/fda-udi";
                    device["msemr_url"]             = "http://www.device.com";
                    device["msemr_version"]         = "1.0.0.0";

                    Guid DeviceId = _serviceProxy.Create(device);

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