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
30 changes: 15 additions & 15 deletions sql/load_demo_data.sql
Original file line number Diff line number Diff line change
Expand Up @@ -2994,21 +2994,21 @@ UNLOCK TABLES;

LOCK TABLES `oh_medicaldsrward` WRITE;
/*!40000 ALTER TABLE `oh_medicaldsrward` DISABLE KEYS */;
INSERT INTO `oh_medicaldsrward` (`MDSRWRD_WRD_ID_A`, `MDSRWRD_MDSR_ID`, `MDSRWRD_IN_QTI`, `MDSRWRD_OUT_QTI`, `MDSRWRD_LT_ID_A`, `MDSRWRD_CREATED_BY`, `MDSRWRD_CREATED_DATE`, `MDSRWRD_LAST_MODIFIED_BY`, `MDSRWRD_LAST_MODIFIED_DATE`, `MDSRWRD_ACTIVE`) VALUES ('C',103,100,4,'AUTO_C_103',NULL,NULL,NULL,NULL,1);
INSERT INTO `oh_medicaldsrward` (`MDSRWRD_WRD_ID_A`, `MDSRWRD_MDSR_ID`, `MDSRWRD_IN_QTI`, `MDSRWRD_OUT_QTI`, `MDSRWRD_LT_ID_A`, `MDSRWRD_CREATED_BY`, `MDSRWRD_CREATED_DATE`, `MDSRWRD_LAST_MODIFIED_BY`, `MDSRWRD_LAST_MODIFIED_DATE`, `MDSRWRD_ACTIVE`) VALUES ('C',275,20,0,'7144453288242750524',NULL,NULL,NULL,NULL,1);
INSERT INTO `oh_medicaldsrward` (`MDSRWRD_WRD_ID_A`, `MDSRWRD_MDSR_ID`, `MDSRWRD_IN_QTI`, `MDSRWRD_OUT_QTI`, `MDSRWRD_LT_ID_A`, `MDSRWRD_CREATED_BY`, `MDSRWRD_CREATED_DATE`, `MDSRWRD_LAST_MODIFIED_BY`, `MDSRWRD_LAST_MODIFIED_DATE`, `MDSRWRD_ACTIVE`) VALUES ('F',99,100,0,'AUTO_F_99',NULL,NULL,NULL,NULL,1);
INSERT INTO `oh_medicaldsrward` (`MDSRWRD_WRD_ID_A`, `MDSRWRD_MDSR_ID`, `MDSRWRD_IN_QTI`, `MDSRWRD_OUT_QTI`, `MDSRWRD_LT_ID_A`, `MDSRWRD_CREATED_BY`, `MDSRWRD_CREATED_DATE`, `MDSRWRD_LAST_MODIFIED_BY`, `MDSRWRD_LAST_MODIFIED_DATE`, `MDSRWRD_ACTIVE`) VALUES ('F',105,1000,0,'AUTO_F_105',NULL,NULL,NULL,NULL,1);
INSERT INTO `oh_medicaldsrward` (`MDSRWRD_WRD_ID_A`, `MDSRWRD_MDSR_ID`, `MDSRWRD_IN_QTI`, `MDSRWRD_OUT_QTI`, `MDSRWRD_LT_ID_A`, `MDSRWRD_CREATED_BY`, `MDSRWRD_CREATED_DATE`, `MDSRWRD_LAST_MODIFIED_BY`, `MDSRWRD_LAST_MODIFIED_DATE`, `MDSRWRD_ACTIVE`) VALUES ('F',368,20,0,'1352158066768470913',NULL,NULL,NULL,NULL,1);
INSERT INTO `oh_medicaldsrward` (`MDSRWRD_WRD_ID_A`, `MDSRWRD_MDSR_ID`, `MDSRWRD_IN_QTI`, `MDSRWRD_OUT_QTI`, `MDSRWRD_LT_ID_A`, `MDSRWRD_CREATED_BY`, `MDSRWRD_CREATED_DATE`, `MDSRWRD_LAST_MODIFIED_BY`, `MDSRWRD_LAST_MODIFIED_DATE`, `MDSRWRD_ACTIVE`) VALUES ('F',404,10,0,'AUTO_F_404',NULL,NULL,NULL,NULL,1);
INSERT INTO `oh_medicaldsrward` (`MDSRWRD_WRD_ID_A`, `MDSRWRD_MDSR_ID`, `MDSRWRD_IN_QTI`, `MDSRWRD_OUT_QTI`, `MDSRWRD_LT_ID_A`, `MDSRWRD_CREATED_BY`, `MDSRWRD_CREATED_DATE`, `MDSRWRD_LAST_MODIFIED_BY`, `MDSRWRD_LAST_MODIFIED_DATE`, `MDSRWRD_ACTIVE`) VALUES ('F',415,200,0,'AUTO_F_415',NULL,NULL,NULL,NULL,1);
INSERT INTO `oh_medicaldsrward` (`MDSRWRD_WRD_ID_A`, `MDSRWRD_MDSR_ID`, `MDSRWRD_IN_QTI`, `MDSRWRD_OUT_QTI`, `MDSRWRD_LT_ID_A`, `MDSRWRD_CREATED_BY`, `MDSRWRD_CREATED_DATE`, `MDSRWRD_LAST_MODIFIED_BY`, `MDSRWRD_LAST_MODIFIED_DATE`, `MDSRWRD_ACTIVE`) VALUES ('I',40,100,0,'AUTO_I_40',NULL,NULL,NULL,NULL,1);
INSERT INTO `oh_medicaldsrward` (`MDSRWRD_WRD_ID_A`, `MDSRWRD_MDSR_ID`, `MDSRWRD_IN_QTI`, `MDSRWRD_OUT_QTI`, `MDSRWRD_LT_ID_A`, `MDSRWRD_CREATED_BY`, `MDSRWRD_CREATED_DATE`, `MDSRWRD_LAST_MODIFIED_BY`, `MDSRWRD_LAST_MODIFIED_DATE`, `MDSRWRD_ACTIVE`) VALUES ('I',50,40,0,'7460012206646986840',NULL,NULL,NULL,NULL,1);
INSERT INTO `oh_medicaldsrward` (`MDSRWRD_WRD_ID_A`, `MDSRWRD_MDSR_ID`, `MDSRWRD_IN_QTI`, `MDSRWRD_OUT_QTI`, `MDSRWRD_LT_ID_A`, `MDSRWRD_CREATED_BY`, `MDSRWRD_CREATED_DATE`, `MDSRWRD_LAST_MODIFIED_BY`, `MDSRWRD_LAST_MODIFIED_DATE`, `MDSRWRD_ACTIVE`) VALUES ('I',98,130,10,'AUTO_I_98',NULL,NULL,NULL,NULL,1);
INSERT INTO `oh_medicaldsrward` (`MDSRWRD_WRD_ID_A`, `MDSRWRD_MDSR_ID`, `MDSRWRD_IN_QTI`, `MDSRWRD_OUT_QTI`, `MDSRWRD_LT_ID_A`, `MDSRWRD_CREATED_BY`, `MDSRWRD_CREATED_DATE`, `MDSRWRD_LAST_MODIFIED_BY`, `MDSRWRD_LAST_MODIFIED_DATE`, `MDSRWRD_ACTIVE`) VALUES ('I',108,1600,0,'AUTO_I_108',NULL,NULL,NULL,NULL,1);
INSERT INTO `oh_medicaldsrward` (`MDSRWRD_WRD_ID_A`, `MDSRWRD_MDSR_ID`, `MDSRWRD_IN_QTI`, `MDSRWRD_OUT_QTI`, `MDSRWRD_LT_ID_A`, `MDSRWRD_CREATED_BY`, `MDSRWRD_CREATED_DATE`, `MDSRWRD_LAST_MODIFIED_BY`, `MDSRWRD_LAST_MODIFIED_DATE`, `MDSRWRD_ACTIVE`) VALUES ('I',415,1000,0,'AUTO_I_415',NULL,NULL,NULL,NULL,1);
INSERT INTO `oh_medicaldsrward` (`MDSRWRD_WRD_ID_A`, `MDSRWRD_MDSR_ID`, `MDSRWRD_IN_QTI`, `MDSRWRD_OUT_QTI`, `MDSRWRD_LT_ID_A`, `MDSRWRD_CREATED_BY`, `MDSRWRD_CREATED_DATE`, `MDSRWRD_LAST_MODIFIED_BY`, `MDSRWRD_LAST_MODIFIED_DATE`, `MDSRWRD_ACTIVE`) VALUES ('INV',124,9000,0,'202402AAC1',NULL,NULL,NULL,NULL,1);
INSERT INTO `oh_medicaldsrward` (`MDSRWRD_WRD_ID_A`, `MDSRWRD_MDSR_ID`, `MDSRWRD_IN_QTI`, `MDSRWRD_OUT_QTI`, `MDSRWRD_LT_ID_A`, `MDSRWRD_CREATED_BY`, `MDSRWRD_CREATED_DATE`, `MDSRWRD_LAST_MODIFIED_BY`, `MDSRWRD_LAST_MODIFIED_DATE`, `MDSRWRD_ACTIVE`) VALUES ('INV',264,100,0,'202402c',NULL,NULL,NULL,NULL,1);
INSERT INTO `oh_medicaldsrward` (`MDSRWRD_WRD_ID_A`, `MDSRWRD_MDSR_ID`, `MDSRWRD_IN_QTI`, `MDSRWRD_OUT_QTI`, `MDSRWRD_LT_ID_A`, `MDSRWRD_CREATED_BY`, `MDSRWRD_CREATED_DATE`, `MDSRWRD_LAST_MODIFIED_BY`, `MDSRWRD_LAST_MODIFIED_DATE`, `MDSRWRD_ACTIVE`) VALUES ('M',98,70,2,'AUTO_M_98',NULL,NULL,NULL,NULL,1);
INSERT INTO `oh_medicaldsrward` (`MDSRWRD_WRD_ID_A`, `MDSRWRD_MDSR_ID`, `MDSRWRD_IN_QTI`, `MDSRWRD_OUT_QTI`, `MDSRWRD_LT_ID_A`, `MDSRWRD_CREATED_BY`, `MDSRWRD_CREATED_DATE`, `MDSRWRD_LAST_MODIFIED_BY`, `MDSRWRD_LAST_MODIFIED_DATE`, `MDSRWRD_ACTIVE`, `MDSRWRD_LOCK`) VALUES ('C',103,100,4,'AUTO_C_103',NULL,NULL,NULL,NULL,1, 0);
INSERT INTO `oh_medicaldsrward` (`MDSRWRD_WRD_ID_A`, `MDSRWRD_MDSR_ID`, `MDSRWRD_IN_QTI`, `MDSRWRD_OUT_QTI`, `MDSRWRD_LT_ID_A`, `MDSRWRD_CREATED_BY`, `MDSRWRD_CREATED_DATE`, `MDSRWRD_LAST_MODIFIED_BY`, `MDSRWRD_LAST_MODIFIED_DATE`, `MDSRWRD_ACTIVE`, `MDSRWRD_LOCK`) VALUES ('C',275,20,0,'7144453288242750524',NULL,NULL,NULL,NULL,1, 0);
INSERT INTO `oh_medicaldsrward` (`MDSRWRD_WRD_ID_A`, `MDSRWRD_MDSR_ID`, `MDSRWRD_IN_QTI`, `MDSRWRD_OUT_QTI`, `MDSRWRD_LT_ID_A`, `MDSRWRD_CREATED_BY`, `MDSRWRD_CREATED_DATE`, `MDSRWRD_LAST_MODIFIED_BY`, `MDSRWRD_LAST_MODIFIED_DATE`, `MDSRWRD_ACTIVE`, `MDSRWRD_LOCK`) VALUES ('F',99,100,0,'AUTO_F_99',NULL,NULL,NULL,NULL,1, 0);
INSERT INTO `oh_medicaldsrward` (`MDSRWRD_WRD_ID_A`, `MDSRWRD_MDSR_ID`, `MDSRWRD_IN_QTI`, `MDSRWRD_OUT_QTI`, `MDSRWRD_LT_ID_A`, `MDSRWRD_CREATED_BY`, `MDSRWRD_CREATED_DATE`, `MDSRWRD_LAST_MODIFIED_BY`, `MDSRWRD_LAST_MODIFIED_DATE`, `MDSRWRD_ACTIVE`, `MDSRWRD_LOCK`) VALUES ('F',105,1000,0,'AUTO_F_105',NULL,NULL,NULL,NULL,1, 0);
INSERT INTO `oh_medicaldsrward` (`MDSRWRD_WRD_ID_A`, `MDSRWRD_MDSR_ID`, `MDSRWRD_IN_QTI`, `MDSRWRD_OUT_QTI`, `MDSRWRD_LT_ID_A`, `MDSRWRD_CREATED_BY`, `MDSRWRD_CREATED_DATE`, `MDSRWRD_LAST_MODIFIED_BY`, `MDSRWRD_LAST_MODIFIED_DATE`, `MDSRWRD_ACTIVE`, `MDSRWRD_LOCK`) VALUES ('F',368,20,0,'1352158066768470913',NULL,NULL,NULL,NULL,1, 0);
INSERT INTO `oh_medicaldsrward` (`MDSRWRD_WRD_ID_A`, `MDSRWRD_MDSR_ID`, `MDSRWRD_IN_QTI`, `MDSRWRD_OUT_QTI`, `MDSRWRD_LT_ID_A`, `MDSRWRD_CREATED_BY`, `MDSRWRD_CREATED_DATE`, `MDSRWRD_LAST_MODIFIED_BY`, `MDSRWRD_LAST_MODIFIED_DATE`, `MDSRWRD_ACTIVE`, `MDSRWRD_LOCK`) VALUES ('F',404,10,0,'AUTO_F_404',NULL,NULL,NULL,NULL,1, 0);
INSERT INTO `oh_medicaldsrward` (`MDSRWRD_WRD_ID_A`, `MDSRWRD_MDSR_ID`, `MDSRWRD_IN_QTI`, `MDSRWRD_OUT_QTI`, `MDSRWRD_LT_ID_A`, `MDSRWRD_CREATED_BY`, `MDSRWRD_CREATED_DATE`, `MDSRWRD_LAST_MODIFIED_BY`, `MDSRWRD_LAST_MODIFIED_DATE`, `MDSRWRD_ACTIVE`, `MDSRWRD_LOCK`) VALUES ('F',415,200,0,'AUTO_F_415',NULL,NULL,NULL,NULL,1, 0);
INSERT INTO `oh_medicaldsrward` (`MDSRWRD_WRD_ID_A`, `MDSRWRD_MDSR_ID`, `MDSRWRD_IN_QTI`, `MDSRWRD_OUT_QTI`, `MDSRWRD_LT_ID_A`, `MDSRWRD_CREATED_BY`, `MDSRWRD_CREATED_DATE`, `MDSRWRD_LAST_MODIFIED_BY`, `MDSRWRD_LAST_MODIFIED_DATE`, `MDSRWRD_ACTIVE`, `MDSRWRD_LOCK`) VALUES ('I',40,100,0,'AUTO_I_40',NULL,NULL,NULL,NULL,1, 0);
INSERT INTO `oh_medicaldsrward` (`MDSRWRD_WRD_ID_A`, `MDSRWRD_MDSR_ID`, `MDSRWRD_IN_QTI`, `MDSRWRD_OUT_QTI`, `MDSRWRD_LT_ID_A`, `MDSRWRD_CREATED_BY`, `MDSRWRD_CREATED_DATE`, `MDSRWRD_LAST_MODIFIED_BY`, `MDSRWRD_LAST_MODIFIED_DATE`, `MDSRWRD_ACTIVE`, `MDSRWRD_LOCK`) VALUES ('I',50,40,0,'7460012206646986840',NULL,NULL,NULL,NULL,1, 0);
INSERT INTO `oh_medicaldsrward` (`MDSRWRD_WRD_ID_A`, `MDSRWRD_MDSR_ID`, `MDSRWRD_IN_QTI`, `MDSRWRD_OUT_QTI`, `MDSRWRD_LT_ID_A`, `MDSRWRD_CREATED_BY`, `MDSRWRD_CREATED_DATE`, `MDSRWRD_LAST_MODIFIED_BY`, `MDSRWRD_LAST_MODIFIED_DATE`, `MDSRWRD_ACTIVE`, `MDSRWRD_LOCK`) VALUES ('I',98,130,10,'AUTO_I_98',NULL,NULL,NULL,NULL,1, 0);
INSERT INTO `oh_medicaldsrward` (`MDSRWRD_WRD_ID_A`, `MDSRWRD_MDSR_ID`, `MDSRWRD_IN_QTI`, `MDSRWRD_OUT_QTI`, `MDSRWRD_LT_ID_A`, `MDSRWRD_CREATED_BY`, `MDSRWRD_CREATED_DATE`, `MDSRWRD_LAST_MODIFIED_BY`, `MDSRWRD_LAST_MODIFIED_DATE`, `MDSRWRD_ACTIVE`, `MDSRWRD_LOCK`) VALUES ('I',108,1600,0,'AUTO_I_108',NULL,NULL,NULL,NULL,1, 0);
INSERT INTO `oh_medicaldsrward` (`MDSRWRD_WRD_ID_A`, `MDSRWRD_MDSR_ID`, `MDSRWRD_IN_QTI`, `MDSRWRD_OUT_QTI`, `MDSRWRD_LT_ID_A`, `MDSRWRD_CREATED_BY`, `MDSRWRD_CREATED_DATE`, `MDSRWRD_LAST_MODIFIED_BY`, `MDSRWRD_LAST_MODIFIED_DATE`, `MDSRWRD_ACTIVE`, `MDSRWRD_LOCK`) VALUES ('I',415,1000,0,'AUTO_I_415',NULL,NULL,NULL,NULL,1, 0);
INSERT INTO `oh_medicaldsrward` (`MDSRWRD_WRD_ID_A`, `MDSRWRD_MDSR_ID`, `MDSRWRD_IN_QTI`, `MDSRWRD_OUT_QTI`, `MDSRWRD_LT_ID_A`, `MDSRWRD_CREATED_BY`, `MDSRWRD_CREATED_DATE`, `MDSRWRD_LAST_MODIFIED_BY`, `MDSRWRD_LAST_MODIFIED_DATE`, `MDSRWRD_ACTIVE`, `MDSRWRD_LOCK`) VALUES ('INV',124,9000,0,'202402AAC1',NULL,NULL,NULL,NULL,1, 0);
INSERT INTO `oh_medicaldsrward` (`MDSRWRD_WRD_ID_A`, `MDSRWRD_MDSR_ID`, `MDSRWRD_IN_QTI`, `MDSRWRD_OUT_QTI`, `MDSRWRD_LT_ID_A`, `MDSRWRD_CREATED_BY`, `MDSRWRD_CREATED_DATE`, `MDSRWRD_LAST_MODIFIED_BY`, `MDSRWRD_LAST_MODIFIED_DATE`, `MDSRWRD_ACTIVE`, `MDSRWRD_LOCK`) VALUES ('INV',264,100,0,'202402c',NULL,NULL,NULL,NULL,1, 0);
INSERT INTO `oh_medicaldsrward` (`MDSRWRD_WRD_ID_A`, `MDSRWRD_MDSR_ID`, `MDSRWRD_IN_QTI`, `MDSRWRD_OUT_QTI`, `MDSRWRD_LT_ID_A`, `MDSRWRD_CREATED_BY`, `MDSRWRD_CREATED_DATE`, `MDSRWRD_LAST_MODIFIED_BY`, `MDSRWRD_LAST_MODIFIED_DATE`, `MDSRWRD_ACTIVE`, `MDSRWRD_LOCK`) VALUES ('M',98,70,2,'AUTO_M_98',NULL,NULL,NULL,NULL,1, 0);
/*!40000 ALTER TABLE `oh_medicaldsrward` ENABLE KEYS */;
UNLOCK TABLES;

