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