Search in sources :

Example 1 with DaoException

use of de.symeda.sormas.app.backend.common.DaoException in project SORMAS-Project by hzi-braunschweig.

the class TestEntityCreator method createCase.

public static Case createCase(Person person) {
    Disease disease = Disease.EVD;
    Region region = DatabaseHelper.getRegionDao().queryUuid(TestHelper.REGION_UUID);
    District district = DatabaseHelper.getDistrictDao().queryUuid(TestHelper.DISTRICT_UUID);
    Community community = DatabaseHelper.getCommunityDao().queryUuid(TestHelper.COMMUNITY_UUID);
    Facility facility = DatabaseHelper.getFacilityDao().queryUuid(TestHelper.FACILITY_UUID);
    CaseClassification caseClassification = CaseClassification.SUSPECT;
    InvestigationStatus investigationStatus = InvestigationStatus.PENDING;
    Case caze = DatabaseHelper.getCaseDao().build(person);
    caze.setDisease(disease);
    caze.setResponsibleRegion(region);
    caze.setResponsibleDistrict(district);
    caze.setResponsibleCommunity(community);
    caze.setHealthFacility(facility);
    caze.setFacilityType(FacilityType.HOSPITAL);
    caze.setCaseClassification(caseClassification);
    caze.setInvestigationStatus(investigationStatus);
    caze.setReportDate(new Date());
    try {
        DatabaseHelper.getCaseDao().saveAndSnapshot(caze);
        DatabaseHelper.getCaseDao().accept(caze);
    } catch (DaoException e) {
        throw new RuntimeException(e);
    }
    return DatabaseHelper.getCaseDao().queryForIdWithEmbedded(caze.getId());
}
Also used : Disease(de.symeda.sormas.api.Disease) CaseClassification(de.symeda.sormas.api.caze.CaseClassification) Region(de.symeda.sormas.app.backend.region.Region) Facility(de.symeda.sormas.app.backend.facility.Facility) InvestigationStatus(de.symeda.sormas.api.caze.InvestigationStatus) DaoException(de.symeda.sormas.app.backend.common.DaoException) District(de.symeda.sormas.app.backend.region.District) Community(de.symeda.sormas.app.backend.region.Community) Date(java.util.Date) Case(de.symeda.sormas.app.backend.caze.Case)

Example 2 with DaoException

use of de.symeda.sormas.app.backend.common.DaoException in project SORMAS-Project by hzi-braunschweig.

the class TestEntityCreator method createEvent.

public static Event createEvent() {
    String eventTitle = "FirstEventTitle";
    String eventDesc = "FirstEventDescription";
    Date eventDate = DateHelper.subtractDays(new Date(), 2);
    Date eventInvestigationStartDate = DateHelper.subtractDays(new Date(), 1);
    Date eventInvestigationEndDate = new Date();
    TypeOfPlace typeOfPlace = TypeOfPlace.PUBLIC_PLACE;
    String srcFirstName = "Emil";
    String srcLastName = "Mpenza";
    String srcTelNo = "0150123123123";
    Event event = DatabaseHelper.getEventDao().build();
    event.setEventTitle(eventTitle);
    event.setEventInvestigationStartDate(eventInvestigationStartDate);
    event.setEventInvestigationEndDate(eventInvestigationEndDate);
    event.setEventDesc(eventDesc);
    event.setStartDate(eventDate);
    event.setTypeOfPlace(typeOfPlace);
    event.setSrcFirstName(srcFirstName);
    event.setSrcLastName(srcLastName);
    event.setSrcTelNo(srcTelNo);
    try {
        DatabaseHelper.getEventDao().saveAndSnapshot(event);
        DatabaseHelper.getEventDao().accept(event);
    } catch (DaoException e) {
        throw new RuntimeException(e);
    }
    return DatabaseHelper.getEventDao().queryForIdWithEmbedded(event.getId());
}
Also used : Event(de.symeda.sormas.app.backend.event.Event) TypeOfPlace(de.symeda.sormas.api.event.TypeOfPlace) DaoException(de.symeda.sormas.app.backend.common.DaoException) Date(java.util.Date)

Example 3 with DaoException

use of de.symeda.sormas.app.backend.common.DaoException in project SORMAS-Project by hzi-braunschweig.

the class TestEntityCreator method createSampleTest.

