easycare.alc.web.patient.SignatureView.java Source code

Java tutorial

Introduction

Here is the source code for easycare.alc.web.patient.SignatureView.java

Source

package easycare.alc.web.patient;

import easycare.alc.model.HstSignature;
import easycare.helper.TimeZoneHelper;
import lombok.EqualsAndHashCode;
import lombok.Getter;
import lombok.Setter;
import org.joda.time.DateTime;
import org.joda.time.LocalDateTime;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Component;

import java.io.Serializable;

@EqualsAndHashCode
public class SignatureView implements Serializable {
    @Getter
    @Setter
    private String title;

    @Getter
    @Setter
    private String firstName;

    @Getter
    @Setter
    private String lastName;

    @Getter
    @Setter
    private String userName;

    @Getter
    @Setter
    private String licenseNumber;

    @Getter
    @Setter
    private String stateCode;

    @Getter
    @Setter
    private String orgName;

    @Getter
    @Setter
    private String countryCode;

    @Getter
    @Setter
    private String addressLine1;

    @Getter
    @Setter
    private String addressLine2;

    @Getter
    @Setter
    private String citySuburb;

    @Getter
    @Setter
    private String postcode;

    @Getter
    @Setter
    private LocalDateTime signedAt;

    @Getter
    @Setter
    private String timezone;

    @Getter
    @Setter
    private boolean detailedReportFormat;

    public SignatureView() {
    }

    @Component
    public static class Helper {

        @Autowired
        @Setter
        private TimeZoneHelper timeZoneHelper;

        public SignatureView getSignatureView(HstSignature hstSignature) {
            return new SignatureView(hstSignature, timeZoneHelper);
        }
    }

    protected SignatureView(HstSignature hstSignature, TimeZoneHelper timeZoneHelper) {
        if (hstSignature.getTitle() != null) {
            this.title = hstSignature.getTitle().toString();
        }
        this.firstName = hstSignature.getFirstName();
        this.lastName = hstSignature.getLastName();
        this.userName = hstSignature.getUsername();
        this.orgName = hstSignature.getOrgName();
        this.licenseNumber = hstSignature.getLicenseNumber();
        this.stateCode = hstSignature.getState().getStateCode();
        this.countryCode = hstSignature.getState().getCountry().getCountryCode();
        this.addressLine1 = hstSignature.getAddressLine1();
        this.addressLine2 = hstSignature.getAddressLine2();
        this.citySuburb = hstSignature.getCitySuburb();
        this.postcode = hstSignature.getPostcode();
        DateTime dateTimeAndZone = timeZoneHelper
                .convertHardwareLocalDateTimeToSystemTZDateTime(hstSignature.getSignedAt());
        this.signedAt = dateTimeAndZone.toLocalDateTime();
        this.timezone = dateTimeAndZone.getZone().getShortName(0);
        this.detailedReportFormat = hstSignature.getHstReportType().isDetailed();
    }
}