Search in sources :

Example 1 with Clinician

use of org.mitre.synthea.world.agents.Clinician in project synthea by synthetichealth.

the class FhirPractitionerExporterDstu2 method export.

/**
 * Export the practitioner in FHIR DSTU2 format.
 */
public static void export(long stop) {
    if (Config.getAsBoolean("exporter.practitioner.fhir_dstu2.export")) {
        Bundle bundle = new Bundle();
        if (Config.getAsBoolean("exporter.fhir.transaction_bundle")) {
            bundle.setType(BundleTypeEnum.BATCH);
        } else {
            bundle.setType(BundleTypeEnum.COLLECTION);
        }
        for (Provider h : Provider.getProviderList()) {
            // filter - exports only those hospitals in use
            Table<Integer, String, AtomicInteger> utilization = h.getUtilization();
            int totalEncounters = utilization.column(Provider.ENCOUNTERS).values().stream().mapToInt(ai -> ai.get()).sum();
            if (totalEncounters > 0) {
                Map<String, ArrayList<Clinician>> clinicians = h.clinicianMap;
                for (String specialty : clinicians.keySet()) {
                    ArrayList<Clinician> docs = clinicians.get(specialty);
                    for (Clinician doc : docs) {
                        if (doc.getEncounterCount() > 0) {
                            Entry entry = FhirDstu2.practitioner(bundle, doc);
                            Practitioner practitioner = (Practitioner) entry.getResource();
                            ExtensionDt extension = new ExtensionDt();
                            extension.setUrl(EXTENSION_URI);
                            extension.setValue(new IntegerDt(doc.getEncounterCount()));
                            practitioner.addUndeclaredExtension(extension);
                        }
                    }
                }
            }
        }
        String bundleJson = FhirDstu2.getContext().newJsonParser().setPrettyPrint(true).encodeResourceToString(bundle);
        // get output folder
        List<String> folders = new ArrayList<>();
        folders.add("fhir_dstu2");
        String baseDirectory = Config.get("exporter.baseDirectory");
        File f = Paths.get(baseDirectory, folders.toArray(new String[0])).toFile();
        f.mkdirs();
        Path outFilePath = f.toPath().resolve("practitionerInformation" + stop + ".json");
        try {
            Files.write(outFilePath, Collections.singleton(bundleJson), StandardOpenOption.CREATE_NEW);
        } catch (IOException e) {
            e.printStackTrace();
        }
    }
}
Also used : Config(org.mitre.synthea.helpers.Config) Files(java.nio.file.Files) Clinician(org.mitre.synthea.world.agents.Clinician) ExtensionDt(ca.uhn.fhir.model.api.ExtensionDt) IntegerDt(ca.uhn.fhir.model.primitive.IntegerDt) StandardOpenOption(java.nio.file.StandardOpenOption) IOException(java.io.IOException) Bundle(ca.uhn.fhir.model.dstu2.resource.Bundle) File(java.io.File) BundleTypeEnum(ca.uhn.fhir.model.dstu2.valueset.BundleTypeEnum) ArrayList(java.util.ArrayList) Provider(org.mitre.synthea.world.agents.Provider) List(java.util.List) Entry(ca.uhn.fhir.model.dstu2.resource.Bundle.Entry) Practitioner(ca.uhn.fhir.model.dstu2.resource.Practitioner) Paths(java.nio.file.Paths) AtomicInteger(java.util.concurrent.atomic.AtomicInteger) Map(java.util.Map) Table(com.google.common.collect.Table) Path(java.nio.file.Path) Collections(java.util.Collections) Path(java.nio.file.Path) IntegerDt(ca.uhn.fhir.model.primitive.IntegerDt) Bundle(ca.uhn.fhir.model.dstu2.resource.Bundle) ArrayList(java.util.ArrayList) IOException(java.io.IOException) Provider(org.mitre.synthea.world.agents.Provider) Clinician(org.mitre.synthea.world.agents.Clinician) AtomicInteger(java.util.concurrent.atomic.AtomicInteger) Practitioner(ca.uhn.fhir.model.dstu2.resource.Practitioner) Entry(ca.uhn.fhir.model.dstu2.resource.Bundle.Entry) AtomicInteger(java.util.concurrent.atomic.AtomicInteger) File(java.io.File) ExtensionDt(ca.uhn.fhir.model.api.ExtensionDt)

