use of org.hl7.fhir.r5.model.Enumerations.FHIRVersion in project ab2d by CMSgov.
the class FhirUtils method addMbiIdsToEobs.
public static void addMbiIdsToEobs(IBaseResource eob, CoverageSummary patient, FhirVersion version) {
if (eob == null) {
return;
}
// Add extesions only if beneficiary id is present and known to memberships
Long benId = EobUtils.getPatientId(eob);
if (benId != null && patient != null) {
Identifiers identifiers = patient.getIdentifiers();
// Add each mbi to each eob
if (identifiers.getCurrentMbi() != null) {
IBase currentMbiExtension = ExtensionUtils.createMbiExtension(identifiers.getCurrentMbi(), true, version);
ExtensionUtils.addExtension(eob, currentMbiExtension, version);
}
for (String mbi : identifiers.getHistoricMbis()) {
IBase mbiExtension = ExtensionUtils.createMbiExtension(mbi, false, version);
ExtensionUtils.addExtension(eob, mbiExtension, version);
}
}
}
use of org.hl7.fhir.r5.model.Enumerations.FHIRVersion in project ab2d by CMSgov.
the class PatientClaimsProcessorImpl method writeOutResource.
@Trace(metricName = "EOBWriteToFile", dispatcher = true)
private String writeOutResource(FhirVersion version, ProgressTrackerUpdate update, List<IBaseResource> eobs, ClaimsStream stream) {
IParser parser = version.getJsonParser().setPrettyPrint(false);
if (eobs == null) {
log.debug("ignoring empty results because pulling eobs failed");
return null;
}
if (eobs.isEmpty()) {
return null;
}
int eobsWritten = 0;
int eobsError = 0;
update.incPatientsWithEobsCount();
update.addEobFetchedCount(eobs.size());
StringBuilder errorPayload = new StringBuilder();
for (IBaseResource resource : eobs) {
try {
stream.write(parser.encodeResourceToString(resource) + System.lineSeparator());
eobsWritten++;
} catch (Exception ex) {
log.warn("Encountered exception while processing job resources: {}", ex.getClass());
String errMsg = ExceptionUtils.getRootCauseMessage(ex);
IBaseResource operationOutcome = version.getErrorOutcome(errMsg);
errorPayload.append(parser.encodeResourceToString(operationOutcome)).append(System.lineSeparator());
eobsError++;
}
}
update.addEobProcessedCount(eobsWritten);
if (eobsError != 0) {
return errorPayload.toString();
}
return errorPayload.toString();
}
use of org.hl7.fhir.r5.model.Enumerations.FHIRVersion in project org.hl7.fhir.core by hapifhir.
the class ExtensionDefinitionGenerator method loadSource.
private List<StructureDefinition> loadSource() throws IOException, FHIRException {
List<StructureDefinition> list = new ArrayList<>();
FilesystemPackageCacheManager pcm = new FilesystemPackageCacheManager(true, ToolsVersion.TOOLS_VERSION);
NpmPackage npm = pcm.loadPackage("hl7.fhir.core", sourceVersion.toCode());
if (sourceVersion == FHIRVersion._4_0_0)
context = SimpleWorkerContext.fromPackage(npm);
else if (sourceVersion == FHIRVersion._3_0_1)
context = SimpleWorkerContext.fromPackage(npm, new R3ToR4Loader());
else if (sourceVersion == FHIRVersion._1_4_0)
context = SimpleWorkerContext.fromPackage(npm, new R2016MayToR4Loader());
else if (sourceVersion == FHIRVersion._1_0_2)
context = SimpleWorkerContext.fromPackage(npm, new R2ToR4Loader());
pu = new ProfileUtilities(context, null, null);
for (String fn : npm.listResources("StructureDefinition")) {
list.add((StructureDefinition) loadResource(npm.load("package", fn), sourceVersion));
}
for (StructureDefinition sd : list) if (sd.getName().equals("Extension")) {
extbase = sd;
extv = extbase.getSnapshot().getElement().get(extbase.getSnapshot().getElement().size() - 1);
}
return list;
}
use of org.hl7.fhir.r5.model.Enumerations.FHIRVersion in project org.hl7.fhir.core by hapifhir.
the class ExtensionDefinitionGenerator method loadResource.
private Resource loadResource(InputStream inputStream, FHIRVersion v) throws IOException, FHIRException {
if (v == FHIRVersion._3_0_1) {
org.hl7.fhir.dstu3.model.Resource res = new org.hl7.fhir.dstu3.formats.JsonParser().parse(inputStream);
return VersionConvertorFactory_30_40.convertResource(res, new BaseAdvisor_30_40(false));
} else if (v == FHIRVersion._1_4_0) {
org.hl7.fhir.dstu2016may.model.Resource res = new org.hl7.fhir.dstu2016may.formats.JsonParser().parse(inputStream);
return VersionConvertorFactory_14_40.convertResource(res);
} else if (v == FHIRVersion._1_0_2) {
org.hl7.fhir.dstu2.model.Resource res = new org.hl7.fhir.dstu2.formats.JsonParser().parse(inputStream);
BaseAdvisor_10_40 advisor = new IGR2ConvertorAdvisor();
return VersionConvertorFactory_10_40.convertResource(res, advisor);
} else if (v == FHIRVersion._4_0_0) {
return new JsonParser().parse(inputStream);
} else
throw new Error("Unsupported version " + v);
}
use of org.hl7.fhir.r5.model.Enumerations.FHIRVersion in project org.hl7.fhir.core by hapifhir.
the class RdfParser method composeCapabilityStatement.
protected void composeCapabilityStatement(Complex parent, String parentType, String name, CapabilityStatement element, int index) {
if (element == null)
return;
Complex t;
if (Utilities.noString(parentType))
t = parent;
else {
t = parent.predicate("fhir:" + parentType + '.' + name);
}
composeDomainResource(t, "CapabilityStatement", name, element, index);
if (element.hasUrlElement())
composeUri(t, "CapabilityStatement", "url", element.getUrlElement(), -1);
if (element.hasVersionElement())
composeString(t, "CapabilityStatement", "version", element.getVersionElement(), -1);
if (element.hasNameElement())
composeString(t, "CapabilityStatement", "name", element.getNameElement(), -1);
if (element.hasTitleElement())
composeString(t, "CapabilityStatement", "title", element.getTitleElement(), -1);
if (element.hasStatusElement())
composeEnum(t, "CapabilityStatement", "status", element.getStatusElement(), -1);
if (element.hasExperimentalElement())
composeBoolean(t, "CapabilityStatement", "experimental", element.getExperimentalElement(), -1);
if (element.hasDateElement())
composeDateTime(t, "CapabilityStatement", "date", element.getDateElement(), -1);
if (element.hasPublisherElement())
composeString(t, "CapabilityStatement", "publisher", element.getPublisherElement(), -1);
for (int i = 0; i < element.getContact().size(); i++) composeContactDetail(t, "CapabilityStatement", "contact", element.getContact().get(i), i);
if (element.hasDescriptionElement())
composeMarkdown(t, "CapabilityStatement", "description", element.getDescriptionElement(), -1);
for (int i = 0; i < element.getUseContext().size(); i++) composeUsageContext(t, "CapabilityStatement", "useContext", element.getUseContext().get(i), i);
for (int i = 0; i < element.getJurisdiction().size(); i++) composeCodeableConcept(t, "CapabilityStatement", "jurisdiction", element.getJurisdiction().get(i), i);
if (element.hasPurposeElement())
composeMarkdown(t, "CapabilityStatement", "purpose", element.getPurposeElement(), -1);
if (element.hasCopyrightElement())
composeMarkdown(t, "CapabilityStatement", "copyright", element.getCopyrightElement(), -1);
if (element.hasKindElement())
composeEnum(t, "CapabilityStatement", "kind", element.getKindElement(), -1);
for (int i = 0; i < element.getInstantiates().size(); i++) composeUri(t, "CapabilityStatement", "instantiates", element.getInstantiates().get(i), i);
if (element.hasSoftware())
composeCapabilityStatementCapabilityStatementSoftwareComponent(t, "CapabilityStatement", "software", element.getSoftware(), -1);
if (element.hasImplementation())
composeCapabilityStatementCapabilityStatementImplementationComponent(t, "CapabilityStatement", "implementation", element.getImplementation(), -1);
if (element.hasFhirVersionElement())
composeId(t, "CapabilityStatement", "fhirVersion", element.getFhirVersionElement(), -1);
if (element.hasAcceptUnknownElement())
composeEnum(t, "CapabilityStatement", "acceptUnknown", element.getAcceptUnknownElement(), -1);
for (int i = 0; i < element.getFormat().size(); i++) composeCode(t, "CapabilityStatement", "format", element.getFormat().get(i), i);
for (int i = 0; i < element.getPatchFormat().size(); i++) composeCode(t, "CapabilityStatement", "patchFormat", element.getPatchFormat().get(i), i);
for (int i = 0; i < element.getImplementationGuide().size(); i++) composeUri(t, "CapabilityStatement", "implementationGuide", element.getImplementationGuide().get(i), i);
for (int i = 0; i < element.getProfile().size(); i++) composeReference(t, "CapabilityStatement", "profile", element.getProfile().get(i), i);
for (int i = 0; i < element.getRest().size(); i++) composeCapabilityStatementCapabilityStatementRestComponent(t, "CapabilityStatement", "rest", element.getRest().get(i), i);
for (int i = 0; i < element.getMessaging().size(); i++) composeCapabilityStatementCapabilityStatementMessagingComponent(t, "CapabilityStatement", "messaging", element.getMessaging().get(i), i);
for (int i = 0; i < element.getDocument().size(); i++) composeCapabilityStatementCapabilityStatementDocumentComponent(t, "CapabilityStatement", "document", element.getDocument().get(i), i);
}
Aggregations