|
12 | 12 | import org.hl7.fhir.r4.model.Task; |
13 | 13 | import org.hl7.fhir.r4.model.UrlType; |
14 | 14 |
|
15 | | -//todo: remove process and processStep + CodeSystems, make message never contain e.getMessage() becaus security |
16 | | -// ping status codesystem should extend old ping status codesystem, map every possible error to a unique name in a new codesystem |
17 | | -// that repaces process + processStep, display values should contain the exact text that is now contained in action |
18 | | -// remove equals method |
19 | | -public record ProcessError(CodeSystem.DsfPingProcesses.Code process, CodeSystem.DsfPingProcessSteps.Code processStep, |
20 | | - String action, String potentialFixUrl, String message) implements Serializable |
| 15 | +public record ProcessError(String process, CodeSystem.DsfPingError.Concept concept, String potentialFixUrl) |
| 16 | + implements Serializable |
21 | 17 | { |
22 | 18 | public static Extension toExtension(ProcessError error) |
23 | 19 | { |
24 | 20 | Objects.requireNonNull(error); |
25 | | - Objects.requireNonNull(error.action()); |
| 21 | + Objects.requireNonNull(error.concept()); |
26 | 22 | Objects.requireNonNull(error.process()); |
27 | | - Objects.requireNonNull(error.message()); |
28 | | - Objects.requireNonNull(error.processStep()); |
29 | 23 |
|
30 | 24 | Extension extension = new Extension(); |
31 | 25 | extension.setUrl(ConstantsPing.STRUCTURE_DEFINITION_URL_EXTENSION_ERROR); |
32 | 26 |
|
33 | | - extension.addExtension().setUrl(ConstantsPing.EXTENSION_URL_PROCESS) |
34 | | - .setValue(new Coding(CodeSystem.DsfPingProcesses.URL, error.process().getValue(), null)); |
35 | | - extension.addExtension().setUrl(ConstantsPing.EXTENSION_URL_PROCESS_STEP) |
36 | | - .setValue(new Coding(CodeSystem.DsfPingProcessSteps.URL, error.process().getValue(), null)); |
37 | | - extension.addExtension().setUrl(ConstantsPing.EXTENSION_URL_ACTION).setValue(new StringType(error.action())); |
| 27 | + extension.addExtension().setUrl(ConstantsPing.EXTENSION_URL_ERROR) |
| 28 | + .setValue(new Coding().setSystem(CodeSystem.DsfPingError.URL).setCode(error.concept.getCode()) |
| 29 | + .setDisplay(error.concept.getDisplay())); |
38 | 30 | if (Objects.nonNull(error.potentialFixUrl)) |
39 | 31 | { |
40 | 32 | extension.addExtension().setUrl(ConstantsPing.EXTENSION_URL_POTENTIAL_FIX) |
41 | 33 | .setValue(new UrlType(error.potentialFixUrl())); |
42 | 34 | } |
43 | | - extension.addExtension().setUrl(ConstantsPing.EXTENSION_URL_MESSAGE).setValue(new StringType(error.message())); |
44 | 35 |
|
45 | 36 | return extension; |
46 | 37 | } |
47 | 38 |
|
48 | | - public static ProcessError toError(Extension extension) |
| 39 | + public static ProcessError toError(Extension extension, String process) |
49 | 40 | { |
50 | | - Extension processExtension = extension.getExtensionByUrl(ConstantsPing.EXTENSION_URL_PROCESS); |
51 | | - Objects.requireNonNull(processExtension); |
52 | | - String process = ((Coding) processExtension.getValue()).getCode(); |
53 | | - |
54 | | - |
55 | | - Extension processStepExtension = extension.getExtensionByUrl(ConstantsPing.EXTENSION_URL_PROCESS_STEP); |
56 | | - Objects.requireNonNull(processStepExtension); |
57 | | - String processStep = ((Coding) processStepExtension.getValue()).getCode(); |
58 | | - |
59 | | - Extension actionExtension = extension.getExtensionByUrl(ConstantsPing.EXTENSION_URL_ACTION); |
60 | | - Objects.requireNonNull(actionExtension); |
61 | | - String action = ((StringType) actionExtension.getValue()).getValue(); |
| 41 | + Extension errorExtension = extension.getExtensionByUrl(ConstantsPing.EXTENSION_URL_ERROR); |
| 42 | + Objects.requireNonNull(errorExtension); |
| 43 | + CodeSystem.DsfPingError.Concept error = CodeSystem.DsfPingError.Concept |
| 44 | + .fromCode(((Coding) errorExtension.getValue()).getCode()); |
62 | 45 |
|
63 | 46 | Extension potentalFixUrlExtension = extension.getExtensionByUrl(ConstantsPing.EXTENSION_URL_POTENTIAL_FIX); |
64 | 47 | String potentialFixUrl = Objects.nonNull(potentalFixUrlExtension) |
65 | 48 | ? ((UrlType) potentalFixUrlExtension.getValue()).getValue() |
66 | 49 | : null; |
67 | 50 |
|
68 | | - Extension messageExtension = extension.getExtensionByUrl(ConstantsPing.EXTENSION_URL_MESSAGE); |
69 | | - Objects.requireNonNull(messageExtension); |
70 | | - String message = ((StringType) messageExtension.getValue()).getValue(); |
71 | | - |
72 | | - CodeSystem.DsfPingProcesses.Code processCode = CodeSystem.DsfPingProcesses.Code.ofValue(process); |
73 | | - CodeSystem.DsfPingProcessSteps.Code stepCode = CodeSystem.DsfPingProcessSteps.Code.ofValue(processStep); |
74 | | - |
75 | | - return new ProcessError(processCode, stepCode, action, potentialFixUrl, message); |
| 51 | + return new ProcessError(process, error, potentialFixUrl); |
76 | 52 | } |
77 | 53 |
|
78 | 54 | public static List<Task.TaskOutputComponent> toTaskOutput(List<ProcessError> errors) |
|
0 commit comments