001/*- 002 * #%L 003 * Smile CDR - CDR 004 * %% 005 * Copyright (C) 2016 - 2024 Smile CDR, Inc. 006 * %% 007 * All rights reserved. 008 * #L% 009 */ 010package ca.cdr.api.fhirgw.json; 011 012import ca.cdr.api.model.json.IModelJson; 013import ca.uhn.fhir.model.api.annotation.ExampleSupplier; 014import com.fasterxml.jackson.annotation.JsonProperty; 015import io.swagger.v3.oas.annotations.media.Schema; 016 017import java.util.ArrayList; 018import java.util.List; 019import java.util.function.Supplier; 020 021@Schema( 022 name = "GatewayConfiguration", 023 description = 024 "This is the outer document element containing configuration for the Smile CDR FHIR Gateway module.") 025@ExampleSupplier(GatewayConfigurationJson.ExampleSupplier.class) 026public class GatewayConfigurationJson implements IModelJson { 027 028 @JsonProperty("targets") 029 private List<GatewayTargetJson> myTargets; 030 031 @JsonProperty("searchRoutes") 032 private List<GatewaySearchRouteJson> mySearchRoutes; 033 034 @JsonProperty("readRoutes") 035 private List<GatewayReadRouteJson> myReadRoutes; 036 037 @JsonProperty("operationRoutes") 038 private List<GatewayOperationRouteJson> myOperationRoutes; 039 040 @JsonProperty("updateRoutes") 041 private List<GatewayUpdateRouteJson> myUpdateRoutes; 042 043 @JsonProperty("createRoutes") 044 private List<GatewayCreateRouteJson> myCreateRoutes; 045 046 @JsonProperty("deleteRoutes") 047 private List<GatewayDeleteRouteJson> myDeleteRoutes; 048 049 @JsonProperty("transactionRoutes") 050 private List<GatewayTransactionRouteJson> myTransactionRoutes; 051 052 public List<GatewayTargetJson> getTargets() { 053 if (myTargets == null) { 054 myTargets = new ArrayList<>(); 055 } 056 return myTargets; 057 } 058 059 public void setTargets(List<GatewayTargetJson> theTargets) { 060 myTargets = theTargets; 061 } 062 063 public List<GatewayReadRouteJson> getReadRoutes() { 064 if (myReadRoutes == null) { 065 myReadRoutes = new ArrayList<>(); 066 } 067 return myReadRoutes; 068 } 069 070 public void setReadRoutes(List<GatewayReadRouteJson> theReadRoutes) { 071 myReadRoutes = theReadRoutes; 072 } 073 074 public List<GatewaySearchRouteJson> getSearchRoutes() { 075 if (mySearchRoutes == null) { 076 mySearchRoutes = new ArrayList<>(); 077 } 078 return mySearchRoutes; 079 } 080 081 public void setSearchRoutes(List<GatewaySearchRouteJson> theSearchRoutes) { 082 mySearchRoutes = theSearchRoutes; 083 } 084 085 public GatewayTargetJson addTarget() { 086 GatewayTargetJson retVal = new GatewayTargetJson(); 087 getTargets().add(retVal); 088 return retVal; 089 } 090 091 public List<GatewayOperationRouteJson> getOperationRoutes() { 092 if (myOperationRoutes == null) { 093 myOperationRoutes = new ArrayList<>(); 094 } 095 return myOperationRoutes; 096 } 097 098 public void setOperationRoutes(List<GatewayOperationRouteJson> theOperationRoutes) { 099 myOperationRoutes = theOperationRoutes; 100 } 101 102 public List<GatewayUpdateRouteJson> getUpdateRoutes() { 103 if (myUpdateRoutes == null) { 104 myUpdateRoutes = new ArrayList<>(); 105 } 106 return myUpdateRoutes; 107 } 108 109 public void setUpdateRoutes(List<GatewayUpdateRouteJson> theUpdateRoutes) { 110 myUpdateRoutes = theUpdateRoutes; 111 } 112 113 public List<GatewayCreateRouteJson> getCreateRoutes() { 114 if (myCreateRoutes == null) { 115 myCreateRoutes = new ArrayList<>(); 116 } 117 return myCreateRoutes; 118 } 119 120 public void setCreateRoutes(List<GatewayCreateRouteJson> theCreateRoutes) { 121 myCreateRoutes = theCreateRoutes; 122 } 123 124 public List<GatewayDeleteRouteJson> getDeleteRoutes() { 125 if (myDeleteRoutes == null) { 126 myDeleteRoutes = new ArrayList<>(); 127 } 128 return myDeleteRoutes; 129 } 130 131 public void setDeleteRoutes(List<GatewayDeleteRouteJson> theDeleteRoutes) { 132 myDeleteRoutes = theDeleteRoutes; 133 } 134 135 public GatewayReadRouteJson addReadRoute() { 136 GatewayReadRouteJson retVal = new GatewayReadRouteJson(); 137 getReadRoutes().add(retVal); 138 return retVal; 139 } 140 141 public GatewaySearchRouteJson addSearchRoute() { 142 GatewaySearchRouteJson retVal = new GatewaySearchRouteJson(); 143 getSearchRoutes().add(retVal); 144 return retVal; 145 } 146 147 public GatewayOperationRouteJson addOperationRoute() { 148 GatewayOperationRouteJson retVal = new GatewayOperationRouteJson(); 149 getOperationRoutes().add(retVal); 150 return retVal; 151 } 152 153 public GatewayUpdateRouteJson addUpdateRoute() { 154 GatewayUpdateRouteJson retval = new GatewayUpdateRouteJson(); 155 getUpdateRoutes().add(retval); 156 return retval; 157 } 158 159 public GatewayCreateRouteJson addCreateRoute() { 160 GatewayCreateRouteJson retval = new GatewayCreateRouteJson(); 161 getCreateRoutes().add(retval); 162 return retval; 163 } 164 165 public GatewayDeleteRouteJson addDeleteRoute() { 166 GatewayDeleteRouteJson retval = new GatewayDeleteRouteJson(); 167 getDeleteRoutes().add(retval); 168 return retval; 169 } 170 171 public List<GatewayTransactionRouteJson> getTransactionRoutes() { 172 if (myTransactionRoutes == null) { 173 myTransactionRoutes = new ArrayList<>(); 174 } 175 return myTransactionRoutes; 176 } 177 178 public GatewayTransactionRouteJson addTransactionRoute() { 179 GatewayTransactionRouteJson retval = new GatewayTransactionRouteJson(); 180 getTransactionRoutes().add(retval); 181 return retval; 182 } 183 184 public void setTransactionRoutes(List<GatewayTransactionRouteJson> theTransactionRoutes) { 185 myTransactionRoutes = theTransactionRoutes; 186 } 187 188 public static class ExampleSupplier implements Supplier<GatewayConfigurationJson> { 189 @Override 190 public GatewayConfigurationJson get() { 191 GatewayConfigurationJson retVal = new GatewayConfigurationJson(); 192 retVal.addTarget().setId("target1").setResourceIdPrefix("TGT1-").setBaseUrl("http://fhir1.example.com/api"); 193 retVal.addTarget().setId("target2").setResourceIdPrefix("TGT2-").setBaseUrl("http://fhir2.example.com/api"); 194 retVal.addSearchRoute() 195 .setId("route1") 196 .setParallel(true) 197 .addResourceType("Patient") 198 .addResourceType("Observation") 199 .addResourceType("Encounter") 200 .addTarget(new GatewayRouteTargetJson().setTargetId("target1")) 201 .addTarget(new GatewayRouteTargetJson().setTargetId("target2")); 202 203 return retVal; 204 } 205 } 206}