Skip to content

Commit

Permalink
#170: Removed unnecessary check for maincontent in LocationDialog. Up…
Browse files Browse the repository at this point in the history
…dated CaseFacadeEjb so that if getHospitalization is not null, null pointer exception will not be thrown. changed locationtype implementation in HospitalizationForm to get the location data in HospitalizationDto.SOUGHT_REGION, HospitalizationDto.SOUGHT_DISTRICT, HospitalizationDto.SOUGHT_COMMUNITY instead of locationtype. Also removed patient status and passed outcome to render same logic.
  • Loading branch information
Flava177 committed Dec 14, 2024
1 parent 2c47b5e commit aed8631
Show file tree
Hide file tree
Showing 4 changed files with 68 additions and 23 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -452,7 +452,7 @@ public void configureAsPersonAddressDialog(boolean showDeleteButton) {
*/

public void showHideFieldsForDisease(Disease caseDisease, FormType formType) {
if (caseDisease == null || contentBinding.mainContent == null) {
if (caseDisease == null) {
return;
}
super.hideFieldsForDisease(caseDisease, contentBinding.mainContent, formType);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3477,13 +3477,22 @@ public Case fillOrBuildEntity(@NotNull CaseDataDto source, Case target, boolean

target.setRiskFactor(riskFactorFacade.fillOrBuildEntity(source.getRiskFactor(), target.getRiskFactor(), checkChangeDate));
if (source.getDisease() == Disease.MONKEYPOX) {
if (source.getHospitalization().getLocationType().getRegion() == null) {
source.getHospitalization().getLocationType().setRegion(source.getResponsibleRegion());
source.getHospitalization().getLocationType().setDistrict(source.getResponsibleDistrict());
source.getHospitalization().getLocationType().setCommunity(source.getResponsibleCommunity());
if (source.getHospitalization() != null) {
if (source.getHospitalization().getLocationType() == null) {
source.getHospitalization().setLocationType(new LocationDto());
}

LocationDto locationType = source.getHospitalization().getLocationType();
if (locationType.getRegion() == null) {
locationType.setRegion(source.getResponsibleRegion());
locationType.setDistrict(source.getResponsibleDistrict());
locationType.setCommunity(source.getResponsibleCommunity());
}

source.getHospitalization().setNameOfFacility(source.getHealthFacility());
}
}

target.setHospitalization(hospitalizationFacade.fillOrBuildEntity(source.getHospitalization(), target.getHospitalization(), checkChangeDate));
target.setEpiData(epiDataFacade.fillOrBuildEntity(source.getEpiData(), target.getEpiData(), checkChangeDate));
if (source.getTherapy() == null) {
Expand Down Expand Up @@ -3699,7 +3708,6 @@ public Case fillOrBuildEntity(@NotNull CaseDataDto source, Case target, boolean
target.setNameOfVillagePersonGotIll(source.getNameOfVillagePersonGotIll());
target.setInvestigationOfficerAddress(source.getInvestigationOfficerAddress());


return target;
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -175,6 +175,7 @@ public class HospitalizationForm extends AbstractEditForm<HospitalizationDto> {
public static final String MPOX_LAYOUT = loc(HOSPITALIZATION_HEADING_LOC) +
fluidRowLocs(HospitalizationDto.ADMITTED_TO_HEALTH_FACILITY_NEW) +
fluidRowLocs(HospitalizationDto.LOCATION_TYPE) +
fluidRowLocs(HospitalizationDto.SOUGHT_REGION, HospitalizationDto.SOUGHT_DISTRICT, HospitalizationDto.SOUGHT_COMMUNITY)+
fluidRowLocs(6,HospitalizationDto.NAME_OF_FACILITY)+
fluidRowLocs(HospitalizationDto.HOSPITAL_RECORD_NUMBER, HospitalizationDto.ADMISSION_DATE);

Expand Down Expand Up @@ -625,19 +626,59 @@ public String getFormattedHtmlMessage() {
FieldHelper.setVisibleWhen(soughtMedicalAttentionField, Arrays.asList(soughtRegion, soughtDistrict, soughtCommunity), Arrays.asList(YesNo.YES), true);

}

if(caze.getDisease() == Disease.MONKEYPOX){
addField(HospitalizationDto.LOCATION_TYPE, addressForm);
addressForm.setCaption(null);

if (caze.getDisease() == Disease.MONKEYPOX) {
setFieldsVisible(true, soughtRegion, soughtDistrict, soughtCommunity, nameOfFacilityField);

// Retrieve and set values for Monkeypox disease
RegionReferenceDto responsibleRegion = caze.getResponsibleRegion();
DistrictReferenceDto responsibleDistrict = caze.getResponsibleDistrict();
CommunityReferenceDto responsibleCommunity = caze.getResponsibleCommunity();
FacilityReferenceDto responsibleFacility = caze.getHealthFacility();

if (responsibleRegion != null) {
soughtRegion.setValue(responsibleRegion); // Set selected value
FieldHelper.updateItems(
soughtDistrict,
FacadeProvider.getDistrictFacade().getAllActiveByRegion(responsibleRegion.getUuid())
);
}

if (responsibleDistrict != null) {
soughtDistrict.setValue(responsibleDistrict); // Set selected value
FieldHelper.updateItems(
soughtCommunity,
FacadeProvider.getCommunityFacade().getAllActiveByDistrict(responsibleDistrict.getUuid())
);
}

if (responsibleCommunity != null) {
soughtCommunity.setValue(responsibleCommunity); // Set selected value
FieldHelper.updateItems(
nameOfFacilityField,
FacadeProvider.getFacilityFacade().getActiveHospitalsByCommunity(responsibleCommunity, true, true, true)
);
}

if (responsibleFacility != null) {
nameOfFacilityField.setValue(responsibleFacility); // Set selected value
}
}

/* if(caze.getDisease() == Disease.MONKEYPOX){
// addField(HospitalizationDto.LOCATION_TYPE, addressForm);
// addressForm.setCaption(null);
setFieldsVisible(true, admittedToHealthFacilityNew);
FieldHelper.setVisibleWhen(
*//*FieldHelper.setVisibleWhen(
getFieldGroup(),
Arrays.asList(HospitalizationDto.ADMISSION_DATE, HospitalizationDto.HOSPITAL_RECORD_NUMBER, HospitalizationDto.LOCATION_TYPE, HospitalizationDto.NAME_OF_FACILITY),
HospitalizationDto.ADMITTED_TO_HEALTH_FACILITY_NEW,
Arrays.asList(YesNo.YES),
false
);
}
);*//*
setFieldsVisible(true, soughtRegion, soughtDistrict, soughtCommunity, nameOfFacilityField);
}*/

if (caze.getDisease() == Disease.GUINEA_WORM) {
hideAllFields();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -261,7 +261,7 @@ public class SymptomsForm extends AbstractEditForm<SymptomsDto> {
fluidRowLocs(ARE_ULCERS_AMONG_LESIONS)+
fluidRowLocs(6, TYPE_OF_RASH) +
loc(PATIENT_STATUS) +
fluidRowLocs(6, STATUS_OF_PATIENT) +
fluidRowLocs(6, OUTCOME) +
fluidRowLocs(DATE_OF_DEATH, PLACE_OF_DEATH);

private static String createSymptomGroupLayout(SymptomGroup symptomGroup, String loc) {
Expand Down Expand Up @@ -1123,7 +1123,7 @@ public String getFormattedHtmlMessage() {

if (disease == Disease.MONKEYPOX) {
createLabel(I18nProperties.getString(Strings.headingPatientStatus), H3, PATIENT_STATUS);
setVisible(false, OUTCOME);
// setVisible(false, OUTCOME);
symptomsHeadingLabel.setVisible(true);
tickSymptomField.setVisible(true);

Expand Down Expand Up @@ -1159,23 +1159,19 @@ public String getFormattedHtmlMessage() {
List<SymptomsList> validValues = Arrays.asList(SymptomsList.MACULAR, SymptomsList.MACULOPAPULAR, SymptomsList.VESICULAR, SymptomsList.PAPULAR, SymptomsList.PETECHIAL);
FieldHelper.updateEnumData(typeOfRash, validValues);

ComboBox outcome = new ComboBox("Outcome");
List<CaseOutcome> outcomes = Arrays.asList(CaseOutcome.ALIVE, CaseOutcome.DECEASED);
FieldHelper.updateEnumData(outcome, outcomes);

for (CaseOutcome caseOutcome : CaseOutcome.values()) {
if (caseOutcome == CaseOutcome.DECEASED || caseOutcome == CaseOutcome.ALIVE) {
outcome.addItem(caseOutcome);
}
}
addField(STATUS_OF_PATIENT, outcome);
DateField dateOfDeath = addField(DATE_OF_DEATH, DateField.class);
TextField placeOfField = addField(PLACE_OF_DEATH, TextField.class);

setVisible(false, dateOfDeath, placeOfField);
outcome.setCaption("Status of the Patient");

FieldHelper.setVisibleWhen(
getFieldGroup(),
Arrays.asList(DATE_OF_DEATH, PLACE_OF_DEATH),
STATUS_OF_PATIENT,
OUTCOME,
Arrays.asList(CaseOutcome.DECEASED),
true
);
Expand Down

0 comments on commit aed8631

Please sign in to comment.