Example 2 with Clinician

use of org.mitre.synthea.world.agents.Clinician in project synthea by synthetichealth.

the class BB2RIFExporter method exportNPIs.

/**
 * Export NPI writer with synthetic providers.
 * @throws IOException if something goes horribly wrong.
 */
public void exportNPIs() throws IOException {
    HashMap<NPI, String> fieldValues = new HashMap<>();
    SynchronizedBBLineWriter rifWriter = rifWriters.getOrCreateWriter(NPI.class, RifEntryStatus.INITIAL, "tsv", "\t");
    for (Provider h : Provider.getProviderList()) {
        // filter - exports only those organizations in use
        Table<Integer, String, AtomicInteger> utilization = h.getUtilization();
        int totalEncounters = utilization.column(Provider.ENCOUNTERS).values().stream().mapToInt(ai -> ai.get()).sum();
        if (totalEncounters > 0) {
            // export organization
            fieldValues.clear();
            fieldValues.put(NPI.NPI, h.npi);
            fieldValues.put(NPI.ENTITY_TYPE_CODE, "2");
            fieldValues.put(NPI.EIN, "<UNAVAIL>");
            fieldValues.put(NPI.ORG_NAME, h.name);
            rifWriter.writeValues(fieldValues);
            Map<String, ArrayList<Clinician>> clinicians = h.clinicianMap;
            for (String specialty : clinicians.keySet()) {
                ArrayList<Clinician> docs = clinicians.get(specialty);
                for (Clinician doc : docs) {
                    if (doc.getEncounterCount() > 0) {
                        // export each doc
                        Map<String, Object> attributes = doc.getAttributes();
                        fieldValues.clear();
                        fieldValues.put(NPI.NPI, doc.npi);
                        fieldValues.put(NPI.ENTITY_TYPE_CODE, "1");
                        fieldValues.put(NPI.LAST_NAME, attributes.get(Clinician.LAST_NAME).toString());
                        fieldValues.put(NPI.FIRST_NAME, attributes.get(Clinician.FIRST_NAME).toString());
                        fieldValues.put(NPI.PREFIX, attributes.get(Clinician.NAME_PREFIX).toString());
                        fieldValues.put(NPI.CREDENTIALS, "M.D.");
                        rifWriter.writeValues(fieldValues);
                    }
                }
            }
        }
    }
}
Also used : JsonObject(com.google.gson.JsonObject) Arrays(java.util.Arrays) TypeToken(com.google.gson.reflect.TypeToken) ClaimEntry(org.mitre.synthea.world.concepts.Claim.ClaimEntry) Date(java.util.Date) Supply(org.mitre.synthea.world.concepts.HealthRecord.Supply) BENEFICIARY_HISTORY(org.mitre.synthea.export.BB2RIFStructure.BENEFICIARY_HISTORY) StringUtils(org.apache.commons.lang3.StringUtils) BENEFICIARY(org.mitre.synthea.export.BB2RIFStructure.BENEFICIARY) Medication(org.mitre.synthea.world.concepts.HealthRecord.Medication) SNF(org.mitre.synthea.export.BB2RIFStructure.SNF) CARRIER(org.mitre.synthea.export.BB2RIFStructure.CARRIER) Person(org.mitre.synthea.world.agents.Person) AtomicInteger(java.util.concurrent.atomic.AtomicInteger) NPI(org.mitre.synthea.export.BB2RIFStructure.NPI) Gson(com.google.gson.Gson) Map(java.util.Map) ClinicianSpecialty(org.mitre.synthea.world.concepts.ClinicianSpecialty) Method(java.lang.reflect.Method) Path(java.nio.file.Path) HHA(org.mitre.synthea.export.BB2RIFStructure.HHA) RandomNumberGenerator(org.mitre.synthea.helpers.RandomNumberGenerator) ProviderType(org.mitre.synthea.world.agents.Provider.ProviderType) HealthRecord(org.mitre.synthea.world.concepts.HealthRecord) MissingResourceException(java.util.MissingResourceException) Set(java.util.Set) Instant(java.time.Instant) ZoneId(java.time.ZoneId) Utilities(org.mitre.synthea.helpers.Utilities) InvocationTargetException(java.lang.reflect.InvocationTargetException) CMSStateCodeMapper(org.mitre.synthea.world.geography.CMSStateCodeMapper) HealthInsuranceModule(org.mitre.synthea.modules.HealthInsuranceModule) List(java.util.List) Type(java.lang.reflect.Type) LocalDate(java.time.LocalDate) EncounterType(org.mitre.synthea.world.concepts.HealthRecord.EncounterType) SimpleCSV(org.mitre.synthea.helpers.SimpleCSV) Clinician(org.mitre.synthea.world.agents.Clinician) SimpleDateFormat(java.text.SimpleDateFormat) HashMap(java.util.HashMap) AtomicReference(java.util.concurrent.atomic.AtomicReference) RandomCollection(org.mitre.synthea.helpers.RandomCollection) ArrayList(java.util.ArrayList) LinkedHashMap(java.util.LinkedHashMap) Code(org.mitre.synthea.world.concepts.HealthRecord.Code) LinkedHashSet(java.util.LinkedHashSet) DME(org.mitre.synthea.export.BB2RIFStructure.DME) Device(org.mitre.synthea.world.concepts.HealthRecord.Device) Config(org.mitre.synthea.helpers.Config) Properties(java.util.Properties) JsonSyntaxException(com.google.gson.JsonSyntaxException) StringWriter(java.io.StringWriter) FileOutputStream(java.io.FileOutputStream) IOException(java.io.IOException) OUTPATIENT(org.mitre.synthea.export.BB2RIFStructure.OUTPATIENT) Payer(org.mitre.synthea.world.agents.Payer) Entry(org.mitre.synthea.world.concepts.HealthRecord.Entry) File(java.io.File) PDE(org.mitre.synthea.export.BB2RIFStructure.PDE) Provider(org.mitre.synthea.world.agents.Provider) AtomicLong(java.util.concurrent.atomic.AtomicLong) HOSPICE(org.mitre.synthea.export.BB2RIFStructure.HOSPICE) Comparator(java.util.Comparator) Table(com.google.common.collect.Table) Collections(java.util.Collections) INPATIENT(org.mitre.synthea.export.BB2RIFStructure.INPATIENT) HashMap(java.util.HashMap) LinkedHashMap(java.util.LinkedHashMap) NPI(org.mitre.synthea.export.BB2RIFStructure.NPI) ArrayList(java.util.ArrayList) Provider(org.mitre.synthea.world.agents.Provider) Clinician(org.mitre.synthea.world.agents.Clinician) AtomicInteger(java.util.concurrent.atomic.AtomicInteger) AtomicInteger(java.util.concurrent.atomic.AtomicInteger) JsonObject(com.google.gson.JsonObject)

