Beispiel #1
0
        public static Patient CreatePatient(string given, string family, DateTime birthDate)
        {
            Patient patient         = new Patient();
            Patient responsePatient = new Patient();

            //Set patient name
            patient.Name = new List <HumanName>();

            HumanName patientName = new HumanName();

            patientName.Use    = HumanName.NameUse.Official;
            patientName.Prefix = new string[] { "Mr" };

            //Default way using properties to set Given and Family name
            //patientName.Given = new string[] { given };
            //patientName.Family = family;

            //Using methods to sets the Given and Family name
            patientName.WithGiven(given).AndFamily(family);

            patient.Name.Add(patientName);

            //Set patient Identifier
            patient.Identifier = new List <Identifier>();

            Identifier patientIdentifier = new Identifier();

            patientIdentifier.System = "http://someurl.net/not-sure-about-the-value/1.0";
            patientIdentifier.Value  = Guid.NewGuid().ToString();

            patient.Identifier.Add(patientIdentifier);

            //Set patient birth date
            patient.BirthDate = birthDate.ToFhirDate();

            //Set Active Flag
            patient.Active = true;

            try
            {
                LogToFile("Creating Patient");

                LogToFile("Request: ");
                var patientXml = FhirSerializer.SerializeResourceToXml(patient);
                LogToFile(XDocument.Parse(patientXml).ToString());

                FhirClient fhirClient = new FhirClient(FhirClientEndPoint);
                responsePatient = fhirClient.Create(patient);

                LogToFile("Response: ");
                var responsePatientXml = FhirSerializer.SerializeResourceToXml(responsePatient);
                LogToFile(XDocument.Parse(responsePatientXml).ToString());
            }
            catch (Exception ex)
            {
                LogToFile(ex.ToString());
            }

            return(responsePatient);
        }
Beispiel #2
0
        private ContactComponent GetContactInfoForKin(entitystorematerialised_CoreNextofkin1 nextOfKin)
        {
            if (nextOfKin.IsNull())
            {
                return(null);
            }

            ContactComponent contactComponent = new ContactComponent
            {
                Address = new Address()
            };

            string addresssLine = string.Join(nextOfKin.Addressstreet, ", ", nextOfKin.Addressstreet2);

            contactComponent.Address.Line       = contactComponent.Address.Line.Append(addresssLine);
            contactComponent.Address.City       = nextOfKin.Addresscity;
            contactComponent.Address.State      = nextOfKin.Addresscountystateprovince;
            contactComponent.Address.Country    = nextOfKin.Addresscountry;
            contactComponent.Address.PostalCode = nextOfKin.Addresspostalcode;
            contactComponent.Address.Type       = Address.AddressType.Both;

            List <CodeableConcept> relationships = new List <CodeableConcept>();

            CodeableConcept relationship = new CodeableConcept
            {
                Text = nextOfKin.Relationship
            };

            relationships.Add(relationship);

            contactComponent.Relationship = relationships;

            HumanName nextOfKinName = new HumanName();

            contactComponent.Name = nextOfKinName.WithGiven(nextOfKin.Givenname).AndFamily(nextOfKin.Familyname);

            ContactPoint contact = new ContactPoint();

            if (!string.IsNullOrEmpty(nextOfKin.Personalcontactinfo))
            {
                contact.Value  = nextOfKin.Personalcontactinfo;
                contact.System = ContactPoint.ContactPointSystem.Phone;
                contact.Use    = ContactPoint.ContactPointUse.Home;
            }

            if (string.IsNullOrEmpty(nextOfKin.Personalcontactinfo) && !string.IsNullOrEmpty(nextOfKin.Businesscontactinfo))
            {
                contact.Value  = nextOfKin.Businesscontactinfo;
                contact.System = ContactPoint.ContactPointSystem.Phone;
                contact.Use    = ContactPoint.ContactPointUse.Work;
            }

            contactComponent.Telecom.Add(contact);

            return(contactComponent);
        }
        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);
        }
        public void HumanNameOnlyGivenMapTest()
        {
            var input = new HumanName();

            input.WithGiven("Pietje");

            var result = sut.Map(input);

            Assert.AreEqual(1, result.Count()); //2 line elements + city, country and postalcode.
            foreach (var res in result)
            {
                Assert.IsInstanceOfType(res, typeof(StringValue));
            }
            Assert.AreEqual(1, result.Where(r => (r as StringValue).Value == "Pietje").Count());
        }
Beispiel #5
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);
        }
