-
Notifications
You must be signed in to change notification settings - Fork 123
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
Open
SteveGT96
wants to merge
9
commits into
informatici:develop
Choose a base branch
from
SteveGT96:update/OH2-409-medical-ward-add-lock-field
base: develop
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
+101
−72
Open
Changes from all commits
Commits
Show all changes
9 commits
Select commit
Hold shift + click to select a range
9f2ae92
update(OH2-409): Add lock field to medical ward
8c27ad2
chore: Update license header
2d01835
chore: Update demo data and fix tests
abec922
chore: Add medical ward lock getter/setter test
a21fcc6
chore: Reformat code
00e2b38
chore: Reformat and refactor code
b86ef77
Merge branch 'develop' into update/OH2-409-medical-ward-add-lock-field
28ac491
chore: Align with develop
b3c9e60
Merge branch 'develop' into update/OH2-409-medical-ward-add-lock-field
mwithi File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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. | ||
* | ||
|
@@ -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; | ||
|
@@ -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)) | ||
|
@@ -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", 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; | ||
|
@@ -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(); | ||
} | ||
|
||
public void setMedical(Medical medical) { | ||
this.id.setMedical(medical); | ||
public void setLot(Lot lot) { | ||
id.setLot(lot); | ||
} | ||
|
||
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(); | ||
} | ||
|
||
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; | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change | ||||
---|---|---|---|---|---|---|
|
@@ -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; | ||||||
|
@@ -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; | ||||||
|
@@ -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 { | ||||||
|
@@ -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(new BigDecimal("0.0")); | ||||||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
Suggested change
|
||||||
lotIoOperationRepository.saveAndFlush(lot); | ||||||
List<Movement> movements = new ArrayList<>(1); | ||||||
movements.add(movement); | ||||||
|
@@ -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; | ||||||
} | ||||||
|
@@ -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); | ||||||
|
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.