Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

BAH-3299 | Handle Inconsistent Behaviour of Quotation Updation #100

Merged
merged 4 commits into from
Jan 9, 2024
Merged
Show file tree
Hide file tree
Changes from 2 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -64,6 +64,7 @@ private String mapOpenERPOrders() throws IOException {
openERPOrder.setProductId(drugOrder.getDrugUuid());
openERPOrder.setProductName(drugOrder.getDrugName());
openERPOrder.setAction(drugOrder.getAction());
openERPOrder.setDateCreated(drugOrder.getDateActivated());
openERPOrder.setQuantity(drugOrder.getQuantity());
openERPOrder.setQuantityUnits(drugOrder.getQuantityUnits());
openERPOrder.setVoided(drugOrder.isVoided());
Expand All @@ -87,6 +88,7 @@ private String mapOpenERPOrders() throws IOException {
openERPOrder.setProductId(order.getConceptUuid());
openERPOrder.setProductName(order.getConceptName());
openERPOrder.setAction(order.getAction());
openERPOrder.setDateCreated(order.getDateCreated());
openERPOrder.setQuantity((double) 1);
openERPOrder.setQuantityUnits("Unit(s)");
openERPOrder.setVoided(order.isVoided());
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
package org.bahmni.feed.openerp.domain.encounter;

import java.util.Date;

public class OpenERPOrder {
private String orderId;
private String previousOrderId;
Expand All @@ -18,6 +20,7 @@ public class OpenERPOrder {
private String providerName;
private String dispensed;
private String conceptName;
private Date dateCreated;


public String getEncounterId() {
Expand Down Expand Up @@ -52,8 +55,6 @@ public void setType(String type) {
this.type = type;
}



public String getDescription() {
return description;
}
Expand Down Expand Up @@ -119,6 +120,14 @@ public void setAction(String action) {
this.action = action;
}

public Date getDateCreated() {
return dateCreated;
}

public void setDateCreated(Date dateCreated) {
this.dateCreated = dateCreated;
}

public String getPreviousOrderId() {
return previousOrderId;
}
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
package org.bahmni.feed.openerp.domain.encounter;

import java.util.ArrayList;
import java.util.List;
import java.util.*;

public class OpenERPOrders {
private String id;
Expand All @@ -13,7 +12,19 @@ public OpenERPOrders(String id){
}

public List<OpenERPOrder> getOpenERPOrders() {
return openERPOrders;
return removeDuplicateOrders(openERPOrders);
}

parvathy00 marked this conversation as resolved.
Show resolved Hide resolved
public List<OpenERPOrder> removeDuplicateOrders(List<OpenERPOrder> orders) {
Map<String, OpenERPOrder> latestOrders = new LinkedHashMap<>();

for (OpenERPOrder order : orders) {
parvathy00 marked this conversation as resolved.
Show resolved Hide resolved
latestOrders.merge(order.getProductId(), order, (existingOrder, newOrder) ->
(existingOrder.getDateCreated().before(newOrder.getDateCreated())) ? newOrder : existingOrder
);
}

return new ArrayList<>(latestOrders.values());
}

public void add(OpenERPOrder order) {
Expand All @@ -34,4 +45,4 @@ public String getId() {
public void setId(String id) {
this.id = id;
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,8 @@

import com.fasterxml.jackson.annotation.JsonIgnoreProperties;

import java.util.Date;

@JsonIgnoreProperties(ignoreUnknown = true)
public class OpenMRSDrugOrder {
private OpenMRSConcept concept;
Expand All @@ -13,6 +15,7 @@ public class OpenMRSDrugOrder {
private String uuid;
private String previousOrderUuid;
private String orderType;
private Date dateActivated;
private boolean voided;

public OpenMRSConcept getConcept() {
Expand Down Expand Up @@ -43,6 +46,10 @@ public String getAction() {
return action;
}

public Date getDateActivated() {
return dateActivated;
}

public String getUuid() {
return uuid;
}
Expand Down
Original file line number Diff line number Diff line change
@@ -1,11 +1,14 @@
package org.bahmni.feed.openerp.domain.encounter;

import java.util.Date;

import com.fasterxml.jackson.annotation.JsonIgnoreProperties;

@JsonIgnoreProperties(ignoreUnknown = true)
public class OpenMRSOrder {
private OpenMRSConcept concept;
private String action;
private Date dateCreated;
private String uuid;
private String orderType;
private String orderNumber;
Expand All @@ -21,6 +24,10 @@ public String getAction() {
return action;
}

public Date getDateCreated() {
return dateCreated;
}

public String getUuid() {
return uuid;
}
Expand Down
Loading