コード例 #1
0
        /// <summary>
        /// Deserialize JSON into a FHIR RelatedPerson
        /// </summary>
        public static void DeserializeJson(this RelatedPerson current, ref Utf8JsonReader reader, JsonSerializerOptions options)
        {
            string propertyName;

            while (reader.Read())
            {
                if (reader.TokenType == JsonTokenType.EndObject)
                {
                    return;
                }

                if (reader.TokenType == JsonTokenType.PropertyName)
                {
                    propertyName = reader.GetString();
                    if (Hl7.Fhir.Serialization.FhirSerializerOptions.Debug)
                    {
                        Console.WriteLine($"RelatedPerson >>> RelatedPerson.{propertyName}, depth: {reader.CurrentDepth}, pos: {reader.BytesConsumed}");
                    }
                    reader.Read();
                    current.DeserializeJsonProperty(ref reader, options, propertyName);
                }
            }

            throw new JsonException($"RelatedPerson: invalid state! depth: {reader.CurrentDepth}, pos: {reader.BytesConsumed}");
        }
コード例 #2
0
        public async Task <RelatedPerson> AddRelatedPersonAsync(RelatedPerson relatedPerson)
        {
            _uow.RelatedPeople.Add(relatedPerson);
            await _uow.SaveChangesAsync().ConfigureAwait(false);

            return(relatedPerson);
        }
コード例 #3
0
        public void gender_null_RelatedPerson_should_map_to_SSG_Identity_correctly()
        {
            var relatedPerson = new RelatedPerson()
            {
                FirstName   = "FirstName",
                Description = "test description",
                Notes       = "notes",
                Gender      = null,
            };
            SSG_Identity ssg_relatedPerson = _mapper.Map <SSG_Identity>(relatedPerson);

            Assert.AreEqual(null, ssg_relatedPerson.Gender);
        }
コード例 #4
0
        public async Task <RelatedPerson> UpdateRelatedPersonAsync(RelatedPerson relatedPerson)
        {
            //var cmd = $"EXEC RelatedPerson_Update @RelatedPersonId = {relatedPerson.RelatedPersonId}," +
            //$" @Name = N'{relatedPerson.Name}',"+
            //$" @Family = N'{relatedPerson.Family}',"+
            //$" @Phone = N'{relatedPerson.Phone}'";

            //await _uow.Database.ExecuteSqlCommandAsync(cmd).ConfigureAwait(false);
            _uow.Entry(relatedPerson).State = EntityState.Modified;
            await _uow.SaveChangesAsync().ConfigureAwait(false);

            return(relatedPerson);
        }
        public async Task <bool> Handle(AddRelatedPersonCommand request, CancellationToken cancellationToken)
        {
            var person = await _personRepository.FindByIdAsync(request.PersonId);

            var relatedPerson = new RelatedPerson((RelationType)request.RelationType, request.RelatedPersonId, request.RelationId);

            if (request.Delete)
            {
                person.RemoveRelatedPerson(relatedPerson);
            }

            person.AddRelatedPerson(relatedPerson);

            return(true);
        }
コード例 #6
0
        //private void OnEditRelatedPerson(RelatedPerson relatedPerson)
        //{
        //    relatedPerson.RelatedPersonId = RelatedId;
        //    EditRelatedPersonRequested(relatedPerson);
        //}

        private async void OnDeleteRelatedPerson(RelatedPerson relatedPerson)
        {
            if (Deleting?.Invoke() == true)
            {
                try
                {
                    await _relatedPeopleService.DeleteRelatedPersonAsync(relatedPerson.RelatedPersonId);

                    RelatedPeople.Remove(relatedPerson);
                    Deleted();
                }
                catch (Exception ex)
                {
                    Failed(ex);
                }
            }
        }
コード例 #7
0
        public void RelatedPerson_should_map_to_SSG_Identity_correctly()
        {
            var relatedPerson = new RelatedPerson()
            {
                FirstName      = "FirstName",
                LastName       = "LastName",
                MiddleName     = "MiddleName",
                OtherName      = "OtherName",
                Type           = "Aunt",
                Description    = "test description",
                Notes          = "notes",
                Gender         = "U",
                DateOfBirth    = new DateTimeOffset(new DateTime(2012, 3, 4)),
                ReferenceDates = new List <ReferenceDate>()
                {
                    new ReferenceDate()
                    {
                        Index = 0, Key = "relation start date", Value = new DateTimeOffset(new DateTime(2012, 1, 1))
                    },
                    new ReferenceDate()
                    {
                        Index = 1, Key = "relation end date", Value = new DateTimeOffset(new DateTime(2014, 1, 1))
                    }
                }
            };
            SSG_Identity ssg_relatedPerson = _mapper.Map <SSG_Identity>(relatedPerson);

            Assert.AreEqual("FirstName", ssg_relatedPerson.FirstName);
            Assert.AreEqual("LastName", ssg_relatedPerson.LastName);
            Assert.AreEqual("MiddleName", ssg_relatedPerson.MiddleName);
            Assert.AreEqual("OtherName", ssg_relatedPerson.ThirdGivenName);
            Assert.AreEqual("test description", ssg_relatedPerson.Description);
            Assert.AreEqual("notes", ssg_relatedPerson.Notes);
            Assert.AreEqual(867670002, ssg_relatedPerson.Type);
            Assert.AreEqual("Aunt", ssg_relatedPerson.SupplierRelationType);
            Assert.AreEqual(new DateTime(2012, 3, 4), ssg_relatedPerson.DateOfBirth);
            Assert.AreEqual(867670002, ssg_relatedPerson.Gender);
            Assert.AreEqual(1, ssg_relatedPerson.StatusCode);
            Assert.AreEqual(0, ssg_relatedPerson.StateCode);
            Assert.AreEqual(new DateTime(2012, 1, 1), ssg_relatedPerson.Date1);
            Assert.AreEqual(new DateTime(2014, 1, 1), ssg_relatedPerson.Date2);
            Assert.AreEqual("relation start date", ssg_relatedPerson.Date1Label);
            Assert.AreEqual("relation end date", ssg_relatedPerson.Date2Label);
        }
コード例 #8
0
        public AddRelatedPersonResponse AddRelatedPerson(AddRelatedPersonRequest request)
        {
            try
            {
                var persons = _db.Persons.AsNoTracking().Where(t => t.Id == request.PersonId || t.Id == request.RelatedPersonId).ToList();
                if (persons.Count == 0)
                {
                    return(Fail(new AddRelatedPersonResponse(), RsStrings.PersonAndRelatedPersonNotFound));
                }

                if (!persons.Where(t => t.Id == request.PersonId).Any())
                {
                    return(Fail(new AddRelatedPersonResponse(), RsStrings.PersonNotFound));
                }

                if (!persons.Where(t => t.Id == request.RelatedPersonId).Any())
                {
                    return(Fail(new AddRelatedPersonResponse(), RsStrings.RelatedPersonNotFound));
                }

                var relatedPerson = new RelatedPerson
                {
                    PersonId        = request.PersonId,
                    RelatedPersonId = request.RelatedPersonId,
                    RelationTypeId  = (int)Enum.Parse(typeof(RelationType), request.RelationType)
                };

                _db.RelatedPersons.Add(relatedPerson);
                _db.SaveChanges();

                return(Success(new AddRelatedPersonResponse()));
            }
            catch (Exception ex)
            {
                return(Error(new AddRelatedPersonResponse(), RsStrings.AddRelatedPersonUnexpectedException));
            }
        }
コード例 #9
0
        public void SSG_Identity_should_map_to_RelatedPerson_correctly()
        {
            SSG_Identity relatedPerson = new SSG_Identity
            {
                PersonType     = RelatedPersonPersonType.Relation.Value,
                Type           = PersonRelationType.Friend.Value,
                FirstName      = "firstName",
                MiddleName     = "middleNm",
                LastName       = "lastNm",
                ThirdGivenName = "middleNm2",
                Gender         = GenderType.Female.Value,
                DateOfBirth    = new DateTime(2015, 1, 1),
                DateOfDeath    = new DateTime(2020, 10, 1)
            };

            RelatedPerson person = _mapper.Map <RelatedPerson>(relatedPerson);

            Assert.AreEqual("firstName", person.FirstName);
            Assert.AreEqual("f", person.Gender);
            Assert.AreEqual("Relation", person.PersonType);
            Assert.AreEqual("Friend", person.Type);
            Assert.AreEqual(new DateTimeOffset(new DateTime(2015, 1, 1)), person.DateOfBirth);
            Assert.AreEqual(new DateTimeOffset(new DateTime(2020, 10, 1)), person.DateOfDeath);
        }
コード例 #10
0
        /// <summary>
        /// Our Primary Thread in this class
        /// It will be created 1 time by the caller
        /// Then it will create secondary worker threads
        /// which it will then block (wait on)
        /// until they have completed or failed or shut down
        /// </summary>
        public string CreateProfiles(OrganizationServiceProxy _service)
        {
            // We need to create our file if it exists
            // or if it's already open, generate a second one.

            /// <summary>
            /// validate if we want to add directly to CRM or not
            /// </summary>
            try
            {
                if (this.Clients > 0)
                {
                    // since we are dividing up the creates per thread
                    // we have to check if it is equal across all threads
                    // if not then we want to add the rest to the last thread
                    // technically we could create another client thread
                    // but we are going by what they told us.
                    // this shouldn't cause too many issues based on count and remainder

                    List <Thread> threads = new List <Thread>();

                    for (int createthreads = 0; createthreads < this.Clients; createthreads++)
                    {
                        // create our thread and start it
                        // it's a parameterized query so pass in the proper values from above
                        Thread clientthread = new Thread(() => CreateCDSProfile(_service));
                        clientthread.Name = createthreads.ToString() + "-" + profileType.ToString();
                        clientthread.Start();

                        // add to our list of threads
                        // we do this so that we can essentially block the main console
                        // thread..otherwise it would exit before these guys are done
                        // add these to the total list first
                        threads.Add(clientthread);
                    }

                    // once all threads are created
                    // join with them.. if it fails that only means the thread
                    // was done (possibly a weird other situation.. but doubtful)
                    // so it's ok to fail on any threads (or all)
                    // which would either make us block for them to complete
                    // or if they were magically done.. join (0) and exit.
                    foreach (Thread t in threads)
                    {
                        try
                        {
                            t.Join();
                        }
                        catch (Exception JoinEx)
                        {
                            // ignore for now as it's not useful to the process
                            // if we error out because the thread was already done
                            // which might be possible in a multi-threaded usage scenario
                            // but that is ok
                            System.Diagnostics.Debug.WriteLine("Thread Join Error: " + JoinEx.ToString());
                        }
                    }


                    switch (ProfileType)
                    {
                    case Profile.ProfileType.Standard:
                    {
                        Contact.ExportToJson(FileName, OutgoingProfiles);
                        break;
                    }

                    case Profile.ProfileType.Patient:
                    {
                        Patient.ExportToJson(FileName, OutgoingProfiles);
                        break;
                    }

                    case Profile.ProfileType.Practitioner:
                    {
                        Practitioner.ExportToJson(FileName, OutgoingProfiles);
                        break;
                    }

                    case Profile.ProfileType.RelatedPerson:
                    {
                        RelatedPerson.ExportToJson(FileName, OutgoingProfiles);
                        break;
                    }

                    case Profile.ProfileType.Organization:
                    {
                        Organization.ExportToJson(FileName, OutgoingProfiles);
                        break;
                    }

                    case Profile.ProfileType.Location:
                    {
                        Location.ExportToJson(FileName, OutgoingProfiles);
                        break;
                    }

                    case Profile.ProfileType.Medication:
                    {
                        Location.ExportToJson(FileName, OutgoingProfiles);
                        break;
                    }
                    }
                }

                else
                {
                    throw new ArgumentException("Invalid Client value. Client must be > 0");
                }
            }
            catch (Exception ex)
            {
                throw new Exception(ex.ToString());
            }

            return(FileName);
        }
コード例 #11
0
        private async Task <(Dictionary <(string resourceType, string resourceId), Resource> serverData, string groupId)> CreateGroupWithPatient(bool includeAllResources)
        {
            // Add data for test
            var patient         = new Patient();
            var patientResponse = await _testFhirClient.CreateAsync(patient);

            var patientId = patientResponse.Resource.Id;

            var relative = new RelatedPerson()
            {
                Patient = new ResourceReference($"{KnownResourceTypes.Patient}/{patientId}"),
            };

            var relativeResponse = await _testFhirClient.CreateAsync(relative);

            var relativeId = relativeResponse.Resource.Id;

            var encounter = new Encounter()
            {
                Status = Encounter.EncounterStatus.InProgress,
                Class  = new Coding()
                {
                    Code = "test",
                },
                Subject = new ResourceReference($"{KnownResourceTypes.Patient}/{patientId}"),
            };

            var encounterResponse = await _testFhirClient.CreateAsync(encounter);

            var encounterId = encounterResponse.Resource.Id;

            var observation = new Observation()
            {
                Status = ObservationStatus.Final,
                Code   = new CodeableConcept()
                {
                    Coding = new List <Coding>()
                    {
                        new Coding()
                        {
                            Code = "test",
                        },
                    },
                },
                Subject = new ResourceReference($"{KnownResourceTypes.Patient}/{patientId}"),
            };

            var observationResponse = await _testFhirClient.CreateAsync(observation);

            var observationId = observationResponse.Resource.Id;

            var group = new FhirGroup()
            {
                Type   = FhirGroup.GroupType.Person,
                Actual = true,
                Member = new List <FhirGroup.MemberComponent>()
                {
                    new FhirGroup.MemberComponent()
                    {
                        Entity = new ResourceReference($"{KnownResourceTypes.Patient}/{patientId}"),
                    },
                },
            };

            var groupResponse = await _testFhirClient.CreateAsync(group);

            var groupId = groupResponse.Resource.Id;

            var resourceDictionary = new Dictionary <(string resourceType, string resourceId), Resource>();

            resourceDictionary.Add((KnownResourceTypes.RelatedPerson, relativeId), relativeResponse.Resource);
            resourceDictionary.Add((KnownResourceTypes.Encounter, encounterId), encounterResponse.Resource);

            if (includeAllResources)
            {
                resourceDictionary.Add((KnownResourceTypes.Patient, patientId), patientResponse.Resource);
                resourceDictionary.Add((KnownResourceTypes.Observation, observationId), observationResponse.Resource);
                resourceDictionary.Add((KnownResourceTypes.Group, groupId), groupResponse.Resource);
            }

            return(resourceDictionary, groupId);
        }
