Пример #1
0
        public Person CreatePerson(PersonDTO personDTO)
        {
            var person = new Person();

            if (personDTO.Names != null)
            {
                foreach (var nameDTO in personDTO.Names)
                {
                    var name = new HumanName();
                    foreach (var givenDTO in nameDTO.Givens)
                    {
                        name.WithGiven(givenDTO);
                    }
                    name.AndFamily(nameDTO.Family);
                    name.Use = nameDTO.Use;
                    person.Name.Add(name);
                }
            }
            if (personDTO.Telecoms != null)
            {
                foreach (var telecomeDTO in personDTO.Telecoms)
                {
                    var telecome = new ContactPoint();
                    telecome.Value  = telecomeDTO.Value;
                    telecome.Use    = telecomeDTO.Use;
                    telecome.System = telecomeDTO.System;
                    person.Telecom.Add(telecome);
                }
            }

            person.Gender = personDTO.Gender;

            person.BirthDate = personDTO.Birthday;

            if (personDTO.Addresses != null)
            {
                foreach (var addressDTO in personDTO.Addresses)
                {
                    var address = new Address();
                    address.Use = addressDTO.Use;
                    foreach (var lineDTO in addressDTO.Lines)
                    {
                        address.Line = address.Line.Append(lineDTO);
                    }
                    address.City       = addressDTO.City;
                    address.State      = addressDTO.State;
                    address.PostalCode = addressDTO.PostalCode;
                    person.Address.Add(address);
                }
            }
            return(person);
        }
Пример #2
0
        public static Patient NewPatient(string family, params string[] given)
        {
            Patient   p = new Patient();
            HumanName n = new HumanName();

            foreach (string g in given)
            {
                n.WithGiven(g);
            }

            n.AndFamily(family);
            p.Name = new List <HumanName>();
            p.Name.Add(n);
            return(p);
        }
        private void InsertOrUpdatePatient(bool insert = true)
        {
            // Call into the model an pass the patient data
            UpdateButtonEnabled = false;
            ChangeBusyState(true);

            try
            {
                var uri    = new Uri(_url);
                var client = new FhirClient(uri);

                var p = new Patient();
                p.Active = this.Active;

                if (!insert && _entry != null)
                {
                    p.Id = _entry.Id;
                    //p.Id = i;
                }
                String dob = BirthDate.Value.ToString("s");

                p.BirthDate = dob;
                p.Gender    = Gender;
                var name = new HumanName();
                name.WithGiven(GivenName);
                name.AndFamily(Name);
                name.Text = GivenName + " " + Name;

                p.Name = new List <HumanName>();
                p.Name.Add(name);


                if (SendImage)
                {
                    p.Photo = new List <Attachment>();
                    var photo = new Attachment();
                    photo.Title = "Potrait - " + GivenName + " " + Name;

                    if (_photo.ToLower().EndsWith(".jpg"))
                    {
                        photo.ContentType = "image/jpeg";
                        using (FileStream fileStream = File.OpenRead(_photo))
                        {
                            int len = (int)fileStream.Length;

                            photo.Size = len;
                            photo.Data = new byte[fileStream.Length];
                            fileStream.Read(photo.Data, 0, len);
                        }
                        p.Photo.Add(photo);
                    }
                }

                p.Telecom = new List <ContactPoint>(3);
                p.FhirCommentsElement.Add(new FhirString("TEST AmbulanceNote"));
                var t = new ContactPoint();
                t.System = ContactPoint.ContactPointSystem.Phone;

                p.Telecom.Add(new ContactPoint()
                {
                    Value  = Mobile,
                    System = ContactPoint.ContactPointSystem.Phone,
                    Use    = ContactPoint.ContactPointUse.Mobile
                });

                p.Telecom.Add(new ContactPoint()
                {
                    Value  = Phone,
                    System = ContactPoint.ContactPointSystem.Phone,
                    Use    = ContactPoint.ContactPointUse.Mobile
                });

                p.Telecom.Add(new ContactPoint()
                {
                    Value  = Email,
                    System = ContactPoint.ContactPointSystem.Phone,
                    Use    = ContactPoint.ContactPointUse.Mobile
                });

                p.Active        = Active;
                p.MultipleBirth = new FhirBoolean(MultipleBirth);
                p.Deceased      = new FhirBoolean(Deceased);

                //ToDo Marital Status

                p.Extension = new List <Extension>();
                //p.Extension.Add(new Extension(new Uri("http://www.englishclub.com/vocabulary/world-countries-nationality.htm"), new FhirString(Nationality)));
                //var ToHospitalName = new Extension("http://www.example.com/hospitalTest", new FhirString(HospitalName));
                //p.Extension.Add(ToHospitalName);
                p.Extension.Add(new Extension("http://www.example.com/triagetest", new FhirString(Triage)));
                p.Extension.Add(new Extension("http://www.example.com/SpecialtyTest", new FhirString(Specialty)));
                p.Extension.Add(new Extension("http://www.example.com/datetimeTest", new FhirDateTime(ETA)));


                //p.Identifier.Add(CPR);

                p.Identifier = new List <Identifier>(2);
                var cprIdentifier = new Identifier();
                cprIdentifier.Value  = CPR;
                cprIdentifier.Use    = Identifier.IdentifierUse.Official;
                cprIdentifier.System = "CPR";
                //cprIdentifier.Id = CPR;

                p.Identifier.Add(cprIdentifier);
                var toHospitalIdentifier = new Identifier();
                toHospitalIdentifier.Value         = HospitalName;
                toHospitalIdentifier.Use           = Identifier.IdentifierUse.Temp;
                toHospitalIdentifier.System        = "ToHospital";
                toHospitalIdentifier.SystemElement = new FhirUri("http://www.example.com/hospitalTest");
                p.Identifier.Add(toHospitalIdentifier);


                var fromDestinationIdentifier = new Identifier();
                fromDestinationIdentifier.Value         = FromDestination;
                fromDestinationIdentifier.Use           = Identifier.IdentifierUse.Temp;
                fromDestinationIdentifier.System        = "FromDestination";
                fromDestinationIdentifier.SystemElement = new FhirUri("http://www.example.com/fromdestination");
                p.Identifier.Add(fromDestinationIdentifier);

                p.Address = new List <Address>(1);
                var a = new Address();
                //a.zip = Zip;
                a.City    = City;
                a.State   = State;
                a.Country = Country;
                var lines = new List <String>();
                if (!String.IsNullOrEmpty(Address1))
                {
                    lines.Add(Address1);
                }
                if (!String.IsNullOrEmpty(Address2))
                {
                    lines.Add(Address2);
                }
                a.Line = lines;
                p.Address.Add(a);


                if (insert)
                {
                    client.PreferredFormat = ResourceFormat.Xml;
                    _entry = client.Create(p);
                }
                else
                {
                    _entry = p;
                    _entry = client.Update(_entry, true);
                }

                var identity = new ResourceIdentity(_entry.Id);
                PatientId = identity.Id;
                MessageBox.Show("Patient updated/created");
                Status = "Created new patient: " + PatientId;
                Debug.WriteLine(Status);
            }
            catch (Exception e)
            {
                Debug.WriteLine(e.StackTrace);
                Status = e.Message;
            }
            finally
            {
                UpdateButtonEnabled = true;
                ChangeBusyState(false);
            }
        }