Example 3 with Clinician

use of org.mitre.synthea.world.agents.Clinician in project synthea by synthetichealth.

the class CSVExporter method exportOrganizationsAndProviders.

/**
 * Export the organizations.csv and providers.csv files. This method should be
 * called once after all the Patient records have been exported using the
 * export(Person,long) method.
 *
 * @throws IOException if any IO errors occur.
 */
public void exportOrganizationsAndProviders() throws IOException {
    for (Provider org : Provider.getProviderList()) {
        // Check utilization for hospital before we export
        Table<Integer, String, AtomicInteger> utilization = org.getUtilization();
        int totalEncounters = utilization.column(Provider.ENCOUNTERS).values().stream().mapToInt(ai -> ai.get()).sum();
        if (totalEncounters > 0) {
            organization(org, totalEncounters);
            Map<String, ArrayList<Clinician>> providers = org.clinicianMap;
            for (String speciality : providers.keySet()) {
                ArrayList<Clinician> clinicians = providers.get(speciality);
                for (Clinician clinician : clinicians) {
                    provider(clinician, org.getResourceID());
                }
            }
        }
        organizations.flush();
        providers.flush();
    }
}
Also used : AtomicInteger(java.util.concurrent.atomic.AtomicInteger) JsonObject(com.google.gson.JsonObject) Arrays(java.util.Arrays) Supply(org.mitre.synthea.world.concepts.HealthRecord.Supply) StringUtils(org.apache.commons.lang3.StringUtils) Medication(org.mitre.synthea.world.concepts.HealthRecord.Medication) BigDecimal(java.math.BigDecimal) Person(org.mitre.synthea.world.agents.Person) AtomicInteger(java.util.concurrent.atomic.AtomicInteger) Locale(java.util.Locale) Map(java.util.Map) Path(java.nio.file.Path) Encounter(org.mitre.synthea.world.concepts.HealthRecord.Encounter) RoundingMode(java.math.RoundingMode) RandomNumberGenerator(org.mitre.synthea.helpers.RandomNumberGenerator) GregorianCalendar(java.util.GregorianCalendar) RandomCodeGenerator(org.mitre.synthea.helpers.RandomCodeGenerator) HealthRecord(org.mitre.synthea.world.concepts.HealthRecord) Collectors(java.util.stream.Collectors) Utilities(org.mitre.synthea.helpers.Utilities) List(java.util.List) ExportHelper.dateFromTimestamp(org.mitre.synthea.export.ExportHelper.dateFromTimestamp) EncounterType(org.mitre.synthea.world.concepts.HealthRecord.EncounterType) Clinician(org.mitre.synthea.world.agents.Clinician) Function(java.util.function.Function) ArrayList(java.util.ArrayList) Calendar(java.util.Calendar) Charset(java.nio.charset.Charset) QualityOfLifeModule(org.mitre.synthea.modules.QualityOfLifeModule) Plan(org.mitre.synthea.world.concepts.CoverageRecord.Plan) Code(org.mitre.synthea.world.concepts.HealthRecord.Code) OutputStreamWriter(java.io.OutputStreamWriter) CarePlan(org.mitre.synthea.world.concepts.HealthRecord.CarePlan) Procedure(org.mitre.synthea.world.concepts.HealthRecord.Procedure) Device(org.mitre.synthea.world.concepts.HealthRecord.Device) Config(org.mitre.synthea.helpers.Config) Iterator(java.util.Iterator) ImagingStudy(org.mitre.synthea.world.concepts.HealthRecord.ImagingStudy) FileOutputStream(java.io.FileOutputStream) IOException(java.io.IOException) ExportHelper.getSystemFromURI(org.mitre.synthea.export.ExportHelper.getSystemFromURI) Payer(org.mitre.synthea.world.agents.Payer) Entry(org.mitre.synthea.world.concepts.HealthRecord.Entry) File(java.io.File) Provider(org.mitre.synthea.world.agents.Provider) CoverageRecord(org.mitre.synthea.world.concepts.CoverageRecord) AtomicLong(java.util.concurrent.atomic.AtomicLong) Claim(org.mitre.synthea.world.concepts.Claim) Observation(org.mitre.synthea.world.concepts.HealthRecord.Observation) NullOutputStream(org.apache.commons.io.output.NullOutputStream) Comparator(java.util.Comparator) ExportHelper.iso8601Timestamp(org.mitre.synthea.export.ExportHelper.iso8601Timestamp) Table(com.google.common.collect.Table) Collections(java.util.Collections) AtomicInteger(java.util.concurrent.atomic.AtomicInteger) ArrayList(java.util.ArrayList) Provider(org.mitre.synthea.world.agents.Provider) Clinician(org.mitre.synthea.world.agents.Clinician)

