Skip to content

Commit

Permalink
Add support to get price by conceptuuid
Browse files Browse the repository at this point in the history
  • Loading branch information
josephatJ committed Aug 5, 2024
1 parent 4ffcdcc commit 02b2602
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 8 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -70,7 +70,7 @@ public interface ICareService extends OpenmrsService {

ItemPrice getItemPriceByConceptId(Integer serviceConceptId, Integer paymentSchemeConceptId, Integer paymentTypeConceptId);

ItemPrice getItemPrice(Visit visit, Concept concept) throws Exception;
ItemPrice getItemPrice(Visit visit, Concept concept) throws ItemNotPayableException, ConfigurationException;

ItemPrice getItemPrice(Visit visit, Drug drug) throws ItemNotPayableException, ConfigurationException;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -238,27 +238,28 @@ public Item onPostItem(Item item) {

@RequestMapping(value = "itemprice", method = RequestMethod.GET)
@ResponseBody
public Map<String, Object> onGet(@RequestParam(defaultValue = "100") Integer limit, @RequestParam(defaultValue = "0") Integer startIndex, @RequestParam(required = false) String paymentType, @RequestParam(required = false) String visitUuid, @RequestParam(required = false) String drugUuid ) throws ConfigurationException {
public Map<String, Object> onGet(@RequestParam(defaultValue = "100") Integer limit, @RequestParam(defaultValue = "0") Integer startIndex, @RequestParam(required = false) String paymentType, @RequestParam(required = false) String visitUuid, @RequestParam(required = false) String drugUuid , @RequestParam(required = false) String conceptUuid ) throws ConfigurationException {
Map<String, Object> results = new HashMap<>();
if (visitUuid == null && drugUuid ==null) {
if (visitUuid == null && drugUuid ==null && conceptUuid == null) {
List<Map<String, Object>> items = new ArrayList<Map<String, Object>>();


for (ItemPrice item : iCareService.getItemPrices(paymentType, limit, startIndex)) {
items.add(item.toMap());
}
results.put("results", items);
}

if (visitUuid != null && drugUuid !=null){

Visit visit = Context.getService(VisitService.class).getVisitByUuid(visitUuid);
Drug drug = Context.getService(ConceptService.class).getDrugByUuid(drugUuid);

ItemPrice item = iCareService.getItemPrice(visit,drug);

results.put("results",item.toMap());
}

if (visitUuid != null && conceptUuid !=null){
Visit visit = Context.getService(VisitService.class).getVisitByUuid(visitUuid);
Concept concept = Context.getService(ConceptService.class).getConceptByUuid(conceptUuid);
ItemPrice item = iCareService.getItemPrice(visit, concept);
results.put("results",item.toMap());
}

return results;
Expand Down

0 comments on commit 02b2602

Please sign in to comment.