Example #1
0
 public static TestHumanName BuildHumanNameFromDataBaseData(string idPerson)
 {
     using (SqlConnection connection = Global.GetSqlConnection())
     {
         string findPerson = "SELECT TOP(1) * FROM Person WHERE IdPerson = '" + idPerson + "'";
         SqlCommand commandPerson = new SqlCommand(findPerson, connection);
         using (SqlDataReader humanNameReader = commandPerson.ExecuteReader())
         {
             HumanName hn = new HumanName();
             while (humanNameReader.Read())
             {
                 hn.FamilyName = Convert.ToString(humanNameReader["FamilyName"]);
                 hn.GivenName = Convert.ToString(humanNameReader["GivenName"]);
                 if (Convert.ToString(humanNameReader["MiddleName"]) != "")
                     hn.MiddleName = Convert.ToString(humanNameReader["MiddleName"]);
                 else
                     hn.MiddleName = null;
                 return (new TestHumanName(hn));
             }
         }
     }
     return null;
 }
        //private async Task ProcessPatients(AgsContext context)
        //{
        //	var patients = await GetAllResources("Patient");
        //	if (patients == null || patients.Entry == null || patients.Entry.Count == 0) {
        //		Console.WriteLine("Null or empty list of Patient resources returned by FHIR server");
        //		return;
        //	}

        //	Console.WriteLine("PROCESSING {0} PATIENTS", patients.Entry.Count);
        //	Console.WriteLine("-----------------------");

        //	foreach (var entry in patients.Entry) {
        //		var resource = entry.Resource;
        //		var patientResource = resource as Patient;
        //		if (resource.ResourceType != ResourceType.Patient) {
        //			throw new FHIRGenomicsException(string.Format("We received a {0} resource where we expected a Patient", resource.ResourceType));
        //		} else if (patientResource == null) {
        //			throw new FHIRGenomicsException(string.Format("Unable to cast resource ID {0} as a Patient", resource.Id));
        //		}
        //		ProcessPatient(patientResource, context);
        //	}
        //}

        private void ProcessPatient(Patient patientResource, AgsContext context)
        {
            var firstName = "";
            var lastName  = "";

            if (patientResource.Name == null || patientResource.Name.Count == 0)
            {
                Console.WriteLine("{0} has no Name entries - using default of 'Patient {0}'",
                                  patientResource.Id);
                firstName = "Patient";
                lastName  = patientResource.Id;
            }
            else
            {
                if (patientResource.Name.Count > 1)
                {
                    Console.WriteLine("{0} has {1} Name entries - using the first entry only",
                                      patientResource.Id, patientResource.Name.Count);
                }

                HumanName name = patientResource.Name[0];
                firstName = string.Join(" ", name.Given);
                lastName  = name.Family;
            }

            var gender        = "U";
            var genderElement = patientResource.Extension.Find(x => x.Url.Equals("http://hl7.org/fhir/us/core/StructureDefinition/us-core-birthsex", StringComparison.CurrentCultureIgnoreCase));

            if (genderElement != null)
            {
                gender = genderElement.Value.ToString();
            }

            DateTime?dateOfBirth = null;

            if (patientResource.BirthDateElement == null)
            {
                Console.WriteLine("No DOB for Patient {0}", patientResource.Id);
            }
            else
            {
#pragma warning disable CS0618 // Type or member is obsolete
                dateOfBirth = patientResource.BirthDateElement.ToDateTime();
#pragma warning restore CS0618 // Type or member is obsolete
            }

            var mrn = "";
            if (patientResource.Identifier == null || patientResource.Identifier.Count == 0)
            {
                Console.WriteLine("Patinet {0} has no identifier entries", patientResource.Id);
            }
            else
            {
                Identifier id = patientResource.Identifier.Find(x => x.System.Equals("https://emerge.mc.vanderbilt.edu/", StringComparison.CurrentCultureIgnoreCase));
                if (patientResource.Identifier.Count > 1)
                {
                    Console.WriteLine("Patient {0} had {1} identifiers. We will use the first eMERGE associated entry of {2}",
                                      patientResource.Id, patientResource.Identifier.Count, id.Value);
                }
                mrn = id.Value;
            }

            var patient = new Agspatients();
            patient.FirstName = firstName;
            patient.LastName  = lastName;
            patient.BirthDate = dateOfBirth;
            patient.Gender    = gender;
            patient.Mrn       = mrn;
            context.Agspatients.Add(patient);
        }
Example #3
0
 public TestHumanName(HumanName b)
 {
     humanName = b;
 }
 protected bool Equals(HumanName other)
 {
     return(string.Equals(Name, other.Name));
 }
Example #5
0
 //public void getErrors(object obj)
 //{
 //    Array errors = obj as Array;
 //    if (errors != null)
 //    {
 //        foreach(RequestFault i in errors)
 //        {
 //            Global.errors1.Add(i.PropertyName + " - " + i.Message);
 //            getErrors(i.Errors);
 //        }
 //    }
 //}
 private EMKServise.HumanName ConvertHumanName(HumanName c)
 {
     if ((object)c != null)
     {
         EMKServise.HumanName ed = new EMKServise.HumanName();
         if (c.FamilyName != "")
             ed.FamilyName = c.FamilyName;
         if (c.MiddleName != "")
             ed.MiddleName = c.MiddleName;
         if (c.GivenName != "")
             ed.GivenName = c.GivenName;
         return ed;
     }
     else
         return null;
 }
        public static Hl7.Fhir.Model.Patient MapModel(iPM_API_Resource.Patient iPMpatient)
        {
            if (iPMpatient == null)
            {
                throw new ArgumentNullException("patient");
            }

            var resource = new Hl7.Fhir.Model.Patient();

            resource.Id = iPMpatient.Pasid;

            resource.Active   = (iPMpatient.ArchvFlag == "Y") ?true : false;
            resource.Deceased = new FhirBoolean((iPMpatient.DecsdFlag == "Y") ? true : false);

            resource.Name = new List <HumanName>();
            var name = new HumanName()
            {
                Family = new[] { iPMpatient.Surname },
                Given  = new[] { iPMpatient.Forename },
                Use    = HumanName.NameUse.Official
            };

            resource.Name.Add(name);

            resource.BirthDate = iPMpatient.DttmOfBirth.ToString();

            //switch (iPMpatient.Gender)
            //{
            //    case GenderCode.Female:
            //        resource.Gender = new CodeableConcept("http://hl7.org/fhir/v3/AdministrativeGender", "F", "Female");
            //        break;

            //    case GenderCode.Male:
            //        resource.Gender = new CodeableConcept("http://hl7.org/fhir/v3/AdministrativeGender", "M", "Male");
            //        break;

            //    case GenderCode.Undetermined:
            //        resource.Gender = new CodeableConcept("http://hl7.org/fhir/v3/AdministrativeGender", "U", "Undetermined");
            //        break;

            //    default:
            //        resource.Gender = new CodeableConcept("http://hl7.org/fhir/v3/NullFlavor", "UNK", "Unknown");
            //        break;
            //}

            //resource.Telecom = new List<ContactPoint>
            //{
            //    new ContactPoint() {
            //        Value = iPMpatient.HomeTelephone.TlandOid.ToString(),
            //        System = ContactPoint.ContactPointSystem.Phone,
            //        Use = ContactPoint.ContactPointUse.Home
            //    },
            //    new ContactPoint() {
            //        Value = "0411445547878",
            //        System =  ContactPoint.ContactPointSystem.Phone,
            //        Use = ContactPoint.ContactPointUse.Mobile
            //    },

            //};

            //resource.Address = new List<Address>
            //{
            //    new Address()
            //    {
            //        Country = iPMpatient.HomeAddress.County,
            //        City = iPMpatient.HomeAddress.Line1,
            //        PostalCode = iPMpatient.HomeAddress.Pcode,
            //        Line = new[]
            //        {
            //            iPMpatient.HomeAddress.Line1,
            //            iPMpatient.HomeAddress.Line2
            //        }
            //    }
            //};

            // Make use of extensions ...
            //
            resource.Extension = new List <Extension>(1);
            //resource.Extension.Add(new Extension(new Uri("http://www.englishclub.com/vocabulary/world-countries-nationality.htm"),
            //                                       new FhirString("Australia")
            //                                     ));

            return(resource);
        }
Example #7
0
        public static Hl7.Fhir.Model.Patient MapModel(Model.Patient patient)
        {
            if (patient == null)
            {
                throw new ArgumentNullException("patient");
            }

            var resource = new Hl7.Fhir.Model.Patient();

            resource.Id = patient.PatientId.ToString("D");

            resource.Active   = patient.Active;
            resource.Deceased = new FhirBoolean(patient.Deceased);

            resource.Name = new List <HumanName>();
            var name = new HumanName()
            {
                Family = new[] { patient.LastName },
                Given  = new[] { patient.FirstName },
                Use    = HumanName.NameUse.Official
            };

            resource.Name.Add(name);

            resource.BirthDate = patient.Birthday.ToString("s");

            switch (patient.Gender)
            {
            case GenderCode.Female:
                resource.Gender = new CodeableConcept("http://hl7.org/fhir/v3/AdministrativeGender", "F", "Female");
                break;

            case GenderCode.Male:
                resource.Gender = new CodeableConcept("http://hl7.org/fhir/v3/AdministrativeGender", "M", "Male");
                break;

            case GenderCode.Undetermined:
                resource.Gender = new CodeableConcept("http://hl7.org/fhir/v3/AdministrativeGender", "U", "Undetermined");
                break;

            default:
                resource.Gender = new CodeableConcept("http://hl7.org/fhir/v3/NullFlavor", "UNK", "Unknown");
                break;
            }

            resource.Telecom = new List <Contact>
            {
                new Contact()
                {
                    Value  = patient.Phone,
                    System = Contact.ContactSystem.Phone,
                    Use    = Contact.ContactUse.Home
                },
                new Contact()
                {
                    Value  = patient.Mobile,
                    System = Contact.ContactSystem.Phone,
                    Use    = Contact.ContactUse.Mobile
                },
                new Contact()
                {
                    Value  = patient.EMail,
                    System = Contact.ContactSystem.Email,
                    Use    = Contact.ContactUse.Home
                },
            };

            resource.Address = new List <Address>
            {
                new Address()
                {
                    Country = patient.Country,
                    City    = patient.City,
                    Zip     = patient.Zip,
                    Line    = new[]
                    {
                        patient.AddressLine1,
                        patient.AddressLine2
                    }
                }
            };

            // Make use of extensions ...
            //
            resource.Extension = new List <Extension>(1);
            resource.Extension.Add(new Extension(new Uri("http://www.englishclub.com/vocabulary/world-countries-nationality.htm"),
                                                 new FhirString(patient.Nationality)
                                                 ));

            return(resource);
        }
Example #8
0
        /// <summary>
        /// Given a Patient POCO, maps the data to a Patient Resource.
        /// </summary>
        /// <param name="patient"></param>
        /// <returns></returns>
        public static Patient MapModel(Models.POCO.Patient patient)
        {
            if (patient == null)
            {
                throw new ArgumentNullException("patient");
            }

            var resource = new Patient();

            resource.Id = patient.PatientId.ToString("D"); // wtf does this line do

            // Patient bools
            resource.Active   = patient.Active;
            resource.Deceased = new FhirBoolean(patient.Deceased);

            // Patient Names
            resource.Name = new List <HumanName>();
            List <HumanName> fhirNames = new List <HumanName>();

            List <string> firstNames = new List <string>();
            List <string> lastNames  = new List <string>();

            foreach (var first in patient.FirstNames)
            {
                firstNames.Add(first);
            }
            foreach (var last in patient.LastNames)
            {
                lastNames.Add(last);
            }
            HumanName fhirName = new HumanName()
            {
                Family = lastNames,
                Given  = firstNames,
                Use    = HumanName.NameUse.Official
            };

            fhirNames.Add(fhirName);
            resource.Name = fhirNames;

            // Patient Birthday
            resource.BirthDate = patient.Birthday.ToString("s");

            // Patient Gender
            switch (patient.Gender)
            {
            case GenderCode.Female:
                resource.Gender = AdministrativeGender.Female;
                //resource.Gender = new CodeableConcept("http://hl7.org/fhir/v3/AdministrativeGender", "F", "Female");
                break;

            case GenderCode.Male:
                resource.Gender = AdministrativeGender.Male;
                //resource.Gender = new CodeableConcept("http://hl7.org/fhir/v3/AdministrativeGender", "M", "Male");
                break;

            case GenderCode.Undetermined:
                resource.Gender = AdministrativeGender.Other;
                //resource.Gender = new CodeableConcept("http://hl7.org/fhir/v3/AdministrativeGender", "U", "Undetermined");
                break;

            default:
                resource.Gender = AdministrativeGender.Unknown;
                //resource.Gender = new CodeableConcept("http://hl7.org/fhir/v3/NullFlavor", "UNK", "Unknown");
                break;
            }

            // Patient Telecom
            ContactPoint phone  = null;
            ContactPoint mobile = null;
            ContactPoint email  = null;

            if (patient.Phone != null)
            {
                phone = new ContactPoint()
                {
                    Value  = patient.Phone,
                    System = ContactPoint.ContactPointSystem.Phone,
                    Use    = ContactPoint.ContactPointUse.Home
                };
            }
            if (patient.Mobile != null)
            {
                mobile = new ContactPoint()
                {
                    Value  = patient.Mobile,
                    System = ContactPoint.ContactPointSystem.Phone,
                    Use    = ContactPoint.ContactPointUse.Mobile
                };
            }
            if (patient.Email != null)
            {
                email = new ContactPoint()
                {
                    Value  = patient.Email,
                    System = ContactPoint.ContactPointSystem.Email,
                    Use    = ContactPoint.ContactPointUse.Home
                };
            }

            if (patient.Phone != null || patient.Mobile != null || patient.Email != null)
            {
                resource.Telecom = new List <ContactPoint> {
                    phone, mobile, email
                };
            }

            // Patient Address
            resource.Address = new List <Address>();
            List <Address> fhirAddresses = new List <Address>();

            for (int j = 0; j < patient.Countries.Count; j++)
            {
                Address fhirAddress = new Address()
                {
                    Country    = patient.Countries[j],
                    City       = patient.Cities[j],
                    State      = patient.States[j],
                    PostalCode = patient.PostalCodes[j],
                    Line       = new[]
                    {
                        patient.AddressLines1[j],
                        patient.AddressLines2[j],
                    },
                    Period = new Period
                    {
                        Start = patient.PeriodStarts[j],
                        End   = patient.PeriodEnds[j],
                    }
                };

                fhirAddresses.Add(fhirAddress);
            }

            resource.Address = fhirAddresses;

            // Make use of extensions ...
            //

            resource.Extension = new List <Extension>(1);
            resource.Extension.Add(new Extension("http://www.englishclub.com/vocabulary/world-countries-nationality.htm",
                                                 new FhirString(patient.Nationality)
                                                 ));
            return(resource);
        }