Example 4 with Clinician

use of org.mitre.synthea.world.agents.Clinician in project synthea by synthetichealth.

the class FhirPractitionerExporterStu3 method export.

/**
 * Export the practitioner in FHIR STU3 format.
 */
public static void export(long stop) {
    if (Config.getAsBoolean("exporter.practitioner.fhir_stu3.export")) {
        Bundle bundle = new Bundle();
        if (Config.getAsBoolean("exporter.fhir.transaction_bundle")) {
            bundle.setType(BundleType.BATCH);
        } else {
            bundle.setType(BundleType.COLLECTION);
        }
        for (Provider h : Provider.getProviderList()) {
            // filter - exports only those hospitals in use
            Table<Integer, String, AtomicInteger> utilization = h.getUtilization();
            int totalEncounters = utilization.column(Provider.ENCOUNTERS).values().stream().mapToInt(ai -> ai.get()).sum();
            if (totalEncounters > 0) {
                Map<String, ArrayList<Clinician>> clinicians = h.clinicianMap;
                for (String specialty : clinicians.keySet()) {
                    ArrayList<Clinician> docs = clinicians.get(specialty);
                    for (Clinician doc : docs) {
                        if (doc.getEncounterCount() > 0) {
                            BundleEntryComponent entry = FhirStu3.practitioner(bundle, doc);
                            Practitioner practitioner = (Practitioner) entry.getResource();
                            practitioner.addExtension().setUrl(EXTENSION_URI).setValue(new IntegerType(doc.getEncounterCount()));
                        }
                    }
                }
            }
        }
        String bundleJson = FhirStu3.getContext().newJsonParser().setPrettyPrint(true).encodeResourceToString(bundle);
        // get output folder
        List<String> folders = new ArrayList<>();
        folders.add("fhir_stu3");
        String baseDirectory = Config.get("exporter.baseDirectory");
        File f = Paths.get(baseDirectory, folders.toArray(new String[0])).toFile();
        f.mkdirs();
        Path outFilePath = f.toPath().resolve("practitionerInformation" + stop + ".json");
        try {
            Files.write(outFilePath, Collections.singleton(bundleJson), StandardOpenOption.CREATE_NEW);
        } catch (IOException e) {
            e.printStackTrace();
        }
    }
}
Also used : Practitioner(org.hl7.fhir.dstu3.model.Practitioner) Config(org.mitre.synthea.helpers.Config) Bundle(org.hl7.fhir.dstu3.model.Bundle) Files(java.nio.file.Files) Clinician(org.mitre.synthea.world.agents.Clinician) BundleEntryComponent(org.hl7.fhir.dstu3.model.Bundle.BundleEntryComponent) StandardOpenOption(java.nio.file.StandardOpenOption) BundleType(org.hl7.fhir.dstu3.model.Bundle.BundleType) IOException(java.io.IOException) IntegerType(org.hl7.fhir.dstu3.model.IntegerType) File(java.io.File) ArrayList(java.util.ArrayList) Provider(org.mitre.synthea.world.agents.Provider) FhirContext(ca.uhn.fhir.context.FhirContext) List(java.util.List) Paths(java.nio.file.Paths) AtomicInteger(java.util.concurrent.atomic.AtomicInteger) Map(java.util.Map) Table(com.google.common.collect.Table) Path(java.nio.file.Path) Collections(java.util.Collections) Path(java.nio.file.Path) Bundle(org.hl7.fhir.dstu3.model.Bundle) ArrayList(java.util.ArrayList) IOException(java.io.IOException) Provider(org.mitre.synthea.world.agents.Provider) Clinician(org.mitre.synthea.world.agents.Clinician) AtomicInteger(java.util.concurrent.atomic.AtomicInteger) Practitioner(org.hl7.fhir.dstu3.model.Practitioner) IntegerType(org.hl7.fhir.dstu3.model.IntegerType) BundleEntryComponent(org.hl7.fhir.dstu3.model.Bundle.BundleEntryComponent) AtomicInteger(java.util.concurrent.atomic.AtomicInteger) File(java.io.File)

Example 5 with Clinician

use of org.mitre.synthea.world.agents.Clinician in project synthea by synthetichealth.

the class FhirPractitionerExporterR4 method export.

/**
 * Export the practitioner in FHIR R4 format.
 */
public static void export(RandomNumberGenerator rand, long stop) {
    if (Config.getAsBoolean("exporter.practitioner.fhir.export")) {
        Bundle bundle = new Bundle();
        if (Config.getAsBoolean("exporter.fhir.transaction_bundle")) {
            bundle.setType(BundleType.BATCH);
        } else {
            bundle.setType(BundleType.COLLECTION);
        }
        for (Provider h : Provider.getProviderList()) {
            // filter - exports only those hospitals in use
            Table<Integer, String, AtomicInteger> utilization = h.getUtilization();
            int totalEncounters = utilization.column(Provider.ENCOUNTERS).values().stream().mapToInt(ai -> ai.get()).sum();
            if (totalEncounters > 0) {
                Map<String, ArrayList<Clinician>> clinicians = h.clinicianMap;
                for (String specialty : clinicians.keySet()) {
                    ArrayList<Clinician> docs = clinicians.get(specialty);
                    for (Clinician doc : docs) {
                        if (doc.getEncounterCount() > 0) {
                            BundleEntryComponent entry = FhirR4.practitioner(rand, bundle, doc);
                            Practitioner practitioner = (Practitioner) entry.getResource();
                            practitioner.addExtension().setUrl(EXTENSION_URI).setValue(new IntegerType(doc.getEncounterCount()));
                        }
                    }
                }
            }
        }
        String bundleJson = FhirR4.getContext().newJsonParser().setPrettyPrint(true).encodeResourceToString(bundle);
        // get output folder
        List<String> folders = new ArrayList<>();
        folders.add("fhir");
        String baseDirectory = Config.get("exporter.baseDirectory");
        File f = Paths.get(baseDirectory, folders.toArray(new String[0])).toFile();
        f.mkdirs();
        Path outFilePath = f.toPath().resolve("practitionerInformation" + stop + ".json");
        try {
            Files.write(outFilePath, Collections.singleton(bundleJson), StandardOpenOption.CREATE_NEW);
        } catch (IOException e) {
            e.printStackTrace();
        }
    }
}
Also used : RandomNumberGenerator(org.mitre.synthea.helpers.RandomNumberGenerator) Config(org.mitre.synthea.helpers.Config) Files(java.nio.file.Files) Clinician(org.mitre.synthea.world.agents.Clinician) StandardOpenOption(java.nio.file.StandardOpenOption) IOException(java.io.IOException) File(java.io.File) ArrayList(java.util.ArrayList) Provider(org.mitre.synthea.world.agents.Provider) FhirContext(ca.uhn.fhir.context.FhirContext) List(java.util.List) Paths(java.nio.file.Paths) AtomicInteger(java.util.concurrent.atomic.AtomicInteger) Map(java.util.Map) BundleEntryComponent(org.hl7.fhir.r4.model.Bundle.BundleEntryComponent) Bundle(org.hl7.fhir.r4.model.Bundle) BundleType(org.hl7.fhir.r4.model.Bundle.BundleType) Table(com.google.common.collect.Table) Path(java.nio.file.Path) Collections(java.util.Collections) IntegerType(org.hl7.fhir.r4.model.IntegerType) Practitioner(org.hl7.fhir.r4.model.Practitioner) Path(java.nio.file.Path) Bundle(org.hl7.fhir.r4.model.Bundle) ArrayList(java.util.ArrayList) IOException(java.io.IOException) Provider(org.mitre.synthea.world.agents.Provider) Clinician(org.mitre.synthea.world.agents.Clinician) AtomicInteger(java.util.concurrent.atomic.AtomicInteger) Practitioner(org.hl7.fhir.r4.model.Practitioner) IntegerType(org.hl7.fhir.r4.model.IntegerType) BundleEntryComponent(org.hl7.fhir.r4.model.Bundle.BundleEntryComponent) AtomicInteger(java.util.concurrent.atomic.AtomicInteger) File(java.io.File)

Aggregations

Clinician (org.mitre.synthea.world.agents.Clinician)6 Provider (org.mitre.synthea.world.agents.Provider)6 Table (com.google.common.collect.Table)5 File (java.io.File)5 IOException (java.io.IOException)5 Path (java.nio.file.Path)5 ArrayList (java.util.ArrayList)5 Collections (java.util.Collections)5 List (java.util.List)5 Map (java.util.Map)5 AtomicInteger (java.util.concurrent.atomic.AtomicInteger)5 Config (org.mitre.synthea.helpers.Config)5 Files (java.nio.file.Files)3 Paths (java.nio.file.Paths)3 StandardOpenOption (java.nio.file.StandardOpenOption)3 FhirContext (ca.uhn.fhir.context.FhirContext)2 JsonObject (com.google.gson.JsonObject)2 FileOutputStream (java.io.FileOutputStream)2 Arrays (java.util.Arrays)2 Comparator (java.util.Comparator)2