Commit fa03af1f authored by Marco Descher's avatar Marco Descher
Browse files

wip

parent 7f63209d
<?xml version="1.0" encoding="UTF-8"?>
<classpath>
<classpathentry kind="con" path="org.eclipse.jdt.launching.JRE_CONTAINER/org.eclipse.jdt.internal.debug.ui.launcher.StandardVMType/JavaSE-1.8"/>
<classpathentry kind="con" path="org.eclipse.pde.core.requiredPlugins"/>
<classpathentry kind="src" path="src"/>
<classpathentry kind="output" path="bin"/>
</classpath>
<?xml version="1.0" encoding="UTF-8"?>
<projectDescription>
<name>mb-importer-mediportinsurer</name>
<comment></comment>
<projects>
</projects>
<buildSpec>
<buildCommand>
<name>org.eclipse.jdt.core.javabuilder</name>
<arguments>
</arguments>
</buildCommand>
<buildCommand>
<name>org.eclipse.pde.ManifestBuilder</name>
<arguments>
</arguments>
</buildCommand>
<buildCommand>
<name>org.eclipse.pde.SchemaBuilder</name>
<arguments>
</arguments>
</buildCommand>
</buildSpec>
<natures>
<nature>org.eclipse.pde.PluginNature</nature>
<nature>org.eclipse.jdt.core.javanature</nature>
</natures>
</projectDescription>
eclipse.preferences.version=1
org.eclipse.jdt.core.compiler.codegen.inlineJsrBytecode=enabled
org.eclipse.jdt.core.compiler.codegen.targetPlatform=1.8
org.eclipse.jdt.core.compiler.compliance=1.8
org.eclipse.jdt.core.compiler.problem.assertIdentifier=error
org.eclipse.jdt.core.compiler.problem.enumIdentifier=error
org.eclipse.jdt.core.compiler.source=1.8
Manifest-Version: 1.0
Bundle-ManifestVersion: 2
Bundle-Name: Mb-importer-mediportinsurer
Bundle-SymbolicName: mb-importer-mediportinsurer
Bundle-Version: 1.0.0.qualifier
Automatic-Module-Name: mb-importer-mediportinsurer
Bundle-RequiredExecutionEnvironment: JavaSE-1.8
Import-Package: org.slf4j
Require-Bundle: ch.elexis.core;bundle-version="3.7.0",
info.elexis.server.misthios;bundle-version="1.0.0"
source.. = src/
output.. = bin/
bin.includes = META-INF/,\
.
name = "Importer Mediport Versichererliste"
description = "Importiere die Mediport Versichererliste"
category = "Importer"
[executor]
type = "Java"
entrypoint = "src/task/MediportInsurerImporter.java"
\ No newline at end of file
package task;
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStream;
import java.io.InputStreamReader;
import java.net.MalformedURLException;
import java.net.URL;
import java.util.ArrayList;
import java.util.List;
import java.util.Map;
import org.slf4j.Logger;
import ch.elexis.core.model.IOrganization;
import ch.elexis.core.model.builder.IContactBuilder;
import ch.elexis.core.services.IModelService;
import info.elexis.server.misthios.MisthiosTask;
import info.elexis.server.misthios.MisthiosTaskResult;
public class MediportInsurerImporter implements MisthiosTask {
@Override
public MisthiosTaskResult run(Map<String, Object> context) {
IModelService coreModelService = (IModelService) context.get("coreModelService");
Logger logger = (Logger) context.get("logger");
URL sourceFile;
try {
sourceFile = new URL("http://downloads.elexis.info/elexis/versichererliste.csv");
} catch (MalformedURLException e1) {
return MisthiosTaskResult.ERROR(e1);
}
try (InputStream is = sourceFile.openStream()) {
importCSVFromStream(coreModelService, logger, is);
} catch (IOException e) {
return MisthiosTaskResult.ERROR(e);
}
return null;
}
private static final String SEPARATOR = ";";
private static final String MEDIPORT_CONNECTED = "an MediPort angeschlossen";
private static final int IDX_ORGANISATION = 0;
private static final int IDX_DEPARTMENT = 1;
private static final int IDX_ADDR1 = 2;
private static final int IDX_ADDR2 = 3;
private static final int IDX_ZIP = 4;
private static final int IDX_CITY = 5;
private static final int IDX_PHONE = 6;
private static final int IDX_WEBSITE = 7;
private static final int IDX_EMAIL = 8;
private static final int IDX_INSURANCE_EAN = 9;
private static final int IDX_RECEPIENT_EAN = 10;
private static final int IDX_XML_INSURANCE_NAME = 11;
private static final int IDX_LAW_CODE = 12;
// private static final int IDX_TP_ELECTRONIC = 13;
// private static final int IDX_CHANGE_BILLTYPE = 14;
private static final int IDX_MEDIPORT_SUPPORT = 15;
public static List<IOrganization> importCSVFromStream(IModelService coreModelService, Logger logger,
InputStream csvInStream) {
List<IOrganization> insurerList = new ArrayList<IOrganization>();
try {
BufferedReader reader = new BufferedReader(new InputStreamReader(csvInStream));
String line = "";
int lineNo = 0;
while ((line = reader.readLine()) != null) {
lineNo++;
if (lineNo == 1) {
continue;
}
String[] parts = line.split(SEPARATOR, -1);
String org = parts[IDX_ORGANISATION];
String dept = parts[IDX_DEPARTMENT];
String street = parts[IDX_ADDR1];
String postbox = parts[IDX_ADDR2];
if (postbox != null && !postbox.isEmpty()) {
street = street + ", " + postbox;
}
String zip = parts[IDX_ZIP];
String city = parts[IDX_CITY];
String phone = parts[IDX_PHONE];
String website = parts[IDX_WEBSITE];
String email = parts[IDX_EMAIL];
String insuranceEAN = parts[IDX_INSURANCE_EAN];
String recepientEAN = parts[IDX_RECEPIENT_EAN];
String xmlInsuranceName = parts[IDX_XML_INSURANCE_NAME];
String lawCode = parts[IDX_LAW_CODE];
String mediport = parts[IDX_MEDIPORT_SUPPORT];
// IQuery<IOrganization> contactQuery = coreModelService.getQuery(IOrganization.class);
// contactQuery.add(Kontakt.FLD_NAME1, Query.EQUALS, org);
// contactQuery.add(Kontakt.FLD_NAME2, Query.EQUALS, dept);
// contactQuery.add(Kontakt.FLD_STREET, Query.EQUALS, street);
// contactQuery.add(Kontakt.FLD_PLACE, Query.EQUALS, city);
// List<IOrganization> contactList = contactQuery.execute();
// if (contactList != null && !contactList.isEmpty()) {
// logger.warn("Kontakt [" + org + " " + dept + ", " + street + ", " + city
// + "] existiert bereits. Wird nicht imporiert.");
// continue;
// }
IOrganization insurer = new IContactBuilder.OrganizationBuilder(coreModelService, org).build();
insurer.setDescription2(dept);
insurer.setStreet(street);
insurer.setZip(zip);
insurer.setCity(city);
insurer.setPhone1(phone);
insurer.setEmail(email);
insurer.setWebsite(website);
// titelSuffix -> lawCode
// allergien -> xmlInsuranceName
// insurer.setAnschrift(new Anschrift(insurer));
// insurer.getXid();
//
// // set EANs
// if (insuranceEAN != null && insuranceEAN.length() == 13) {
// insurer.setInsurerEAN(insuranceEAN);
// }
// if (recepientEAN != null && recepientEAN.length() == 13) {
// insurer.setRecepientEAN(recepientEAN);
// }
//
// // set further information
// insurer.setSupportsMediport(MEDIPORT_CONNECTED.equalsIgnoreCase(mediport));
insurerList.add(insurer);
}
reader.close();
} catch (Exception e) {
logger.error("Exception on execution", e);
return insurerList;
}
return insurerList;
}
}
......@@ -5,4 +5,7 @@ Bundle-SymbolicName: sample-misthios-bundle
Bundle-Version: 1.0.0.qualifier
Automatic-Module-Name: sample-misthios-bundle
Import-Package: info.elexis.server.misthios,
org.eclipse.core.runtime;version="3.5.0"
org.eclipse.core.runtime;version="3.5.0",
org.slf4j;version="1.7.2"
Require-Bundle: ch.elexis.core;bundle-version="3.7.0",
ch.elexis.core.model;bundle-version="1.0.0"
package task;
import java.util.Map;
import java.util.Optional;
import org.eclipse.core.runtime.IProgressMonitor;
import org.eclipse.core.runtime.IStatus;
import org.eclipse.core.runtime.Status;
import ch.elexis.core.services.IModelService;
import ch.elexis.core.utils.OsgiServiceUtil;
import info.elexis.server.misthios.MisthiosTask;
import info.elexis.server.misthios.MisthiosTaskResult;
import org.slf4j.Logger;
public class BasicExecutionTask implements MisthiosTask {
@Override
public IStatus run(IProgressMonitor monitor) {
public MisthiosTaskResult run(Map<String, Object> context) {
IProgressMonitor monitor = (IProgressMonitor) context.get("monitor");
Logger logger = (Logger) context.get("logger");
logger.error("Error test");
logger.info("Info test");
logger.warn("Warn test");
logger.debug("Debug test");
monitor.beginTask("Basic task", 1);
System.out.println("I am executed");
Optional<IModelService> service = OsgiServiceUtil.getService(IModelService.class);
System.out.println(service);
monitor.done();
return Status.OK_STATUS;
return MisthiosTaskResult.OK();
}
}
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment