Fix for wrong display when server returns error

This commit is contained in:
Grahame Grieve 2023-05-08 07:09:32 -05:00
parent 6232c54f15
commit 491b5ccb4a
5 changed files with 111 additions and 20 deletions

View File

@ -84,16 +84,34 @@ public class ResourceUtilities {
StringBuilder b = new StringBuilder();
for (OperationOutcomeIssueComponent t : error.getIssue())
if (t.getSeverity() == IssueSeverity.ERROR)
b.append("Error:" +t.getDetails()+"\r\n");
b.append("Error:" +gen(t.getDetails())+"\r\n");
else if (t.getSeverity() == IssueSeverity.FATAL)
b.append("Fatal:" +t.getDetails()+"\r\n");
b.append("Fatal:" +gen(t.getDetails())+"\r\n");
else if (t.getSeverity() == IssueSeverity.WARNING)
b.append("Warning:" +t.getDetails()+"\r\n");
b.append("Warning:" +gen(t.getDetails())+"\r\n");
else if (t.getSeverity() == IssueSeverity.INFORMATION)
b.append("Information:" +t.getDetails()+"\r\n");
b.append("Information:" +gen(t.getDetails())+"\r\n");
return b.toString();
}
private static String gen(CodeableConcept details) {
if (details.hasText()) {
return details.getText();
}
for (Coding c : details.getCoding()) {
if (c.hasDisplay()) {
return c.getDisplay();
}
}
for (Coding c : details.getCoding()) {
if (c.hasCode()) {
return c.getCode();
}
}
return "(no details supplied)";
}
public static Resource getById(Bundle feed, ResourceType type, String reference) {
for (BundleEntryComponent item : feed.getEntry()) {
if (item.getResource().getId().equals(reference) && item.getResource().getResourceType() == type)

View File

@ -85,16 +85,34 @@ public class ResourceUtilities {
StringBuilder b = new StringBuilder();
for (OperationOutcomeIssueComponent t : error.getIssue())
if (t.getSeverity() == IssueSeverity.ERROR)
b.append("Error:" +t.getDetails()+"\r\n");
b.append("Error:" +gen(t.getDetails())+"\r\n");
else if (t.getSeverity() == IssueSeverity.FATAL)
b.append("Fatal:" +t.getDetails()+"\r\n");
b.append("Fatal:" +gen(t.getDetails())+"\r\n");
else if (t.getSeverity() == IssueSeverity.WARNING)
b.append("Warning:" +t.getDetails()+"\r\n");
b.append("Warning:" +gen(t.getDetails())+"\r\n");
else if (t.getSeverity() == IssueSeverity.INFORMATION)
b.append("Information:" +t.getDetails()+"\r\n");
b.append("Information:" +gen(t.getDetails())+"\r\n");
return b.toString();
}
private static String gen(CodeableConcept details) {
if (details.hasText()) {
return details.getText();
}
for (Coding c : details.getCoding()) {
if (c.hasDisplay()) {
return c.getDisplay();
}
}
for (Coding c : details.getCoding()) {
if (c.hasCode()) {
return c.getCode();
}
}
return "(no details supplied)";
}
public static Resource getById(Bundle feed, ResourceType type, String reference) {
for (BundleEntryComponent item : feed.getEntry()) {
if (item.getResource().getId().equals(reference) && item.getResource().getResourceType() == type)

View File

@ -78,16 +78,34 @@ public class ResourceUtilities {
StringBuilder b = new StringBuilder();
for (OperationOutcomeIssueComponent t : error.getIssue())
if (t.getSeverity() == IssueSeverity.ERROR)
b.append("Error:" +t.getDetails()+"\r\n");
b.append("Error:" + gen(t.getDetails())+"\r\n");
else if (t.getSeverity() == IssueSeverity.FATAL)
b.append("Fatal:" +t.getDetails()+"\r\n");
b.append("Fatal:"+gen(t.getDetails())+"\r\n");
else if (t.getSeverity() == IssueSeverity.WARNING)
b.append("Warning:" +t.getDetails()+"\r\n");
b.append("Warning:" +gen(t.getDetails())+"\r\n");
else if (t.getSeverity() == IssueSeverity.INFORMATION)
b.append("Information:" +t.getDetails()+"\r\n");
b.append("Information:" +gen(t.getDetails())+"\r\n");
return b.toString();
}
private static String gen(CodeableConcept details) {
if (details.hasText()) {
return details.getText();
}
for (Coding c : details.getCoding()) {
if (c.hasDisplay()) {
return c.getDisplay();
}
}
for (Coding c : details.getCoding()) {
if (c.hasCode()) {
return c.getCode();
}
}
return "(no details supplied)";
}
public static Resource getById(Bundle feed, ResourceType type, String reference) {
for (BundleEntryComponent item : feed.getEntry()) {
if (item.getResource().getId().equals(reference) && item.getResource().getResourceType() == type)

View File

@ -79,18 +79,36 @@ public class ResourceUtilities {
StringBuilder b = new StringBuilder();
for (OperationOutcomeIssueComponent t : error.getIssue()) {
if (t.getSeverity() == IssueSeverity.ERROR) {
b.append("Error:" +t.getDetails()+"\r\n");
b.append("Error:" +gen(t.getDetails())+"\r\n");
} else if (t.getSeverity() == IssueSeverity.FATAL) {
b.append("Fatal:" +t.getDetails()+"\r\n");
b.append("Fatal:" +gen(t.getDetails())+"\r\n");
} else if (t.getSeverity() == IssueSeverity.WARNING) {
b.append("Warning:" +t.getDetails()+"\r\n");
b.append("Warning:" +gen(t.getDetails())+"\r\n");
} else if (t.getSeverity() == IssueSeverity.INFORMATION) {
b.append("Information:" +t.getDetails()+"\r\n");
b.append("Information:" +gen(t.getDetails())+"\r\n");
}
}
return b.toString();
}
private static String gen(CodeableConcept details) {
if (details.hasText()) {
return details.getText();
}
for (Coding c : details.getCoding()) {
if (c.hasDisplay()) {
return c.getDisplay();
}
}
for (Coding c : details.getCoding()) {
if (c.hasCode()) {
return c.getCode();
}
}
return "(no details supplied)";
}
public static Resource getById(Bundle feed, ResourceType type, String reference) {
for (BundleEntryComponent item : feed.getEntry()) {
if (item.getResource().getId().equals(reference) && item.getResource().getResourceType() == type)

View File

@ -34,6 +34,7 @@ import java.util.List;
import java.util.Locale;
import java.util.Set;
import org.hl7.fhir.r5.model.Coding;
import org.hl7.fhir.r5.model.Base;
import org.hl7.fhir.r5.model.Bundle;
import org.hl7.fhir.r5.model.Bundle.BundleEntryComponent;
@ -78,18 +79,36 @@ public class ResourceUtilities {
StringBuilder b = new StringBuilder();
for (OperationOutcomeIssueComponent t : error.getIssue()) {
if (t.getSeverity() == IssueSeverity.ERROR) {
b.append("Error:" +t.getDetails()+"\r\n");
b.append("Error:" +gen(t.getDetails())+"\r\n");
} else if (t.getSeverity() == IssueSeverity.FATAL) {
b.append("Fatal:" +t.getDetails()+"\r\n");
b.append("Fatal:" +gen(t.getDetails())+"\r\n");
} else if (t.getSeverity() == IssueSeverity.WARNING) {
b.append("Warning:" +t.getDetails()+"\r\n");
b.append("Warning:" +gen(t.getDetails())+"\r\n");
} else if (t.getSeverity() == IssueSeverity.INFORMATION) {
b.append("Information:" +t.getDetails()+"\r\n");
b.append("Information:" +gen(t.getDetails())+"\r\n");
}
}
return b.toString();
}
private static String gen(CodeableConcept details) {
if (details.hasText()) {
return details.getText();
}
for (Coding c : details.getCoding()) {
if (c.hasDisplay()) {
return c.getDisplay();
}
}
for (Coding c : details.getCoding()) {
if (c.hasCode()) {
return c.getCode();
}
}
return "(no details supplied)";
}
public static Resource getById(Bundle feed, ResourceType type, String reference) {
for (BundleEntryComponent item : feed.getEntry()) {
if (item.getResource().getId().equals(reference) && item.getResource().getResourceType() == type)