コード例 #12
0
 public async Task AddAsync(RelatedPerson relatedPerson)
 {
     _context.RelatedPersons.Add(relatedPerson);
     await _context.SaveChangesAsync();
 }
コード例 #13
0
        public static Bundle getBundle(string basePath)
        {
            Bundle bdl = new Bundle();

            bdl.Type = Bundle.BundleType.Document;

            // A document must have an identifier with a system and a value () type = 'document' implies (identifier.system.exists() and identifier.value.exists())

            bdl.Identifier = new Identifier()
            {
                System = "urn:ietf:rfc:3986",
                Value  = FhirUtil.createUUID()
            };

            //Composition for Discharge Summary
            Composition c = new Composition();

            //B.2 患者基本情報
            // TODO 退院時サマリー V1.41 B.2 患者基本情報のproviderOrganizationの意図を確認 B.8 受診、入院時情報に入院した
            //医療機関の記述が書かれているならば、ここの医療機関はどういう位置づけのもの? とりあえず、managingOrganizationにいれておくが。
            Patient patient = null;

            if (true)
            {
                //Patientリソースを自前で生成する場合
                patient = PatientUtil.create();
            }
            else
            {
                //Patientリソースをサーバから取ってくる場合
                #pragma warning disable 0162
                patient = PatientUtil.get();
            }

            Practitioner practitioner = PractitionerUtil.create();
            Organization organization = OrganizationUtil.create();

            patient.ManagingOrganization = new ResourceReference()
            {
                Reference = organization.Id
            };


            //Compositionの作成

            c.Id     = FhirUtil.createUUID();         //まだFHIRサーバにあげられていないから,一時的なUUIDを生成してリソースIDとしてセットする
            c.Status = CompositionStatus.Preliminary; //最終版は CompositionStatus.Final
            c.Type   = new CodeableConcept()
            {
                Text   = "Discharge Summary", //[疑問]Codable Concept内のTextと、Coding内のDisplayとの違いは。Lead Term的な表示?
                Coding = new List <Coding>()
                {
                    new Coding()
                    {
                        Display = "Discharge Summary",
                        System  = "http://loinc.org",
                        Code    = "18842-5",
                    }
                }
            };

            c.Date   = DateTime.Now.ToString("yyyy-MM-ddTHH:mm:sszzzz");
            c.Author = new List <ResourceReference>()
            {
                new ResourceReference()
                {
                    Reference = practitioner.Id
                }
            };

            c.Subject = new ResourceReference()
            {
                Reference = patient.Id
            };

            c.Title = "退院時サマリー"; //タイトルはこれでいいのかな。

            //B.3 承認者

            var attester = new Composition.AttesterComponent();

            var code = new Code <Composition.CompositionAttestationMode>();
            code.Value = Composition.CompositionAttestationMode.Legal;
            attester.ModeElement.Add(code);

            attester.Party = new ResourceReference()
            {
                Reference = practitioner.Id
            };
            attester.Time = "20140620";

            c.Attester.Add(attester);

            //B.4 退院時サマリー記載者

            var author = new Practitioner();
            author.Id = FhirUtil.createUUID();

            var authorName = new HumanName().WithGiven("太郎").AndFamily("本日");
            authorName.Use = HumanName.NameUse.Official;
            authorName.AddExtension("http://hl7.org/fhir/StructureDefinition/iso21090-EN-representation", new FhirString("IDE"));
            author.Name.Add(authorName);

            c.Author.Add(new ResourceReference()
            {
                Reference = author.Id
            });

            //B.5 原本管理者

            c.Custodian = new ResourceReference()
            {
                Reference = organization.Id
            };

            //B.6 関係者 保険者 何故退院サマリーに保険者の情報を入れているのかな?
            //TODO 未実装


            //sections

            //B.7 主治医
            var section_careteam = new Composition.SectionComponent();
            section_careteam.Title = "careteam";

            var careteam = new CareTeam();
            careteam.Id = FhirUtil.createUUID();

            var attendingPhysician = new Practitioner();
            attendingPhysician.Id = FhirUtil.createUUID();

            var attendingPhysicianName = new HumanName().WithGiven("二郎").AndFamily("日本");
            attendingPhysicianName.Use = HumanName.NameUse.Official;
            attendingPhysicianName.AddExtension("http://hl7.org/fhir/StructureDefinition/iso21090-EN-representation", new FhirString("IDE"));
            attendingPhysician.Name.Add(attendingPhysicianName);

            //医師の診療科はPracitionerRole/speciality + PracticeSettingCodeValueSetで表現する.
            //TODO: 膠原病内科は、Specilityのprefered ValueSetの中にはなかった。日本の診療科に関するValueSetを作る必要がある。
            var attendingPractitionerRole = new PractitionerRole();

            attendingPractitionerRole.Id           = FhirUtil.createUUID();
            attendingPractitionerRole.Practitioner = new ResourceReference()
            {
                Reference = attendingPhysician.Id
            };
            attendingPractitionerRole.Code.Add(new CodeableConcept("http://hl7.org/fhir/ValueSet/participant-role", "394733009", "Attending physician"));
            attendingPractitionerRole.Specialty.Add(new CodeableConcept("http://hl7.org/fhir/ValueSet/c80-practice-codes", "405279007", "Medical specialty--OTHER--NOT LISTED"));

            var participant = new CareTeam.ParticipantComponent();
            participant.Member = new ResourceReference()
            {
                Reference = attendingPractitionerRole.Id
            };

            careteam.Participant.Add(participant);


            section_careteam.Entry.Add(new ResourceReference()
            {
                Reference = careteam.Id
            });
            c.Section.Add(section_careteam);


            //B.8 受診、入院情報
            //B.12 本文 (Entry部) 退院時サマリーV1.41の例では入院時診断を本文に書くような形に
            //なっているが、FHIRではadmissionDetailセクション中のEncounterで記載するのが自然だろう。

            var section_admissionDetail = new Composition.SectionComponent();
            section_admissionDetail.Title = "admissionDetail";

            var encounter = new Encounter();
            encounter.Id = FhirUtil.createUUID();

            encounter.Period = new Period()
            {
                Start = "20140328", End = "20140404"
            };

            var hospitalization = new Encounter.HospitalizationComponent();
            hospitalization.DischargeDisposition = new CodeableConcept("\thttp://hl7.org/fhir/discharge-disposition", "01", "Discharged to home care or self care (routine discharge)");

            encounter.Hospitalization = hospitalization;

            var locationComponent = new Encounter.LocationComponent();
            var location          = new Location()
            {
                Id   = FhirUtil.createUUID(),
                Name = "○○クリニック",
                Type = new CodeableConcept("http://terminology.hl7.org/ValueSet/v3-ServiceDeliveryLocationRoleType", "COAG", "Coagulation clinic")
            };

            locationComponent.Location = new ResourceReference()
            {
                Reference = location.Id
            };

            section_admissionDetail.Entry.Add(new ResourceReference()
            {
                Reference = encounter.Id
            });



            var diagnosisAtAdmission = new Condition()
            {
                Code = new CodeableConcept("http://hl7.org/fhir/ValueSet/icd-10", "N801", "右卵巣嚢腫")
            };
            diagnosisAtAdmission.Id = FhirUtil.createUUID();

            var diagnosisComponentAtAdmission = new Encounter.DiagnosisComponent()
            {
                Condition = new ResourceReference()
                {
                    Reference = diagnosisAtAdmission.Id
                },
                Role = new CodeableConcept("http://hl7.org/fhir/ValueSet/diagnosis-role", "AD", "Admission diagnosis")
            };

            var encounterAtAdmission = new Encounter();
            encounterAtAdmission.Id = FhirUtil.createUUID();
            encounterAtAdmission.Diagnosis.Add(diagnosisComponentAtAdmission);
            section_admissionDetail.Entry.Add(new ResourceReference()
            {
                Reference = encounterAtAdmission.Id
            });


            c.Section.Add(section_admissionDetail);

            //B.9情報提供者

            var section_informant = new Composition.SectionComponent();
            section_informant.Title = "informant";

            var informant = new RelatedPerson();
            informant.Id = FhirUtil.createUUID();

            var informantName = new HumanName().WithGiven("藤三郎").AndFamily("東京");
            informantName.Use = HumanName.NameUse.Official;
            informantName.AddExtension("http://hl7.org/fhir/StructureDefinition/iso21090-EN-representation", new FhirString("IDE"));
            informant.Name.Add(informantName);
            informant.Patient = new ResourceReference()
            {
                Reference = patient.Id
            };
            informant.Relationship = new CodeableConcept("http://hl7.org/fhir/ValueSet/relatedperson-relationshiptype", "FTH", "father");

            informant.Address.Add(new Address()
            {
                Line       = new string[] { "新宿区神楽坂一丁目50番地" },
                State      = "東京都",
                PostalCode = "01803",
                Country    = "日本"
            });

            informant.Telecom.Add(new ContactPoint()
            {
                System = ContactPoint.ContactPointSystem.Phone,
                Use    = ContactPoint.ContactPointUse.Work,
                Value  = "tel:(03)3555-1212"
            });


            section_informant.Entry.Add(new ResourceReference()
            {
                Reference = informant.Id
            });
            c.Section.Add(section_informant);


            // B.10 本文
            // B.10.1 本文記述

            var section_clinicalSummary = new Composition.SectionComponent();
            section_clinicalSummary.Title = "来院理由";

            section_clinicalSummary.Code = new CodeableConcept("http://loinc.org", "29299-5", "Reason for visit Narrative");

            var dischargeSummaryNarrative = new Narrative();
            dischargeSummaryNarrative.Status = Narrative.NarrativeStatus.Additional;
            dischargeSummaryNarrative.Div    = @"
<div xmlns=""http://www.w3.org/1999/xhtml"">\n\n
<p>平成19年喘息と診断を受けた。平成20年7月喘息の急性増悪にて当院呼吸器内科入院。退院後HL7医院にてFollowされていた</p>
<p>平成21年10月20日頃より右足首にじんじん感が出現。左足首、両手指にも認めるようになった。同時に37℃台の熱発出現しWBC28000、Eosi58%と上昇していた</p>
<p>このとき尿路感染症が疑われセフメタゾン投与されるも改善せず。WBC31500、Eosi64%と上昇、しびれ感の増悪認めた。またHb 7.3 Ht 20.0と貧血を認めた</p>
<p>膠原病、特にChuge-stress-syndoromeが疑われ平成21年11月8日当院膠原病内科入院となった</p>
</div>
            ";

            section_clinicalSummary.Text = dischargeSummaryNarrative;
            c.Section.Add(section_clinicalSummary);

            //B.10.3 観察・検査等
            //section-observations

            var section_observations = new Composition.SectionComponent();
            section_observations.Title = "observations";

            var obs = new List <Observation>()
            {
                FhirUtil.createLOINCObservation(patient, "8302-2", "身長", new Quantity()
                {
                    Value = (decimal)2.004,
                    Unit  = "m"
                }),
                FhirUtil.createLOINCObservation(patient, "8302-2", "身長", new Quantity()
                {
                    Value = (decimal)2.004,
                    Unit  = "m"
                }),
                //Component Resultsの例 血圧- 拡張期血圧、収縮期血圧のコンポーネントを含む。
                new Observation()
                {
                    Id      = FhirUtil.createUUID(),
                    Subject = new ResourceReference()
                    {
                        Reference = patient.Id
                    },
                    Status = ObservationStatus.Final,
                    Code   = new CodeableConcept()
                    {
                        Text   = "血圧",
                        Coding = new List <Coding>()
                        {
                            new Coding()
                            {
                                System  = "http://loinc.org",
                                Code    = "18684-1",
                                Display = "血圧"
                            }
                        }
                    },
                    Component = new List <Observation.ComponentComponent>()
                    {
                        new Observation.ComponentComponent()
                        {
                            Code = new CodeableConcept()
                            {
                                Text   = "収縮期血圧血圧",
                                Coding = new List <Coding>()
                                {
                                    new Coding()
                                    {
                                        System  = "http://loinc.org",
                                        Code    = "8480-6",
                                        Display = "収縮期血圧"
                                    }
                                }
                            },
                            Value = new Quantity()
                            {
                                Value = (decimal)120,
                                Unit  = "mm[Hg]"
                            }
                        },
                        new Observation.ComponentComponent()
                        {
                            Code = new CodeableConcept()
                            {
                                Text   = "拡張期血圧",
                                Coding = new List <Coding>()
                                {
                                    new Coding()
                                    {
                                        System  = "http://loinc.org",
                                        Code    = "8462-4",
                                        Display = "拡張期血圧"
                                    }
                                }
                            },
                            Value = new Quantity()
                            {
                                Value = (decimal)100,
                                Unit  = "mm[Hg]"
                            }
                        },
                    }
                }
            };


            foreach (var res in obs)
            {
                section_observations.Entry.Add(new ResourceReference()
                {
                    Reference = res.Id
                });
            }

            c.Section.Add(section_observations);


            //B.10.4 キー画像
            //section-medicalImages


            var mediaPath = basePath + "/../../resource/Hydrocephalus_(cropped).jpg";
            var media     = new Media();
            media.Id      = FhirUtil.createUUID();
            media.Type    = Media.DigitalMediaType.Photo;
            media.Content = FhirUtil.CreateAttachmentFromFile(mediaPath);

            /* R3ではImagingStudyに入れられるのはDICOM画像だけみたい。 R4ではreasonReferenceでMediaも参照できる。
             * とりあえずDSTU3ではMediaリソースをmedicalImagesセクションにセットする。
             * var imagingStudy = new ImagingStudy();
             * imagingStudy.Id = FhirUtil.getUUID(); //まだFHIRサーバにあげられていないから,一時的なUUIDを生成してリソースIDとしてセットする
             * imagingStudy.re
             */

            var section_medicalImages = new Composition.SectionComponent();
            section_medicalImages.Title = "medicalImages";
            //TODO: sectionのcodeは?
            section_medicalImages.Entry.Add(new ResourceReference()
            {
                Reference = media.Id
            });
            c.Section.Add(section_medicalImages);


            //Bundleの構築

            //Bundleの構成要素
            //Bunbdleの一番最初はCompostion Resourceであること。
            List <Resource> bdl_entries = new List <Resource> {
                c, patient, organization, practitioner, author, careteam, encounter, encounterAtAdmission,
                diagnosisAtAdmission, location, informant, media, attendingPhysician, attendingPractitionerRole
            };
            bdl_entries.AddRange(obs);


            foreach (Resource res in bdl_entries)
            {
                var entry = new Bundle.EntryComponent();
                //entry.FullUrl = res.ResourceBase.ToString()+res.ResourceType.ToString() + res.Id;
                entry.FullUrl  = res.Id;
                entry.Resource = res;
                bdl.Entry.Add(entry);
            }

            return(bdl);
        }
