@@ -161,18 +161,33 @@ public void createFromEventParticipantDifferentDisease(EventParticipantDto event
161161 }
162162
163163 public void createFromContact (ContactDto contact ) {
164- CommitDiscardWrapperComponent <CaseCreateForm > caseCreateComponent = getCaseCreateComponent (contact , null , null );
165- caseCreateComponent .addCommitListener (new CommitListener () {
166-
167- @ Override
168- public void onCommit () {
169- ContactDto updatedContact = FacadeProvider .getContactFacade ().getContactByUuid (contact .getUuid ());
170- updatedContact .setContactClassification (ContactClassification .CONFIRMED );
171- FacadeProvider .getContactFacade ().saveContact (updatedContact );
164+ PersonDto selectedPerson = FacadeProvider .getPersonFacade ().getPersonByUuid (contact .getPerson ().getUuid ());
165+ CaseDataDto dto = CaseDataDto .build (PersonDto .build ().toReference (), contact .getDisease ());
166+
167+ dto .setDiseaseDetails (contact .getDiseaseDetails ());
168+ dto .setRegion (contact .getRegion ());
169+ dto .setDistrict (contact .getDistrict ());
170+ dto .setReportDate (contact .getReportDateTime ());
171+ dto .setCommunity (contact .getCommunity ());
172+ dto .setReportingUser (UserProvider .getCurrent ().getUserReference ());
173+
174+ selectOrCreateCase (dto , FacadeProvider .getPersonFacade ().getPersonByUuid (selectedPerson .getUuid ()), uuid -> {
175+ if (uuid == null ) {
176+ CommitDiscardWrapperComponent <CaseCreateForm > caseCreateComponent = getCaseCreateComponent (contact , null , null );
177+ caseCreateComponent .addCommitListener (new CommitListener () {
178+
179+ @ Override
180+ public void onCommit () {
181+ ContactDto updatedContact = FacadeProvider .getContactFacade ().getContactByUuid (contact .getUuid ());
182+ updatedContact .setContactClassification (ContactClassification .CONFIRMED );
183+ FacadeProvider .getContactFacade ().saveContact (updatedContact );
184+ }
185+ });
186+ VaadinUiUtil .showModalPopupWindow (caseCreateComponent , I18nProperties .getString (Strings .headingCreateNewCase ));
187+ } else {
188+ navigateToView (CaseDataView .VIEW_NAME , uuid , null );
172189 }
173190 });
174-
175- VaadinUiUtil .showModalPopupWindow (caseCreateComponent , I18nProperties .getString (Strings .headingCreateNewCase ));
176191 }
177192
178193 public void createFromUnrelatedContact (ContactDto contact , Disease disease ) {
0 commit comments