Expand Down
3 changes: 3 additions & 0 deletions sql/step_a111_add_missing_lock_columns.sql
Original file line number Diff line number Diff line change
Expand Up @@ -31,3 +31,6 @@ ALTER TABLE `oh_pricesothers`

ALTER TABLE `oh_visits`
ADD COLUMN `VST_LOCK` INT(11) NOT NULL DEFAULT 0;

ALTER TABLE `oh_medicaldsrward`
ADD COLUMN `MDSRWRD_LOCK` INT(11) NOT NULL DEFAULT 0;
116 changes: 66 additions & 50 deletions src/main/java/org/isf/medicalstockward/model/MedicalWard.java
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
/*
* Open Hospital (www.open-hospital.org)
* Copyright © 2006-2023 Informatici Senza Frontiere ([email protected])
* Copyright © 2006-2024 Informatici Senza Frontiere ([email protected])
*
* Open Hospital is a free and open source software for healthcare data management.
*
Expand Down 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,52 @@
@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", columnDefinition = "INT(11) NOT NULL DEFAULT 0")
private int lock;

@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 +100,101 @@ 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 int getLock() {
return lock;
}

public void setLock(int 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;
}
}
29 changes: 22 additions & 7 deletions src/test/java/org/isf/medicalstock/Tests.java
Original file line number Diff line number Diff line change
Expand Up @@ -75,6 +75,7 @@
import org.junit.jupiter.api.AfterAll;
import org.junit.jupiter.api.BeforeAll;
import org.junit.jupiter.api.BeforeEach;
import org.junit.jupiter.api.Test;
import org.junit.jupiter.params.ParameterizedTest;
import org.junit.jupiter.params.provider.Arguments;
import org.junit.jupiter.params.provider.MethodSource;
Expand Down Expand Up @@ -153,11 +154,6 @@ static void setUpClass() {
testMedicalStock = new TestMedicalStock();
}

@BeforeEach
void setUp() throws OHException {
cleanH2InMemoryDb();
}

@AfterAll
SteveGT96 marked this conversation as resolved.
Show resolved Hide resolved
static void tearDownClass() {
testLot = null;
Expand All @@ -170,6 +166,11 @@ static void tearDownClass() {
testMedicalStock = null;
}

@BeforeEach
SteveGT96 marked this conversation as resolved.
Show resolved Hide resolved
void setUp() throws OHException {
cleanH2InMemoryDb();
}
SteveGT96 marked this conversation as resolved.
Show resolved Hide resolved

@ParameterizedTest(name = "Test with AUTOMATICLOT_IN={0}, AUTOMATICLOT_OUT={1}, AUTOMATICLOTWARD_TOWARD={2}")
@MethodSource("automaticlot")
void testLotGets(boolean in, boolean out, boolean toward) throws Exception {
Expand Down Expand Up @@ -1106,7 +1107,7 @@ void testMgrValidateLotWithCostZero() {
Movement movement = movementIoOperationRepository.findById(code).orElse(null);
assertThat(movement).isNotNull();
Lot lot = movement.getLot();
lot.setCost(new BigDecimal(0.0));
lot.setCost(BigDecimal.ZERO);
lotIoOperationRepository.saveAndFlush(lot);
List<Movement> movements = new ArrayList<>(1);
movements.add(movement);
Expand Down Expand Up @@ -1520,7 +1521,7 @@ void testIoUpdateMedicalStockTableEmptyTableWithNegativeQuantity() throws Except
method.invoke(medicalStockIoOperation, medical, newDate, quantity);
} catch (InvocationTargetException e) {
if (e.getCause() instanceof OHServiceException) {
throw (OHServiceException) e.getCause();
throw e.getCause();
} else {
throw e;
}
Expand All @@ -1529,6 +1530,20 @@ void testIoUpdateMedicalStockTableEmptyTableWithNegativeQuantity() throws Except
.isInstanceOf(OHServiceException.class);
}

@Test
void testMedicalWardLockGetterSetter() throws Exception {
int code = setupTestMovement(false);
Movement movement = movementIoOperationRepository.findById(code).orElse(null);
assertThat(movement).isNotNull();
MovementType movementType = movement.getType();
movementType.setType("-");
MedicalWard medicalWard = new MedicalWard(movement.getWard(), movement.getMedical(), 0, 0, movement.getLot());

assertThat(medicalWard.getLock()).isZero();
medicalWard.setLock(8);
assertThat(medicalWard.getLock()).isEqualTo(8);
}

private String setupTestLot(boolean usingSet) throws OHException {
MedicalType medicalType = testMedicalType.setup(false);
Medical medical = testMedical.setup(medicalType, false);
Expand Down