Skip to content

Commit 611ef31

Browse files
authored
Merge pull request #212 from slubwama/U4X-1030
U4X-1030: Fix duplicate numberOfResourcesInBundle while creating a sync fhir profile
2 parents b22aebd + e863106 commit 611ef31

1 file changed

Lines changed: 125 additions & 74 deletions

File tree

omod/src/main/java/org/openmrs/module/ugandaemrsync/web/resource/SyncFhirProfileResource.java

Lines changed: 125 additions & 74 deletions
Original file line numberDiff line numberDiff line change
@@ -106,7 +106,6 @@ public DelegatingResourceDescription getRepresentationDescription(Representation
106106
description.addProperty("urlUserName");
107107
description.addProperty("urlPassword");
108108
description.addProperty("syncDataEverSince");
109-
description.addProperty("isCaseBasedProfile");
110109
description.addProperty("dataToSyncStartDate");
111110
description.addProperty("searchable");
112111
description.addProperty("searchURL");
@@ -125,26 +124,24 @@ public DelegatingResourceDescription getRepresentationDescription(Representation
125124
description.addProperty("isCaseBasedProfile");
126125
description.addProperty("caseBasedPrimaryResourceType");
127126
description.addProperty("caseBasedPrimaryResourceTypeId");
128-
description.addProperty("caseBasedPrimaryResourceType");
129127
description.addProperty("resourceSearchParameter");
130128
description.addProperty("conceptSource", Representation.REF);
131-
description.addProperty("url");
132129
description.addProperty("syncLimit");
130+
description.addProperty("url");
133131
description.addProperty("urlToken");
134132
description.addProperty("urlUserName");
135133
description.addProperty("urlPassword");
134+
description.addProperty("syncDataEverSince");
135+
description.addProperty("dataToSyncStartDate");
136+
description.addProperty("searchable");
137+
description.addProperty("searchURL");
136138
description.addProperty("creator", Representation.REF);
137139
description.addProperty("dateCreated");
138140
description.addProperty("changedBy", Representation.REF);
139141
description.addProperty("dateChanged");
140142
description.addProperty("voidedBy", Representation.REF);
141143
description.addProperty("dateVoided");
142144
description.addProperty("voidReason");
143-
description.addProperty("syncDataEverSince");
144-
description.addProperty("isCaseBasedProfile");
145-
description.addProperty("dataToSyncStartDate");
146-
description.addProperty("searchable");
147-
description.addProperty("searchURL");
148145
description.addSelfLink();
149146
description.addLink("full", ".?v=" + RestConstants.REPRESENTATION_FULL);
150147
return description;
@@ -169,7 +166,6 @@ public DelegatingResourceDescription getRepresentationDescription(Representation
169166
description.addProperty("urlUserName");
170167
description.addProperty("urlPassword");
171168
description.addProperty("syncDataEverSince");
172-
description.addProperty("isCaseBasedProfile");
173169
description.addProperty("dataToSyncStartDate");
174170
description.addProperty("searchable");
175171
description.addProperty("searchURL");
@@ -197,7 +193,7 @@ public DelegatingResourceDescription getCreatableProperties() throws ResourceDoe
197193
description.addProperty("profileEnabled");
198194
description.addProperty("patientIdentifierType");
199195
description.addProperty("numberOfResourcesInBundle");
200-
description.addProperty("numberOfResourcesInBundle");
196+
description.addProperty("durationToKeepSyncedResources");
201197
description.addProperty("generateBundle");
202198
description.addProperty("isCaseBasedProfile");
203199
description.addProperty("caseBasedPrimaryResourceType");
@@ -210,14 +206,47 @@ public DelegatingResourceDescription getCreatableProperties() throws ResourceDoe
210206
description.addProperty("urlUserName");
211207
description.addProperty("urlPassword");
212208
description.addProperty("syncDataEverSince");
213-
description.addProperty("isCaseBasedProfile");
214209
description.addProperty("dataToSyncStartDate");
215210
description.addProperty("searchable");
216211
description.addProperty("searchURL");
217212

218213
return description;
219214
}
220215

216+
@Override
217+
public DelegatingResourceDescription getUpdatableProperties() throws ResourceDoesNotSupportOperationException {
218+
DelegatingResourceDescription description = new DelegatingResourceDescription();
219+
description.addProperty("name");
220+
description.addProperty("resourceTypes");
221+
description.addProperty("profileEnabled");
222+
description.addProperty("patientIdentifierType");
223+
description.addProperty("numberOfResourcesInBundle");
224+
description.addProperty("durationToKeepSyncedResources");
225+
description.addProperty("generateBundle");
226+
description.addProperty("isCaseBasedProfile");
227+
description.addProperty("caseBasedPrimaryResourceType");
228+
description.addProperty("caseBasedPrimaryResourceTypeId");
229+
description.addProperty("resourceSearchParameter");
230+
description.addProperty("conceptSource");
231+
description.addProperty("syncLimit");
232+
description.addProperty("url");
233+
description.addProperty("urlToken");
234+
description.addProperty("urlUserName");
235+
description.addProperty("urlPassword");
236+
description.addProperty("syncDataEverSince");
237+
description.addProperty("dataToSyncStartDate");
238+
description.addProperty("searchable");
239+
description.addProperty("searchURL");
240+
description.addProperty("dateChanged");
241+
description.addProperty("changedBy");
242+
description.addProperty("dateVoided");
243+
description.addProperty("voidReason");
244+
description.addProperty("voidedBy");
245+
return description;
246+
}
247+
248+
249+
221250
@Override
222251
protected PageableResult doSearch(RequestContext context) {
223252
UgandaEMRSyncService ugandaEMRSyncService = Context.getService(UgandaEMRSyncService.class);
@@ -237,36 +266,40 @@ public Model getGETModel(Representation rep) {
237266
ModelImpl model = (ModelImpl) super.getGETModel(rep);
238267
if (rep instanceof DefaultRepresentation || rep instanceof FullRepresentation) {
239268
model.property("uuid", new StringProperty())
240-
.property("name", new StringProperty())
241-
.property("resourceTypes", new StringProperty())
269+
.property("name", new StringProperty())
270+
.property("resourceTypes", new StringProperty())
242271
.property("profileEnabled", new BooleanProperty())
243-
.property("patientIdentifierType", new StringProperty())
244272
.property("numberOfResourcesInBundle", new IntegerProperty())
245-
.property("durationToKeepSyncedResources", new IntegerProperty())
273+
.property("durationToKeepSyncedResources", new IntegerProperty())
246274
.property("generateBundle", new BooleanProperty())
247-
.property("dataToSyncStartDate", new DateProperty())
248275
.property("isCaseBasedProfile", new BooleanProperty())
249-
.property("syncDataEverSince", new BooleanProperty())
250-
.property("isCaseBasedProfile", new BooleanProperty())
251276
.property("caseBasedPrimaryResourceType", new StringProperty())
252-
.property("caseBasedPrimaryResourceTypeId", new StringProperty())
277+
.property("caseBasedPrimaryResourceTypeId", new StringProperty())
253278
.property("resourceSearchParameter", new StringProperty())
279+
.property("syncLimit", new StringProperty())
280+
.property("url", new StringProperty())
281+
.property("urlToken", new StringProperty())
282+
.property("urlUserName", new StringProperty())
283+
.property("urlPassword", new StringProperty())
284+
.property("syncDataEverSince", new BooleanProperty())
285+
.property("dataToSyncStartDate", new DateProperty())
254286
.property("searchable", new BooleanProperty())
255-
.property("searchURL", new StringProperty());
287+
.property("searchURL", new StringProperty())
288+
.property("patientIdentifierType", new RefProperty("#/definitions/PatientIdentifierTypeGetRef"))
289+
.property("conceptSource", new RefProperty("#/definitions/ConceptGetRef"));
256290
}
257291
if (rep instanceof DefaultRepresentation) {
258-
model.property("patientIdentifierType", new RefProperty("#/definitions/PatientIdentifierTypeGetRef"))
259-
.property("conceptSource", new RefProperty("#/definitions/ConceptGetRef"))
260-
.property("creator", new RefProperty("#/definitions/UserGetRef"))
261-
.property("changedBy", new RefProperty("#/definitions/UserGetRef"))
262-
.property("voidedBy", new RefProperty("#/definitions/UserGetRef"));
263-
292+
model.property("dateChanged", new DateProperty())
293+
.property("dateVoided", new DateProperty())
294+
.property("creator", new RefProperty("#/definitions/UserGetRef"))
295+
.property("changedBy", new RefProperty("#/definitions/UserGetRef"))
296+
.property("voidedBy", new RefProperty("#/definitions/UserGetRef"));
264297
} else if (rep instanceof FullRepresentation) {
265-
model.property("patientIdentifierType", new RefProperty("#/definitions/PatientIdentifierTypeGetRef"))
266-
.property("conceptSource", new RefProperty("#/definitions/ConceptGetRef"))
267-
.property("creator", new RefProperty("#/definitions/UserGetRef"))
268-
.property("changedBy", new RefProperty("#/definitions/UserGetRef"))
269-
.property("voidedBy", new RefProperty("#/definitions/UserGetRef"));
298+
model.property("dateChanged", new DateProperty())
299+
.property("dateVoided", new DateProperty())
300+
.property("creator", new RefProperty("#/definitions/UserGetRef"))
301+
.property("changedBy", new RefProperty("#/definitions/UserGetRef"))
302+
.property("voidedBy", new RefProperty("#/definitions/UserGetRef"));
270303
}
271304
return model;
272305
}
@@ -275,66 +308,84 @@ public Model getGETModel(Representation rep) {
275308
public Model getCREATEModel(Representation rep) {
276309
ModelImpl model = (ModelImpl) super.getGETModel(rep);
277310
if (rep instanceof DefaultRepresentation || rep instanceof FullRepresentation) {
278-
model.property("uuid", new StringProperty())
279-
.property("name", new StringProperty())
280-
.property("resourceTypes", new StringProperty())
311+
model.property("name", new StringProperty())
312+
.property("resourceTypes", new StringProperty())
281313
.property("profileEnabled", new BooleanProperty())
282-
.property("patientIdentifierType", new StringProperty())
283314
.property("numberOfResourcesInBundle", new IntegerProperty())
284-
.property("durationToKeepSyncedResources", new IntegerProperty())
315+
.property("durationToKeepSyncedResources", new IntegerProperty())
285316
.property("generateBundle", new BooleanProperty())
286-
.property("isCaseBasedProfile", new BooleanProperty())
287-
.property("syncDataEverSince", new BooleanProperty())
288-
.property("dataToSyncStartDate", new DateProperty())
289-
.property("isCaseBasedProfile", new BooleanProperty())
317+
.property("isCaseBasedProfile", new BooleanProperty())
290318
.property("caseBasedPrimaryResourceType", new StringProperty())
291-
.property("caseBasedPrimaryResourceTypeId", new StringProperty())
319+
.property("caseBasedPrimaryResourceTypeId", new StringProperty())
292320
.property("resourceSearchParameter", new StringProperty())
321+
.property("syncLimit", new StringProperty())
322+
.property("url", new StringProperty())
323+
.property("urlToken", new StringProperty())
324+
.property("urlUserName", new StringProperty())
325+
.property("urlPassword", new StringProperty())
326+
.property("syncDataEverSince", new BooleanProperty())
327+
.property("dataToSyncStartDate", new DateProperty())
293328
.property("searchable", new BooleanProperty())
294-
.property("searchURL", new StringProperty());
295-
329+
.property("searchURL", new StringProperty())
330+
.property("patientIdentifierType", new RefProperty("#/definitions/PatientIdentifierTypeGetRef"))
331+
.property("conceptSource", new RefProperty("#/definitions/ConceptGetRef"));
296332
}
297333
if (rep instanceof DefaultRepresentation) {
298-
model.property("patientIdentifierType", new RefProperty("#/definitions/PatientIdentifierTypeGetRef"))
299-
.property("conceptSource", new RefProperty("#/definitions/ConceptGetRef"))
300-
.property("creator", new RefProperty("#/definitions/UserGetRef"))
334+
model.property("dateChanged", new DateProperty())
335+
.property("dateVoided", new DateProperty())
336+
.property("creator", new RefProperty("#/definitions/UserGetRef"))
301337
.property("changedBy", new RefProperty("#/definitions/UserGetRef"))
302338
.property("voidedBy", new RefProperty("#/definitions/UserGetRef"));
303-
304339
} else if (rep instanceof FullRepresentation) {
305-
model.property("patientIdentifierType", new RefProperty("#/definitions/PatientIdentifierTypeGetRef"))
306-
.property("conceptSource", new RefProperty("#/definitions/ConceptGetRef"))
307-
.property("creator", new RefProperty("#/definitions/UserGetRef"))
308-
.property("changedBy", new RefProperty("#/definitions/UserGetRef"))
309-
.property("voidedBy", new RefProperty("#/definitions/UserGetRef"));
340+
model.property("dateChanged", new DateProperty())
341+
.property("dateVoided", new DateProperty())
342+
.property("creator", new RefProperty("#/definitions/UserGetRef"))
343+
.property("changedBy", new RefProperty("#/definitions/UserGetRef"))
344+
.property("voidedBy", new RefProperty("#/definitions/UserGetRef"));
310345
}
311346
return model;
312347
}
313348

314349
@Override
315350
public Model getUPDATEModel(Representation rep) {
316-
return new ModelImpl().property("uuid", new StringProperty())
317-
.property("name", new StringProperty())
318-
.property("resourceTypes", new StringProperty())
319-
.property("profileEnabled", new BooleanProperty())
320-
.property("patientIdentifierType", new StringProperty())
321-
.property("numberOfResourcesInBundle", new IntegerProperty())
322-
.property("durationToKeepSyncedResources", new IntegerProperty())
323-
.property("dataToSyncStartDate", new DateProperty())
324-
.property("generateBundle", new BooleanProperty())
325-
.property("isCaseBasedProfile", new BooleanProperty())
326-
.property("syncDataEverSince", new BooleanProperty())
327-
.property("isCaseBasedProfile", new BooleanProperty())
328-
.property("caseBasedPrimaryResourceType", new StringProperty())
329-
.property("caseBasedPrimaryResourceTypeId", new StringProperty())
330-
.property("resourceSearchParameter", new StringProperty())
331-
.property("searchable", new BooleanProperty())
332-
.property("searchURL", new StringProperty())
333-
.property("patientIdentifierType", new RefProperty("#/definitions/PatientIdentifierTypeGetRef"))
334-
.property("conceptSource", new RefProperty("#/definitions/ConceptGetRef"))
335-
.property("creator", new RefProperty("#/definitions/UserGetRef"))
336-
.property("changedBy", new RefProperty("#/definitions/UserGetRef"))
337-
.property("voidedBy", new RefProperty("#/definitions/UserGetRef"));
351+
ModelImpl model = (ModelImpl) super.getGETModel(rep);
352+
if (rep instanceof DefaultRepresentation || rep instanceof FullRepresentation) {
353+
model.property("name", new StringProperty())
354+
.property("resourceTypes", new StringProperty())
355+
.property("profileEnabled", new BooleanProperty())
356+
.property("numberOfResourcesInBundle", new IntegerProperty())
357+
.property("durationToKeepSyncedResources", new IntegerProperty())
358+
.property("generateBundle", new BooleanProperty())
359+
.property("isCaseBasedProfile", new BooleanProperty())
360+
.property("caseBasedPrimaryResourceType", new StringProperty())
361+
.property("caseBasedPrimaryResourceTypeId", new StringProperty())
362+
.property("resourceSearchParameter", new StringProperty())
363+
.property("syncLimit", new StringProperty())
364+
.property("url", new StringProperty())
365+
.property("urlToken", new StringProperty())
366+
.property("urlUserName", new StringProperty())
367+
.property("urlPassword", new StringProperty())
368+
.property("syncDataEverSince", new BooleanProperty())
369+
.property("dataToSyncStartDate", new DateProperty())
370+
.property("searchable", new BooleanProperty())
371+
.property("searchURL", new StringProperty())
372+
.property("patientIdentifierType", new RefProperty("#/definitions/PatientIdentifierTypeGetRef"))
373+
.property("conceptSource", new RefProperty("#/definitions/ConceptGetRef"));
374+
}
375+
if (rep instanceof DefaultRepresentation) {
376+
model.property("dateChanged", new DateProperty())
377+
.property("dateVoided", new DateProperty())
378+
.property("creator", new RefProperty("#/definitions/UserGetRef"))
379+
.property("changedBy", new RefProperty("#/definitions/UserGetRef"))
380+
.property("voidedBy", new RefProperty("#/definitions/UserGetRef"));
381+
} else if (rep instanceof FullRepresentation) {
382+
model.property("dateChanged", new DateProperty())
383+
.property("dateVoided", new DateProperty())
384+
.property("creator", new RefProperty("#/definitions/UserGetRef"))
385+
.property("changedBy", new RefProperty("#/definitions/UserGetRef"))
386+
.property("voidedBy", new RefProperty("#/definitions/UserGetRef"));
387+
}
388+
return model;
338389
}
339390

340391
private String processResourceSearchParameter(String resourceSearchParameter){

0 commit comments

Comments
 (0)