コード例 #14
0
        /// <summary>
        /// Deserialize JSON into a FHIR RelatedPerson
        /// </summary>
        public static void DeserializeJsonProperty(this RelatedPerson current, ref Utf8JsonReader reader, JsonSerializerOptions options, string propertyName)
        {
            switch (propertyName)
            {
            case "identifier":
                if ((reader.TokenType != JsonTokenType.StartArray) || (!reader.Read()))
                {
                    throw new JsonException($"RelatedPerson error reading 'identifier' expected StartArray, found {reader.TokenType}! depth: {reader.CurrentDepth}, pos: {reader.BytesConsumed}");
                }

                current.Identifier = new List <Identifier>();

                while (reader.TokenType != JsonTokenType.EndArray)
                {
                    Hl7.Fhir.Model.Identifier v_Identifier = new Hl7.Fhir.Model.Identifier();
                    v_Identifier.DeserializeJson(ref reader, options);
                    current.Identifier.Add(v_Identifier);

                    if (!reader.Read())
                    {
                        throw new JsonException($"RelatedPerson error reading 'identifier' array, read failed! depth: {reader.CurrentDepth}, pos: {reader.BytesConsumed}");
                    }
                    if (reader.TokenType == JsonTokenType.EndObject)
                    {
                        reader.Read();
                    }
                }

                if (current.Identifier.Count == 0)
                {
                    current.Identifier = null;
                }
                break;

            case "active":
                if (reader.TokenType == JsonTokenType.Null)
                {
                    current.ActiveElement = new FhirBoolean();
                    reader.Skip();
                }
                else
                {
                    current.ActiveElement = new FhirBoolean(reader.GetBoolean());
                }
                break;

            case "_active":
                if (current.ActiveElement == null)
                {
                    current.ActiveElement = new FhirBoolean();
                }
                ((Hl7.Fhir.Model.Element)current.ActiveElement).DeserializeJson(ref reader, options);
                break;

            case "patient":
                current.Patient = new Hl7.Fhir.Model.ResourceReference();
                ((Hl7.Fhir.Model.ResourceReference)current.Patient).DeserializeJson(ref reader, options);
                break;

            case "relationship":
                if ((reader.TokenType != JsonTokenType.StartArray) || (!reader.Read()))
                {
                    throw new JsonException($"RelatedPerson error reading 'relationship' expected StartArray, found {reader.TokenType}! depth: {reader.CurrentDepth}, pos: {reader.BytesConsumed}");
                }

                current.Relationship = new List <CodeableConcept>();

                while (reader.TokenType != JsonTokenType.EndArray)
                {
                    Hl7.Fhir.Model.CodeableConcept v_Relationship = new Hl7.Fhir.Model.CodeableConcept();
                    v_Relationship.DeserializeJson(ref reader, options);
                    current.Relationship.Add(v_Relationship);

                    if (!reader.Read())
                    {
                        throw new JsonException($"RelatedPerson error reading 'relationship' array, read failed! depth: {reader.CurrentDepth}, pos: {reader.BytesConsumed}");
                    }
                    if (reader.TokenType == JsonTokenType.EndObject)
                    {
                        reader.Read();
                    }
                }

                if (current.Relationship.Count == 0)
                {
                    current.Relationship = null;
                }
                break;

            case "name":
                if ((reader.TokenType != JsonTokenType.StartArray) || (!reader.Read()))
                {
                    throw new JsonException($"RelatedPerson error reading 'name' expected StartArray, found {reader.TokenType}! depth: {reader.CurrentDepth}, pos: {reader.BytesConsumed}");
                }

                current.Name = new List <HumanName>();

                while (reader.TokenType != JsonTokenType.EndArray)
                {
                    Hl7.Fhir.Model.HumanName v_Name = new Hl7.Fhir.Model.HumanName();
                    v_Name.DeserializeJson(ref reader, options);
                    current.Name.Add(v_Name);

                    if (!reader.Read())
                    {
                        throw new JsonException($"RelatedPerson error reading 'name' array, read failed! depth: {reader.CurrentDepth}, pos: {reader.BytesConsumed}");
                    }
                    if (reader.TokenType == JsonTokenType.EndObject)
                    {
                        reader.Read();
                    }
                }

                if (current.Name.Count == 0)
                {
                    current.Name = null;
                }
                break;

            case "telecom":
                if ((reader.TokenType != JsonTokenType.StartArray) || (!reader.Read()))
                {
                    throw new JsonException($"RelatedPerson error reading 'telecom' expected StartArray, found {reader.TokenType}! depth: {reader.CurrentDepth}, pos: {reader.BytesConsumed}");
                }

                current.Telecom = new List <ContactPoint>();

                while (reader.TokenType != JsonTokenType.EndArray)
                {
                    Hl7.Fhir.Model.ContactPoint v_Telecom = new Hl7.Fhir.Model.ContactPoint();
                    v_Telecom.DeserializeJson(ref reader, options);
                    current.Telecom.Add(v_Telecom);

                    if (!reader.Read())
                    {
                        throw new JsonException($"RelatedPerson error reading 'telecom' array, read failed! depth: {reader.CurrentDepth}, pos: {reader.BytesConsumed}");
                    }
                    if (reader.TokenType == JsonTokenType.EndObject)
                    {
                        reader.Read();
                    }
                }

                if (current.Telecom.Count == 0)
                {
                    current.Telecom = null;
                }
                break;

            case "gender":
                if (reader.TokenType == JsonTokenType.Null)
                {
                    current.GenderElement = new Code <Hl7.Fhir.Model.AdministrativeGender>();
                    reader.Skip();
                }
                else
                {
                    current.GenderElement = new Code <Hl7.Fhir.Model.AdministrativeGender>(Hl7.Fhir.Utility.EnumUtility.ParseLiteral <Hl7.Fhir.Model.AdministrativeGender>(reader.GetString()));
                }
                break;

            case "_gender":
                if (current.GenderElement == null)
                {
                    current.GenderElement = new Code <Hl7.Fhir.Model.AdministrativeGender>();
                }
                ((Hl7.Fhir.Model.Element)current.GenderElement).DeserializeJson(ref reader, options);
                break;

            case "birthDate":
                if (reader.TokenType == JsonTokenType.Null)
                {
                    current.BirthDateElement = new Date();
                    reader.Skip();
                }
                else
                {
                    current.BirthDateElement = new Date(reader.GetString());
                }
                break;

            case "_birthDate":
                if (current.BirthDateElement == null)
                {
                    current.BirthDateElement = new Date();
                }
                ((Hl7.Fhir.Model.Element)current.BirthDateElement).DeserializeJson(ref reader, options);
                break;

            case "address":
                if ((reader.TokenType != JsonTokenType.StartArray) || (!reader.Read()))
                {
                    throw new JsonException($"RelatedPerson error reading 'address' expected StartArray, found {reader.TokenType}! depth: {reader.CurrentDepth}, pos: {reader.BytesConsumed}");
                }

                current.Address = new List <Address>();

                while (reader.TokenType != JsonTokenType.EndArray)
                {
                    Hl7.Fhir.Model.Address v_Address = new Hl7.Fhir.Model.Address();
                    v_Address.DeserializeJson(ref reader, options);
                    current.Address.Add(v_Address);

                    if (!reader.Read())
                    {
                        throw new JsonException($"RelatedPerson error reading 'address' array, read failed! depth: {reader.CurrentDepth}, pos: {reader.BytesConsumed}");
                    }
                    if (reader.TokenType == JsonTokenType.EndObject)
                    {
                        reader.Read();
                    }
                }

                if (current.Address.Count == 0)
                {
                    current.Address = null;
                }
                break;

            case "photo":
                if ((reader.TokenType != JsonTokenType.StartArray) || (!reader.Read()))
                {
                    throw new JsonException($"RelatedPerson error reading 'photo' expected StartArray, found {reader.TokenType}! depth: {reader.CurrentDepth}, pos: {reader.BytesConsumed}");
                }

                current.Photo = new List <Attachment>();

                while (reader.TokenType != JsonTokenType.EndArray)
                {
                    Hl7.Fhir.Model.Attachment v_Photo = new Hl7.Fhir.Model.Attachment();
                    v_Photo.DeserializeJson(ref reader, options);
                    current.Photo.Add(v_Photo);

                    if (!reader.Read())
                    {
                        throw new JsonException($"RelatedPerson error reading 'photo' array, read failed! depth: {reader.CurrentDepth}, pos: {reader.BytesConsumed}");
                    }
                    if (reader.TokenType == JsonTokenType.EndObject)
                    {
                        reader.Read();
                    }
                }

                if (current.Photo.Count == 0)
                {
                    current.Photo = null;
                }
                break;

            case "period":
                current.Period = new Hl7.Fhir.Model.Period();
                ((Hl7.Fhir.Model.Period)current.Period).DeserializeJson(ref reader, options);
                break;

            case "communication":
                if ((reader.TokenType != JsonTokenType.StartArray) || (!reader.Read()))
                {
                    throw new JsonException($"RelatedPerson error reading 'communication' expected StartArray, found {reader.TokenType}! depth: {reader.CurrentDepth}, pos: {reader.BytesConsumed}");
                }

                current.Communication = new List <RelatedPerson.CommunicationComponent>();

                while (reader.TokenType != JsonTokenType.EndArray)
                {
                    Hl7.Fhir.Model.RelatedPerson.CommunicationComponent v_Communication = new Hl7.Fhir.Model.RelatedPerson.CommunicationComponent();
                    v_Communication.DeserializeJson(ref reader, options);
                    current.Communication.Add(v_Communication);

                    if (!reader.Read())
                    {
                        throw new JsonException($"RelatedPerson error reading 'communication' array, read failed! depth: {reader.CurrentDepth}, pos: {reader.BytesConsumed}");
                    }
                    if (reader.TokenType == JsonTokenType.EndObject)
                    {
                        reader.Read();
                    }
                }

                if (current.Communication.Count == 0)
                {
                    current.Communication = null;
                }
                break;

            // Complex: RelatedPerson, Export: RelatedPerson, Base: DomainResource
            default:
                ((Hl7.Fhir.Model.DomainResource)current).DeserializeJsonProperty(ref reader, options, propertyName);
                break;
            }
        }
 public int DeleteRelatedPerson(RelatedPerson relatedPerson)
 {
     _uow.RelatedPeople.Remove(relatedPerson);
     return(_uow.SaveChanges());
 }
 public void AddRelatedPerson(RelatedPerson relatedPerson)
 {
     _uow.RelatedPeople.Add(relatedPerson);
 }
 private void cancelRadButton_Click(object sender, RoutedEventArgs e)
 {
     RelatedPerson = null;
     Close();
 }
