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

OH2-409 | Add lock field to medical ward #1448

Merged
1 change: 1 addition & 0 deletions sql/step_04_all_following_steps.sql
Original file line number Diff line number Diff line change
Expand Up @@ -105,3 +105,4 @@ source step_a108_audit_dicom_type_and_dicom_data.sql;
source step_a109_update_user_settings_table_constraints_and_add_usergroups_permissions.sql;
source step_a110_update_operations_table_change_ope_for_to_enum.sql;
source step_a111_add_missing_lock_columns.sql;
source step_a112_add_medical_ward_lock_column.sql;
SteveGT96 marked this conversation as resolved.
Show resolved Hide resolved
6 changes: 6 additions & 0 deletions sql/step_a112_add_medical_ward_lock_column.sql
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
--
SteveGT96 marked this conversation as resolved.
Show resolved Hide resolved
-- Add lock (version) column in oh_medicaldsrward
--

ALTER TABLE `oh_medicaldsrward`
ADD COLUMN `MDSRWRD_LOCK` INT(11) NOT NULL DEFAULT 0;
109 changes: 60 additions & 49 deletions src/main/java/org/isf/medicalstockward/model/MedicalWard.java
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@
import jakarta.persistence.EntityListeners;
import jakarta.persistence.Table;
import jakarta.persistence.Transient;
import jakarta.persistence.Version;

import org.isf.medicals.model.Medical;
import org.isf.medicalstock.model.Lot;
Expand All @@ -36,7 +37,7 @@
import org.springframework.data.jpa.domain.support.AuditingEntityListener;

@Entity
@Table(name="OH_MEDICALDSRWARD")
@Table(name = "OH_MEDICALDSRWARD")
@EntityListeners(AuditingEntityListener.class)
@AttributeOverride(name = "createdBy", column = @Column(name = "MDSRWRD_CREATED_BY", updatable = false))
@AttributeOverride(name = "createdDate", column = @Column(name = "MDSRWRD_CREATED_DATE", updatable = false))
Expand All @@ -45,45 +46,51 @@
@AttributeOverride(name = "lastModifiedDate", column = @Column(name = "MDSRWRD_LAST_MODIFIED_DATE"))
public class MedicalWard extends Auditable<String> implements Comparable<Object> {

@EmbeddedId
@EmbeddedId
MedicalWardId id;
@Column(name="MDSRWRD_IN_QTI")

@Column(name = "MDSRWRD_IN_QTI")
private float in_quantity;
@Column(name="MDSRWRD_OUT_QTI")

@Column(name = "MDSRWRD_OUT_QTI")
private float out_quantity;


/**
* Lock control
*/
@Version
@Column(name = "MDSRWRD_LOCK")
private Integer lock;
SteveGT96 marked this conversation as resolved.
Show resolved Hide resolved
@Transient
private Double qty = 0.0;

@Transient
private volatile int hashCode;

public MedicalWard() {
super();
this.id = new MedicalWardId();
}

public MedicalWard(Medical medical, Double qty) {
super();
this.id = new MedicalWardId();
this.id = new MedicalWardId();
this.id.setMedical(medical);
this.qty = qty;
}

public MedicalWard(Ward ward, Medical medical, float inQuantity, float outQuantity, Lot lot) {
super();
this.id = new MedicalWardId(ward, medical, lot);
this.id = new MedicalWardId(ward, medical, lot);
this.in_quantity = inQuantity;
this.out_quantity = outQuantity;

}

public MedicalWard(Medical med, double qanty, Lot lot) {
super();
this.id = new MedicalWardId();
this.id = new MedicalWardId();

this.id.setMedical(med);
this.id.setLot(lot);
this.qty = qanty;
Expand All @@ -92,93 +99,97 @@ public MedicalWard(Medical med, double qanty, Lot lot) {
public MedicalWardId getId() {
return id;
}

public void setId(Ward ward, Medical medical, Lot lot) {
this.id = new MedicalWardId(ward, medical, lot);
this.id = new MedicalWardId(ward, medical, lot);
}

public Lot getLot() {
return id.getLot();
}

SteveGT96 marked this conversation as resolved.
Show resolved Hide resolved
public void setMedical(Medical medical) {
this.id.setMedical(medical);
public void setLot(Lot lot) {
id.setLot(lot);
}

SteveGT96 marked this conversation as resolved.
Show resolved Hide resolved
public Double getQty() {
return qty;
}

public void setQty(Double qty) {
this.qty = qty;
}


public Integer getLock() {
return lock;
}

public void setLock(Integer lock) {
this.lock = lock;
}

@Override
public int compareTo(Object anObject) {
Medical medical = id.getMedical();
if (anObject instanceof MedicalWard) {
return (medical.getDescription().toUpperCase().compareTo(
((MedicalWard) anObject).getMedical().getDescription().toUpperCase()));
((MedicalWard) anObject).getMedical().getDescription().toUpperCase()));
}
return 0;
}

public Ward getWard() {
return this.id.getWard();
}

public void setWard(Ward ward) {
this.id.setWard(ward);
}

public Medical getMedical() {
return this.id.getMedical();
}

SteveGT96 marked this conversation as resolved.
Show resolved Hide resolved
public void setLot(Lot lot) {
id.setLot(lot);
public void setMedical(Medical medical) {
this.id.setMedical(medical);
}

public float getIn_quantity() {
return this.in_quantity;
}

public void setIn_quantity(float inQuantity) {
this.in_quantity = inQuantity;
}

public float getOut_quantity() {
return this.out_quantity;
}

public void setOut_quantity(float outQuantity) {
this.out_quantity = outQuantity;
}

@Override
public boolean equals(Object obj) {
if (this == obj) {
return true;
}

if (!(obj instanceof MedicalWard ward)) {
return false;
}

return (this.id.getMedical() == ward.id.getMedical());
}

@Override
public int hashCode() {
if (this.hashCode == 0) {
final int m = 23;
int c = 133;
c = m * c + this.id.getMedical().getCode();
this.hashCode = c;
}
return this.hashCode;
}
if (this.hashCode == 0) {
final int m = 23;
int c = 133;

c = m * c + this.id.getMedical().getCode();

this.hashCode = c;
}

return this.hashCode;
}
}
Loading