Example #9
0
        public static HumanName NameObject(string FullName)
        {
            var oName = new HumanName(FullName);

            return(oName);
        }
        private Patient makeAPatient()
        {
            // example Patient setup, fictional data only
            var pat = new Patient();

            var id = new Identifier();

            id.System = "http://hl7.org/fhir/sid/us-ssn";
            id.Value  = "010119-4589";
            pat.Identifier.Add(id);

            var name = new HumanName().WithGiven("Christiane").WithGiven("A.H.").AndFamily("Julemand");

            name.Prefix = new string[] { "Mrs." };
            name.Use    = HumanName.NameUse.Official;

            var nickname = new HumanName();

            nickname.Use = HumanName.NameUse.Nickname;
            nickname.GivenElement.Add(new FhirString("Chrissy"));

            pat.Name.Add(name);
            pat.Name.Add(nickname);

            pat.Gender = AdministrativeGender.Female;

            pat.BirthDate = "2019-01-01";

            var birthplace = new Extension();

            birthplace.Url   = "http://hl7.org/fhir/StructureDefinition/birthPlace";
            birthplace.Value = new Address()
            {
                City = "Aarhus N"
            };
            pat.Extension.Add(birthplace);

            var birthtime = new Extension("http://hl7.org/fhir/StructureDefinition/patient-birthTime",
                                          new FhirDateTime(2021, 11, 4, 10, 00));

            pat.BirthDateElement.Extension.Add(birthtime);

            var address = new Address()
            {
                Line       = new string[] { "Finlandsgade 22" },
                City       = "Aarhus N",
                State      = "",
                PostalCode = "8200",
                Country    = "Denmark"
            };

            pat.Address.Add(address);

            var contact = new Patient.ContactComponent();

            contact.Name        = new HumanName();
            contact.Name.Given  = new string[] { "Knud" };
            contact.Name.Family = "Julemand";
            contact.Gender      = AdministrativeGender.Female;
            contact.Relationship.Add(new CodeableConcept("http://hl7.org/fhir/v2/0131", "N"));
            contact.Telecom.Add(new ContactPoint(ContactPoint.ContactPointSystem.Phone, null, ""));
            pat.Contact.Add(contact);

            pat.Deceased = new FhirBoolean(false);

            return(pat);
        }
Example #11
0
        internal static Patient ToFhirInternal(Personal personal, Patient patient)
        {
            if (personal.BirthDate?.Date != null)
            {
                patient.BirthDateElement = new Date(personal.BirthDate.Date.Year, personal.BirthDate.Date.Month, personal.BirthDate.Date.Day);

                if (personal.BirthDate?.Time != null)
                {
                    patient.BirthDateElement.AddExtension(HealthVaultExtensions.PatientBirthTime, personal.BirthDate.Time.ToFhir());
                }
            }

            if (personal.DateOfDeath != null)
            {
                patient.Deceased = personal.DateOfDeath.ToFhir();
            }
            else
            {
                patient.Deceased = new FhirBoolean(personal.IsDeceased);
            }

            patient.Extension.Add(PopulatePersonalExtension(personal));

            if (personal.Name != null)
            {
                var humanName = new HumanName
                {
                    Family = personal.Name.Last,
                    Text   = personal.Name.Full,
                };

                var givenNames = new List <string>();
                if (!string.IsNullOrEmpty(personal.Name.First))
                {
                    givenNames.Add(personal.Name.First);
                }

                if (!string.IsNullOrEmpty(personal.Name.Middle))
                {
                    givenNames.Add(personal.Name.Middle);
                }
                humanName.Given = givenNames;

                if (personal.Name.Title != null)
                {
                    humanName.Prefix = new List <string> {
                        personal.Name.Title.Text
                    };
                }

                if (personal.Name.Suffix != null)
                {
                    humanName.Suffix = new List <string> {
                        personal.Name.Suffix.Text
                    };
                }

                patient.Name.Add(humanName);
            }

            if (!string.IsNullOrEmpty(personal.SocialSecurityNumber))
            {
                patient.Identifier.Add(new Identifier {
                    Value  = personal.SocialSecurityNumber,
                    System = Constants.FhirExtensions.SSN,
                }
                                       );
            }

            return(patient);
        }
Example #12
0
        /// <summary>
        /// Serialize a FHIR HumanName into JSON
        /// </summary>
        public static void SerializeJson(this HumanName current, Utf8JsonWriter writer, JsonSerializerOptions options, bool includeStartObject = true)
        {
            if (includeStartObject)
            {
                writer.WriteStartObject();
            }
            // Complex: HumanName, Export: HumanName, Base: Element (Element)
            ((Hl7.Fhir.Model.Element)current).SerializeJson(writer, options, false);

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

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

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

            if ((current.GivenElement != null) && (current.GivenElement.Count != 0))
            {
                int valueCount     = 0;
                int extensionCount = 0;
                foreach (FhirString val in current.GivenElement)
                {
                    if (!string.IsNullOrEmpty(val.Value))
                    {
                        valueCount++;
                    }
                    if (val.HasExtensions())
                    {
                        extensionCount++;
                    }
                }

                if (valueCount > 0)
                {
                    writer.WritePropertyName("given");
                    writer.WriteStartArray();
                    foreach (FhirString val in current.GivenElement)
                    {
                        if (string.IsNullOrEmpty(val.Value))
                        {
                            writer.WriteNullValue();
                        }
                        else
                        {
                            writer.WriteStringValue(val.Value);
                        }
                    }

                    writer.WriteEndArray();
                }

                if (extensionCount > 0)
                {
                    writer.WritePropertyName("_given");
                    writer.WriteStartArray();
                    foreach (FhirString val in current.GivenElement)
                    {
                        if (val.HasExtensions() || (!string.IsNullOrEmpty(val.ElementId)))
                        {
                            JsonStreamUtilities.SerializeExtensionList(writer, options, string.Empty, true, val.Extension, val.ElementId);
                        }
                        else
                        {
                            writer.WriteNullValue();
                        }
                    }

                    writer.WriteEndArray();
                }
            }

            if ((current.PrefixElement != null) && (current.PrefixElement.Count != 0))
            {
                int valueCount     = 0;
                int extensionCount = 0;
                foreach (FhirString val in current.PrefixElement)
                {
                    if (!string.IsNullOrEmpty(val.Value))
                    {
                        valueCount++;
                    }
                    if (val.HasExtensions())
                    {
                        extensionCount++;
                    }
                }

                if (valueCount > 0)
                {
                    writer.WritePropertyName("prefix");
                    writer.WriteStartArray();
                    foreach (FhirString val in current.PrefixElement)
                    {
                        if (string.IsNullOrEmpty(val.Value))
                        {
                            writer.WriteNullValue();
                        }
                        else
                        {
                            writer.WriteStringValue(val.Value);
                        }
                    }

                    writer.WriteEndArray();
                }

                if (extensionCount > 0)
                {
                    writer.WritePropertyName("_prefix");
                    writer.WriteStartArray();
                    foreach (FhirString val in current.PrefixElement)
                    {
                        if (val.HasExtensions() || (!string.IsNullOrEmpty(val.ElementId)))
                        {
                            JsonStreamUtilities.SerializeExtensionList(writer, options, string.Empty, true, val.Extension, val.ElementId);
                        }
                        else
                        {
                            writer.WriteNullValue();
                        }
                    }

                    writer.WriteEndArray();
                }
            }

            if ((current.SuffixElement != null) && (current.SuffixElement.Count != 0))
            {
                int valueCount     = 0;
                int extensionCount = 0;
                foreach (FhirString val in current.SuffixElement)
                {
                    if (!string.IsNullOrEmpty(val.Value))
                    {
                        valueCount++;
                    }
                    if (val.HasExtensions())
                    {
                        extensionCount++;
                    }
                }

                if (valueCount > 0)
                {
                    writer.WritePropertyName("suffix");
                    writer.WriteStartArray();
                    foreach (FhirString val in current.SuffixElement)
                    {
                        if (string.IsNullOrEmpty(val.Value))
                        {
                            writer.WriteNullValue();
                        }
                        else
                        {
                            writer.WriteStringValue(val.Value);
                        }
                    }

                    writer.WriteEndArray();
                }

                if (extensionCount > 0)
                {
                    writer.WritePropertyName("_suffix");
                    writer.WriteStartArray();
                    foreach (FhirString val in current.SuffixElement)
                    {
                        if (val.HasExtensions() || (!string.IsNullOrEmpty(val.ElementId)))
                        {
                            JsonStreamUtilities.SerializeExtensionList(writer, options, string.Empty, true, val.Extension, val.ElementId);
                        }
                        else
                        {
                            writer.WriteNullValue();
                        }
                    }

                    writer.WriteEndArray();
                }
            }

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

            if (includeStartObject)
            {
                writer.WriteEndObject();
            }
        }