コード例 #18
0
        /// <summary>
        /// Serialize a FHIR RelatedPerson into JSON
        /// </summary>
        public static void SerializeJson(this RelatedPerson current, Utf8JsonWriter writer, JsonSerializerOptions options, bool includeStartObject = true)
        {
            if (includeStartObject)
            {
                writer.WriteStartObject();
            }
            writer.WriteString("resourceType", "RelatedPerson");
            // Complex: RelatedPerson, Export: RelatedPerson, Base: DomainResource (DomainResource)
            ((Hl7.Fhir.Model.DomainResource)current).SerializeJson(writer, options, false);

            if ((current.Identifier != null) && (current.Identifier.Count != 0))
            {
                writer.WritePropertyName("identifier");
                writer.WriteStartArray();
                foreach (Identifier val in current.Identifier)
                {
                    val.SerializeJson(writer, options, true);
                }
                writer.WriteEndArray();
            }

            if (current.ActiveElement != null)
            {
                if (current.ActiveElement.Value != null)
                {
                    writer.WriteBoolean("active", (bool)current.ActiveElement.Value);
                }
                if (current.ActiveElement.HasExtensions() || (!string.IsNullOrEmpty(current.ActiveElement.ElementId)))
                {
                    JsonStreamUtilities.SerializeExtensionList(writer, options, "_active", false, current.ActiveElement.Extension, current.ActiveElement.ElementId);
                }
            }

            writer.WritePropertyName("patient");
            current.Patient.SerializeJson(writer, options);

            if ((current.Relationship != null) && (current.Relationship.Count != 0))
            {
                writer.WritePropertyName("relationship");
                writer.WriteStartArray();
                foreach (CodeableConcept val in current.Relationship)
                {
                    val.SerializeJson(writer, options, true);
                }
                writer.WriteEndArray();
            }

            if ((current.Name != null) && (current.Name.Count != 0))
            {
                writer.WritePropertyName("name");
                writer.WriteStartArray();
                foreach (HumanName val in current.Name)
                {
                    val.SerializeJson(writer, options, true);
                }
                writer.WriteEndArray();
            }

            if ((current.Telecom != null) && (current.Telecom.Count != 0))
            {
                writer.WritePropertyName("telecom");
                writer.WriteStartArray();
                foreach (ContactPoint val in current.Telecom)
                {
                    val.SerializeJson(writer, options, true);
                }
                writer.WriteEndArray();
            }

            if (current.GenderElement != null)
            {
                if (current.GenderElement.Value != null)
                {
                    writer.WriteString("gender", Hl7.Fhir.Utility.EnumUtility.GetLiteral(current.GenderElement.Value));
                }
                if (current.GenderElement.HasExtensions() || (!string.IsNullOrEmpty(current.GenderElement.ElementId)))
                {
                    JsonStreamUtilities.SerializeExtensionList(writer, options, "_gender", false, current.GenderElement.Extension, current.GenderElement.ElementId);
                }
            }

            if (current.BirthDateElement != null)
            {
                if (!string.IsNullOrEmpty(current.BirthDateElement.Value))
                {
                    writer.WriteString("birthDate", current.BirthDateElement.Value);
                }
                if (current.BirthDateElement.HasExtensions() || (!string.IsNullOrEmpty(current.BirthDateElement.ElementId)))
                {
                    JsonStreamUtilities.SerializeExtensionList(writer, options, "_birthDate", false, current.BirthDateElement.Extension, current.BirthDateElement.ElementId);
                }
            }

            if ((current.Address != null) && (current.Address.Count != 0))
            {
                writer.WritePropertyName("address");
                writer.WriteStartArray();
                foreach (Address val in current.Address)
                {
                    val.SerializeJson(writer, options, true);
                }
                writer.WriteEndArray();
            }

            if ((current.Photo != null) && (current.Photo.Count != 0))
            {
                writer.WritePropertyName("photo");
                writer.WriteStartArray();
                foreach (Attachment val in current.Photo)
                {
                    val.SerializeJson(writer, options, true);
                }
                writer.WriteEndArray();
            }

            if (current.Period != null)
            {
                writer.WritePropertyName("period");
                current.Period.SerializeJson(writer, options);
            }

            if ((current.Communication != null) && (current.Communication.Count != 0))
            {
                writer.WritePropertyName("communication");
                writer.WriteStartArray();
                foreach (RelatedPerson.CommunicationComponent val in current.Communication)
                {
                    val.SerializeJson(writer, options, true);
                }
                writer.WriteEndArray();
            }

            if (includeStartObject)
            {
                writer.WriteEndObject();
            }
        }