public static PathogenTest createSampleTest(Sample sample) {
    PathogenTestType pathogenTestType = PathogenTestType.RAPID_TEST;
    PathogenTestResultType pathogenTestResultType = PathogenTestResultType.NEGATIVE;
    Date sampleTestDateTime = new Date();
    PathogenTest pathogenTest = DatabaseHelper.getSampleTestDao().build(sample);
    pathogenTest.setTestType(pathogenTestType);
    pathogenTest.setTestResult(pathogenTestResultType);
    pathogenTest.setTestDateTime(sampleTestDateTime);
    try {
        DatabaseHelper.getSampleTestDao().saveAndSnapshot(pathogenTest);
        DatabaseHelper.getSampleTestDao().accept(pathogenTest);
    } catch (DaoException e) {
        throw new RuntimeException(e);
    }
    return DatabaseHelper.getSampleTestDao().queryForIdWithEmbedded(pathogenTest.getId());
}
Also used : PathogenTestResultType(de.symeda.sormas.api.sample.PathogenTestResultType) PathogenTest(de.symeda.sormas.app.backend.sample.PathogenTest) PathogenTestType(de.symeda.sormas.api.sample.PathogenTestType) DaoException(de.symeda.sormas.app.backend.common.DaoException) Date(java.util.Date)

Example 4 with DaoException

use of de.symeda.sormas.app.backend.common.DaoException in project SORMAS-Project by hzi-braunschweig.

the class TestEntityCreator method createWeeklyReport.

public static WeeklyReport createWeeklyReport(EpiWeek epiWeek) {
    WeeklyReport weeklyReport;
    try {
        weeklyReport = DatabaseHelper.getWeeklyReportDao().build(epiWeek);
        DatabaseHelper.getWeeklyReportDao().saveAndSnapshot(weeklyReport);
    } catch (DaoException e) {
        throw new RuntimeException(e);
    }
    return DatabaseHelper.getWeeklyReportDao().queryForIdWithEmbedded(weeklyReport.getId());
}
Also used : WeeklyReport(de.symeda.sormas.app.backend.report.WeeklyReport) DaoException(de.symeda.sormas.app.backend.common.DaoException)

Example 5 with DaoException

use of de.symeda.sormas.app.backend.common.DaoException in project SORMAS-Project by hzi-braunschweig.

the class TestEntityCreator method createSample.

public static Sample createSample(Case caze) {
    if (caze == null) {
        caze = createCase();
    }
    Date sampleDateTime = DateHelper.subtractDays(new Date(), 1);
    Facility lab = DatabaseHelper.getFacilityDao().queryForAll().get(0);
    SampleMaterial material = SampleMaterial.BLOOD;
    Sample sample = DatabaseHelper.getSampleDao().build(caze);
    sample.setSampleDateTime(sampleDateTime);
    sample.setLab(lab);
    sample.setSampleMaterial(material);
    try {
        DatabaseHelper.getSampleDao().saveAndSnapshot(sample);
        DatabaseHelper.getSampleDao().accept(sample);
    } catch (DaoException e) {
        throw new RuntimeException(e);
    }
    return DatabaseHelper.getSampleDao().queryForIdWithEmbedded(sample.getId());
}
Also used : Sample(de.symeda.sormas.app.backend.sample.Sample) SampleMaterial(de.symeda.sormas.api.sample.SampleMaterial) Facility(de.symeda.sormas.app.backend.facility.Facility) DaoException(de.symeda.sormas.app.backend.common.DaoException) Date(java.util.Date)

Aggregations

DaoException (de.symeda.sormas.app.backend.common.DaoException)18 Date (java.util.Date)10 Contact (de.symeda.sormas.app.backend.contact.Contact)4 Task (de.symeda.sormas.app.backend.task.Task)3 TaskDto (de.symeda.sormas.api.task.TaskDto)2 ValidationException (de.symeda.sormas.api.utils.ValidationException)2 Case (de.symeda.sormas.app.backend.caze.Case)2 Event (de.symeda.sormas.app.backend.event.Event)2 EventParticipant (de.symeda.sormas.app.backend.event.EventParticipant)2 Facility (de.symeda.sormas.app.backend.facility.Facility)2 Person (de.symeda.sormas.app.backend.person.Person)2 Sample (de.symeda.sormas.app.backend.sample.Sample)2 TaskDtoHelper (de.symeda.sormas.app.backend.task.TaskDtoHelper)2 User (de.symeda.sormas.app.backend.user.User)2 ConfirmationDialog (de.symeda.sormas.app.component.dialog.ConfirmationDialog)2 Intent (android.content.Intent)1 PackageManager (android.content.pm.PackageManager)1 Location (android.location.Location)1 Bundle (android.os.Bundle)1 LayoutInflater (android.view.LayoutInflater)1