示例#1
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 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;
            }
        }
示例#3
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;
            }
        }
        /// <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;
            }
        }