コード例 #19
0
        /// <summary>
        /// Demonstrates sharing records by exercising various access messages including:
        /// Grant, Modify, Revoke, RetrievePrincipalAccess, and
        /// RetrievePrincipalsAndAccess.
        /// </summary>
        /// <param name="serverConfig">Contains server connection information.</param>
        /// <param name="promptforDelete">When True, the user will be prompted to delete all
        /// created entities.</param>
        public void Run(ServerConnection.Configuration serverConfig)
        {
            try
            {
                // we need this to support communicating with Dynamics Online Instances
                ServicePointManager.SecurityProtocol = SecurityProtocolType.Tls12;

                //<snippetSharingRecords1>
                // 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();

                    int accountcount  = int.Parse(ConfigurationManager.AppSettings["cdm:createaccountcount"]);
                    int locationcount = int.Parse(ConfigurationManager.AppSettings["cdm:createlocationcount"]);

                    int productcount = int.Parse(ConfigurationManager.AppSettings["cdm:createproductcount"]);

                    int patientcount       = int.Parse(ConfigurationManager.AppSettings["cdm:createpatientcount"]);
                    int practitionercount  = int.Parse(ConfigurationManager.AppSettings["cdm:createpractitionercount"]);
                    int relatedpersoncount = int.Parse(ConfigurationManager.AppSettings["cdm:createrelatedpersoncount"]);
                    int contactcount       = int.Parse(ConfigurationManager.AppSettings["cdm:createcontactcount"]);

                    int practitionerrolecount          = int.Parse(ConfigurationManager.AppSettings["cdm:practitionerrolecount"]);
                    int practitionerqualificationcount = int.Parse(ConfigurationManager.AppSettings["cdm:practitionerqualificationcount"]);

                    int patientallergycount           = int.Parse(ConfigurationManager.AppSettings["cdm:patientallergycount"]);
                    int patientnutritionordercount    = int.Parse(ConfigurationManager.AppSettings["cdm:patientnutritionordercount"]);
                    int patientconditioncount         = int.Parse(ConfigurationManager.AppSettings["cdm:patientconditioncount"]);
                    int patientdevicecount            = int.Parse(ConfigurationManager.AppSettings["cdm:patientdevicecount"]);
                    int patientprocedurecount         = int.Parse(ConfigurationManager.AppSettings["cdm:patientprocedurecount"]);
                    int patientreferralcount          = int.Parse(ConfigurationManager.AppSettings["cdm:patientreferralcount"]);
                    int patientmedicationrequestcount = int.Parse(ConfigurationManager.AppSettings["cdm:patientmedicationrequestcount"]);
                    int patientepisodesofcarecount    = int.Parse(ConfigurationManager.AppSettings["cdm:patientepisodesofacarecount"]);
                    int patientappointmentcount       = int.Parse(ConfigurationManager.AppSettings["cdm:patientappointmentcount"]);
                    int patientencountercount         = int.Parse(ConfigurationManager.AppSettings["cdm:patientencountercount"]);
                    int patientcareplancount          = int.Parse(ConfigurationManager.AppSettings["cdm:patientcareplancount"]);

                    string filepath = ConfigurationManager.AppSettings["cdm:temporaryfilepath"];

                    Console.WriteLine("Start Time: " + DateTime.Now.ToString());

                    List <Profile>    localcontacts       = null;
                    List <Profile>    localpatients       = null;
                    List <Profile>    localpractitioners  = null;
                    List <Profile>    localrelatedpersons = null;
                    List <Profile>    localaccounts       = null;
                    List <Profile>    locallocations      = null;
                    List <Medication> localmedications    = null;

                    string practitonerFile    = string.Empty;
                    string relatedpersonsFile = string.Empty;
                    string patientsFile       = string.Empty;
                    string accountsFile       = string.Empty;
                    string locationsFile      = string.Empty;
                    string medicationsFile    = string.Empty;


                    #region Create Products, Pricelists
                    if (productcount > 0)
                    {
                        CreateCDMHealthData createProducts = new CreateCDMHealthData();
                        createProducts.ProfileType = Profile.ProfileType.Medication;
                        createProducts.FileName    = filepath + "medications_" + accountcount.ToString() + "_" + Guid.NewGuid().ToString() + ".json";

                        // we only ever generate a single instance, unless you want more than 1 product on seperate price lists
                        // this will generate N products on the same price list through one object instance (unlike others)
                        localmedications = Medication.GenerateProfilesByCount(productcount, productcount);

                        createProducts.CreateCount = createProducts.IncomingProfiles.Count;
                        createProducts.Clients     = int.Parse(ConfigurationManager.AppSettings["cdm:clients"]);
                        Console.WriteLine("\r\nCreating [" + createProducts.CreateCount.ToString() + "]  Medications [products]\r\n");

                        createProducts.CreateProducts(_serviceProxy, localmedications);
                    }

                    #endregion

                    #region Create Accounts (Organizations)

                    if (accountcount > 0)
                    {
                        CreateCDMHealthData createAccounts = new CreateCDMHealthData();
                        createAccounts.ProfileType = Profile.ProfileType.Organization;
                        createAccounts.FileName    = filepath + "organizations_" + accountcount.ToString() + "_" + Guid.NewGuid().ToString() + ".json";

                        localaccounts = Organization.GenerateProfilesByCount(accountcount, "NA");

                        foreach (Organization account in localaccounts)
                        {
                            createAccounts.IncomingProfiles.Enqueue(account);
                        }

                        createAccounts.CreateCount = createAccounts.IncomingProfiles.Count;
                        createAccounts.Clients     = int.Parse(ConfigurationManager.AppSettings["cdm:clients"]);
                        Console.WriteLine("\r\nCreating [" + createAccounts.CreateCount.ToString() + "]  Organizations\r\n");

                        accountsFile = createAccounts.CreateProfiles(_serviceProxy);
                    }

                    #endregion

                    #region Create Locations

                    if (locationcount > 0)
                    {
                        CreateCDMHealthData createLocations = new CreateCDMHealthData();
                        createLocations.ProfileType = Profile.ProfileType.Location;
                        createLocations.FileName    = filepath + "locations_" + locationcount.ToString() + "_" + Guid.NewGuid().ToString() + ".json";

                        locallocations = Location.GenerateProfilesByCount(locationcount, accountsFile);

                        foreach (Location location in locallocations)
                        {
                            createLocations.IncomingProfiles.Enqueue(location);
                        }

                        createLocations.CreateCount = createLocations.IncomingProfiles.Count;
                        createLocations.Clients     = int.Parse(ConfigurationManager.AppSettings["cdm:clients"]);

                        Console.WriteLine("\r\nCreating [" + createLocations.CreateCount.ToString() + "]  Locations\r\n");

                        locationsFile = createLocations.CreateProfiles(_serviceProxy);
                    }

                    #endregion

                    #region Create Standard Contacts

                    if (contactcount > 0)
                    {
                        CreateCDMHealthData createContacts = new CreateCDMHealthData();
                        createContacts.ProfileType = Profile.ProfileType.Standard;
                        createContacts.FileName    = filepath + "relatedpersons_" + relatedpersoncount.ToString() + "_" + Guid.NewGuid().ToString() + ".tab";

                        localcontacts = Contact.GenerateProfilesByCount(contactcount, "NA");

                        foreach (Profile contact in localcontacts)
                        {
                            createContacts.IncomingProfiles.Enqueue(contact);
                        }

                        createContacts.CreateCount = createContacts.IncomingProfiles.Count;
                        createContacts.EmailDomain = ConfigurationManager.AppSettings["cdm:emaildomain"];
                        createContacts.Clients     = int.Parse(ConfigurationManager.AppSettings["cdm:clients"]);

                        Console.WriteLine("\r\nCreating [" + createContacts.CreateCount.ToString() + "]  Contacts\r\n");

                        practitonerFile = createContacts.CreateProfiles(_serviceProxy);
                    }

                    #endregion

                    #region Create Practitioners

                    if (practitionercount > 0)
                    {
                        PractitionerConfiguration configuration = new PractitionerConfiguration();
                        configuration.Qualifications = practitionerqualificationcount;
                        configuration.Roles          = practitionerrolecount;

                        CreateCDMHealthData createPractitioners = new CreateCDMHealthData();
                        createPractitioners.ProfileType = Profile.ProfileType.Practitioner;
                        createPractitioners.FileName    = filepath + "practitioners_" + practitionercount.ToString() + "_" + Guid.NewGuid().ToString() + ".json";

                        localpractitioners = Practitioner.GenerateProfilesByCount(practitionercount, configuration);

                        foreach (Profile practitioner in localpractitioners)
                        {
                            createPractitioners.IncomingProfiles.Enqueue(practitioner);
                        }

                        createPractitioners.CreateCount = createPractitioners.IncomingProfiles.Count;
                        createPractitioners.EmailDomain = ConfigurationManager.AppSettings["cdm:emaildomain"];
                        createPractitioners.Clients     = int.Parse(ConfigurationManager.AppSettings["cdm:clients"]); //;

                        Console.WriteLine("\r\nCreating [" + createPractitioners.CreateCount.ToString() + "]  Practitioners\r\n");

                        practitonerFile = createPractitioners.CreateProfiles(_serviceProxy);
                    }

                    #endregion

                    #region Create Related Persons
                    if (relatedpersoncount > 0)
                    {
                        CreateCDMHealthData createRelatedPersons = new CreateCDMHealthData();
                        createRelatedPersons.FileName    = filepath + "relatedpersons_" + relatedpersoncount.ToString() + "_" + Guid.NewGuid().ToString() + ".json";
                        createRelatedPersons.ProfileType = Profile.ProfileType.RelatedPerson;

                        localrelatedpersons = RelatedPerson.GenerateProfilesByCount(relatedpersoncount, "NA");

                        foreach (Profile relatedperson in localrelatedpersons)
                        {
                            createRelatedPersons.IncomingProfiles.Enqueue(relatedperson);
                        }

                        createRelatedPersons.CreateCount = createRelatedPersons.IncomingProfiles.Count;
                        createRelatedPersons.EmailDomain = ConfigurationManager.AppSettings["cdm:emaildomain"];
                        createRelatedPersons.Clients     = int.Parse(ConfigurationManager.AppSettings["cdm:clients"]); //;

                        Console.WriteLine("\r\nCreating [" + createRelatedPersons.CreateCount.ToString() + "]  Related Persons\r\n");

                        relatedpersonsFile = createRelatedPersons.CreateProfiles(_serviceProxy);
                    }

                    #endregion

                    #region Create Patients

                    if (patientcount > 0)
                    {
                        PatientConfiguration configuration = new PatientConfiguration();
                        configuration.PractionerFileName     = practitonerFile;
                        configuration.RelatedPersonsFileName = relatedpersonsFile;
                        configuration.AccountsFileName       = accountsFile;
                        configuration.LocationsFileName      = locationsFile;

                        configuration.AllergyIntoleranceCount = patientallergycount;
                        configuration.NutritionOrderCount     = patientnutritionordercount;
                        configuration.ConditionCount          = patientconditioncount;
                        configuration.DeviceCount             = patientdevicecount;
                        configuration.ProcedureCount          = patientprocedurecount;
                        configuration.MedicationCount         = patientmedicationrequestcount;
                        configuration.EpisodesOfCareCount     = patientepisodesofcarecount;
                        configuration.EncountersCount         = patientencountercount;
                        configuration.AppointmentCount        = patientappointmentcount;
                        configuration.CarePlanCount           = patientcareplancount;

                        CreateCDMHealthData createPatients = new CreateCDMHealthData();
                        createPatients.FileName    = filepath + "patients_" + patientcount.ToString() + "_" + Guid.NewGuid().ToString() + ".json";
                        createPatients.ProfileType = Profile.ProfileType.Patient;

                        localpatients = Patient.GenerateProfilesByCount(patientcount, configuration);

                        foreach (Profile patient in localpatients)
                        {
                            ((Patient)(patient)).Products = localmedications;
                            createPatients.IncomingProfiles.Enqueue(patient);
                        }

                        createPatients.CreateCount = createPatients.IncomingProfiles.Count;
                        createPatients.EmailDomain = ConfigurationManager.AppSettings["cdm:emaildomain"];
                        createPatients.Clients     = int.Parse(ConfigurationManager.AppSettings["cdm:clients"]); //;

                        Console.WriteLine("\r\nCreating [" + createPatients.CreateCount.ToString() + "]  Patients\r\n");

                        patientsFile = createPatients.CreateProfiles(_serviceProxy);
                    }

                    #endregion

                    Console.WriteLine("End Time: " + DateTime.Now.ToString());

                    return;
                }
            }

            // 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;
            }
        }
 public AddEditRelatedPersonWindow()
 {
     InitializeComponent();
     RelatedPerson = new RelatedPerson();
     DataContext   = this;
 }
コード例 #21
0
 public void SetRelatedPerson(RelatedPerson relatedPerson)
 {
     RelatedPerson = Mapper.Map <RelatedPerson, EditableRelatedPerson>(relatedPerson);
     RelatedPerson.ErrorsChanged += RaiseCanExecuteChanged;
 }