Example #13
0
        /// <summary>
        /// Deserialize JSON into a FHIR HumanName
        /// </summary>
        public static void DeserializeJsonProperty(this HumanName current, ref Utf8JsonReader reader, JsonSerializerOptions options, string propertyName)
        {
            switch (propertyName)
            {
            case "use":
                if (reader.TokenType == JsonTokenType.Null)
                {
                    current.UseElement = new Code <Hl7.Fhir.Model.HumanName.NameUse>();
                    reader.Skip();
                }
                else
                {
                    current.UseElement = new Code <Hl7.Fhir.Model.HumanName.NameUse>(Hl7.Fhir.Utility.EnumUtility.ParseLiteral <Hl7.Fhir.Model.HumanName.NameUse>(reader.GetString()));
                }
                break;

            case "_use":
                if (current.UseElement == null)
                {
                    current.UseElement = new Code <Hl7.Fhir.Model.HumanName.NameUse>();
                }
                ((Hl7.Fhir.Model.Element)current.UseElement).DeserializeJson(ref reader, options);
                break;

            case "text":
                if (reader.TokenType == JsonTokenType.Null)
                {
                    current.TextElement = new FhirString();
                    reader.Skip();
                }
                else
                {
                    current.TextElement = new FhirString(reader.GetString());
                }
                break;

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

            case "family":
                if (reader.TokenType == JsonTokenType.Null)
                {
                    current.FamilyElement = new FhirString();
                    reader.Skip();
                }
                else
                {
                    current.FamilyElement = new FhirString(reader.GetString());
                }
                break;

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

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

                current.GivenElement = new List <FhirString>();

                while (reader.TokenType != JsonTokenType.EndArray)
                {
                    if (reader.TokenType == JsonTokenType.Null)
                    {
                        current.GivenElement.Add(new FhirString());
                        reader.Skip();
                    }
                    else
                    {
                        current.GivenElement.Add(new FhirString(reader.GetString()));
                    }

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

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

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

                int i_given = 0;

                while (reader.TokenType != JsonTokenType.EndArray)
                {
                    if (i_given >= current.GivenElement.Count)
                    {
                        current.GivenElement.Add(new FhirString());
                    }
                    if (reader.TokenType == JsonTokenType.Null)
                    {
                        reader.Skip();
                    }
                    else
                    {
                        ((Hl7.Fhir.Model.Element)current.GivenElement[i_given++]).DeserializeJson(ref reader, options);
                    }

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

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

                current.PrefixElement = new List <FhirString>();

                while (reader.TokenType != JsonTokenType.EndArray)
                {
                    if (reader.TokenType == JsonTokenType.Null)
                    {
                        current.PrefixElement.Add(new FhirString());
                        reader.Skip();
                    }
                    else
                    {
                        current.PrefixElement.Add(new FhirString(reader.GetString()));
                    }

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

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

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

                int i_prefix = 0;

                while (reader.TokenType != JsonTokenType.EndArray)
                {
                    if (i_prefix >= current.PrefixElement.Count)
                    {
                        current.PrefixElement.Add(new FhirString());
                    }
                    if (reader.TokenType == JsonTokenType.Null)
                    {
                        reader.Skip();
                    }
                    else
                    {
                        ((Hl7.Fhir.Model.Element)current.PrefixElement[i_prefix++]).DeserializeJson(ref reader, options);
                    }

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

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

                current.SuffixElement = new List <FhirString>();

                while (reader.TokenType != JsonTokenType.EndArray)
                {
                    if (reader.TokenType == JsonTokenType.Null)
                    {
                        current.SuffixElement.Add(new FhirString());
                        reader.Skip();
                    }
                    else
                    {
                        current.SuffixElement.Add(new FhirString(reader.GetString()));
                    }

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

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

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

                int i_suffix = 0;

                while (reader.TokenType != JsonTokenType.EndArray)
                {
                    if (i_suffix >= current.SuffixElement.Count)
                    {
                        current.SuffixElement.Add(new FhirString());
                    }
                    if (reader.TokenType == JsonTokenType.Null)
                    {
                        reader.Skip();
                    }
                    else
                    {
                        ((Hl7.Fhir.Model.Element)current.SuffixElement[i_suffix++]).DeserializeJson(ref reader, options);
                    }

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

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

            // Complex: HumanName, Export: HumanName, Base: Element
            default:
                ((Hl7.Fhir.Model.Element)current).DeserializeJsonProperty(ref reader, options, propertyName);
                break;
            }
        }
Example #14
0
        private static Resource MediMobiExample()
        {
            var patient = new Patient
            {
                Id         = "patient",
                Identifier = new List <Identifier>
                {
                    new Identifier("https://www.ehealth.fgov.be/standards/fhir/NamingSystem/ssin", "00.01.01-003.03")
                },
                Name = new List <HumanName> {
                    HumanName.ForFamily("Doe").WithGiven("Jane")
                },
                Gender   = AdministrativeGender.Female,
                Language = "nl-be",
                Address  = new List <Address>
                {
                    new Address()
                    {
                        Line       = new [] { "Astridstraat 192" },
                        City       = "Zottegem",
                        PostalCode = "9620",
                        Use        = Address.AddressUse.Home
                    }
                },
                Telecom = new List <ContactPoint>
                {
                    new ContactPoint(ContactPoint.ContactPointSystem.Phone, ContactPoint.ContactPointUse.Mobile,
                                     "+32478123456"),
                    new ContactPoint(ContactPoint.ContactPointSystem.Email, ContactPoint.ContactPointUse.Home,
                                     "*****@*****.**")
                }
            };

            var campus = new Location()
            {
                Id      = "campus",
                Name    = "Hospital X - campus Ghent",
                Address = new Address
                {
                    Line = new List <string>()
                    {
                        "Steenweg 37"
                    },
                    PostalCode = "9000",
                    City       = "Ghent"
                }
            };

            var location = new Location
            {
                Id        = "location",
                Name      = "Wachtzaal Orthopedie",
                Alias     = new [] { "Route 37" },
                PartOf    = new ResourceReference("#campus"),
                Contained = new List <Resource> {
                    campus
                }
            };

            var healthcareService = new HealthcareService()
            {
                Id         = "healthcareService",
                Identifier =
                    new List <Identifier> {
                    new Identifier("http://demohospital.mediligo.com/service", "orthopedics")
                },
                Specialty = new List <CodeableConcept> {
                    new CodeableConcept("http://snomed.info/sct", "394801008")
                },
                Name = "Orthopedie"
            };

            var x = new Appointment
            {
                Id        = "example",
                Contained = new List <Resource>
                {
                    patient, location, healthcareService
                },
                Identifier =
                    new List <Identifier> {
                    new Identifier("http://demohospital.mediligo.com/appointement", "1234")
                },
                Status          = Appointment.AppointmentStatus.Booked,
                ServiceCategory = new List <CodeableConcept>
                {
                    new CodeableConcept("https://demohospital.mediligo.com/serviceType", "shoulder-first-consult"),
                    new CodeableConcept("http://mediligo.com/fhir/MediMobi/CodeSystem/medimobi-appointment-class",
                                        "consultation-mobile")
                },
                Start       = new DateTimeOffset(2020, 10, 24, 10, 0, 0, TimeSpan.FromHours(1)),
                End         = new DateTimeOffset(2020, 10, 24, 11, 0, 0, TimeSpan.FromHours(1)),
                Participant = new List <Appointment.ParticipantComponent>
                {
                    new Appointment.ParticipantComponent {
                        Actor = new ResourceReference("#patient")
                    },
                    new Appointment.ParticipantComponent {
                        Actor = new ResourceReference("#location")
                    },
                    new Appointment.ParticipantComponent {
                        Actor = new ResourceReference("#healthcareService")
                    }
                }
            };

            return(x);
        }
Example #15
0
        /// <summary>
        /// Generates the candidate registry.
        /// </summary>
        /// <param name="options">The options.</param>
        /// <returns>Patient.</returns>
        public static Patient GenerateCandidateRegistry(Demographic options)
        {
            var patient = new Patient
            {
                Active  = true,
                Address = new List <Hl7.Fhir.Model.Address>()
            };

            foreach (var address in options.Addresses)
            {
                patient.Address.Add(new Hl7.Fhir.Model.Address
                {
                    City    = address.City,
                    Country = address.Country,
                    Line    = new List <string>
                    {
                        address.StreetAddress
                    },
                    State      = address.StateProvince,
                    PostalCode = address.ZipPostalCode
                });
            }

            if (options.DateOfBirthOptions != null)
            {
                if (options.DateOfBirthOptions.Exact.HasValue)
                {
                    patient.BirthDate = options.DateOfBirthOptions?.Exact.Value.ToString("yyyy-MM-dd");
                }
                else if (options.DateOfBirthOptions.Start.HasValue && options.DateOfBirthOptions.End.HasValue)
                {
                    var startYear = options.DateOfBirthOptions.Start.Value.Year;
                    var endYear   = options.DateOfBirthOptions.End.Value.Year;

                    var startMonth = options.DateOfBirthOptions.Start.Value.Month;
                    var endMonth   = options.DateOfBirthOptions.End.Value.Month;

                    var startDay = options.DateOfBirthOptions.Start.Value.Day;
                    var endDay   = options.DateOfBirthOptions.End.Value.Day;

                    patient.BirthDate = new DateTime(new Random().Next(startYear, endYear), new Random().Next(startMonth, endMonth), new Random().Next(startDay, endDay)).ToString("yyyy-MM-dd");
                }
                else
                {
                    patient.BirthDate = new DateTime(new Random().Next(1900, DateTime.Now.Year - 1), new Random().Next(1, 12), new Random().Next(1, 28)).ToString("yyyy-MM-dd");
                }
            }

            switch (options.Gender)
            {
            case "F":
            case "f":
            case "female":
            case "Female":
                patient.Gender = AdministrativeGender.Female;
                break;

            case "M":
            case "m":
            case "male":
            case "Male":
                patient.Gender = AdministrativeGender.Male;
                break;

            case "O":
            case "o":
            case "other":
            case "Other":
                patient.Gender = AdministrativeGender.Other;
                break;

            default:
                patient.Gender = AdministrativeGender.Unknown;
                break;
            }

            patient.Identifier = new List <Identifier>();
            patient.Identifier.AddRange(options.OtherIdentifiers.Select(i => new Identifier(i.AssigningAuthority, i.Value)));

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

            foreach (var name in options.Names)
            {
                var humanName = new HumanName
                {
                    Family = name.LastName,
                    Given  = new List <string>
                    {
                        name.FirstName
                    }
                };

                humanName.Given = new List <string>(name.MiddleNames)
                {
                    name.FirstName
                };

                patient.Name.Add(humanName);
            }

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

            patient.Telecom.AddRange(options.TelecomOptions.EmailAddresses.Select(e => new ContactPoint(ContactPoint.ContactPointSystem.Email, ContactPoint.ContactPointUse.Mobile, e)));
            patient.Telecom.AddRange(options.TelecomOptions.PhoneNumbers.Select(p => new ContactPoint(ContactPoint.ContactPointSystem.Phone, ContactPoint.ContactPointUse.Mobile, p)));

            return(patient);
        }
Example #16
0
    void FileReaderTStart(string dir)
    {
        if (started)
        {
            return;
        }
        started = true;



        StreamReader file =
            new StreamReader(dir);
        CultureInfo MyCultureInfo = new CultureInfo("ko-KR");


        Title = file.ReadLine();


        var dateTime = file.ReadLine().Split(":".ToArray(), 2)[1];

        SaveDate = DateTime.Parse(dateTime, MyCultureInfo);

        string   line;
        DateTime?readingDate = null;
        var      todayTalk   = new List <SingleChat>();

        while (!file.EndOfStream)
        {
            line = file.ReadLine();
            if (line.Equals(""))
            {
                continue;
            }
            else if (Regex.Match(line, "[0-9]{4}년 [0-9]{1,2}월 [0-9]{1,2}일 오[전+후] [0-9]{1,2}:[0-9]{1,2}$").Success)
            {
                if (readingDate != null)
                {
                    Thread DayReader = new Thread(new ParameterizedThreadStart(ReadDayTStart));
                    unitTimeCommsSnapShotUpdater.Add((DateTime)readingDate, DayReader);
                    lock (((ICollection)allTalks).SyncRoot)
                        allTalks.Add((DateTime)readingDate, todayTalk);
                    DayReader.Start(readingDate);
                    todayTalk = new List <SingleChat>();
                }
                readingDate = DateTime.Parse(line, MyCultureInfo).Date;
                lock (progLock)
                    prog.daysFoundFromFile++;
            }//Day Start
            else if (Regex.Match(line, "[0-9]{4}년 [0-9]{1,2}월 [0-9]{1,2}일 오[전+후] [0-9]{1,2}:[0-9]{1,2}, .* : .*").Success)
            {
                var dt_text     = line.Split(",".ToArray(), 2);
                var name_text   = dt_text[1].Split(":".ToArray(), 2);
                var lastTalk    = todayTalk.LastOrDefault();
                var currentName = new HumanName(name_text[0]);
                if (lastTalk != null && lastTalk.name == currentName)
                {
                    lastTalk.length += name_text[1].Length - 1;
                }
                else
                {
                    todayTalk.Add(new SingleChat()
                    {
                        time   = DateTime.Parse(dt_text[0], MyCultureInfo),
                        name   = new HumanName(name_text[0]),
                        length = name_text[1].Length - 1
                    });
                }
            }//Chat
            else
            {
                continue; //TODO: add to last line
            }
        }
        {
            Thread DayReader = new Thread(new ParameterizedThreadStart(ReadDayTStart));
            unitTimeCommsSnapShotUpdater.Add((DateTime)readingDate, DayReader);
            lock (((ICollection)allTalks).SyncRoot)
                allTalks.Add((DateTime)readingDate, todayTalk);
            DayReader.Start(readingDate);
            lock (progLock)
                prog.daysFoundFromFile++;
        }
    }
        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);
            }
        }
Example #18
0
        /// <summary>
        /// Executes the specified arguments.
        /// </summary>
        /// <param name="arguments">The arguments.</param>
        /// <returns>System.Int32.</returns>
        public override int Execute(Arguments arguments)
        {
            // Get us the needed parameters first
            //
            var url = arguments["url"];

            var name      = arguments["name"];
            var firstname = arguments["firstname"];
            var gender    = arguments["gender"];
            var dob       = arguments["dob"];
            var phone     = arguments["phone"];
            var email     = arguments["email"];

            // Create an in-memory representation of a Patient resource

            var patient = new Patient();

            if (!(String.IsNullOrEmpty(name) && !String.IsNullOrEmpty(firstname)))
            {
                patient.Name = new List <HumanName>();
                patient.Name.Add(HumanName.ForFamily(name).WithGiven(firstname));
            }

            if (!String.IsNullOrEmpty(gender))
            {
                patient.Gender = new CodeableConcept("http://dummy.org/gender", gender, gender);
            }

            if (!String.IsNullOrEmpty(dob))
            {
                var birthdate = DateTime.ParseExact(dob, "dd/MM/yyyy", new CultureInfo("en-US"));
                patient.BirthDate = birthdate.ToString("s");
            }

            patient.Telecom = new List <Contact>();
            if (!String.IsNullOrEmpty(phone))
            {
                patient.Telecom.Add(new Contact()
                {
                    Value  = phone,
                    System = Contact.ContactSystem.Phone,
                    Use    = Contact.ContactUse.Home
                });
            }

            if (!String.IsNullOrEmpty(email))
            {
                patient.Telecom.Add(new Contact()
                {
                    Value  = email,
                    System = Contact.ContactSystem.Email,
                    Use    = Contact.ContactUse.Home
                });
            }


            try
            {
                var client = new FhirClient(url);
                var entry  = client.Create(patient);

                if (entry == null)
                {
                    Console.WriteLine("Couldn not register patient on server {0}", url);
                    return(1);
                }

                var identity = new ResourceIdentity(entry.Id);
                ID = identity.Id;

                Console.WriteLine("Registered patient {0} on server {1}", ID, url);
                return(0);
            }
            catch (Exception e)
            {
                Console.WriteLine(e.Message);
                return(1);
            }
        }
    public void Test_CaseSensitive_FHIR_Id()
    {
      CleanUpByIdentifier(ResourceType.Patient);

      Hl7.Fhir.Rest.FhirClient clientFhir = new Hl7.Fhir.Rest.FhirClient(StaticTestData.FhirEndpoint(), false);
      clientFhir.Timeout = 1000 * 720; // give the call a while to execute (particularly while debugging).
      
      //Add a Patient resource by Update
      Patient PatientOne = new Patient();
      string PatientOneResourceId = Guid.NewGuid().ToString().ToLower();
      PatientOne.Id = PatientOneResourceId;
      string PatientOneFamilyName = "TestPatientOne";
      PatientOne.Name.Add(HumanName.ForFamily(PatientOneFamilyName).WithGiven("Test"));
      PatientOne.BirthDateElement = new Date("1979-09-30");
      string PatientOneMRNIdentifer = Guid.NewGuid().ToString();
      PatientOne.Identifier.Add(new Identifier(StaticTestData.TestIdentiferSystem, PatientOneMRNIdentifer));
      PatientOne.Gender = AdministrativeGender.Unknown;

      Patient PatientResult = null;
      try
      {
        PatientResult = clientFhir.Update(PatientOne);
      }
      catch (Exception Exec)
      {
        Assert.True(false, "Exception thrown on resource Create: " + Exec.Message);
      }
      Assert.NotNull(PatientResult, "Resource create by Updated returned resource of null");      
      PatientResult = null;


      //Add a Patient resource by Update
      Patient PatientTwo = new Patient();
      string PatientTwoResourceId = PatientOneResourceId.ToUpper();
      PatientTwo.Id = PatientTwoResourceId;
      string PatientTwoFamilyName = "TestPatientTwo";
      PatientTwo.Name.Add(HumanName.ForFamily(PatientTwoFamilyName).WithGiven("Test"));
      PatientTwo.BirthDateElement = new Date("1979-09-30");
      string PatientTwoMRNIdentifer = Guid.NewGuid().ToString();
      PatientTwo.Identifier.Add(new Identifier(StaticTestData.TestIdentiferSystem, PatientOneMRNIdentifer));
      PatientTwo.Gender = AdministrativeGender.Unknown;

      PatientResult = null;
      try
      {
        PatientResult = clientFhir.Update(PatientTwo);
      }
      catch (Exception Exec)
      {
        Assert.True(false, "Exception thrown on resource Create: " + Exec.Message);
      }
      Assert.NotNull(PatientResult, "Resource create by Updated returned resource of null");      
      PatientResult = null;

      Bundle SearchResult = null;
      try
      {
        SearchResult = clientFhir.SearchById<Patient>(PatientOneResourceId);
      }
      catch (Exception Exec)
      {
        Assert.True(false, "Exception thrown on resource Create: " + Exec.Message);
      }
      Assert.AreEqual(1, SearchResult.Entry.Count);
      Assert.AreEqual(PatientOneFamilyName, (SearchResult.Entry[0].Resource as Patient).Name[0].Family);

      SearchResult = null;
      try
      {
        SearchResult = clientFhir.SearchById<Patient>(PatientTwoResourceId);
      }
      catch (Exception Exec)
      {
        Assert.True(false, "Exception thrown on resource Create: " + Exec.Message);
      }
      Assert.AreEqual(1, SearchResult.Entry.Count);
      Assert.AreEqual(PatientTwoFamilyName, (SearchResult.Entry[0].Resource as Patient).Name[0].Family);

      //--- Clean Up ---------------------------------------------------------
      //Clean up by deleting all Test Patients
      SearchParams sp = new SearchParams().Where($"identifier={StaticTestData.TestIdentiferSystem}|");
      try
      {
        clientFhir.Delete("Patient", sp);
      }
      catch (Exception Exec)
      {
        Assert.True(false, "Exception thrown on conditional delete of resource Patient: " + Exec.Message);
      }

    }
Example #20
0
        /// <summary>
        /// Executes the specified arguments.
        /// </summary>
        /// <param name="arguments">The arguments.</param>
        /// <returns>System.Int32.</returns>
        /// <remarks>N/A</remarks>
        public override int Execute(Arguments arguments)
        {
            // Get us the needed parameters first
            //
            var url = arguments["url"];
            var id  = arguments["id"];

            var name      = arguments["name"];
            var firstname = arguments["firstname"];
            var gender    = arguments["gender"];
            var dob       = arguments["dob"];
            var phone     = arguments["phone"];
            var email     = arguments["email"];


            // Try to retrieve patient from server and update it
            try
            {
                // Get patient representation from server
                //
                #region retrieve patient
                var client   = new FhirClient(url);
                var identity = ResourceIdentity.Build("Patient", id);
                var entry    = client.Read(identity) as ResourceEntry <Patient>;

                var patient = entry.Resource as Patient;
                if (patient == null)
                {
                    Console.WriteLine("Could not retrieve patient {0} from server {1}", id, url);
                    return(1);
                }
                #endregion

                // We have the patient now modify local representation
                //
                #region prepare patient update
                if (!(String.IsNullOrEmpty(name) && !String.IsNullOrEmpty(firstname)))
                {
                    patient.Name = new List <HumanName>();
                    patient.Name.Add(HumanName.ForFamily(name).WithGiven(firstname));
                }

                if (!String.IsNullOrEmpty(gender))
                {
                    patient.Gender = new CodeableConcept("http://dummy.org/gender", gender, gender);
                }

                if (!String.IsNullOrEmpty(dob))
                {
                    var birthdate = DateTime.ParseExact(dob, "dd/MM/yyyy", new CultureInfo("en-US"));
                    patient.BirthDate = birthdate.ToString("s");
                }

                patient.Telecom = new List <Contact>();
                if (!String.IsNullOrEmpty(phone))
                {
                    patient.Telecom.Add(new Contact()
                    {
                        Value  = phone,
                        System = Contact.ContactSystem.Phone,
                        Use    = Contact.ContactUse.Home
                    });
                }

                if (!String.IsNullOrEmpty(email))
                {
                    patient.Telecom.Add(new Contact()
                    {
                        Value  = email,
                        System = Contact.ContactSystem.Email,
                        Use    = Contact.ContactUse.Home
                    });
                }
                #endregion

                // Finally send the update to the server
                //
                #region do patient update
                entry.Resource = patient;
                client.Update(entry, false);
                Console.WriteLine("Patient {0} updated on server {1}", id, url);
                return(0);

                #endregion
            }
            catch (Exception e)
            {
                Console.WriteLine(e.Message);
                return(1);
            }
        }
    public void Test_CRUD()
    {

      Hl7.Fhir.Rest.FhirClient clientFhir = new Hl7.Fhir.Rest.FhirClient(StaticTestData.FhirEndpoint(), false);
      clientFhir.Timeout = 1000 * 720; // give the call a while to execute (particularly while debugging).

      string PatientResourceId = string.Empty;

      //Add a Patient resource by Update
      Patient PatientOne = new Patient();
      PatientOne.Name.Add(HumanName.ForFamily("TestPatient").WithGiven("Test"));
      PatientOne.BirthDateElement = new Date("1979-09-30");
      string PatientOneMRNIdentifer = Guid.NewGuid().ToString();
      PatientOne.Identifier.Add(new Identifier(StaticTestData.TestIdentiferSystem, PatientOneMRNIdentifer));
      PatientOne.Gender = AdministrativeGender.Unknown;

      Patient PatientResult = null;
      try
      {
        PatientResult = clientFhir.Create(PatientOne);
      }
      catch (Exception Exec)
      {
        Assert.True(false, "Exception thrown on resource Create: " + Exec.Message);
      }
      Assert.NotNull(PatientResult, "Resource create by Updated returned resource of null");
      PatientResourceId = PatientResult.Id;
      PatientResult = null;

      //Get the Added resource by Id
      try
      {
        //PatientOneResourceId
        PatientResult = (Patient)clientFhir.Get($"{StaticTestData.FhirEndpoint()}/Patient/{PatientResourceId}");
      }
      catch (Exception Exec)
      {
        Assert.True(false, "Exception thrown on resource Get: " + Exec.Message);
      }
      Assert.NotNull(PatientResult, "Resource Get returned resource of null");
      Assert.AreEqual(PatientResourceId, PatientResult.Id, "Resource created by Updated has incorrect Resource Id");
      Assert.AreEqual(AdministrativeGender.Unknown, PatientResult.Gender, "Patient gender does not match.");

      //Update
      PatientResult.Gender = AdministrativeGender.Male;
      try
      {
        clientFhir.Update(PatientResult);
      }
      catch (Exception Exec)
      {
        Assert.True(false, "Exception thrown on resource Get: " + Exec.Message);
      }
      PatientResult = null;

      //Get the Added resource by Id
      try
      {
        PatientResult = (Patient)clientFhir.Get($"{StaticTestData.FhirEndpoint()}/Patient/{PatientResourceId}");
      }
      catch (Exception Exec)
      {
        Assert.True(false, "Exception thrown on resource Get: " + Exec.Message);
      }
      Assert.NotNull(PatientResult, "Resource Get returned resource of null");
      Assert.AreEqual(AdministrativeGender.Male, PatientResult.Gender, "Patient gender does not match.");

      //Delete Resource
      try
      {
        clientFhir.Delete($"Patient/{PatientResourceId}");
      }
      catch (Exception Exec)
      {
        Assert.True(false, "Exception thrown on resource Get: " + Exec.Message);
      }

      //Get the Added resource by Id
      try
      {
        var Result = clientFhir.Get($"{StaticTestData.FhirEndpoint()}/Patient/{PatientResourceId}");
      }
      catch (Hl7.Fhir.Rest.FhirOperationException OpExec)
      {
        Assert.AreEqual(OpExec.Status, System.Net.HttpStatusCode.Gone, "Final Get did not return Http Status of Gone.");
      }

    }
Example #22
0
        static void Main(string[] args)
        {
            List <string> list = new List <string>
            {
                "RICHARD M HARMON JR"
                , "RICHARD M"
                , "HARMON JR"
                , "Charles Tiberi, Jr"
                , "Jose Jimenez"
                , "Olga Blanco"
                , "Edwin Brown"
                , "MARIA-MIREYA M LEDUC"
                , "Richard Carroll"
                , "MARGARITA VELASQUEZ"
                , "WILBERT MELVIN"
                , "Irene Sikora"
                , "WILLIO JOSEPH"
                , "JENNY M CERUZZI"
                , "TAMMY SMITH"
                , "TRACY NAGELHOUT"
                , "CHRISTOPHER COLEMAN"
                , "Hector Tovar"
                , "Forest Nelson"
                , "MARIO CASTILLO"
                , "CLIFFORD WRIGHT"
                , "JAMES ABRAMSON"
                , "LYMARIS PABELLON"
                , "GEORGE LEWIS"
                , "JAMES NOVAK"
                , "SILAS N AUSTIN"
                , "Lester Shaffer"
                , "Irineo Garay"
                , "GERARDO FERREIRA"
                , "Sebna Hernandez"
                , "Bernadine Parker"
                , "Jacqueline Ryan"
                , "Timothy Stowes"
                , "GLORIA MERA"
                , "CHARLES EDWARDS JR"
                , "HERNAN D CASTANO"
                , "DAVID REPOLGLE"
                , "KERI BAUGH"
                , "Yordani Pedraza"
                , "Jonathan Hernandez-Gonzalez"
                , "Spencer Johnson"
                , "Kathlene L Bentley"
                , "Ryan Schultz"
                , "SEBASTIANO GUZZARDI"
                , "WILLIAM HENDREN"
                , "RAFAEL ESPELETA JR"
                , "Benjamin Molenaar"
                , "Barbara Geronimo"
                , "Donald Crews"
                , "DAWN BONETA"
                , "Traci Bahr"
                , "BARBARA A SHIVERS"
                , "Brian Mack"
                , "VITO POLERA"
                , "INDRY HERNANDEZ MEDINA"
                , "DOMINIQUE CORNWELL"
                , "ANDRA WALTERS"
                , "TREVOR LENZMEIER"
                , "DANIEL MACELROY"
                , "Milton R Blount"
                , "Osmel Fonseca"
                , "Antonio Hernandez"
                , "Maria Espinoza"
                , "Adrian Temali"
                , "John Beall"
                , "FABIO PAEZ"
                , "TERRY DANIEL"
                , "Willard Rodgers"
                , "JIMMY JONES"
                , "WILBUR BUCHANAN"
                , "Eric Johnson"
                , "Raquel Armendariz"
                , "Belinda Borge"
                , "Donna Streavel"
                , "CARMEN OYUELA"
                , "MAURICIO MISCO"
                , "AMY REINKE"
                , "WILLIAM KARDAS"
                , "Cathryn Milby"
                , "Pierre Phanor"
                , "Eric R Russell"
                , "Jennifer L Kasman"
                , "BRIAN BECERRA"
                , "ANDREA DYAL"
                , "LEONNE LOUIS-CHARLES"
                , "COREY LANDRUM"
                , "JOSEPH PATNELLA"
                , "AHILLIA PERMANAN"
                , "Francisco Gimenez"
                , "Juan R De Leon"
                , "Adrian Saez"
                , "MARTIN F GONZALEZ"
                , "Elizet Cardona"
                , "Elaine Hunter"
                , "MANUEL MENDEZ"
                , "VILMA EDWARDS"
                , "IKESHA ROPER"
                , "LAVERN RENEA MINTZ"
                , "RONESHIA L SWAIN"
                , "LUIZ F EBENAU"
                , "JACEK MLYNARSKI"
                , "ZACHARY GRANT"
                , "GREGORY MESSICK"
                , "Krystyna Klemba"
                , "TRENAY M JEFFERSON"
                , "LISA M DRESBACK"
                , "Michal Gora"
                , "Davina Kinney"
                , "GREGORY ROBBINS"
                , "JOSEPH TURNER"
                , "JAMES HARDENDORF"
                , "LUIS RIVERO"
                , "AMANDA AYCOCK"
                , "Nancy McConnell"
                , "Philomene Daniel"
                , "Donald J Martin"
                , "Delores Campbell"
                , "Tresia Baker"
                , "Anna K Harrison"
                , "JAMES MIMS"
                , "JEREMY MURPHREE"
                , "EUDELIA RIVERA"
                , "CALVIN CHRISTIAN"
                , "RUSLAN OLIVERA"
                , "MARITZA CABRERA"
                , "LAWRENCE J GUYNUP"
                , "WARREN HALL"
                , "ANGEL RODRIGUEZ"
                , "Gary R Orns"
                , "John Mort"
                , "Montana Loredo"
                , "Allison Focht"
                , "ROSSANA I GARCIA DE CECA"
                , "TINA C GERSTEIN"
                , "RICHARD GILL"
                , "APRIL GOINS"
                , "STEVEN SCHNEIDER"
                , "GAIL MULLANEY"
                , "Amy Baxter"
                , "Jason Barrett"
                , "Kelly Ferguson"
                , "Shelly M Wise"
                , "Davey Andino"
                , "Altagracia Rohttis Villaman"
                , "JAMES J LANHAM"
                , "MYRA DIAZ"
                , "KEYONTE BAXTER"
                , "Efrain S Mercado"
                , "ROBERT STRADER"
                , "SANDRA REINER"
                , "LESLIE BAVONE"
                , "DERRICK BUXTON"
                , "MICHAEL R BROWN"
                , "Candace Sundby"
                , "John Stark"
                , "Gilberto Arguelles"
                , "David Guzman Jr"
                , "Scott Brush"
                , "Amanda Deeds"
                , "DEBRA POLLETT"
                , "ERIC HOLLAN"
                , "Jose Alva"
                , "JUAN CORTES"
                , "STRACY BROWN"
                , "EDWARD WEEKS"
                , "MARY ZAPATA"
                , "GROVER SHELTON"
                , "Martin Noblit"
                , "Gregory Russell"
                , "Kenneth Dye"
                , "Vicki L Wilson"
                , "TYRONE S GRIFFITHS"
                , "Gladis Lopez"
                , "TERESA SCHERTZER"
                , "TIMOTHY Oconnell"
                , "GARY BRESNICK"
                , "MICHAEL SAWIN"
                , "VICTORIA KOSTER"
                , "YOMARY OLIVA"
                , "VIKI JACKSON"
                , "ANTHONY DOCKERY"
                , "RAMONA SUKHANDAN"
                , "Jorge Reina"
                , "Rigoberto Arteaga"
                , "Rapahel G Valdes"
                , "Jeremy Colson"
                , "Corey Lovett"
                , "SCOTT E STEPHENSON"
                , "ROSITA A BROOKS"
                , "ALEXIS VARGAS"
                , "BRIDGETTE HOPKINS"
                , "Michael Sizemore"
                , "CHANTELE OGLE"
                , "YVETTE S GRANNUM"
                , "VILMA FLORES"
                , "BENNY MENDEZ"
                , "GREGORY MATHERLY"
                , "Padmore D Samuels"
                , "David j Maslanka"
                , "Richard Auskalnis"
                , "Colleen Urlton"
                , "Wilber Frometa"
                , "Beth Reed"
                , "MAUREEN ANDERSON"
                , "WELTON R FRAZER"
                , "Lisa A Alwine"
                , "DORIS E BECK"
                , "PAUL A GLASS"
                , "William Nahorodny"
                , "EDGARDO VELEZ"
                , "DOMENIC KINDBERG"
                , "Andrew J Schechinger"
                , "Karlene Douglas"
                , "Trica L Dickerson"
                , "Gloria P Pucher"
                , "Roger Lee Edwards"
                , "THOMAS A CRAFT"
                , "MELISSA CAVENDER"
                , "COREEN BROWN"
                , "Kaitlin Marshall"
                , "Tina Davis"
                , "NATALIA SANABRIA"
                , "CHRISTINE MARIE MAULE"
                , "JASON ROBISON"
                , "ANDREW EIFERT"
                , "Karin Kirchner"
                , "Robert Bergner"
                , "Viviana Llanes"
                , "Catherine Gage"
                , "William Darby"
                , "STEPHANIE LOCKHART"
                , "COLE DOVER"
                , "DENNIS TAJAH"
                , "RICARDO ESTEVEZ"
                , "JAMES L MONROE"
                , "ALAN MOYER"
                , "CARLOS JIMENEZ"
                , "ERIN SLEEPER"
                , "ESMERALDA LUGO"
                , "KAMERON BROOK"
                , "ANNA W MEDRZYCKI"
                , "ALICIA STERLING-TORRES"
                , "Maikel Batista"
                , "Melius Farncois"
                , "Hector Rivera"
                , "DONALD GANSNER"
                , "AMIRA KORAJKIC"
                , "MANUEL BENTON"
                , "KIM MCDONALD-MICHEL"
                , "TIA EVANS"
                , "ERIC CARPENTER"
                , "JORGE RIVERA"
                , "EDWARD QUINONES"
                , "Terri Moak"
                , "Dustin Clark"
                , "Jose Sifuentes"
                , "Christal Cummings"
                , "Edwin Lugo Santiago"
                , "RICARDO JORDON"
                , "ASHLEY HART"
                , "BRUCE PELHAM"
                , "ARELY RODAS"
                , "CELIA CAMPOS RAMIREZ DE CARRERO"
                , "VICTOR M COTTO"
                , "SHAQUILLA ROSS"
                , "ERVIN LIZANO-LOPEZ"
                , "Rhonda Tucker"
                , "RONALD D GRUBBS"
                , "Marquita Helton"
                , "ZORAIDA MEDINA"
                , "R.B MILLER"
                , "MLADENA STOJANOVIC"
                , "WILLIAM FRALEIGH"
                , "OSHITA TOMOYOSHI"
                , "Diana L LaJeunesse"
                , "Farides Cantillo"
                , "Macorel Exarius"
                , "Margaret Nation Cooper"
                , "Anthony Blanc"
                , "KELA V SIMPSON"
                , "VANCE WEST"
                , "KATHLEEN DRAPER"
                , "FELIX MITCHELL"
                , "ROBERT CHERRY"
                , "Virginia Sarno"
                , "Mindy Skaggs-Sage"
                , "MAURICE L ROMERO"
                , "MATTHEW RUMPLE"
                , "PAMELA TURNER"
                , "Renee Pomante"
                , "John J Strickland"
                , "James Elders"
                , "JAMES E BRYANT"
                , "Nancy, J Bleytghing Crews"
                , "BELEN PAPP"
                , "Fazli Fazlija"
                , "SHEILA SHERMAN"
                , "TESSA ROBERTSON"
                , "RYAN VILLAFRANCO"
                , "TAMYRA LAHSANGAH"
                , "CAROLE KANTOR"
                , "CHRISTINE WELCH"
                , "TAMMY DOUGLAS"
                , "Delayna Blain"
                , "DONALD G TARR"
                , "Michael B Bennett"
                , "CARL BASTIAN"
                , "BRITTANY COTRONEO"
                , "ALFRED EVANS"
                , "Janet Scott"
                , "Jesus Tamez"
                , "Greg Caldwell"
                , "Asha Y Smith"
                , "Mark Ellis"
                , "Tammy M Crouse"
                , "PETER SCHMID"
                , "AMY ABRAHAM"
                , "JONATHAN STEPHENS"
                , "DARLENE HERRICK"
                , "Gregory Cooper"
                , "Jose Cruz"
                , "Vidal Valdiva"
                , "Dan Younger"
                , "Wendy Bartley"
                , "Cande Martinez"
                , "Scott Bovee"
                , "RONNY YOUNG"
                , "JULIO FIGUEROA"
                , "TARA EARNS"
                , "JAMES JOHNSON"
                , "ZAMIR GUNN"
                , "RENE MENENDEZ"
                , "SUMANA ISLAM"
                , "TYLAR WILLIAMS"
                , "JAVIER RIVERA RUIZ"
                , "James E Shifflett"
                , "Kathryn Benson"
                , "Daniel F Ryder"
                , "MARTHA C GONZALEZ"
                , "Elliott Shifman"
                , "EUGENIO AGUILAR"
                , "Maura Cecilia Jurado"
                , "MEGAN PERSONG"
                , "JULIE KELLY"
                , "BERTO MATA"
                , "Delia Fuentes"
                , "Steve Imboden"
                , "Tyla Covington"
                , "Andrew Legg"
                , "Rachel Wood"
                , "DORA AVILA"
                , "CHARLES SIMPSON"
                , "HENRY CRUZ"
                , "JENNIFER DAWSON"
                , "JASON M EMERY"
                , "KEITH SPERNAK"
                , "Pedro Torres"
                , "Armando Valtierra"
                , "Deborah L Atrozskin"
                , "Victor C Mateo"
                , "Patrick Reilley"
                , "JENNIFER GOODRICH"
                , "Carl Nelson"
                , "CLAIRE GAMBALE"
                , "CLINTON DEVAULT"
                , "ALLISON GARBETT"
                , "JASON CUCCHI"
                , "ANGELA PANDOLFO"
                , "MILDRED T HICKS"
                , "Keith Tyler"
                , "Joseph Boone"
                , "Confesor Garcia Rijo"
                , "Amanda Test"
                , "Stacy M Blue"
                , "JAIME BARAJAS"
                , "LILIVETTE PLANTEN"
                , "Brandon Santiago"
                , "Laura D Hefner"
                , "Yara Gomez"
                , "Omar Mercado Aguilar"
                , "Monica Pesantes"
                , "Anabel Delangel"
                , "Milious Saint Louis"
                , "Cindy Stewart"
                , "RAMSES A SILVA"
                , "Tara K Toppino"
                , "Dennis Rodenhofer"
                , "Maria Toledo-Herrera"
                , "Deborah Adams"
                , "Iara Bonatto Caldeira"
                , "Lynn A Munno"
                , "Louisi Joseph"
                , "RYAN FISCH"
                , "DAMON DANESI"
                , "DANIEL ROWE"
                , "Stephen M Staudt"
                , "Gretchen Cook"
                , "Gary Romano"
                , "ROBERT WOODLAND"
                , "JAMES KITTS"
                , "BRADLEY COON"
                , "MARIA URDANETA-GONZALEZ"
                , "Jack Difresco"
                , "JALISA RIVERS"
                , "Lynda Biegaj"
                , "BRITTANY CLEVELAND"
                , "Tiffany Sheely"
                , "Alan Klingensmith"
                , "Jeremiah Huggins"
                , "Donna Jennings"
                , "Denise Corsetti"
                , "Samuel Blasini"
                , "Katia Chuleva"
                , "JUDY ZUK"
                , "RAY CHAPA"
                , "Danny Fiber"
                , "Pedro Rivera"
                , "LINDA STROHM"
                , "Keith Stamp"
                , "Melius Francois"
                , "Maydelin Mesa"
                , "Jessica Johnson"
                , "David S Kelley"
                , "Richard L Long"
                , "KIMBERLY SONNENSCHEIN"
                , "John Millican"
                , "Reynaldo Salinas"
                , "JULIO MARTINEZ"
                , "ELREY C COLES"
                , "MIGUEL CAMACHO"
                , "PAUL BABINEAU"
                , "Harold Castel"
                , "Tamara M Zboril"
                , "David Nelson"
                , "Meaghan E Towne"
                , "Holly Vaughn"
                , "Timothy Maietta"
                , "JUSTINE FOURNIER"
                , "MICHAEL BELL"
                , "KEILA SANTIAGO"
                , "NORA LEWARK"
                , "Claudia Cadena Perez"
                , "Marietta Bibbs"
                , "OSVALDO PADILLA-MARTINEZ"
                , "BEKIRA KURTOVIC"
                , "TIM HARPER"
                , "JUAN GOMEZ"
                , "SAMUEL HILSON"
                , "JOSE CARRILLO"
                , "Hector Munoz"
                , "TEMPEST THOMPSON"
                , "EVERTON C MCLEAN"
                , "CLAUDIA TABORDA"
                , "Bonnie Sandy"
                , "CLARENCE OWEN"
                , "Richard L Werner"
                , "Nancy C Olson"
                , "CHRIS O MONTERO"
                , "Michael Brown"
                , "Elizabeth Stephen"
                , "BRIANNA WHITTINGTON"
                , "BONNIE S GIULIANI"
                , "BLADIMIRO BARRIOS"
                , "Ruben Lopez"
                , "Daniel Duarte"
                , "Christopher J Wood"
                , "Patricia Spatcher"
                , "Milissa M Morley"
                , "Cathy F Bulgar"
                , "Miguel Q Paz"
                , "XIOMARA LORIE"
                , "CORA MCGALLIARD"
                , "EUNICE VIDALES"
                , "HANS LAFONTANT"
                , "Mirella Ramos"
                , "Candyce Bearley"
                , "WILLIAM E JOHNSTON"
                , "Ericka Brown"
                , "Ashley Kozlowski"
                , "ANTONIA AUSED"
                , "KRISTIN STAPLETON"
                , "HERVE GRESSY"
                , "CRAIG MOORE"
                , "Linda Davis"
                , "JAMES MARSHBURN"
                , "Brooks Cantlay"
                , "ANDRES VALLEJO"
                , "Ana Carrasco"
                , "Arthur Mott Jr"
                , "John Ruffner"
                , "JOSE FAMANIA"
                , "Thermidor Minock"
                , "Sharmon Phelps"
                , "CLARENCE ODUMS"
                , "MICHAEL BRADSHAW"
                , "JOHN ROTH"
                , "Kelle Dixon"
                , "Fernando Aleman"
                , "Patrick Stevick"
                , "Donald Pierpoint"
                , "ROSANNY LAZO VARGAS"
                , "ALEJANDRO FERNANDEZ"
                , "Ricky A Yarnell"
                , "Zulma Golden"
                , "Reina Aguilera"
                , "Ed Dibeler"
                , "Gerardino Figueroa"
                , "JESUS D GUEVARA"
                , "LOUIS WELLS"
                , "VICTOR ORTIZ JR"
                , "FRANCISCO GUERRA"
                , "Paul D Bober"
                , "Michelle L Hewson"
                , "Monica Henderson"
                , "David Throesch"
                , "Elizabeth Owen"
                , "MARCELLINE M MESIDOR"
                , "GABRIEL OYOQUE"
                , "MUGE CENGIL"
                , "SUSAN MENNING"
                , "Jack Heckman"
                , "Marlene Leggett"
                , "YELVA LOUISSAINT"
                , "ERINE ERIUS"
                , "SHRI SATAWAN SHIWPRASAD"
                , "JESUS SANTANA"
                , "Robert W Rickert"
                , "Sharon McGorry"
                , "Diane Martini"
                , "Julie Harmon"
                , "SACARIUS A RAGIN"
                , "AMY SALOMONE"
                , "Arturo Ruiz"
                , "TRAVIS CHAPPEL"
                , "REGINA CRANGI"
                , "Rashawn L Jones"
                , "Doug Smith"
                , "Jeffrey Sullivan"
                , "Timothy Mitchell"
                , "Raymond Soucy"
                , "Mary M Newton"
                , "Olivia Coleman"
                , "MARIO AGUIRRE"
                , "BILLY THOMAS"
                , "CATINA STINE-SAMPSON"
                , "Louis Negron"
                , "ALAIN ALVAREZ"
                , "Elaine Bishop"
                , "Barbara Reyes"
                , "Robert Lipford"
                , "Jack Hart"
                , "Kristie Lavigne"
                , "Jeffrey Shreiner"
                , "WILLIAM SPANN"
                , "JAMES PROUDFOOT"
                , "IAN KEMP"
                , "CHRISTOPHER HOUSTON"
                , "JOSE PACHECO"
                , "BRENDA PURSEL"
                , "GEORGE SEPCIC"
                , "DAVID BERNSTEIN"
                , "Abel Perez"
                , "William C Hubbs"
                , "Matthew Sherman"
                , "ROBERT S MCLARTY"
                , "VANESSA URREA BUSTOS"
                , "ALISHA D HARVEY"
                , "Delores Goethe"
                , "Sonia Lopez"
                , "Jeanne Arnette"
                , "Jonathan Gentle"
                , "Gary Schoonmaker"
                , "EDGAR ORTEGA"
                , "ELIZABETH BROWN"
                , "TRAMAIN TARVER"
                , "DOMINIC S PYZYNSKI"
                , "MARK A FAELLA"
                , "LAURISTON SAMUEL"
                , "RICHARD HURLEY"
                , "JENNIFER DERI"
                , "MIGUEL PASTRANA"
                , "Bernard Keenan"
                , "Linda Earley"
                , "Kathleen L Cardyn"
                , "Adela Lopez"
                , "Jacqueline Anderson"
                , "Olga Irianty Mcgreevy"
                , "WILLARD J MCCULLEN"
                , "AMY SOTO"
                , "Rafael G Valdes"
                , "DAMARIS VARGAS"
                , "YANETH A FLORES"
                , "ROBERT NICKERAUER"
                , "CHRISTOPHER REDDING"
                , "JOHN HOLT"
                , "John Cannady"
                , "TATIANA MACRINSCAIA"
                , "Eric Miller"
                , "Angela Houdesheldt"
                , "Judith Oleary"
                , "David Yusupov"
                , "KYLE DAVIS"
                , "ANN WAIN"
                , "RUNGAROON SINGHPRASERT"
                , "ZOEY FOOS"
                , "Ivelyne Estimond"
                , "DAYNA CARTER"
                , "RAINA SCOTT"
                , "LEONARD TERRY"
                , "BRIAN FLOYD"
                , "MARYANN TRANSKI"
                , "Israel Sierra"
                , "Joseph Fordham"
                , "Leyda Martinez"
                , "Mariela V Aguila"
                , "LUCILIA DEFREITAS"
                , "JACQUELYN VIBBERT"
                , "STEVEN COOK"
                , "Patricia Petrov"
                , "Richard Brown"
                , "Kaytrine Atkins"
                , "Candace C Cooney"
                , "Steve Berenguer"
                , "Gerald Lalanne"
                , "ALKA K KHANNA"
                , "SUSAN MARINELLI"
                , "Thomas A Machie"
                , "ERIKA HERNADEZ"
                , "STEVEN D REIFEIS"
                , "Daniel W Steward"
                , "MICHAEL DAVIS"
                , "HOWARD NORTHROP"
                , "Dontee M Hedger"
                , "Eda Jones"
                , "Jason Skjordal"
                , "ROELOF VAN NIEKERK"
                , "Robert T Dunn"
                , "Patrick Chervoni"
                , "John R Anderson"
                , "ANTONIO GARCIA"
                , "JEREMY HERNANDEZ"
                , "Mary J Johnson"
                , "Ann Dougherty"
                , "JUAN C PEREZ"
                , "WHITNEY WALDEN"
                , "JHOAN TZINA"
                , "LILIOSA MABAQUIAO"
                , "Terri Chase"
                , "Charlene M Broa"
                , "Christine Seymour"
                , "Maribel Ramos"
                , "JOSE L SANCHEZ"
                , "RICHARD A BARRETT"
                , "JACQUELYN COOPER"
                , "JOSE VALAZQUEZ"
                , "ISRAEL GARCIA-REGALADO"
                , "Elaine P Ponzio"
                , "Shannon Slaughter"
                , "Jose Francisco Flores"
                , "Matt Sherman"
                , "JOSE E SIBRIAN"
                , "Tamara Webster"
                , "MIRTA MERRTTE"
                , "BRENDA A LEE"
                , "ZACARIAS PENA"
                , "DANIEL MESA"
                , "STEVEN BOLES"
                , "TALMADGE WALL"
                , "TROY PIPER"
                , "Rosaria Trevino"
                , "Casey Baughman"
                , "German Lopez"
                , "Catherine Murphy"
                , "Patricia Alvarez"
                , "Pamela A Strong"
                , "Rani J Chiudina"
                , "Lee W Llewellyn"
                , "REBECCA FOSTER"
                , "KAREN DECKER"
                , "TERESA A NORRIS"
                , "Manuel Lara Orbeal"
                , "Reynaldo Navarro"
                , "Leon Bullock"
                , "Cesar Contreras"
                , "Briania Jenkins"
                , "Linda, C Murray"
                , "CHRIS CAZAZOS"
                , "NATHALIE LAJEUNESSE"
                , "JOSEFINA TORRES"
                , "Robert Lemere"
                , "LINDA DESMARAIS"
                , "Julio Gilart"
                , "STEVEN LEE"
                , "HASANI JACKSON"
                , "Tamberla M Ruhlman"
                , "JEANNE BATCHELDER"
                , "RAMIZA PILAV"
                , "DAVID M MAXWELL"
                , "TONI PAGAN"
                , "Kody Cox"
                , "Armando Rodriguez"
                , "Carlos E Herrera-Hernandez"
                , "Larry F Tiner"
                , "Bythine Laster"
                , "Juan C Alvarez"
                , "Carlos Borrego"
                , "MICHELLE WALKER"
                , "AARON MYSLINSKI"
                , "DERRICK LEWIS"
                , "Clifton Green"
                , "BLANCA MAS"
                , "OSVALDO GONZALEZ"
                , "Phillip E Sawyer"
                , "Chad Turnbeaugh"
                , "VANESSA BYAS"
                , "Grant R McCullough"
                , "Tiffany Brinlow"
                , "Rigoberto Pena"
                , "Mayra Valentin"
                , "CURTIS ABBOTT"
                , "NANCY CARMONA"
                , "NOREEN P MAHEU"
                , "BEATRICE ZURITA HERNANDEZ"
                , "VICTOR COBAS PEREZ"
                , "CHRISTIAN ROMAN"
                , "BRANDY PISCIUNERI"
                , "Jesus Cruz-Flores"
                , "Rosita Turrubiartez"
                , "Sherri Hubbard"
                , "RODRIGO CARMONA"
                , "LUIS STELLA-RODRIGUEZ"
                , "ALICIA ARGUETA"
                , "Leticia Aquino"
                , "JOSE CENTENO"
                , "PATRICIA HYLTON"
                , "MAXIME DEZUME"
                , "JOSEPH ULMAN"
                , "JOSEPH GUCCIARCO"
            };

            foreach (var item in list)
            {
                Console.WriteLine($"Full name = {item}");
                //NameParserSharp
                var person = new HumanName(item); //("president john 'jack' f kennedy");
                Console.WriteLine($"First {person.First}, Middle {person.Middle} , Last { person.Last}");


                //FOG NameParser
                //string fullName = item; // "Mr. Jack Johnson";
                //FullNameParser target = FullNameParser.Parse(fullName);
                //Console.WriteLine($"First {target.FirstName}, Middle {target.MiddleName} , Last { target.LastName}");

                Console.WriteLine("=================================================");
            }
            Console.WriteLine("Hello World!");
            Console.ReadLine();
        }
Example #23
0
        public static Patient CreateTestFHIRPatientProfile
        (
            string organizationName, string sessionID, string internalNoID, string language, string birthDate,
            string genderCode, string multipleBirth, string firstName, string middleName, string lastName,
            string address1, string address2, string city, string state, string postalCode,
            string homePhone, string cellPhone, string workPhone, string emailAddress
        )
        {
            Patient    pt = new Patient();
            Identifier idSession;
            Identifier idPatientCertificate;

            idSession        = new Identifier();
            idSession.System = "http://www.mynoid.com/fhir/SessionID";
            idSession.Value  = sessionID;
            pt.Identifier.Add(idSession);

            idPatientCertificate        = new Identifier();
            idPatientCertificate.System = "http://www.mynoid.com/fhir/PatientCertificateID";
            idPatientCertificate.Value  = internalNoID;
            pt.Identifier.Add(idPatientCertificate);

            ResourceReference managingOrganization = new ResourceReference(NoID_OID, organizationName);

            pt.ManagingOrganization = managingOrganization;

            pt.Language  = language;
            pt.BirthDate = birthDate;
            if (genderCode.Substring(0, 1).ToLower() == "f")
            {
                pt.Gender = AdministrativeGender.Female;
            }
            else if (genderCode.Substring(0, 1).ToLower() == "m")
            {
                pt.Gender = AdministrativeGender.Male;
            }
            else
            {
                pt.Gender = AdministrativeGender.Other;
            }

            // just use Yes or No
            if (multipleBirth.ToLower() == "no")
            {
                pt.MultipleBirth = new FhirString(multipleBirth);
            }
            else
            {
                pt.MultipleBirth = new FhirString("Yes");
            }

            // Add patient name
            HumanName ptName = new HumanName();

            ptName.Given  = new string[] { firstName, middleName };
            ptName.Family = lastName;
            pt.Name       = new List <HumanName> {
                ptName
            };
            // Add patient address
            Address address = new Address();

            address.Line       = new string[] { address1, address2 };
            address.City       = city;
            address.State      = state;
            address.Country    = "USA";
            address.PostalCode = postalCode;
            pt.Address.Add(address);

            Patient.ContactComponent contact = new Patient.ContactComponent();
            bool addContact = false;

            if ((emailAddress != null) && emailAddress.Length > 0)
            {
                ContactPoint newContact = new ContactPoint(ContactPoint.ContactPointSystem.Email, ContactPoint.ContactPointUse.Home, emailAddress);
                contact.Telecom.Add(newContact);
                addContact = true;
            }
            if ((homePhone != null) && homePhone.Length > 0)
            {
                ContactPoint newContact = new ContactPoint(ContactPoint.ContactPointSystem.Phone, ContactPoint.ContactPointUse.Home, homePhone);
                contact.Telecom.Add(newContact);
                addContact = true;
            }
            if ((cellPhone != null) && cellPhone.Length > 0)
            {
                ContactPoint newContact = new ContactPoint(ContactPoint.ContactPointSystem.Phone, ContactPoint.ContactPointUse.Mobile, cellPhone);
                contact.Telecom.Add(newContact);
                addContact = true;
            }
            if ((workPhone != null) && workPhone.Length > 0)
            {
                ContactPoint newContact = new ContactPoint(ContactPoint.ContactPointSystem.Phone, ContactPoint.ContactPointUse.Work, workPhone);
                contact.Telecom.Add(newContact);
                addContact = true;
            }
            if (addContact)
            {
                pt.Contact.Add(contact);
            }
            return(pt);
        }
        public void Test_DeleteHistoryIndexes()
        {
            FhirClient clientFhir = new FhirClient(StaticTestData.FhirEndpoint(), false);

            clientFhir.Timeout = 1000 * 720; // give the call a while to execute (particularly while debugging).

            string PatientOneResourceId   = Guid.NewGuid().ToString();
            string PatientOneMRNIdentifer = Guid.NewGuid().ToString();

            //Add a Patient resource by Create
            Patient PatientOne = new Patient();

            PatientOne.Id = PatientOneResourceId;
            PatientOne.Name.Add(HumanName.ForFamily("TestPatient").WithGiven("Test"));
            PatientOne.BirthDateElement = new Date("1979-09-30");
            PatientOne.Identifier.Add(new Identifier(StaticTestData.TestIdentiferSystem, PatientOneMRNIdentifer));
            PatientOne.Gender = AdministrativeGender.Unknown;

            Patient PatientResult = null;

            try
            {
                PatientResult = clientFhir.Update <Patient>(PatientOne);
            }
            catch (Exception Exec)
            {
                Assert.True(false, "Exception thrown on Patient resource Update: " + Exec.Message);
            }
            Assert.NotNull(PatientResult, "Resource create by Updated returned resource of null");

            PatientResult = null;

            //Update the patient again to ensure there are History indexes to delete
            try
            {
                PatientResult = clientFhir.Update <Patient>(PatientOne);
            }
            catch (Exception Exec)
            {
                Assert.True(false, "Exception thrown on Patient resource Update: " + Exec.Message);
            }
            Assert.NotNull(PatientResult, "Resource create by Updated returned resource of null");

            //------------------------------------------------------------------------------------
            // ------------ Base Operation, limited types by parameters --------------------------
            //------------------------------------------------------------------------------------

            //Now setup to use the base operation $delete-history-indexes
            //Parameter Resource
            Parameters ParametersIn = new Parameters();

            //ParametersIn.Id = Guid.NewGuid().ToString();
            ParametersIn.Parameter = new List <Parameters.ParameterComponent>();
            var ParamOne = new Parameters.ParameterComponent();

            ParametersIn.Parameter.Add(ParamOne);
            ParamOne.Name  = "ResourceType";
            ParamOne.Value = new FhirString(FHIRAllTypes.Patient.GetLiteral());

            Parameters ParametersResult = null;

            try
            {
                var ResourceResult = clientFhir.WholeSystemOperation(OperationName, ParametersIn);
                ParametersResult = ResourceResult as Parameters;
            }
            catch (Exception Exec)
            {
                Assert.True(false, $"Exception thrown on Operation call to ${OperationName}: " + Exec.Message);
            }
            Assert.NotNull(ParametersResult, "Resource create by Updated returned resource of null");
            Assert.NotNull(ParametersResult.Parameter, "ParametersResult.Parameter is null");
            Assert.AreEqual(ParametersResult.Parameter.Count(), 1, "ParametersResult.Parameter contains more than one parameter.");
            Assert.AreEqual(ParametersResult.Parameter[0].Name, $"{FHIRAllTypes.Patient.GetLiteral()}_TotalIndexesDeletedCount", "ParametersResult.Parameter.Name not as expected.");
            Assert.IsInstanceOf <FhirDecimal>(ParametersResult.Parameter[0].Value, "ParametersResult.Parameter.Value expected FhirDecimal.");
            Assert.Greater((ParametersResult.Parameter[0].Value as FhirDecimal).Value, 0, "ParametersResult.Parameter.Value expected to be greater than 0.");
            ParametersResult = null;


            //------------------------------------------------------------------------------------
            // ------------ Resource Base Operation ALL resource ResourceType = *----------------------------------------------
            //------------------------------------------------------------------------------------

            //Now setup to use the base operation $delete-history-indexes
            //Parameter Resource
            ParametersIn           = new Parameters();
            ParametersIn.Id        = Guid.NewGuid().ToString();
            ParametersIn.Parameter = new List <Parameters.ParameterComponent>();
            ParamOne = new Parameters.ParameterComponent();
            ParametersIn.Parameter.Add(ParamOne);
            ParamOne.Name  = "ResourceType";
            ParamOne.Value = new FhirString("*");

            ParametersResult = null;
            try
            {
                var ResourceResult = clientFhir.WholeSystemOperation(OperationName, ParametersIn);
                ParametersResult = ResourceResult as Parameters;
            }
            catch (Exception Exec)
            {
                Assert.True(false, $"Exception thrown on Operation call to ${OperationName}: " + Exec.Message);
            }
            Assert.NotNull(ParametersResult, "Resource create by Updated returned resource of null");
            Assert.NotNull(ParametersResult.Parameter, "ParametersResult.Parameter is null");
            Assert.AreEqual(ParametersResult.Parameter.Count(), ModelInfo.SupportedResources.Count, "ParametersResult.Parameter.Count Not equal to Supported resource total.");
            ParametersResult = null;

            //------------------------------------------------------------------------------------
            // ------------ Resource Type Operation ----------------------------------------------
            //------------------------------------------------------------------------------------

            //Update the patient again to ensure there are History indexes to delete
            PatientResult = null;
            try
            {
                PatientResult = clientFhir.Update <Patient>(PatientOne);
            }
            catch (Exception Exec)
            {
                Assert.True(false, "Exception thrown on Patient resource Update: " + Exec.Message);
            }
            Assert.NotNull(PatientResult, "Resource create by Updated returned resource of null");

            ParametersIn    = new Parameters();
            ParametersIn.Id = Guid.NewGuid().ToString();

            ParametersResult = null;
            try
            {
                var ResourceResult = clientFhir.TypeOperation <Patient>(OperationName, ParametersIn);
                ParametersResult = ResourceResult as Parameters;
            }
            catch (Exception Exec)
            {
                Assert.True(false, $"Exception thrown on Operation call to ${OperationName}: " + Exec.Message);
            }
            Assert.NotNull(ParametersResult, "Resource create by Updated returned resource of null");
            Assert.NotNull(ParametersResult.Parameter, "ParametersResult.Parameter is null");
            Assert.AreEqual(ParametersResult.Parameter.Count(), 1, "ParametersResult.Parameter contains more than one parameter.");
            Assert.AreEqual(ParametersResult.Parameter[0].Name, $"{FHIRAllTypes.Patient.GetLiteral()}_TotalIndexesDeletedCount", "ParametersResult.Parameter.Name not as expected.");
            Assert.IsInstanceOf <FhirDecimal>(ParametersResult.Parameter[0].Value, "ParametersResult.Parameter.Value expected FhirDecimal.");
            Assert.Greater((ParametersResult.Parameter[0].Value as FhirDecimal).Value, 0, "ParametersResult.Parameter.Value expected to be greater than 0.");

            //--- Clean Up ---------------------------------------------------------
            //Clean up by deleting all Test Patients
            SearchParams sp = new SearchParams().Where($"identifier={StaticTestData.TestIdentiferSystem}|");

            try
            {
                clientFhir.Delete("Patient", sp);
            }
            catch (Exception Exec)
            {
                Assert.True(false, "Exception thrown on conditional delete of resource Patient: " + Exec.Message);
            }
        }
Example #25
0
        public static Patient CreateTestFHIRPatientProfile()
        {
            Patient    pt = new Patient();
            Identifier idSession;
            Identifier idPatientCertificate;

            idSession        = new Identifier();
            idSession.System = "http://www.mynoid.com/fhir/SessionID";
            idSession.Value  = "S12348";
            pt.Identifier.Add(idSession);

            idPatientCertificate        = new Identifier();
            idPatientCertificate.System = "http://www.mynoid.com/fhir/PatientCertificateID";
            idPatientCertificate.Value  = "PT67891";
            pt.Identifier.Add(idPatientCertificate);

            ResourceReference managingOrganization = new ResourceReference(NoID_OID, "Test NoID");

            pt.ManagingOrganization = managingOrganization;

            pt.Language      = "English";
            pt.BirthDate     = "2006-07-03";
            pt.Gender        = AdministrativeGender.Female;
            pt.MultipleBirth = new FhirString("No");
            // Add patient name
            HumanName ptName = new HumanName();

            ptName.Given  = new string[] { "Mary", "J" };
            ptName.Family = "Bling";
            pt.Name       = new List <HumanName> {
                ptName
            };
            // Add patient address
            Address address = new Address();

            address.Line       = new string[] { "300 Exit St", "Unit 5" };
            address.City       = "New Orleans";
            address.State      = "LA";
            address.Country    = "USA";
            address.PostalCode = "70112-1202";
            pt.Address.Add(address);
            Attachment attach = new Attachment();
            Media      media  = new Media();

            media.AddExtension("Healthcare Node", FHIRUtilities.OrganizationExtension("Test NoID FHIR Message", "noidtest.net", "devtest.noidtest.net"));
            media.AddExtension("Biometic Capture", FHIRUtilities.CaptureSiteExtension(
                                   CaptureSiteSnoMedCode.IndexFinger, LateralitySnoMedCode.Left, "Test Scanner Device", 500, 350, 290));
            Extension extFingerPrintMedia = FHIRUtilities.FingerPrintMediaExtension(
                "123",
                "211",
                "43",
                "0"
                );

            media.Extension.Add(extFingerPrintMedia);

            extFingerPrintMedia = FHIRUtilities.FingerPrintMediaExtension(
                "180",
                "91",
                "211",
                "1"
                );

            media.Extension.Add(extFingerPrintMedia);

            extFingerPrintMedia = FHIRUtilities.FingerPrintMediaExtension(
                "201",
                "154",
                "44",
                "1"
                );

            media.Extension.Add(extFingerPrintMedia);

            extFingerPrintMedia = FHIRUtilities.FingerPrintMediaExtension(
                "21",
                "279",
                "310",
                "0"
                );

            media.Extension.Add(extFingerPrintMedia);


            attach.Data = FhirSerializer.SerializeToJsonBytes(media, summary: Hl7.Fhir.Rest.SummaryType.False);

            pt.Photo.Add(attach);

            return(pt);
        }
Example #26
0
 public TestHumanName(HumanName b)
 {
     humanName = b;
 }
Example #27
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);
        }
Example #28
0
        //public static string dirstr = @"C:\Users\woong\Desktop\KakaoTalkChats[1].txt";
        //팩린이뉴들박 33 님과 카카오톡 대화.txtKakaoTalkChats[1].txt

        static void Main(string[] args)
        {
            var c = new DynamicGraphFactory(dirstr);

            Thread.Sleep(1000);
            while (true)
            {
                Console.WriteLine(c.Lv0Progression + ", " + c.Lv1Progression + ", " + c.Lv2Progression);
                if (c.GraphFinished)
                {
                    break;
                }
                Thread.Sleep(100);
            }


            DateTime maxDay = c.GetUnitTimeCommsSnapShot().Max(k => k.Key);


            var data    = c.GetUnitTimeCommsSnapShot();
            int maxNode = data.Last().Value.MatrixSize;

            int edgeid = 0;//edgeid++;
            //c.GetUnitTimeCommsSnapShot()[]
            var nodes = new StringBuilder().Append("Id,").Append("Label,").Append("Timestamp,").Append("Score\n");
            var edges = new StringBuilder().Append("Source,").Append("Target,").Append("Type,").Append("id,").Append("Timestamp,").Append("weightdynamic\n");

            for (int nodeid = 0; nodeid < maxNode; nodeid++)
            {
                {
                    nodes.Append(nodeid).Append(',').Append(HumanName.GetNameByCode(nodeid)).Append(',').Append("\"<[");
                    bool isremove = false;
                    foreach (var timeset in data)
                    {
                        isremove = true;
                        if (timeset.Value.MatrixSize > nodeid)
                        {
                            nodes.Append(timeset.Key.ToString("yyyy-MM-ddTHH\\:mm\\:ss.fffffffzzz")).Append(",");
                        }
                    }
                    if (isremove)
                    {
                        nodes.Remove(nodes.Length - 1, 1);
                    }
                    nodes.Append("]>\",");
                    nodes.Append("\"<");
                    foreach (var timeset in data)
                    {
                        if (timeset.Value.MatrixSize > nodeid)
                        {
                            nodes.Append("[");
                            nodes.Append(timeset.Key.ToString("yyyy-MM-ddTHH\\:mm\\:ss.fffffffzzz")).Append(",");
                            nodes.Append(timeset.Value.GetScore(nodeid));
                            nodes.Append("];");
                        }
                    }
                    nodes.Append(">\"");
                    nodes.Append("\n");
                }
                {
                    for (int targetnode = 0; targetnode < nodeid; targetnode++)
                    {
                        edges.Append(nodeid).Append(',').Append(targetnode).Append(',').Append("Undirected").Append(',').Append(edgeid++).Append(" ,").Append("\"<[");
                        bool isremove = false;
                        foreach (var timeset in data)
                        {
                            isremove = true;
                            if (timeset.Value.MatrixSize > nodeid)
                            {
                                edges.Append(timeset.Key.ToString("yyyy-MM-ddTHH\\:mm\\:ss.fffffffzzz")).Append(",");
                            }
                        }
                        if (isremove)
                        {
                            edges.Length--;
                        }
                        edges.Append("]>\",");



                        edges.Append("\"<");
                        foreach (var timeset in data)
                        {
                            if (timeset.Value.GetConnectionBetween(targetnode, nodeid) > 0)
                            {
                                edges.Append("[");
                                edges.Append(timeset.Key.ToString("yyyy-MM-ddTHH\\:mm\\:ss.fffffffzzz")).Append(",");
                                edges.Append(timeset.Value.GetConnectionBetween(targetnode, nodeid));
                                edges.Append("];");
                            }
                        }
                        edges.Append(">\"");
                        edges.Append("\n");
                    }
                }
            }


            File.WriteAllText(@"D:\Data\edges.csv", edges.ToString());
            File.WriteAllText(@"D:\Data\nodes.csv", nodes.ToString());
        }
Example #29
0
        public void Setup()
        {
            Server = StaticTestData.StartupServer();

            clientFhir         = new Hl7.Fhir.Rest.FhirClient(StaticTestData.FhirEndpoint(), false);
            clientFhir.Timeout = 1000 * 720; // give the call a while to execute (particularly while debugging).

            //This Set up creates an Observation linked to a Patient as the 'subject' and an Organization as the 'performer'
            // Observation1
            //           --> Patient
            //           --> Organization - > Endpoint
            //           --> Observation2
            //                           ----> Observation3

            //Add a Endpoint resource
            //Loop only here for load testing
            for (int i = 0; i < 1; i++)
            {
                Endpoint EndpointOnex = new Endpoint();
                EndpointOnex.Name    = EndpointOneName;
                EndpointOneIdentifer = Guid.NewGuid().ToString();
                EndpointOnex.Identifier.Add(new Identifier(StaticTestData.TestIdentiferSystem, EndpointOneIdentifer));
                Endpoint EndPointOneResult = null;
                try
                {
                    EndPointOneResult = clientFhir.Create(EndpointOnex);
                }
                catch (Exception Exec)
                {
                    Assert.True(false, "Exception thrown on resource Create: " + Exec.Message);
                }
                Assert.NotNull(EndPointOneResult, "Resource created but returned resource is null");
                EndpointOneResourceId = EndPointOneResult.Id;
            }

            //Add a Endpoint resource
            Endpoint EndpointTwo = new Endpoint();

            EndpointTwo.Name = EndpointOneName;
            string EndpointTwoIdentifer = Guid.NewGuid().ToString();

            EndpointTwo.Identifier.Add(new Identifier(StaticTestData.TestIdentiferSystem, EndpointTwoIdentifer));
            Endpoint EndPointTwoResult = null;

            try
            {
                EndPointTwoResult = clientFhir.Create(EndpointTwo);
            }
            catch (Exception Exec)
            {
                Assert.True(false, "Exception thrown on resource Create: " + Exec.Message);
            }
            Assert.NotNull(EndPointTwoResult, "Resource created but returned resource is null");
            string EndpointTwoResourceId = EndPointTwoResult.Id;



            //Add a Organization resource by Update
            Organization OrganizationOne = new Organization();

            OrganizationOne.Name     = OrganizationOneName;
            OrganizationOneIdentifer = Guid.NewGuid().ToString();
            OrganizationOne.Identifier.Add(new Identifier(StaticTestData.TestIdentiferSystem, OrganizationOneIdentifer));
            OrganizationOne.Endpoint = new List <ResourceReference>()
            {
                new ResourceReference($"{ResourceType.Endpoint.GetLiteral()}/{EndpointOneResourceId}")
            };
            Organization OrganizationOneResult = null;

            try
            {
                OrganizationOneResult = clientFhir.Create(OrganizationOne);
            }
            catch (Exception Exec)
            {
                Assert.True(false, "Exception thrown on resource Create: " + Exec.Message);
            }
            Assert.NotNull(OrganizationOneResult, "Resource created but returned resource is null");
            OrganizationOneResourceId = OrganizationOneResult.Id;

            //Patient where Obs.performer -> Org.name
            // Add a Patient to Link to a Observation below  ================================
            //Loop only here for load testing debugging
            for (int i = 0; i < 10; i++)
            {
                Patient PatientOne = new Patient();
                PatientOne.Name.Add(HumanName.ForFamily(PatientOneFamily).WithGiven("Test"));
                PatientOne.BirthDateElement = new Date("1979-09-30");
                PatientOneMRNIdentifer      = Guid.NewGuid().ToString();
                PatientOne.Identifier.Add(new Identifier(StaticTestData.TestIdentiferSystem, PatientOneMRNIdentifer));
                PatientOne.Gender = AdministrativeGender.Unknown;
                PatientOne.ManagingOrganization = new ResourceReference($"{ResourceType.Organization.GetLiteral()}/{OrganizationOneResourceId}");
                Patient PatientResult = null;
                try
                {
                    PatientResult = clientFhir.Create(PatientOne);
                }
                catch (Exception Exec)
                {
                    Assert.True(false, "Exception thrown on resource Create: " + Exec.Message);
                }
                Assert.NotNull(PatientResult, "Resource created but returned resource is null");
                PatientResourceId = PatientResult.Id;
            }

            //Here we set up 3 observations linked in a chain Obs1 -> Obs2 - > Obs3 to test recursive includes

            // Add Observation 3 Linked to no other observation
            // This is to test recursive includes
            Observation ObsResourceThree = new Observation();

            ObsResourceThree.Status   = ObservationStatus.Final;
            ObsResourceThree.Code     = new CodeableConcept("http://somesystem.net/ObSystem", "WCC");
            ObservationThreeIdentifer = Guid.NewGuid().ToString();
            ObsResourceThree.Identifier.Add(new Identifier(StaticTestData.TestIdentiferSystem, ObservationTwoIdentifer));
            ObsResourceThree.Subject   = new ResourceReference($"{ResourceType.Patient.GetLiteral()}/{PatientResourceId}");
            ObsResourceThree.Performer = new List <ResourceReference>()
            {
                new ResourceReference($"{ResourceType.Organization.GetLiteral()}/{OrganizationOneResourceId}")
            };
            Observation ObservationThreeResult = null;

            try
            {
                ObservationThreeResult = clientFhir.Create(ObsResourceThree);
            }
            catch (Exception Exec)
            {
                Assert.True(false, "Exception thrown on Observation resource two create: " + Exec.Message);
            }
            Assert.NotNull(ObservationThreeResult, "Resource created but returned resource is null");
            ObservationThreeResourceId = ObservationThreeResult.Id;
            ObservationThreeResult     = null;


            // Add Observation 2 Linked to the Observation3 above and Patient above
            // This is to test recursive includes
            Observation ObsResourceTwo = new Observation();

            ObsResourceTwo.Status   = ObservationStatus.Final;
            ObsResourceTwo.Code     = new CodeableConcept("http://somesystem.net/ObSystem", "WCC");
            ObservationTwoIdentifer = Guid.NewGuid().ToString();
            ObsResourceTwo.Identifier.Add(new Identifier(StaticTestData.TestIdentiferSystem, ObservationTwoIdentifer));
            ObsResourceTwo.Subject   = new ResourceReference($"{ResourceType.Patient.GetLiteral()}/{PatientResourceId}");
            ObsResourceTwo.Performer = new List <ResourceReference>()
            {
                new ResourceReference($"{ResourceType.Organization.GetLiteral()}/{OrganizationOneResourceId}")
            };
            ObsResourceTwo.Related = new List <Observation.RelatedComponent>();
            var RelatedArtifact2 = new Observation.RelatedComponent();

            RelatedArtifact2.Target = new ResourceReference($"{ResourceType.Observation.GetLiteral()}/{ObservationThreeResourceId}");
            ObsResourceTwo.Related.Add(RelatedArtifact2);
            Observation ObservationTwoResult = null;

            try
            {
                ObservationTwoResult = clientFhir.Create(ObsResourceTwo);
            }
            catch (Exception Exec)
            {
                Assert.True(false, "Exception thrown on Observation resource two create: " + Exec.Message);
            }
            Assert.NotNull(ObservationTwoResult, "Resource created but returned resource is null");
            ObservationTwoResourceId = ObservationTwoResult.Id;
            ObservationTwoResult     = null;

            // Add Observation1 linked to Observation 2 above and the Patient above ================================
            Observation ObsResourceOne = new Observation();

            ObsResourceOne.Status   = ObservationStatus.Final;
            ObsResourceOne.Code     = new CodeableConcept("http://somesystem.net/ObSystem", "HB");
            ObservationOneIdentifer = Guid.NewGuid().ToString();
            ObsResourceOne.Identifier.Add(new Identifier(StaticTestData.TestIdentiferSystem, ObservationOneIdentifer));
            ObsResourceOne.Subject   = new ResourceReference($"{ResourceType.Patient.GetLiteral()}/{PatientResourceId}");
            ObsResourceOne.Performer = new List <ResourceReference>()
            {
                new ResourceReference($"{ResourceType.Organization.GetLiteral()}/{OrganizationOneResourceId}")
            };
            ObsResourceOne.Related = new List <Observation.RelatedComponent>();
            var RelatedArtifact1 = new Observation.RelatedComponent();

            RelatedArtifact1.Target = new ResourceReference($"{ResourceType.Observation.GetLiteral()}/{ObservationTwoResourceId}");
            ObsResourceOne.Related.Add(RelatedArtifact1);
            Observation ObservationOneResult = null;

            try
            {
                ObservationOneResult = clientFhir.Create(ObsResourceOne);
            }
            catch (Exception Exec)
            {
                Assert.True(false, "Exception thrown on resource Create: " + Exec.Message);
            }
            Assert.NotNull(ObservationOneResult, "Resource created but returned resource is null");
            ObservationOneResourceId = ObservationOneResult.Id;
            ObservationOneResult     = null;
        }
    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));
    }
 public void NullInput()
 {
     var parsed = new HumanName(null);
 }
