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();
}
}
}
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);
}
}
}
}
}
}
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();
}
}
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();
}
}
}
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();
}
}
}
Aggregations