Beispiel #6
0
        public void HumanNameOnlyGivenMapTest()
        {
            var input = new HumanName();

            input.WithGiven("Pietje");

            var result = _sut.Map(input);

            Assert.Single(result); //2 line elements + city, country and postalcode.
            foreach (var res in result)
            {
                Assert.IsType <StringValue>(res);
            }

            Assert.Single(result.Where(r => (r as StringValue).Value == "Pietje"));
        }
Beispiel #7
0
        public ActionResult EditPatient([Bind] EditPatient patient)
        {
            bool   status  = false;
            string Message = "";

            //SPRAWDZENIE MODELU
            if (ModelState.IsValid)
            {
                //PODŁĄCZENIE KLIENTA
                var client = new FhirClient("http://localhost:8080/baseR4");
                client.PreferredFormat = ResourceFormat.Json;

                //PRZEKAZANIE DANYCH
                Patient   original = client.Read <Patient>("Patient/" + patient.ID);
                HumanName name     = new HumanName();
                name.WithGiven(patient.Name).AndFamily(patient.Surname);
                original.Name.Add(name);
                Address address = new Address();
                address.Text = patient.Address;
                original.Address.Add(address);

                //UPDATE
                client.Update(original);
                Message = "Your item successfully UPDATE";
                status  = true;
            }
            else
            {
                Message = "You haven't got right model";
            }

            ViewBag.ID      = patient.ID;
            ViewBag.Status  = status;
            ViewBag.Message = Message;
            return(View(patient));
        }
    public void OnClickSignUp()
    {
        Patient   patient     = new Patient();
        HumanName p_humanName = new HumanName();

        p_humanName.Family = TEXTFIELD_FAMILYNAME.text;
        p_humanName.WithGiven(TEXTFIELD_GIVENNAME.text);
        p_humanName.Prefix = new string[] { DROPDOWN_PREFIX.captionText.text };
        p_humanName.Use    = HumanName.NameUse.Official;
        Identifier p_Identifier = new Identifier("jaist.ac.jp", TEXTFIELD_ID.text);
        var        p_contact    = new Hl7.Fhir.Model.ContactPoint(Hl7.Fhir.Model.ContactPoint.ContactPointSystem.Phone,
                                                                  Hl7.Fhir.Model.ContactPoint.ContactPointUse.Mobile,
                                                                  TEXTFIELD_PHONE.text);


        AdministrativeGender p_gender;

        if (DROPDOWN_GENDER.value == 0)
        {
            p_gender = AdministrativeGender.Male;
        }
        else if (DROPDOWN_GENDER.value == 1)
        {
            p_gender = AdministrativeGender.Female;
        }
        else
        {
            p_gender = AdministrativeGender.Other;
        }


        Address p_address = new Address();

        if (DROPDOWN_ADDR_TYPE.value == 0)
        {
            p_address.Use = Address.AddressUse.Home;
        }
        else if (DROPDOWN_ADDR_TYPE.value == 1)
        {
            p_address.Use = Address.AddressUse.Work;
        }
        else
        {
            p_address.Use = Address.AddressUse.Temp;
        }
        p_address.Type       = Address.AddressType.Postal;
        p_address.Country    = TEXTFIEL_ADDR_COUNTRY.text;
        p_address.State      = TEXTFIEL_ADDR_STATE.text;
        p_address.PostalCode = TEXTFIEL_ADDR_ZIPCODE.text;
        p_address.City       = TEXTFIEL_ADDR_CITY.text;
        p_address.Line       = new string[] { TEXTFIEL_ADDR_STREET.text };
        p_address.Text       = TEXTFIEL_ADDR_BUILDING.text;


        // Create patient with info
        patient.Name.Add(p_humanName);
        patient.Identifier.Add(p_Identifier);
        patient.Telecom.Add(p_contact);
        patient.Address.Add(p_address);


        if (Date.IsValidValue(TEXTFIELD_BIRTHDAY.text))
        {
            Debug.Log("OK IRTHDAY");
            patient.BirthDate = TEXTFIELD_BIRTHDAY.text;
        }
        else
        {
            patient.BirthDateElement = Hl7.Fhir.Model.Date.Today();            // System.DateTime.Parse(TEXTFIELD_BIRTHDAY.text);
        }
        patient.Gender = p_gender;
        // Create Fhir client instance


        TW.I.AddWarning("", "Signning up...");
        StartCoroutine(startregister(patient));
    }
        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);
            }
        }