/// <summary>Writes an organization bundle.</summary>
        /// <param name="orgId">The organization.</param>
        /// <param name="dir">  The dir.</param>
        private static void WriteOrgBundle(
            string orgId,
            string dir)
        {
            string filename = Path.Combine(dir, $"{orgId}{_extension}");

            string bundleId = FhirGenerator.NextId;

            Bundle bundle = new Bundle()
            {
                Id         = bundleId,
                Identifier = FhirGenerator.IdentifierForId(bundleId),
                Type       = Bundle.BundleType.Collection,
                Timestamp  = new DateTimeOffset(DateTime.Now),
                Meta       = new Meta(),
            };

            bundle.Entry = new List <Bundle.EntryComponent>();

            bundle.AddResourceEntry(
                _orgById[orgId],
                $"{SystemLiterals.Internal}{_orgById[orgId].ResourceType}/{orgId}");

            bundle.AddResourceEntry(
                _rootLocationByOrgId[orgId],
                $"{SystemLiterals.Internal}{_rootLocationByOrgId[orgId].ResourceType}/{_rootLocationByOrgId[orgId].Id}");

            WriteBundle(filename, bundle);
        }
Ejemplo n.º 2
0
 /// <summary>Organisation for record.</summary>
 /// <param name="hosp">The hosp.</param>
 /// <returns>A Hl7.Fhir.Model.Organization.</returns>
 private static Hl7.Fhir.Model.Organization OrgForRec(HospitalRecord hosp)
 {
     return(new Hl7.Fhir.Model.Organization()
     {
         Meta = new Hl7.Fhir.Model.Meta()
         {
             Security = FhirTriplet.SecurityTest.GetCodingList(),
         },
         Id = _connectathonFlag ? hosp.ID : IdForOrg(hosp.OBJECTID),
         Identifier = _connectathonFlag
             ? IdentifierForConnectathonOrg(hosp.ID)
             : IdentifierForOrg(hosp.OBJECTID),
         Active = true,
         Type = FhirGenerator.ConceptListForOrganizationType(),
         Name = hosp.NAME,
         Address = new List <Hl7.Fhir.Model.Address>()
         {
             new Hl7.Fhir.Model.Address()
             {
                 Use = Hl7.Fhir.Model.Address.AddressUse.Work,
                 Type = Hl7.Fhir.Model.Address.AddressType.Both,
                 Line = new List <string>()
                 {
                     hosp.ADDRESS,
                 },
                 City = hosp.CITY,
                 State = hosp.STATE,
                 District = hosp.COUNTY,
                 PostalCode = hosp.ZIP,
                 Country = "USA",
                 Extension = new List <Hl7.Fhir.Model.Extension>()
                 {
                     new Hl7.Fhir.Model.Extension()
                     {
                         Url = "http://hl7.org/fhir/StructureDefinition/geolocation",
                         Extension = new List <Hl7.Fhir.Model.Extension>()
                         {
                             new Hl7.Fhir.Model.Extension()
                             {
                                 Url = "latitude",
                                 Value = new Hl7.Fhir.Model.FhirDecimal((decimal)hosp.LATITUDE),
                             },
                             new Hl7.Fhir.Model.Extension()
                             {
                                 Url = "longitude",
                                 Value = new Hl7.Fhir.Model.FhirDecimal((decimal)hosp.LONGITUDE),
                             },
                         },
                     },
                 },
             },
         },
     });
 }
Ejemplo n.º 3
0
        /// <summary>Organisation for geo.</summary>
        /// <param name="city">      The city.</param>
        /// <param name="state">     The state.</param>
        /// <param name="postalCode">The postal code.</param>
        /// <returns>A Hl7.Fhir.Model.Organization.</returns>
        private static Hl7.Fhir.Model.Organization CreateOrgForGeo(
            string city,
            string state,
            string postalCode)
        {
            string id   = FhirGenerator.NextOrgId;
            string name = $"HOSPITAL {id}";

            return(new Hl7.Fhir.Model.Organization()
            {
                Id = id,
                Identifier = FhirGenerator.IdentifierListForId(id),
                Active = true,
                Type = FhirGenerator.ConceptListForOrganizationType(),
                Name = name,
                Address = new List <Hl7.Fhir.Model.Address>()
                {
                    CreateAddress(city, state, postalCode),
                },
            });
        }
        /// <summary>Creates the orgs.</summary>
        /// <param name="count">        Number of.</param>
        /// <param name="state">        State to restrict generation to (default: none).</param>
        /// <param name="postalCode">   Postal code to restrict generation to (default: none).</param>
        /// <param name="recordsToSkip">(Optional) Number of records to skip before starting generation
        ///  (default: 0).</param>
        private static void CreateOrgs(
            int count,
            string state,
            string postalCode,
            int recordsToSkip = 0)
        {
            List <Organization> orgs = _useLookup
                ? HospitalManager.GetOrganizations(count, state, postalCode, recordsToSkip)
                : GeoManager.GetOrganizations(count, state, postalCode);

            foreach (Organization org in orgs)
            {
                if (_orgById.ContainsKey(org.Id))
                {
                    // ignore for now - need to figure out what to do for counts later
                    continue;
                }

                _orgById.Add(org.Id, org);

                Location orgLoc = FhirGenerator.RootLocationForOrg(org);
                _rootLocationByOrgId.Add(org.Id, orgLoc);
            }
        }