4242 "2.2.* - 9.*" })
4343public class ConditionResource2_2 extends DataDelegatingCrudResource <Condition > {
4444
45- private ConditionService conditionService = Context .getConditionService ();
45+ private ConditionService conditionService ;
46+
47+ private ConditionService getConditionService () {
48+ if (conditionService == null ) {
49+ conditionService = Context .getConditionService ();
50+ }
51+ return conditionService ;
52+ }
4653
4754 /**
4855 * @see org.openmrs.module.webservices.rest.web.resource.impl.DelegatingCrudResource#getRepresentationDescription(Representation)
@@ -180,7 +187,7 @@ public DelegatingResourceDescription getUpdatableProperties() {
180187 */
181188 @ Override
182189 public Condition getByUniqueId (String uuid ) {
183- return conditionService .getConditionByUuid (uuid );
190+ return getConditionService () .getConditionByUuid (uuid );
184191 }
185192
186193 /**
@@ -189,7 +196,7 @@ public Condition getByUniqueId(String uuid) {
189196 */
190197 @ Override
191198 protected void delete (Condition condition , String reason , RequestContext requestContext ) throws ResponseException {
192- conditionService .voidCondition (condition , reason );
199+ getConditionService () .voidCondition (condition , reason );
193200 }
194201
195202 /**
@@ -205,7 +212,7 @@ public Condition newDelegate() {
205212 */
206213 @ Override
207214 public Condition save (Condition condition ) {
208- return conditionService .saveCondition (condition );
215+ return getConditionService () .saveCondition (condition );
209216 }
210217
211218 /**
@@ -214,7 +221,7 @@ public Condition save(Condition condition) {
214221 */
215222 @ Override
216223 public void purge (Condition condition , RequestContext requestContext ) throws ResponseException {
217- conditionService .purgeCondition (condition );
224+ getConditionService () .purgeCondition (condition );
218225 }
219226
220227 /**
@@ -237,7 +244,6 @@ public String getDisplayString(Condition condition) {
237244 protected PageableResult doSearch (RequestContext context ) {
238245 String patientUuid = context .getRequest ().getParameter ("patientUuid" );
239246 String includeInactive = context .getRequest ().getParameter ("includeInactive" );
240- ConditionService conditionService = Context .getConditionService ();
241247 if (StringUtils .isBlank (patientUuid )) {
242248 return new EmptySearchResult ();
243249 }
@@ -249,13 +255,13 @@ protected PageableResult doSearch(RequestContext context) {
249255 if (StringUtils .isNotBlank (includeInactive )) {
250256 boolean isIncludeInactive = BooleanUtils .toBoolean (includeInactive );
251257 if (isIncludeInactive ) {
252- return new NeedsPaging <Condition >(conditionService .getAllConditions (patient ), context );
258+ return new NeedsPaging <Condition >(getConditionService () .getAllConditions (patient ), context );
253259 } else {
254- return new NeedsPaging <Condition >(conditionService .getActiveConditions (patient ), context );
260+ return new NeedsPaging <Condition >(getConditionService () .getActiveConditions (patient ), context );
255261 }
256262 }
257263 else {
258- return new NeedsPaging <Condition >(conditionService .getActiveConditions (patient ), context );
264+ return new NeedsPaging <Condition >(getConditionService () .getActiveConditions (patient ), context );
259265 }
260266 }
261267}
0 commit comments