use of org.hl7.fhir.r5.model.Enumerations.FHIRVersion in project ab2d by CMSgov.
the class PatientClaimsProcessorImpl method writeOutData.
String writeOutData(PatientClaimsRequest request, FhirVersion fhirVersion, ProgressTrackerUpdate update) throws IOException {
File file = null;
String anyErrors = null;
try (ClaimsStream stream = new ClaimsStream(request.getJob(), request.getEfsMount(), DATA, searchConfig.getStreamingDir(), searchConfig.getFinishedDir(), searchConfig.getBufferSize())) {
file = stream.getFile();
logManager.log(new FileEvent(request.getOrganization(), request.getJob(), stream.getFile(), FileEvent.FileStatus.OPEN));
for (CoverageSummary patient : request.getCoverageSummary()) {
List<IBaseResource> eobs = getEobBundleResources(request, patient);
anyErrors = writeOutResource(fhirVersion, update, eobs, stream);
update.incPatientProcessCount();
}
} finally {
logManager.log(new FileEvent(request.getOrganization(), request.getJob(), file, FileEvent.FileStatus.CLOSE));
}
return anyErrors;
}
use of org.hl7.fhir.r5.model.Enumerations.FHIRVersion in project camel-spring-boot-examples by apache.
the class MyCamelRouter method configure.
@Override
public void configure() throws Exception {
from("file:{{input}}").routeId("fhir-example").onException(ProtocolException.class).handled(true).log(LoggingLevel.ERROR, "Error connecting to FHIR server with URL:{{serverUrl}}, please check the application.properties file ${exception.message}").end().onException(HL7Exception.class).handled(true).log(LoggingLevel.ERROR, "Error unmarshalling ${file:name} ${exception.message}").end().log("Converting ${file:name}").unmarshal().hl7().process(exchange -> {
ORU_R01 msg = exchange.getIn().getBody(ORU_R01.class);
final PID pid = msg.getPATIENT_RESULT().getPATIENT().getPID();
String surname = pid.getPatientName()[0].getFamilyName().getFn1_Surname().getValue();
String name = pid.getPatientName()[0].getGivenName().getValue();
String patientId = msg.getPATIENT_RESULT().getPATIENT().getPID().getPatientID().getCx1_ID().getValue();
Patient patient = new Patient();
patient.addName().addGiven(name);
patient.getNameFirstRep().setFamily(surname);
patient.setId(patientId);
exchange.getIn().setBody(patient);
}).marshal().fhirJson("{{fhirVersion}}").convertBodyTo(String.class).log("Inserting Patient: ${body}").to("fhir://create/resource?inBody=resourceAsString&serverUrl={{serverUrl}}&fhirVersion={{fhirVersion}}").log("Patient created successfully: ${body}");
}
use of org.hl7.fhir.r5.model.Enumerations.FHIRVersion in project kindling by HL7.
the class SpecNPMPackageGenerator method generate.
//
// public static void main(String[] args) throws Exception {
// // generateForVersion("F:\\fhir\\web\\DSTU2", "http://hl7.org/fhir/DSTU2");
// generateForVersion("E:\\fhir\\web\\2016May", "http://hl7.org/fhir/2016May", new Date());
// // generateForVersion("F:\\fhir\\web\\STU3", "http://hl7.org/fhir/2016STU3");
// System.out.println("Done");
// }
// private static void generateForVersion(String folder, String url, Date genDate) throws Exception {
// SpecNPMPackageGenerator self = new SpecNPMPackageGenerator();
// self.generate(folder, url, false, genDate);
// }
//
public void generate(String folder, String url, boolean forWeb, Date genDate, String pidRoot) throws Exception {
System.out.println("Generate Package for " + folder);
Map<String, byte[]> files = loadZip(new FileInputStream(Utilities.path(folder, "igpack.zip")));
FHIRVersion version = determineVersion(files);
System.out.println(" .. Loading v" + version);
SpecMapManager spm = new SpecMapManager(files.get("spec.internals"), version.toCode());
System.out.println(" .. Conformance Resources");
List<ResourceEntry> reslist = makeResourceList(files, version.toCode());
System.out.println(" .. Other Resources");
addToResList(folder, reslist, version.toCode());
System.out.println(" .. building IG");
ImplementationGuide ig = new ImplementationGuide();
ig.setId("fhir");
ig.setUrl("http://hl7.org/fhir/ImplementationGuide/fhir");
ig.setVersion(version.toCode());
ig.addFhirVersion(version);
ig.setLicense(SPDXLicense.CC01_0);
ig.setTitle("FHIR Core package");
ig.setDescription("FHIR Core package - the NPM package that contains all the definitions for the base FHIR specification");
ig.setPublisher("HL7 Inc");
ig.getContactFirstRep().getTelecomFirstRep().setSystem(ContactPointSystem.URL).setValue("http://hl7.org/fhir");
ig.setPackageId(pidRoot + ".core");
ig.getManifest().setRendering(url);
for (ResourceEntry e : reslist) {
ManifestResourceComponent r = ig.getManifest().addResource();
r.setReference(new Reference(e.type + "/" + e.id));
if (e.conf)
r.setExample(new BooleanType(true));
r.setRelativePath(spm.getPath(e.canonical, null));
}
for (String k : files.keySet()) {
if (k.endsWith(".png") || k.endsWith(".gif"))
ig.getManifest().addImage(k);
else if (k.endsWith(".css"))
ig.getManifest().addOther(k);
}
Map<String, ManifestPageComponent> map = new HashMap<String, ManifestPageComponent>();
for (String k : spm.getPages()) {
ManifestPageComponent pp = ig.getManifest().addPage();
pp.setName(k).setTitle(spm.getPage(k));
map.put(pp.getName(), pp);
}
for (String k : spm.getTargets()) {
String n = null;
String f = null;
if (k.contains("#")) {
n = k.substring(0, k.indexOf("#"));
f = k.substring(k.indexOf("#") + 1);
} else
n = k;
ManifestPageComponent p = map.get(n);
if (p == null) {
p = ig.getManifest().addPage();
p.setName(n);
map.put(p.getName(), p);
}
if (f != null)
p.addAnchor(f);
}
// ok ig is full loaded...
System.out.println(" .. Building NPM Package");
NPMPackageGenerator npm = new NPMPackageGenerator(Utilities.path(folder, pidRoot + ".core.tgz"), "http://hl7.org/fhir", url, PackageType.CORE, ig, genDate, true);
ByteArrayOutputStream bs = new ByteArrayOutputStream();
new org.hl7.fhir.r5.formats.JsonParser().setOutputStyle(OutputStyle.NORMAL).compose(bs, ig);
// npm.addFile(Category.RESOURCE, "ig-r4.json", bs.toByteArray());
addConvertedIg(npm, ig, version.toCode());
for (ResourceEntry e : reslist) {
npm.addFile(Category.RESOURCE, e.type + "-" + e.id + ".json", e.json);
}
for (String k : files.keySet()) {
if (k.endsWith(".png") || k.endsWith(".css") || k.endsWith(".template") || k.endsWith(".zip") || k.endsWith(".gif") || k.equals("spec.internals") || k.equals("mappingSpaces.details"))
npm.addFile(Category.OTHER, k, files.get(k));
}
for (String fn : new File(folder).list()) {
if (fn.endsWith(".schema.json") || fn.endsWith(".openapi.json")) {
byte[] b = TextFile.fileToBytes(Utilities.path(folder, fn));
npm.addFile(Category.OPENAPI, fn, b);
}
if (fn.endsWith(".xsd") || fn.endsWith(".sch")) {
byte[] b = TextFile.fileToBytes(Utilities.path(folder, fn));
npm.addFile(Category.SCHEMATRON, fn, b);
}
}
npm.finish();
System.out.println(" .. Built");
System.out.println(" .. Building NPM Package (xml)");
ig.setId("fhir-xml");
ig.setUrl("http://hl7.org/fhir/ImplementationGuide/fhir-xml");
ig.setTitle("FHIR Core package (XML Conformance files)");
ig.setDescription("FHIR Core package - the NPM package that contains all the definitions for the base FHIR specification (XML)");
ig.setPackageId(pidRoot + ".corexml");
npm = new NPMPackageGenerator(Utilities.path(folder, pidRoot + ".corexml.tgz"), "http://hl7.org/fhir", url, PackageType.CORE, ig, genDate, true);
bs = new ByteArrayOutputStream();
new org.hl7.fhir.r5.formats.XmlParser().setOutputStyle(OutputStyle.NORMAL).compose(bs, ig);
npm.addFile(Category.RESOURCE, "ig-r4.json", bs.toByteArray());
addConvertedIgX(npm, ig, version.toCode());
for (ResourceEntry e : reslist) {
if (e.xml != null)
npm.addFile(Category.RESOURCE, e.type + "-" + e.id + ".xml", e.xml);
}
npm.finish();
System.out.println(" .. Built");
}
use of org.hl7.fhir.r5.model.Enumerations.FHIRVersion in project kindling by HL7.
the class JsonLDGenerator method generate.
public void generate(JsonObject context, ElementDefn root, FHIRVersion version, String genDate) throws Exception {
enums.clear();
enumDefs.clear();
scanTypes(root, root);
generateType(context, root, root.getName(), root, true, context, new HashSet<String>());
for (ElementDefn e : types.keySet()) {
generateType(context, root, types.get(e), e, true, context, new HashSet<String>());
}
}
use of org.hl7.fhir.r5.model.Enumerations.FHIRVersion in project org.hl7.fhir.core by hapifhir.
the class RdfParser method composeConformance.
protected void composeConformance(Complex parent, String parentType, String name, Conformance element, int index) {
if (element == null)
return;
Complex t;
if (Utilities.noString(parentType))
t = parent;
else {
t = parent.predicate("fhir:" + parentType + '.' + name);
}
composeDomainResource(t, "Conformance", name, element, index);
if (element.hasUrlElement())
composeUri(t, "Conformance", "url", element.getUrlElement(), -1);
if (element.hasVersionElement())
composeString(t, "Conformance", "version", element.getVersionElement(), -1);
if (element.hasNameElement())
composeString(t, "Conformance", "name", element.getNameElement(), -1);
if (element.hasStatusElement())
composeEnum(t, "Conformance", "status", element.getStatusElement(), -1);
if (element.hasExperimentalElement())
composeBoolean(t, "Conformance", "experimental", element.getExperimentalElement(), -1);
if (element.hasDateElement())
composeDateTime(t, "Conformance", "date", element.getDateElement(), -1);
if (element.hasPublisherElement())
composeString(t, "Conformance", "publisher", element.getPublisherElement(), -1);
for (int i = 0; i < element.getContact().size(); i++) composeConformanceConformanceContactComponent(t, "Conformance", "contact", element.getContact().get(i), i);
if (element.hasDescriptionElement())
composeString(t, "Conformance", "description", element.getDescriptionElement(), -1);
for (int i = 0; i < element.getUseContext().size(); i++) composeCodeableConcept(t, "Conformance", "useContext", element.getUseContext().get(i), i);
if (element.hasRequirementsElement())
composeString(t, "Conformance", "requirements", element.getRequirementsElement(), -1);
if (element.hasCopyrightElement())
composeString(t, "Conformance", "copyright", element.getCopyrightElement(), -1);
if (element.hasKindElement())
composeEnum(t, "Conformance", "kind", element.getKindElement(), -1);
if (element.hasSoftware())
composeConformanceConformanceSoftwareComponent(t, "Conformance", "software", element.getSoftware(), -1);
if (element.hasImplementation())
composeConformanceConformanceImplementationComponent(t, "Conformance", "implementation", element.getImplementation(), -1);
if (element.hasFhirVersionElement())
composeId(t, "Conformance", "fhirVersion", element.getFhirVersionElement(), -1);
if (element.hasAcceptUnknownElement())
composeEnum(t, "Conformance", "acceptUnknown", element.getAcceptUnknownElement(), -1);
for (int i = 0; i < element.getFormat().size(); i++) composeCode(t, "Conformance", "format", element.getFormat().get(i), i);
for (int i = 0; i < element.getProfile().size(); i++) composeReference(t, "Conformance", "profile", element.getProfile().get(i), i);
for (int i = 0; i < element.getRest().size(); i++) composeConformanceConformanceRestComponent(t, "Conformance", "rest", element.getRest().get(i), i);
for (int i = 0; i < element.getMessaging().size(); i++) composeConformanceConformanceMessagingComponent(t, "Conformance", "messaging", element.getMessaging().get(i), i);
for (int i = 0; i < element.getDocument().size(); i++) composeConformanceConformanceDocumentComponent(t, "Conformance", "document", element.getDocument().get(i), i);
}
Aggregations