Example #32
0
        public void Test_BundleTransaction()
        {
            Hl7.Fhir.Rest.FhirClient clientFhir = new Hl7.Fhir.Rest.FhirClient(StaticTestData.FhirEndpoint(), false);
            clientFhir.Timeout = 1000 * 1000; // give the call a while to execute (particularly while debugging).

            //------------------------------------------------------------------------------------------------------
            //Transaction Bundle 1 (Create) ---------------------------------------------------------------------------------
            //------------------------------------------------------------------------------------------------------

            Bundle TransBundle = new Bundle();

            TransBundle.Id    = Guid.NewGuid().ToString();
            TransBundle.Type  = Bundle.BundleType.Transaction;
            TransBundle.Entry = new List <Bundle.EntryComponent>();
            string PatientOneMRNIdentifer      = Guid.NewGuid().ToString();
            string OrganizationOneMRNIdentifer = Guid.NewGuid().ToString();

            //Add a Patient resource by Create
            Patient PatientOne             = StaticTestData.CreateTestPatient(PatientOneMRNIdentifer);
            string  OrgOneResourceIdFulUrl = CreateFullUrlUUID(Guid.NewGuid().ToString());

            PatientOne.ManagingOrganization = new ResourceReference()
            {
                Reference = OrgOneResourceIdFulUrl
            };

            var PatientEntry = new Bundle.EntryComponent();

            TransBundle.Entry.Add(PatientEntry);
            PatientEntry.Resource       = PatientOne;
            PatientEntry.Request        = new Bundle.RequestComponent();
            PatientEntry.Request.Method = Bundle.HTTPVerb.POST;
            string PatientResourceIdFulUrl = CreateFullUrlUUID(Guid.NewGuid().ToString());

            PatientEntry.FullUrl        = PatientResourceIdFulUrl;
            PatientEntry.Resource       = PatientOne;
            PatientEntry.Request        = new Bundle.RequestComponent();
            PatientEntry.Request.Method = Bundle.HTTPVerb.POST;
            PatientEntry.Request.Url    = "Patient";

            //Add a Organization resource by Create
            Organization OrganizationOne = new Organization();

            OrganizationOne.Name = "Test OrganizationOne";
            OrganizationOne.Identifier.Add(new Identifier(StaticTestData.TestIdentiferSystem, OrganizationOneMRNIdentifer));

            var OrganizationOneEntry = new Bundle.EntryComponent();

            TransBundle.Entry.Add(OrganizationOneEntry);
            OrganizationOneEntry.Resource       = OrganizationOne;
            OrganizationOneEntry.Request        = new Bundle.RequestComponent();
            OrganizationOneEntry.Request.Method = Bundle.HTTPVerb.POST;
            OrganizationOneEntry.FullUrl        = OrgOneResourceIdFulUrl;

            OrganizationOneEntry.Resource       = OrganizationOne;
            OrganizationOneEntry.Request        = new Bundle.RequestComponent();
            OrganizationOneEntry.Request.Method = Bundle.HTTPVerb.POST;
            OrganizationOneEntry.Request.Url    = "Organization";


            Bundle TransactionResult = null;

            try
            {
                TransactionResult = clientFhir.Transaction(TransBundle);
            }
            catch (Exception Exec)
            {
                Assert.True(false, "Exception thrown on POST Transaction bundle: " + Exec.Message);
            }

            Assert.True(TransactionResult.Type == Bundle.BundleType.TransactionResponse);
            Assert.IsTrue(TransactionResult.Entry[0].Response.Status.Contains(System.Net.HttpStatusCode.Created.ToString()));
            Assert.IsTrue(TransactionResult.Entry[1].Response.Status.Contains(System.Net.HttpStatusCode.Created.ToString()));
            Patient      TransactionResultPatient      = TransactionResult.Entry[0].Resource as Patient;
            Organization TransactionResultOrganization = TransactionResult.Entry[1].Resource as Organization;
            string       PatientOneResourceId          = TransactionResult.Entry[0].Resource.Id;
            string       OrgOneResourceId = TransactionResult.Entry[1].Resource.Id;


            //Check that the referance in the Patient to the Organization has been updated.
            Assert.AreEqual(TransactionResultPatient.ManagingOrganization.Reference, $"Organization/{TransactionResultOrganization.Id}");

            //Check the Response Etag matches the resource Version number
            string PatientResourceVersionNumber = TransactionResultPatient.VersionId;

            Assert.AreEqual(Common.Tools.HttpHeaderSupport.GetEntityTagHeaderValueFromVersion(PatientResourceVersionNumber).Tag, Common.Tools.HttpHeaderSupport.GetETagEntityTagHeaderValueFromETagString(TransactionResult.Entry[0].Response.Etag).Tag);

            //Check that the FullURL of the entry is correct aginst the returned Resource
            string PatientFullUrlExpected = $"{StaticTestData.FhirEndpoint()}/Patient/{PatientOneResourceId}";

            Assert.AreEqual(PatientFullUrlExpected, TransactionResult.Entry[0].FullUrl);

            //------------------------------------------------------------------------------------------------------
            //Transaction Bundle 2 (Update) ------------------------------------------------------------------------
            //------------------------------------------------------------------------------------------------------

            TransBundle.Id = Guid.NewGuid().ToString();
            TransBundle.Entry.Clear();
            //Patient
            PatientOne.Id = PatientOneResourceId;
            PatientOne.Name.Clear();
            string PatientFamilyName = "TestPatientUpdate";

            PatientOne.Name.Add(HumanName.ForFamily(PatientFamilyName).WithGiven("TestUpdate"));
            //PatientOne.BirthDateElement = new Date("1979-09-30");
            //PatientOne.Identifier.Add(new Identifier(StaticTestData.TestIdentiferSystem, PatientOneMRNIdentifer));
            //PatientOne.Gender = AdministrativeGender.Unknown;

            PatientEntry = new Bundle.EntryComponent();
            TransBundle.Entry.Add(PatientEntry);
            PatientResourceIdFulUrl     = $"{StaticTestData.FhirEndpoint()}/Patient/{PatientOneResourceId}";
            PatientEntry.FullUrl        = PatientResourceIdFulUrl;
            PatientEntry.Resource       = PatientOne;
            PatientEntry.Request        = new Bundle.RequestComponent();
            PatientEntry.Request.Method = Bundle.HTTPVerb.PUT;
            PatientEntry.Request.Url    = $"Patient/{PatientOneResourceId}";

            //Organization
            OrganizationOne.Id   = OrgOneResourceId;
            OrganizationOne.Name = "Test OrganizationOne Updated";
            //OrganizationOne.Identifier.Add(new Identifier(StaticTestData.TestIdentiferSystem, OrganizationOneMRNIdentifer));

            OrganizationOneEntry = new Bundle.EntryComponent();
            TransBundle.Entry.Add(OrganizationOneEntry);
            OrgOneResourceIdFulUrl              = $"{StaticTestData.FhirEndpoint()}/Organization/{OrgOneResourceId}";
            OrganizationOneEntry.FullUrl        = OrgOneResourceIdFulUrl;
            OrganizationOneEntry.Resource       = OrganizationOne;
            OrganizationOneEntry.Request        = new Bundle.RequestComponent();
            OrganizationOneEntry.Request.Method = Bundle.HTTPVerb.PUT;
            OrganizationOneEntry.Request.Url    = $"Organization/{OrgOneResourceId}";

            TransactionResult = null;
            try
            {
                TransactionResult = clientFhir.Transaction(TransBundle);
            }
            catch (Exception Exec)
            {
                Assert.True(false, "Exception thrown on PUT Transaction bundle: " + Exec.Message);
            }
            Assert.IsTrue(TransactionResult.Entry[0].Response.Status.Contains(System.Net.HttpStatusCode.OK.ToString()));
            Assert.IsTrue(TransactionResult.Entry[1].Response.Status.Contains(System.Net.HttpStatusCode.OK.ToString()));

            TransactionResultPatient      = TransactionResult.Entry[0].Resource as Patient;
            TransactionResultOrganization = TransactionResult.Entry[1].Resource as Organization;

            //Check the family name was updated in the returned resource
            Assert.AreEqual(PatientFamilyName, TransactionResultPatient.Name[0].Family);

            //------------------------------------------------------------------------------------------------------
            //Transaction Bundle 3 (GET) ------------------------------------------------------------------------
            //------------------------------------------------------------------------------------------------------
            TransBundle.Id = Guid.NewGuid().ToString();
            TransBundle.Entry.Clear();

            PatientEntry = new Bundle.EntryComponent();
            TransBundle.Entry.Add(PatientEntry);
            PatientEntry.Request        = new Bundle.RequestComponent();
            PatientEntry.Request.Method = Bundle.HTTPVerb.GET;
            PatientEntry.Request.Url    = $"Patient/{TransactionResultPatient.Id}";

            OrganizationOneEntry = new Bundle.EntryComponent();
            TransBundle.Entry.Add(OrganizationOneEntry);
            OrganizationOneEntry.Request        = new Bundle.RequestComponent();
            OrganizationOneEntry.Request.Method = Bundle.HTTPVerb.GET;
            OrganizationOneEntry.Request.Url    = $"Organization/{TransactionResultOrganization.Id}";

            TransactionResult = null;
            try
            {
                TransactionResult = clientFhir.Transaction(TransBundle);
            }
            catch (Exception Exec)
            {
                Assert.True(false, "Exception thrown on GET Transaction bundle" + Exec.Message);
            }
            Assert.IsTrue(TransactionResult.Entry[0].Response.Status.Contains(System.Net.HttpStatusCode.OK.ToString()));
            Assert.IsTrue(TransactionResult.Entry[1].Response.Status.Contains(System.Net.HttpStatusCode.OK.ToString()));

            TransactionResultPatient      = TransactionResult.Entry[0].Resource as Patient;
            TransactionResultOrganization = TransactionResult.Entry[1].Resource as Organization;

            //------------------------------------------------------------------------------------------------------
            //Transaction Bundle 4 Search (GET) ------------------------------------------------------------------------
            //------------------------------------------------------------------------------------------------------
            TransBundle.Id = Guid.NewGuid().ToString();
            TransBundle.Entry.Clear();

            PatientEntry = new Bundle.EntryComponent();
            TransBundle.Entry.Add(PatientEntry);
            PatientEntry.Request        = new Bundle.RequestComponent();
            PatientEntry.Request.Method = Bundle.HTTPVerb.GET;
            PatientEntry.Request.Url    = $"Patient?identifier={StaticTestData.TestIdentiferSystem}|{PatientOneMRNIdentifer}";

            OrganizationOneEntry = new Bundle.EntryComponent();
            TransBundle.Entry.Add(OrganizationOneEntry);
            OrganizationOneEntry.Request        = new Bundle.RequestComponent();
            OrganizationOneEntry.Request.Method = Bundle.HTTPVerb.GET;
            OrganizationOneEntry.Request.Url    = $"Organization?identifier={StaticTestData.TestIdentiferSystem}|{OrganizationOneMRNIdentifer}";

            TransactionResult = null;
            try
            {
                TransactionResult = clientFhir.Transaction(TransBundle);
            }
            catch (Exception Exec)
            {
                Assert.True(false, "Exception thrown on GET Transaction bundle" + Exec.Message);
            }
            Assert.IsTrue(TransactionResult.Entry[0].Response.Status.Contains(System.Net.HttpStatusCode.OK.ToString()));
            Assert.IsTrue(TransactionResult.Entry[1].Response.Status.Contains(System.Net.HttpStatusCode.OK.ToString()));

            Bundle TransactionResultSearchPatientOneBundle   = TransactionResult.Entry[0].Resource as Bundle;
            Bundle TransactionResultOrganizationSearchBundle = TransactionResult.Entry[1].Resource as Bundle;

            //Check we only got one back in the search bundle
            Assert.AreEqual(TransactionResultSearchPatientOneBundle.Entry.Count, 1);
            Assert.AreEqual(TransactionResultOrganizationSearchBundle.Entry.Count, 1);

            //Check that each we got back were the two we added.
            Assert.AreEqual(TransactionResultSearchPatientOneBundle.Entry[0].Resource.Id, PatientOneResourceId);
            Assert.AreEqual(TransactionResultOrganizationSearchBundle.Entry[0].Resource.Id, OrgOneResourceId);

            //------------------------------------------------------------------------------------------------------
            //Transaction Bundle 5 If-Match (GET) --------------------------------------------------------------------
            //------------------------------------------------------------------------------------------------------
            TransBundle.Id = Guid.NewGuid().ToString();
            TransBundle.Entry.Clear();

            PatientEntry = new Bundle.EntryComponent();
            TransBundle.Entry.Add(PatientEntry);
            PatientEntry.Request         = new Bundle.RequestComponent();
            PatientEntry.Request.Method  = Bundle.HTTPVerb.GET;
            PatientEntry.Request.Url     = $"Patient?identifier={StaticTestData.TestIdentiferSystem}|{PatientOneMRNIdentifer}";
            PatientEntry.Request.IfMatch = Common.Tools.HttpHeaderSupport.GetETagString(TransactionResultSearchPatientOneBundle.Entry[0].Resource.VersionId);

            OrganizationOneEntry = new Bundle.EntryComponent();
            TransBundle.Entry.Add(OrganizationOneEntry);
            OrganizationOneEntry.Request         = new Bundle.RequestComponent();
            OrganizationOneEntry.Request.Method  = Bundle.HTTPVerb.GET;
            OrganizationOneEntry.Request.Url     = $"Organization?identifier={StaticTestData.TestIdentiferSystem}|{OrganizationOneMRNIdentifer}";
            OrganizationOneEntry.Request.IfMatch = Common.Tools.HttpHeaderSupport.GetETagString(TransactionResultOrganizationSearchBundle.Entry[0].Resource.VersionId);

            TransactionResult = null;
            try
            {
                TransactionResult = clientFhir.Transaction(TransBundle);
            }
            catch (Exception Exec)
            {
                Assert.True(false, "Exception thrown on GET Transaction bundle" + Exec.Message);
            }
            Assert.IsTrue(TransactionResult.Entry[0].Response.Status.Contains(System.Net.HttpStatusCode.OK.ToString()));
            Assert.IsTrue(TransactionResult.Entry[1].Response.Status.Contains(System.Net.HttpStatusCode.OK.ToString()));

            TransactionResultSearchPatientOneBundle   = TransactionResult.Entry[0].Resource as Bundle;
            TransactionResultOrganizationSearchBundle = TransactionResult.Entry[1].Resource as Bundle;

            //Check we only got one back in the search bundle
            Assert.AreEqual(TransactionResultSearchPatientOneBundle.Entry.Count, 1);
            Assert.AreEqual(TransactionResultOrganizationSearchBundle.Entry.Count, 1);


            //------------------------------------------------------------------------------------------------------
            //Transaction Bundle 6 If-Match (DELETE) --------------------------------------------------------------------
            //------------------------------------------------------------------------------------------------------
            TransBundle.Id = Guid.NewGuid().ToString();
            TransBundle.Entry.Clear();

            PatientEntry = new Bundle.EntryComponent();
            TransBundle.Entry.Add(PatientEntry);
            PatientEntry.Request         = new Bundle.RequestComponent();
            PatientEntry.Request.Method  = Bundle.HTTPVerb.DELETE;
            PatientEntry.Request.Url     = $"Patient?identifier={StaticTestData.TestIdentiferSystem}|{PatientOneMRNIdentifer}";
            PatientEntry.Request.IfMatch = Common.Tools.HttpHeaderSupport.GetETagString(TransactionResultSearchPatientOneBundle.Entry[0].Resource.VersionId);

            OrganizationOneEntry = new Bundle.EntryComponent();
            TransBundle.Entry.Add(OrganizationOneEntry);
            OrganizationOneEntry.Request         = new Bundle.RequestComponent();
            OrganizationOneEntry.Request.Method  = Bundle.HTTPVerb.DELETE;
            OrganizationOneEntry.Request.Url     = $"Organization?identifier={StaticTestData.TestIdentiferSystem}|{OrganizationOneMRNIdentifer}";
            OrganizationOneEntry.Request.IfMatch = Common.Tools.HttpHeaderSupport.GetETagString(TransactionResultOrganizationSearchBundle.Entry[0].Resource.VersionId);

            TransactionResult = null;
            try
            {
                TransactionResult = clientFhir.Transaction(TransBundle);
            }
            catch (Exception Exec)
            {
                Assert.True(false, "Exception thrown on GET Transaction bundle" + Exec.Message);
            }
            Assert.IsTrue(TransactionResult.Entry[0].Response.Status.Contains(System.Net.HttpStatusCode.NoContent.ToString()));
            Assert.IsTrue(TransactionResult.Entry[1].Response.Status.Contains(System.Net.HttpStatusCode.NoContent.ToString()));

            CleanUpByIdentifier(ResourceType.Patient);
            CleanUpByIdentifier(ResourceType.Organization);
        }
Example #33
0
        public void Test_ConditionalUpdate()
        {
            Hl7.Fhir.Rest.FhirClient clientFhir = new Hl7.Fhir.Rest.FhirClient(StaticTestData.FhirEndpoint(), false);
            clientFhir.Timeout = 1000 * 720; // give the call a while to execute (particularly while debugging).

            // Prepare 3 test patients
            Patient p1       = new Patient();
            string  TestPat1 = Guid.NewGuid().ToString();

            p1.Id = TestPat1;
            p1.Name.Add(HumanName.ForFamily("Postlethwaite").WithGiven("Brian"));
            p1.BirthDateElement = new Date("1970-01");
            p1.Identifier.Add(new Identifier(StaticTestData.TestIdentiferSystem, "1"));
            var r1 = clientFhir.Update(p1);

            Patient p2       = new Patient();
            string  TestPat2 = Guid.NewGuid().ToString();

            p2.Id = TestPat2;
            p2.Name.Add(HumanName.ForFamily("Portlethwhite").WithGiven("Brian"));
            p2.BirthDateElement = new Date("1970-01");
            p2.Identifier.Add(new Identifier(StaticTestData.TestIdentiferSystem, "1"));
            var r2 = clientFhir.Update(p2);

            Patient p3       = new Patient();
            string  TestPat3 = Guid.NewGuid().ToString();

            p3.Id = TestPat3;
            p3.Name.Add(HumanName.ForFamily("Dole").WithGiven("Bob"));
            p3.BirthDateElement = new Date("1957-01");
            p3.Identifier.Add(new Identifier(StaticTestData.TestIdentiferSystem, "1"));
            var r3 = clientFhir.Update(p3);


            // Test the conditional update now
            // Try to update Bob Doles data
            Patient p3a = new Patient();

            p3a.Name.Add(HumanName.ForFamily("Dole").WithGiven("Bob"));
            p3a.BirthDateElement = new Date("1957-01-12");
            p3a.Identifier.Add(new Identifier(StaticTestData.TestIdentiferSystem, "1"));
            SearchParams sp  = new SearchParams().Where("name=Dole").Where("birthdate=1957-01");
            var          r3a = clientFhir.Update(p3a, sp);

            Assert.AreEqual(TestPat3, r3a.Id, "pat3 should have been updated (not a new one created)");
            Assert.AreEqual("1957-01-12", r3a.BirthDate, "Birth date should have been updated");

            // Try to update Brian's data (which has multuple rows!)
            Patient p1a = new Patient();

            p1a.Name.Add(HumanName.ForFamily("Postlethwaite").WithGiven("Brian"));
            p1a.BirthDateElement = new Date("1970-02");
            p1a.Identifier.Add(new Identifier(StaticTestData.TestIdentiferSystem, "1"));
            sp = new SearchParams().Where("identifier=1");
            try
            {
                var r1a = clientFhir.Update(p1a, sp);
                Assert.Fail("This identifier is used multiple times, the conditional update should have failed");
            }
            catch (FhirOperationException ex)
            {
                Assert.AreEqual(System.Net.HttpStatusCode.PreconditionFailed, ex.Status, "Expected failure of the update due to a pre-condition check");
            }

            // Try to update Bob Doles data with incorrect id
            Patient p3b = new Patient();

            p3b.Id = "NotTheCorrectId";
            p3b.Name.Add(HumanName.ForFamily("Dole").WithGiven("Bob"));
            p3b.BirthDateElement = new Date("1957-01-01");
            p3b.Identifier.Add(new Identifier(StaticTestData.TestIdentiferSystem, "1"));
            try
            {
                var r3b = clientFhir.Update(p3b, sp);
                Assert.Fail("This identifier given in the resource Update does not match the Id in the resource located by search.");
            }
            catch (FhirOperationException ex)
            {
                Assert.AreEqual(System.Net.HttpStatusCode.PreconditionFailed, ex.Status, "Expected failure of the update due to a pre-condition check");
            }

            // Try to update New Patient resource where search returns zero hits and Resource is created occurs
            Patient p4 = new Patient();

            p4.Name.Add(HumanName.ForFamily("Dole4").WithGiven("John"));
            p4.BirthDateElement = new Date("1957-01-01");
            p4.Identifier.Add(new Identifier(StaticTestData.TestIdentiferSystem, "2"));
            sp = new SearchParams().Where("identifier=http://TestingSystem.org/id|2");
            Patient r4 = null;

            try
            {
                r4 = clientFhir.Update(p4, sp);
            }
            catch (FhirOperationException ex)
            {
                Assert.True(false, "Update p4 failed" + ex.Message);
            }


            //Clean up by deleting all resources created while also testing Conditional Delete many
            sp = new SearchParams().Where("identifier=http://TestingSystem.org/id|");
            try
            {
                clientFhir.Delete("Patient", sp);
            }
            catch (Exception Exec)
            {
                Assert.True(false, "Exception thrown on conditional delete of resource G: " + Exec.Message);
            }
        }