Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- import com.fasterxml.jackson.annotation.JsonFormat;
- import com.fasterxml.jackson.databind.ObjectMapper;
- import com.fasterxml.jackson.databind.SerializationFeature;
- import java.io.IOException;
- import java.time.LocalDate;
- public class PatientRecord {
- private String recordId;
- private String patientId;
- private String name;
- private int age;
- @JsonFormat(pattern = "yyyy-MM-dd")
- private LocalDate appointmentDate;
- private String diagnosis;
- private boolean followUpNeeded;
- private String assignedDoctor;
- @JsonFormat(pattern = "yyyy-MM-dd")
- private LocalDate nextAppointmentDate;
- public PatientRecord() {
- }
- // Геттеры и сеттеры для всех полей
- public String getRecordId() {
- return recordId;
- }
- public void setRecordId(String recordId) {
- this.recordId = recordId;
- }
- public String getPatientId() {
- return patientId;
- }
- public void setPatientId(String patientId) {
- this.patientId = patientId;
- }
- public String getName() {
- return name;
- }
- public void setName(String name) {
- this.name = name;
- }
- public int getAge() {
- return age;
- }
- public void setAge(int age) {
- this.age = age;
- }
- public LocalDate getAppointmentDate() {
- return appointmentDate;
- }
- public void setAppointmentDate(LocalDate appointmentDate) {
- this.appointmentDate = appointmentDate;
- }
- public String getDiagnosis() {
- return diagnosis;
- }
- public void setDiagnosis(String diagnosis) {
- this.diagnosis = diagnosis;
- }
- public boolean isFollowUpNeeded() {
- return followUpNeeded;
- }
- public void setFollowUpNeeded(boolean followUpNeeded) {
- this.followUpNeeded = followUpNeeded;
- }
- public String getAssignedDoctor() {
- return assignedDoctor;
- }
- public void setAssignedDoctor(String assignedDoctor) {
- this.assignedDoctor = assignedDoctor;
- }
- public LocalDate getNextAppointmentDate() {
- return nextAppointmentDate;
- }
- public void setNextAppointmentDate(LocalDate nextAppointmentDate) {
- this.nextAppointmentDate = nextAppointmentDate;
- }
- // Методы для сериализации и десериализации JSON
- private static final ObjectMapper objectMapper = new ObjectMapper()
- .findAndRegisterModules() // Регистрация модулей для работы с JavaTime
- .configure(SerializationFeature.WRITE_DATES_AS_TIMESTAMPS, false);
- public static PatientRecord fromJson(String json) {
- try {
- return objectMapper.readValue(json, PatientRecord.class);
- } catch (IOException e) {
- e.printStackTrace();
- return null;
- }
- }
- public String toJson() {
- try {
- return objectMapper.writeValueAsString(this);
- } catch (IOException e) {
- e.printStackTrace();
- return null;
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment