diff --git a/.jhipster/Department.json b/.jhipster/Department.json new file mode 100644 index 0000000..19167ed --- /dev/null +++ b/.jhipster/Department.json @@ -0,0 +1,52 @@ +{ + "name": "Department", + "fields": [ + { + "fieldName": "name", + "fieldType": "String", + "fieldValidateRules": [ + "maxlength", + "required" + ], + "fieldValidateRulesMaxlength": "200" + }, + { + "fieldName": "type", + "fieldType": "DepartmentType", + "fieldValues": "SERVICE,POLYCLINIC" + }, + { + "fieldName": "description", + "fieldType": "String", + "fieldValidateRules": [ + "maxlength" + ], + "fieldValidateRulesMaxlength": "1000" + }, + { + "fieldName": "active", + "fieldType": "Boolean" + } + ], + "relationships": [ + { + "relationshipType": "many-to-many", + "otherEntityName": "doctor", + "otherEntityRelationshipName": "department", + "relationshipName": "doctor", + "otherEntityField": "id", + "ownerSide": false + } + ], + "changelogDate": "20200501230500", + "entityTableName": "department", + "dto": "mapstruct", + "pagination": "pagination", + "service": "serviceImpl", + "jpaMetamodelFiltering": false, + "fluentMethods": true, + "readOnly": false, + "embedded": false, + "clientRootFolder": "", + "applications": "*" +} \ No newline at end of file diff --git a/.jhipster/Doctor.json b/.jhipster/Doctor.json new file mode 100644 index 0000000..ba2e1c0 --- /dev/null +++ b/.jhipster/Doctor.json @@ -0,0 +1,47 @@ +{ + "name": "Doctor", + "fields": [ + { + "fieldName": "name", + "fieldType": "String", + "fieldValidateRules": [ + "maxlength", + "required" + ], + "fieldValidateRulesMaxlength": "100" + }, + { + "fieldName": "phone", + "fieldType": "String", + "fieldValidateRules": [ + "maxlength" + ], + "fieldValidateRulesMaxlength": "20" + }, + { + "fieldName": "salary", + "fieldType": "Long" + } + ], + "relationships": [ + { + "relationshipType": "many-to-many", + "otherEntityName": "department", + "otherEntityRelationshipName": "doctor", + "relationshipName": "department", + "otherEntityField": "name", + "ownerSide": true + } + ], + "changelogDate": "20200501230600", + "entityTableName": "doctor", + "dto": "mapstruct", + "pagination": "pagination", + "service": "serviceImpl", + "jpaMetamodelFiltering": false, + "fluentMethods": true, + "readOnly": false, + "embedded": false, + "clientRootFolder": "", + "applications": "*" +} \ No newline at end of file diff --git a/.jhipster/Patient.json b/.jhipster/Patient.json new file mode 100644 index 0000000..14b2097 --- /dev/null +++ b/.jhipster/Patient.json @@ -0,0 +1,47 @@ +{ + "name": "Patient", + "fields": [ + { + "fieldName": "name", + "fieldType": "String", + "fieldValidateRules": [ + "maxlength", + "required" + ], + "fieldValidateRulesMaxlength": "100" + }, + { + "fieldName": "phone", + "fieldType": "String", + "fieldValidateRules": [ + "maxlength" + ], + "fieldValidateRulesMaxlength": "20" + }, + { + "fieldName": "birthDate", + "fieldType": "LocalDate" + }, + { + "fieldName": "citizenNumber", + "fieldType": "String", + "fieldValidateRules": [ + "maxlength", + "required" + ], + "fieldValidateRulesMaxlength": "11" + } + ], + "relationships": [], + "changelogDate": "20200501230400", + "entityTableName": "patient", + "dto": "mapstruct", + "pagination": "pagination", + "service": "serviceImpl", + "jpaMetamodelFiltering": false, + "fluentMethods": true, + "readOnly": false, + "embedded": false, + "clientRootFolder": "", + "applications": "*" +} \ No newline at end of file diff --git a/.jhipster/Visit.json b/.jhipster/Visit.json new file mode 100644 index 0000000..e70f8a3 --- /dev/null +++ b/.jhipster/Visit.json @@ -0,0 +1,56 @@ +{ + "name": "Visit", + "fields": [ + { + "fieldName": "date", + "fieldType": "Instant" + }, + { + "fieldName": "type", + "fieldType": "VisitType", + "fieldValues": "EXAMINATION,ANALYSIS" + } + ], + "relationships": [ + { + "relationshipType": "many-to-one", + "otherEntityName": "patient", + "otherEntityRelationshipName": "visit", + "relationshipName": "patient", + "otherEntityField": "name" + }, + { + "relationshipType": "many-to-one", + "otherEntityName": "doctor", + "otherEntityRelationshipName": "visit", + "relationshipName": "doctor", + "otherEntityField": "name" + }, + { + "relationshipType": "many-to-one", + "otherEntityName": "department", + "otherEntityRelationshipName": "visit", + "relationshipName": "department", + "otherEntityField": "name" + }, + { + "relationshipType": "many-to-many", + "otherEntityName": "visitService", + "otherEntityRelationshipName": "visit", + "relationshipName": "visitService", + "otherEntityField": "name", + "ownerSide": true + } + ], + "changelogDate": "20200501230800", + "entityTableName": "visit", + "dto": "mapstruct", + "pagination": "pagination", + "service": "serviceImpl", + "jpaMetamodelFiltering": false, + "fluentMethods": true, + "readOnly": false, + "embedded": false, + "clientRootFolder": "", + "applications": "*" +} \ No newline at end of file diff --git a/.jhipster/VisitService.json b/.jhipster/VisitService.json new file mode 100644 index 0000000..5869a76 --- /dev/null +++ b/.jhipster/VisitService.json @@ -0,0 +1,51 @@ +{ + "name": "VisitService", + "fields": [ + { + "fieldName": "name", + "fieldType": "String", + "fieldValidateRules": [ + "maxlength", + "required" + ], + "fieldValidateRulesMaxlength": "200" + }, + { + "fieldName": "description", + "fieldType": "String", + "fieldValidateRules": [ + "maxlength" + ], + "fieldValidateRulesMaxlength": "1000" + }, + { + "fieldName": "active", + "fieldType": "Boolean" + }, + { + "fieldName": "price", + "fieldType": "Double" + } + ], + "relationships": [ + { + "relationshipType": "many-to-many", + "otherEntityName": "visit", + "otherEntityRelationshipName": "visitService", + "relationshipName": "visit", + "otherEntityField": "id", + "ownerSide": false + } + ], + "changelogDate": "20200501230700", + "entityTableName": "visit_service", + "dto": "mapstruct", + "pagination": "pagination", + "service": "serviceImpl", + "jpaMetamodelFiltering": false, + "fluentMethods": true, + "readOnly": false, + "embedded": false, + "clientRootFolder": "", + "applications": "*" +} \ No newline at end of file diff --git a/jhipster-jdl-1.jh b/jhipster-jdl-1.jh index 094bc17..18893ef 100644 --- a/jhipster-jdl-1.jh +++ b/jhipster-jdl-1.jh @@ -12,11 +12,11 @@ entity Patient { /* * Hasta Adi */ - name String max(100) required, + name String maxlength(100) required, /* * Telefon Numarasi */ - phone String max(20), + phone String maxlength(20), /* * Dogum Tarihi */ @@ -24,8 +24,8 @@ entity Patient { /* * Kimlik numarasi */ - citizenNumber String max(11) required - + citizenNumber String maxlength(11) required + } /* @@ -35,7 +35,7 @@ entity Department{ /* * Bolum Adi */ - name String max(200) required, + name String maxlength(200) required, /* * Bolum Tipi */ @@ -43,7 +43,7 @@ entity Department{ /* * Acciklama */ - description String max(1000), + description String maxlength(1000), /* * Aktiflik durumu */ @@ -56,11 +56,11 @@ entity Doctor{ /* * Doktor Adi */ - name String max(100) required, + name String maxlength(100) required, /* * Telefon Numarasi */ - phone String max(20), + phone String maxlength(20), /* * Maas bilgisi */ @@ -70,7 +70,7 @@ entity Doctor{ * Hastanin basvuru */ enum VisitType{ - EXAMINATION, ANALYSIS + EXAMINATION, ANALYSIS } /* * Hastaya verilebilecek Hizmet listesi @@ -79,11 +79,11 @@ entity VisitService{ /* * Hizmet Adi */ - name String max(200) required, + name String maxlength(200) required, /* * Aciklama */ - description String max(1000), + description String maxlength(1000), /* * Aktiflik durumu */ @@ -121,15 +121,15 @@ relationship ManyToOne{ * Hastanin basvurdugu bolum */ Visit{department(name)} to Department, - + } relationship ManyToMany{ - + /* * Hasta ve basvuru iliskisi */ - Visit{service(name)} to VisitService, + Visit{visitService(name)} to VisitService{visit}, /* * Hasta ve basvuru iliskisi */ @@ -143,7 +143,3 @@ dto * with mapstruct // Set service options to all except few service all with serviceImpl - - - - diff --git a/src/main/java/tr/com/aurora/hbys/healthcare/config/CacheConfiguration.java b/src/main/java/tr/com/aurora/hbys/healthcare/config/CacheConfiguration.java index ed62fb6..6dd970a 100644 --- a/src/main/java/tr/com/aurora/hbys/healthcare/config/CacheConfiguration.java +++ b/src/main/java/tr/com/aurora/hbys/healthcare/config/CacheConfiguration.java @@ -42,6 +42,15 @@ public JCacheManagerCustomizer cacheManagerCustomizer() { createCache(cm, tr.com.aurora.hbys.healthcare.domain.User.class.getName()); createCache(cm, tr.com.aurora.hbys.healthcare.domain.Authority.class.getName()); createCache(cm, tr.com.aurora.hbys.healthcare.domain.User.class.getName() + ".authorities"); + createCache(cm, tr.com.aurora.hbys.healthcare.domain.Patient.class.getName()); + createCache(cm, tr.com.aurora.hbys.healthcare.domain.Department.class.getName()); + createCache(cm, tr.com.aurora.hbys.healthcare.domain.Department.class.getName() + ".doctors"); + createCache(cm, tr.com.aurora.hbys.healthcare.domain.Doctor.class.getName()); + createCache(cm, tr.com.aurora.hbys.healthcare.domain.Doctor.class.getName() + ".departments"); + createCache(cm, tr.com.aurora.hbys.healthcare.domain.VisitService.class.getName()); + createCache(cm, tr.com.aurora.hbys.healthcare.domain.VisitService.class.getName() + ".visits"); + createCache(cm, tr.com.aurora.hbys.healthcare.domain.Visit.class.getName()); + createCache(cm, tr.com.aurora.hbys.healthcare.domain.Visit.class.getName() + ".visitServices"); // jhipster-needle-ehcache-add-entry }; } diff --git a/src/main/java/tr/com/aurora/hbys/healthcare/domain/Department.java b/src/main/java/tr/com/aurora/hbys/healthcare/domain/Department.java new file mode 100644 index 0000000..ae2f1f9 --- /dev/null +++ b/src/main/java/tr/com/aurora/hbys/healthcare/domain/Department.java @@ -0,0 +1,166 @@ +package tr.com.aurora.hbys.healthcare.domain; + +import com.fasterxml.jackson.annotation.JsonIgnore; +import org.hibernate.annotations.Cache; +import org.hibernate.annotations.CacheConcurrencyStrategy; + +import javax.persistence.*; +import javax.validation.constraints.*; + +import java.io.Serializable; +import java.util.Objects; +import java.util.HashSet; +import java.util.Set; + +import tr.com.aurora.hbys.healthcare.domain.enumeration.DepartmentType; + +/** + * A Department. + */ +@Entity +@Table(name = "department") +@Cache(usage = CacheConcurrencyStrategy.NONSTRICT_READ_WRITE) +public class Department implements Serializable { + + private static final long serialVersionUID = 1L; + + @Id + @GeneratedValue(strategy = GenerationType.SEQUENCE, generator = "sequenceGenerator") + @SequenceGenerator(name = "sequenceGenerator") + private Long id; + + @NotNull + @Size(max = 200) + @Column(name = "name", length = 200, nullable = false) + private String name; + + @Enumerated(EnumType.STRING) + @Column(name = "type") + private DepartmentType type; + + @Size(max = 1000) + @Column(name = "description", length = 1000) + private String description; + + @Column(name = "active") + private Boolean active; + + @ManyToMany(mappedBy = "departments") + @Cache(usage = CacheConcurrencyStrategy.NONSTRICT_READ_WRITE) + @JsonIgnore + private Set doctors = new HashSet<>(); + + // jhipster-needle-entity-add-field - JHipster will add fields here, do not remove + public Long getId() { + return id; + } + + public void setId(Long id) { + this.id = id; + } + + public String getName() { + return name; + } + + public Department name(String name) { + this.name = name; + return this; + } + + public void setName(String name) { + this.name = name; + } + + public DepartmentType getType() { + return type; + } + + public Department type(DepartmentType type) { + this.type = type; + return this; + } + + public void setType(DepartmentType type) { + this.type = type; + } + + public String getDescription() { + return description; + } + + public Department description(String description) { + this.description = description; + return this; + } + + public void setDescription(String description) { + this.description = description; + } + + public Boolean isActive() { + return active; + } + + public Department active(Boolean active) { + this.active = active; + return this; + } + + public void setActive(Boolean active) { + this.active = active; + } + + public Set getDoctors() { + return doctors; + } + + public Department doctors(Set doctors) { + this.doctors = doctors; + return this; + } + + public Department addDoctor(Doctor doctor) { + this.doctors.add(doctor); + doctor.getDepartments().add(this); + return this; + } + + public Department removeDoctor(Doctor doctor) { + this.doctors.remove(doctor); + doctor.getDepartments().remove(this); + return this; + } + + public void setDoctors(Set doctors) { + this.doctors = doctors; + } + // jhipster-needle-entity-add-getters-setters - JHipster will add getters and setters here, do not remove + + @Override + public boolean equals(Object o) { + if (this == o) { + return true; + } + if (!(o instanceof Department)) { + return false; + } + return id != null && id.equals(((Department) o).id); + } + + @Override + public int hashCode() { + return 31; + } + + @Override + public String toString() { + return "Department{" + + "id=" + getId() + + ", name='" + getName() + "'" + + ", type='" + getType() + "'" + + ", description='" + getDescription() + "'" + + ", active='" + isActive() + "'" + + "}"; + } +} diff --git a/src/main/java/tr/com/aurora/hbys/healthcare/domain/Doctor.java b/src/main/java/tr/com/aurora/hbys/healthcare/domain/Doctor.java new file mode 100644 index 0000000..53e4e29 --- /dev/null +++ b/src/main/java/tr/com/aurora/hbys/healthcare/domain/Doctor.java @@ -0,0 +1,147 @@ +package tr.com.aurora.hbys.healthcare.domain; + +import org.hibernate.annotations.Cache; +import org.hibernate.annotations.CacheConcurrencyStrategy; + +import javax.persistence.*; +import javax.validation.constraints.*; + +import java.io.Serializable; +import java.util.Objects; +import java.util.HashSet; +import java.util.Set; + +/** + * A Doctor. + */ +@Entity +@Table(name = "doctor") +@Cache(usage = CacheConcurrencyStrategy.NONSTRICT_READ_WRITE) +public class Doctor implements Serializable { + + private static final long serialVersionUID = 1L; + + @Id + @GeneratedValue(strategy = GenerationType.SEQUENCE, generator = "sequenceGenerator") + @SequenceGenerator(name = "sequenceGenerator") + private Long id; + + @NotNull + @Size(max = 100) + @Column(name = "name", length = 100, nullable = false) + private String name; + + @Size(max = 20) + @Column(name = "phone", length = 20) + private String phone; + + @Column(name = "salary") + private Long salary; + + @ManyToMany + @Cache(usage = CacheConcurrencyStrategy.NONSTRICT_READ_WRITE) + @JoinTable(name = "doctor_department", + joinColumns = @JoinColumn(name = "doctor_id", referencedColumnName = "id"), + inverseJoinColumns = @JoinColumn(name = "department_id", referencedColumnName = "id")) + private Set departments = new HashSet<>(); + + // jhipster-needle-entity-add-field - JHipster will add fields here, do not remove + public Long getId() { + return id; + } + + public void setId(Long id) { + this.id = id; + } + + public String getName() { + return name; + } + + public Doctor name(String name) { + this.name = name; + return this; + } + + public void setName(String name) { + this.name = name; + } + + public String getPhone() { + return phone; + } + + public Doctor phone(String phone) { + this.phone = phone; + return this; + } + + public void setPhone(String phone) { + this.phone = phone; + } + + public Long getSalary() { + return salary; + } + + public Doctor salary(Long salary) { + this.salary = salary; + return this; + } + + public void setSalary(Long salary) { + this.salary = salary; + } + + public Set getDepartments() { + return departments; + } + + public Doctor departments(Set departments) { + this.departments = departments; + return this; + } + + public Doctor addDepartment(Department department) { + this.departments.add(department); + department.getDoctors().add(this); + return this; + } + + public Doctor removeDepartment(Department department) { + this.departments.remove(department); + department.getDoctors().remove(this); + return this; + } + + public void setDepartments(Set departments) { + this.departments = departments; + } + // jhipster-needle-entity-add-getters-setters - JHipster will add getters and setters here, do not remove + + @Override + public boolean equals(Object o) { + if (this == o) { + return true; + } + if (!(o instanceof Doctor)) { + return false; + } + return id != null && id.equals(((Doctor) o).id); + } + + @Override + public int hashCode() { + return 31; + } + + @Override + public String toString() { + return "Doctor{" + + "id=" + getId() + + ", name='" + getName() + "'" + + ", phone='" + getPhone() + "'" + + ", salary=" + getSalary() + + "}"; + } +} diff --git a/src/main/java/tr/com/aurora/hbys/healthcare/domain/Patient.java b/src/main/java/tr/com/aurora/hbys/healthcare/domain/Patient.java new file mode 100644 index 0000000..595cdec --- /dev/null +++ b/src/main/java/tr/com/aurora/hbys/healthcare/domain/Patient.java @@ -0,0 +1,133 @@ +package tr.com.aurora.hbys.healthcare.domain; + +import org.hibernate.annotations.Cache; +import org.hibernate.annotations.CacheConcurrencyStrategy; + +import javax.persistence.*; +import javax.validation.constraints.*; + +import java.io.Serializable; +import java.util.Objects; +import java.time.LocalDate; + +/** + * A Patient. + */ +@Entity +@Table(name = "patient") +@Cache(usage = CacheConcurrencyStrategy.NONSTRICT_READ_WRITE) +public class Patient implements Serializable { + + private static final long serialVersionUID = 1L; + + @Id + @GeneratedValue(strategy = GenerationType.SEQUENCE, generator = "sequenceGenerator") + @SequenceGenerator(name = "sequenceGenerator") + private Long id; + + @NotNull + @Size(max = 100) + @Column(name = "name", length = 100, nullable = false) + private String name; + + @Size(max = 20) + @Column(name = "phone", length = 20) + private String phone; + + @Column(name = "birth_date") + private LocalDate birthDate; + + @NotNull + @Size(max = 11) + @Column(name = "citizen_number", length = 11, nullable = false) + private String citizenNumber; + + // jhipster-needle-entity-add-field - JHipster will add fields here, do not remove + public Long getId() { + return id; + } + + public void setId(Long id) { + this.id = id; + } + + public String getName() { + return name; + } + + public Patient name(String name) { + this.name = name; + return this; + } + + public void setName(String name) { + this.name = name; + } + + public String getPhone() { + return phone; + } + + public Patient phone(String phone) { + this.phone = phone; + return this; + } + + public void setPhone(String phone) { + this.phone = phone; + } + + public LocalDate getBirthDate() { + return birthDate; + } + + public Patient birthDate(LocalDate birthDate) { + this.birthDate = birthDate; + return this; + } + + public void setBirthDate(LocalDate birthDate) { + this.birthDate = birthDate; + } + + public String getCitizenNumber() { + return citizenNumber; + } + + public Patient citizenNumber(String citizenNumber) { + this.citizenNumber = citizenNumber; + return this; + } + + public void setCitizenNumber(String citizenNumber) { + this.citizenNumber = citizenNumber; + } + // jhipster-needle-entity-add-getters-setters - JHipster will add getters and setters here, do not remove + + @Override + public boolean equals(Object o) { + if (this == o) { + return true; + } + if (!(o instanceof Patient)) { + return false; + } + return id != null && id.equals(((Patient) o).id); + } + + @Override + public int hashCode() { + return 31; + } + + @Override + public String toString() { + return "Patient{" + + "id=" + getId() + + ", name='" + getName() + "'" + + ", phone='" + getPhone() + "'" + + ", birthDate='" + getBirthDate() + "'" + + ", citizenNumber='" + getCitizenNumber() + "'" + + "}"; + } +} diff --git a/src/main/java/tr/com/aurora/hbys/healthcare/domain/Visit.java b/src/main/java/tr/com/aurora/hbys/healthcare/domain/Visit.java new file mode 100644 index 0000000..91d82e8 --- /dev/null +++ b/src/main/java/tr/com/aurora/hbys/healthcare/domain/Visit.java @@ -0,0 +1,182 @@ +package tr.com.aurora.hbys.healthcare.domain; + +import com.fasterxml.jackson.annotation.JsonIgnoreProperties; +import org.hibernate.annotations.Cache; +import org.hibernate.annotations.CacheConcurrencyStrategy; + +import javax.persistence.*; + +import java.io.Serializable; +import java.util.Objects; +import java.time.Instant; +import java.util.HashSet; +import java.util.Set; + +import tr.com.aurora.hbys.healthcare.domain.enumeration.VisitType; + +/** + * A Visit. + */ +@Entity +@Table(name = "visit") +@Cache(usage = CacheConcurrencyStrategy.NONSTRICT_READ_WRITE) +public class Visit implements Serializable { + + private static final long serialVersionUID = 1L; + + @Id + @GeneratedValue(strategy = GenerationType.SEQUENCE, generator = "sequenceGenerator") + @SequenceGenerator(name = "sequenceGenerator") + private Long id; + + @Column(name = "date") + private Instant date; + + @Enumerated(EnumType.STRING) + @Column(name = "type") + private VisitType type; + + @ManyToOne + @JsonIgnoreProperties("visits") + private Patient patient; + + @ManyToOne + @JsonIgnoreProperties("visits") + private Doctor doctor; + + @ManyToOne + @JsonIgnoreProperties("visits") + private Department department; + + @ManyToMany + @Cache(usage = CacheConcurrencyStrategy.NONSTRICT_READ_WRITE) + @JoinTable(name = "visit_visit_service", + joinColumns = @JoinColumn(name = "visit_id", referencedColumnName = "id"), + inverseJoinColumns = @JoinColumn(name = "visit_service_id", referencedColumnName = "id")) + private Set visitServices = new HashSet<>(); + + // jhipster-needle-entity-add-field - JHipster will add fields here, do not remove + public Long getId() { + return id; + } + + public void setId(Long id) { + this.id = id; + } + + public Instant getDate() { + return date; + } + + public Visit date(Instant date) { + this.date = date; + return this; + } + + public void setDate(Instant date) { + this.date = date; + } + + public VisitType getType() { + return type; + } + + public Visit type(VisitType type) { + this.type = type; + return this; + } + + public void setType(VisitType type) { + this.type = type; + } + + public Patient getPatient() { + return patient; + } + + public Visit patient(Patient patient) { + this.patient = patient; + return this; + } + + public void setPatient(Patient patient) { + this.patient = patient; + } + + public Doctor getDoctor() { + return doctor; + } + + public Visit doctor(Doctor doctor) { + this.doctor = doctor; + return this; + } + + public void setDoctor(Doctor doctor) { + this.doctor = doctor; + } + + public Department getDepartment() { + return department; + } + + public Visit department(Department department) { + this.department = department; + return this; + } + + public void setDepartment(Department department) { + this.department = department; + } + + public Set getVisitServices() { + return visitServices; + } + + public Visit visitServices(Set visitServices) { + this.visitServices = visitServices; + return this; + } + + public Visit addVisitService(VisitService visitService) { + this.visitServices.add(visitService); + visitService.getVisits().add(this); + return this; + } + + public Visit removeVisitService(VisitService visitService) { + this.visitServices.remove(visitService); + visitService.getVisits().remove(this); + return this; + } + + public void setVisitServices(Set visitServices) { + this.visitServices = visitServices; + } + // jhipster-needle-entity-add-getters-setters - JHipster will add getters and setters here, do not remove + + @Override + public boolean equals(Object o) { + if (this == o) { + return true; + } + if (!(o instanceof Visit)) { + return false; + } + return id != null && id.equals(((Visit) o).id); + } + + @Override + public int hashCode() { + return 31; + } + + @Override + public String toString() { + return "Visit{" + + "id=" + getId() + + ", date='" + getDate() + "'" + + ", type='" + getType() + "'" + + "}"; + } +} diff --git a/src/main/java/tr/com/aurora/hbys/healthcare/domain/VisitService.java b/src/main/java/tr/com/aurora/hbys/healthcare/domain/VisitService.java new file mode 100644 index 0000000..4f8b82c --- /dev/null +++ b/src/main/java/tr/com/aurora/hbys/healthcare/domain/VisitService.java @@ -0,0 +1,163 @@ +package tr.com.aurora.hbys.healthcare.domain; + +import com.fasterxml.jackson.annotation.JsonIgnore; +import org.hibernate.annotations.Cache; +import org.hibernate.annotations.CacheConcurrencyStrategy; + +import javax.persistence.*; +import javax.validation.constraints.*; + +import java.io.Serializable; +import java.util.Objects; +import java.util.HashSet; +import java.util.Set; + +/** + * A VisitService. + */ +@Entity +@Table(name = "visit_service") +@Cache(usage = CacheConcurrencyStrategy.NONSTRICT_READ_WRITE) +public class VisitService implements Serializable { + + private static final long serialVersionUID = 1L; + + @Id + @GeneratedValue(strategy = GenerationType.SEQUENCE, generator = "sequenceGenerator") + @SequenceGenerator(name = "sequenceGenerator") + private Long id; + + @NotNull + @Size(max = 200) + @Column(name = "name", length = 200, nullable = false) + private String name; + + @Size(max = 1000) + @Column(name = "description", length = 1000) + private String description; + + @Column(name = "active") + private Boolean active; + + @Column(name = "price") + private Double price; + + @ManyToMany(mappedBy = "visitServices") + @Cache(usage = CacheConcurrencyStrategy.NONSTRICT_READ_WRITE) + @JsonIgnore + private Set visits = new HashSet<>(); + + // jhipster-needle-entity-add-field - JHipster will add fields here, do not remove + public Long getId() { + return id; + } + + public void setId(Long id) { + this.id = id; + } + + public String getName() { + return name; + } + + public VisitService name(String name) { + this.name = name; + return this; + } + + public void setName(String name) { + this.name = name; + } + + public String getDescription() { + return description; + } + + public VisitService description(String description) { + this.description = description; + return this; + } + + public void setDescription(String description) { + this.description = description; + } + + public Boolean isActive() { + return active; + } + + public VisitService active(Boolean active) { + this.active = active; + return this; + } + + public void setActive(Boolean active) { + this.active = active; + } + + public Double getPrice() { + return price; + } + + public VisitService price(Double price) { + this.price = price; + return this; + } + + public void setPrice(Double price) { + this.price = price; + } + + public Set getVisits() { + return visits; + } + + public VisitService visits(Set visits) { + this.visits = visits; + return this; + } + + public VisitService addVisit(Visit visit) { + this.visits.add(visit); + visit.getVisitServices().add(this); + return this; + } + + public VisitService removeVisit(Visit visit) { + this.visits.remove(visit); + visit.getVisitServices().remove(this); + return this; + } + + public void setVisits(Set visits) { + this.visits = visits; + } + // jhipster-needle-entity-add-getters-setters - JHipster will add getters and setters here, do not remove + + @Override + public boolean equals(Object o) { + if (this == o) { + return true; + } + if (!(o instanceof VisitService)) { + return false; + } + return id != null && id.equals(((VisitService) o).id); + } + + @Override + public int hashCode() { + return 31; + } + + @Override + public String toString() { + return "VisitService{" + + "id=" + getId() + + ", name='" + getName() + "'" + + ", description='" + getDescription() + "'" + + ", active='" + isActive() + "'" + + ", price=" + getPrice() + + "}"; + } +} diff --git a/src/main/java/tr/com/aurora/hbys/healthcare/domain/enumeration/DepartmentType.java b/src/main/java/tr/com/aurora/hbys/healthcare/domain/enumeration/DepartmentType.java new file mode 100644 index 0000000..ab17137 --- /dev/null +++ b/src/main/java/tr/com/aurora/hbys/healthcare/domain/enumeration/DepartmentType.java @@ -0,0 +1,8 @@ +package tr.com.aurora.hbys.healthcare.domain.enumeration; + +/** + * The DepartmentType enumeration. + */ +public enum DepartmentType { + SERVICE, POLYCLINIC +} diff --git a/src/main/java/tr/com/aurora/hbys/healthcare/domain/enumeration/VisitType.java b/src/main/java/tr/com/aurora/hbys/healthcare/domain/enumeration/VisitType.java new file mode 100644 index 0000000..10dc6a2 --- /dev/null +++ b/src/main/java/tr/com/aurora/hbys/healthcare/domain/enumeration/VisitType.java @@ -0,0 +1,8 @@ +package tr.com.aurora.hbys.healthcare.domain.enumeration; + +/** + * The VisitType enumeration. + */ +public enum VisitType { + EXAMINATION, ANALYSIS +} diff --git a/src/main/java/tr/com/aurora/hbys/healthcare/repository/DepartmentRepository.java b/src/main/java/tr/com/aurora/hbys/healthcare/repository/DepartmentRepository.java new file mode 100644 index 0000000..f6fe8d7 --- /dev/null +++ b/src/main/java/tr/com/aurora/hbys/healthcare/repository/DepartmentRepository.java @@ -0,0 +1,14 @@ +package tr.com.aurora.hbys.healthcare.repository; + +import tr.com.aurora.hbys.healthcare.domain.Department; + +import org.springframework.data.jpa.repository.*; +import org.springframework.stereotype.Repository; + +/** + * Spring Data repository for the Department entity. + */ +@SuppressWarnings("unused") +@Repository +public interface DepartmentRepository extends JpaRepository { +} diff --git a/src/main/java/tr/com/aurora/hbys/healthcare/repository/DoctorRepository.java b/src/main/java/tr/com/aurora/hbys/healthcare/repository/DoctorRepository.java new file mode 100644 index 0000000..94c4c2f --- /dev/null +++ b/src/main/java/tr/com/aurora/hbys/healthcare/repository/DoctorRepository.java @@ -0,0 +1,29 @@ +package tr.com.aurora.hbys.healthcare.repository; + +import tr.com.aurora.hbys.healthcare.domain.Doctor; + +import org.springframework.data.domain.Page; +import org.springframework.data.domain.Pageable; +import org.springframework.data.jpa.repository.*; +import org.springframework.data.repository.query.Param; +import org.springframework.stereotype.Repository; + +import java.util.List; +import java.util.Optional; + +/** + * Spring Data repository for the Doctor entity. + */ +@Repository +public interface DoctorRepository extends JpaRepository { + + @Query(value = "select distinct doctor from Doctor doctor left join fetch doctor.departments", + countQuery = "select count(distinct doctor) from Doctor doctor") + Page findAllWithEagerRelationships(Pageable pageable); + + @Query("select distinct doctor from Doctor doctor left join fetch doctor.departments") + List findAllWithEagerRelationships(); + + @Query("select doctor from Doctor doctor left join fetch doctor.departments where doctor.id =:id") + Optional findOneWithEagerRelationships(@Param("id") Long id); +} diff --git a/src/main/java/tr/com/aurora/hbys/healthcare/repository/PatientRepository.java b/src/main/java/tr/com/aurora/hbys/healthcare/repository/PatientRepository.java new file mode 100644 index 0000000..a661150 --- /dev/null +++ b/src/main/java/tr/com/aurora/hbys/healthcare/repository/PatientRepository.java @@ -0,0 +1,14 @@ +package tr.com.aurora.hbys.healthcare.repository; + +import tr.com.aurora.hbys.healthcare.domain.Patient; + +import org.springframework.data.jpa.repository.*; +import org.springframework.stereotype.Repository; + +/** + * Spring Data repository for the Patient entity. + */ +@SuppressWarnings("unused") +@Repository +public interface PatientRepository extends JpaRepository { +} diff --git a/src/main/java/tr/com/aurora/hbys/healthcare/repository/VisitRepository.java b/src/main/java/tr/com/aurora/hbys/healthcare/repository/VisitRepository.java new file mode 100644 index 0000000..11afa20 --- /dev/null +++ b/src/main/java/tr/com/aurora/hbys/healthcare/repository/VisitRepository.java @@ -0,0 +1,29 @@ +package tr.com.aurora.hbys.healthcare.repository; + +import tr.com.aurora.hbys.healthcare.domain.Visit; + +import org.springframework.data.domain.Page; +import org.springframework.data.domain.Pageable; +import org.springframework.data.jpa.repository.*; +import org.springframework.data.repository.query.Param; +import org.springframework.stereotype.Repository; + +import java.util.List; +import java.util.Optional; + +/** + * Spring Data repository for the Visit entity. + */ +@Repository +public interface VisitRepository extends JpaRepository { + + @Query(value = "select distinct visit from Visit visit left join fetch visit.visitServices", + countQuery = "select count(distinct visit) from Visit visit") + Page findAllWithEagerRelationships(Pageable pageable); + + @Query("select distinct visit from Visit visit left join fetch visit.visitServices") + List findAllWithEagerRelationships(); + + @Query("select visit from Visit visit left join fetch visit.visitServices where visit.id =:id") + Optional findOneWithEagerRelationships(@Param("id") Long id); +} diff --git a/src/main/java/tr/com/aurora/hbys/healthcare/repository/VisitServiceRepository.java b/src/main/java/tr/com/aurora/hbys/healthcare/repository/VisitServiceRepository.java new file mode 100644 index 0000000..4427c5f --- /dev/null +++ b/src/main/java/tr/com/aurora/hbys/healthcare/repository/VisitServiceRepository.java @@ -0,0 +1,14 @@ +package tr.com.aurora.hbys.healthcare.repository; + +import tr.com.aurora.hbys.healthcare.domain.VisitService; + +import org.springframework.data.jpa.repository.*; +import org.springframework.stereotype.Repository; + +/** + * Spring Data repository for the VisitService entity. + */ +@SuppressWarnings("unused") +@Repository +public interface VisitServiceRepository extends JpaRepository { +} diff --git a/src/main/java/tr/com/aurora/hbys/healthcare/service/DepartmentService.java b/src/main/java/tr/com/aurora/hbys/healthcare/service/DepartmentService.java new file mode 100644 index 0000000..f9944a5 --- /dev/null +++ b/src/main/java/tr/com/aurora/hbys/healthcare/service/DepartmentService.java @@ -0,0 +1,45 @@ +package tr.com.aurora.hbys.healthcare.service; + +import tr.com.aurora.hbys.healthcare.service.dto.DepartmentDTO; + +import org.springframework.data.domain.Page; +import org.springframework.data.domain.Pageable; + +import java.util.Optional; + +/** + * Service Interface for managing {@link tr.com.aurora.hbys.healthcare.domain.Department}. + */ +public interface DepartmentService { + + /** + * Save a department. + * + * @param departmentDTO the entity to save. + * @return the persisted entity. + */ + DepartmentDTO save(DepartmentDTO departmentDTO); + + /** + * Get all the departments. + * + * @param pageable the pagination information. + * @return the list of entities. + */ + Page findAll(Pageable pageable); + + /** + * Get the "id" department. + * + * @param id the id of the entity. + * @return the entity. + */ + Optional findOne(Long id); + + /** + * Delete the "id" department. + * + * @param id the id of the entity. + */ + void delete(Long id); +} diff --git a/src/main/java/tr/com/aurora/hbys/healthcare/service/DoctorService.java b/src/main/java/tr/com/aurora/hbys/healthcare/service/DoctorService.java new file mode 100644 index 0000000..07d8205 --- /dev/null +++ b/src/main/java/tr/com/aurora/hbys/healthcare/service/DoctorService.java @@ -0,0 +1,52 @@ +package tr.com.aurora.hbys.healthcare.service; + +import tr.com.aurora.hbys.healthcare.service.dto.DoctorDTO; + +import org.springframework.data.domain.Page; +import org.springframework.data.domain.Pageable; + +import java.util.Optional; + +/** + * Service Interface for managing {@link tr.com.aurora.hbys.healthcare.domain.Doctor}. + */ +public interface DoctorService { + + /** + * Save a doctor. + * + * @param doctorDTO the entity to save. + * @return the persisted entity. + */ + DoctorDTO save(DoctorDTO doctorDTO); + + /** + * Get all the doctors. + * + * @param pageable the pagination information. + * @return the list of entities. + */ + Page findAll(Pageable pageable); + + /** + * Get all the doctors with eager load of many-to-many relationships. + * + * @return the list of entities. + */ + Page findAllWithEagerRelationships(Pageable pageable); + + /** + * Get the "id" doctor. + * + * @param id the id of the entity. + * @return the entity. + */ + Optional findOne(Long id); + + /** + * Delete the "id" doctor. + * + * @param id the id of the entity. + */ + void delete(Long id); +} diff --git a/src/main/java/tr/com/aurora/hbys/healthcare/service/PatientService.java b/src/main/java/tr/com/aurora/hbys/healthcare/service/PatientService.java new file mode 100644 index 0000000..12edb0e --- /dev/null +++ b/src/main/java/tr/com/aurora/hbys/healthcare/service/PatientService.java @@ -0,0 +1,45 @@ +package tr.com.aurora.hbys.healthcare.service; + +import tr.com.aurora.hbys.healthcare.service.dto.PatientDTO; + +import org.springframework.data.domain.Page; +import org.springframework.data.domain.Pageable; + +import java.util.Optional; + +/** + * Service Interface for managing {@link tr.com.aurora.hbys.healthcare.domain.Patient}. + */ +public interface PatientService { + + /** + * Save a patient. + * + * @param patientDTO the entity to save. + * @return the persisted entity. + */ + PatientDTO save(PatientDTO patientDTO); + + /** + * Get all the patients. + * + * @param pageable the pagination information. + * @return the list of entities. + */ + Page findAll(Pageable pageable); + + /** + * Get the "id" patient. + * + * @param id the id of the entity. + * @return the entity. + */ + Optional findOne(Long id); + + /** + * Delete the "id" patient. + * + * @param id the id of the entity. + */ + void delete(Long id); +} diff --git a/src/main/java/tr/com/aurora/hbys/healthcare/service/VisitService.java b/src/main/java/tr/com/aurora/hbys/healthcare/service/VisitService.java new file mode 100644 index 0000000..3bc8c40 --- /dev/null +++ b/src/main/java/tr/com/aurora/hbys/healthcare/service/VisitService.java @@ -0,0 +1,52 @@ +package tr.com.aurora.hbys.healthcare.service; + +import tr.com.aurora.hbys.healthcare.service.dto.VisitDTO; + +import org.springframework.data.domain.Page; +import org.springframework.data.domain.Pageable; + +import java.util.Optional; + +/** + * Service Interface for managing {@link tr.com.aurora.hbys.healthcare.domain.Visit}. + */ +public interface VisitService { + + /** + * Save a visit. + * + * @param visitDTO the entity to save. + * @return the persisted entity. + */ + VisitDTO save(VisitDTO visitDTO); + + /** + * Get all the visits. + * + * @param pageable the pagination information. + * @return the list of entities. + */ + Page findAll(Pageable pageable); + + /** + * Get all the visits with eager load of many-to-many relationships. + * + * @return the list of entities. + */ + Page findAllWithEagerRelationships(Pageable pageable); + + /** + * Get the "id" visit. + * + * @param id the id of the entity. + * @return the entity. + */ + Optional findOne(Long id); + + /** + * Delete the "id" visit. + * + * @param id the id of the entity. + */ + void delete(Long id); +} diff --git a/src/main/java/tr/com/aurora/hbys/healthcare/service/VisitServiceService.java b/src/main/java/tr/com/aurora/hbys/healthcare/service/VisitServiceService.java new file mode 100644 index 0000000..2304f29 --- /dev/null +++ b/src/main/java/tr/com/aurora/hbys/healthcare/service/VisitServiceService.java @@ -0,0 +1,45 @@ +package tr.com.aurora.hbys.healthcare.service; + +import tr.com.aurora.hbys.healthcare.service.dto.VisitServiceDTO; + +import org.springframework.data.domain.Page; +import org.springframework.data.domain.Pageable; + +import java.util.Optional; + +/** + * Service Interface for managing {@link tr.com.aurora.hbys.healthcare.domain.VisitService}. + */ +public interface VisitServiceService { + + /** + * Save a visitService. + * + * @param visitServiceDTO the entity to save. + * @return the persisted entity. + */ + VisitServiceDTO save(VisitServiceDTO visitServiceDTO); + + /** + * Get all the visitServices. + * + * @param pageable the pagination information. + * @return the list of entities. + */ + Page findAll(Pageable pageable); + + /** + * Get the "id" visitService. + * + * @param id the id of the entity. + * @return the entity. + */ + Optional findOne(Long id); + + /** + * Delete the "id" visitService. + * + * @param id the id of the entity. + */ + void delete(Long id); +} diff --git a/src/main/java/tr/com/aurora/hbys/healthcare/service/dto/DepartmentDTO.java b/src/main/java/tr/com/aurora/hbys/healthcare/service/dto/DepartmentDTO.java new file mode 100644 index 0000000..190277e --- /dev/null +++ b/src/main/java/tr/com/aurora/hbys/healthcare/service/dto/DepartmentDTO.java @@ -0,0 +1,98 @@ +package tr.com.aurora.hbys.healthcare.service.dto; + +import javax.validation.constraints.*; +import java.io.Serializable; +import java.util.Objects; +import tr.com.aurora.hbys.healthcare.domain.enumeration.DepartmentType; + +/** + * A DTO for the {@link tr.com.aurora.hbys.healthcare.domain.Department} entity. + */ +public class DepartmentDTO implements Serializable { + + private Long id; + + @NotNull + @Size(max = 200) + private String name; + + private DepartmentType type; + + @Size(max = 1000) + private String description; + + private Boolean active; + + + public Long getId() { + return id; + } + + public void setId(Long id) { + this.id = id; + } + + public String getName() { + return name; + } + + public void setName(String name) { + this.name = name; + } + + public DepartmentType getType() { + return type; + } + + public void setType(DepartmentType type) { + this.type = type; + } + + public String getDescription() { + return description; + } + + public void setDescription(String description) { + this.description = description; + } + + public Boolean isActive() { + return active; + } + + public void setActive(Boolean active) { + this.active = active; + } + + @Override + public boolean equals(Object o) { + if (this == o) { + return true; + } + if (o == null || getClass() != o.getClass()) { + return false; + } + + DepartmentDTO departmentDTO = (DepartmentDTO) o; + if (departmentDTO.getId() == null || getId() == null) { + return false; + } + return Objects.equals(getId(), departmentDTO.getId()); + } + + @Override + public int hashCode() { + return Objects.hashCode(getId()); + } + + @Override + public String toString() { + return "DepartmentDTO{" + + "id=" + getId() + + ", name='" + getName() + "'" + + ", type='" + getType() + "'" + + ", description='" + getDescription() + "'" + + ", active='" + isActive() + "'" + + "}"; + } +} diff --git a/src/main/java/tr/com/aurora/hbys/healthcare/service/dto/DoctorDTO.java b/src/main/java/tr/com/aurora/hbys/healthcare/service/dto/DoctorDTO.java new file mode 100644 index 0000000..4a69d7a --- /dev/null +++ b/src/main/java/tr/com/aurora/hbys/healthcare/service/dto/DoctorDTO.java @@ -0,0 +1,98 @@ +package tr.com.aurora.hbys.healthcare.service.dto; + +import javax.validation.constraints.*; +import java.io.Serializable; +import java.util.HashSet; +import java.util.Set; +import java.util.Objects; + +/** + * A DTO for the {@link tr.com.aurora.hbys.healthcare.domain.Doctor} entity. + */ +public class DoctorDTO implements Serializable { + + private Long id; + + @NotNull + @Size(max = 100) + private String name; + + @Size(max = 20) + private String phone; + + private Long salary; + + private Set departments = new HashSet<>(); + + public Long getId() { + return id; + } + + public void setId(Long id) { + this.id = id; + } + + public String getName() { + return name; + } + + public void setName(String name) { + this.name = name; + } + + public String getPhone() { + return phone; + } + + public void setPhone(String phone) { + this.phone = phone; + } + + public Long getSalary() { + return salary; + } + + public void setSalary(Long salary) { + this.salary = salary; + } + + public Set getDepartments() { + return departments; + } + + public void setDepartments(Set departments) { + this.departments = departments; + } + + @Override + public boolean equals(Object o) { + if (this == o) { + return true; + } + if (o == null || getClass() != o.getClass()) { + return false; + } + + DoctorDTO doctorDTO = (DoctorDTO) o; + if (doctorDTO.getId() == null || getId() == null) { + return false; + } + return Objects.equals(getId(), doctorDTO.getId()); + } + + @Override + public int hashCode() { + return Objects.hashCode(getId()); + } + + @Override + public String toString() { + return "DoctorDTO{" + + "id=" + getId() + + ", name='" + getName() + "'" + + ", phone='" + getPhone() + "'" + + ", salary=" + getSalary() + + ", departments='" + getDepartments() + "'" + + "}"; + } +} diff --git a/src/main/java/tr/com/aurora/hbys/healthcare/service/dto/PatientDTO.java b/src/main/java/tr/com/aurora/hbys/healthcare/service/dto/PatientDTO.java new file mode 100644 index 0000000..2027892 --- /dev/null +++ b/src/main/java/tr/com/aurora/hbys/healthcare/service/dto/PatientDTO.java @@ -0,0 +1,100 @@ +package tr.com.aurora.hbys.healthcare.service.dto; + +import java.time.LocalDate; +import javax.validation.constraints.*; +import java.io.Serializable; +import java.util.Objects; + +/** + * A DTO for the {@link tr.com.aurora.hbys.healthcare.domain.Patient} entity. + */ +public class PatientDTO implements Serializable { + + private Long id; + + @NotNull + @Size(max = 100) + private String name; + + @Size(max = 20) + private String phone; + + private LocalDate birthDate; + + @NotNull + @Size(max = 11) + private String citizenNumber; + + + public Long getId() { + return id; + } + + public void setId(Long id) { + this.id = id; + } + + public String getName() { + return name; + } + + public void setName(String name) { + this.name = name; + } + + public String getPhone() { + return phone; + } + + public void setPhone(String phone) { + this.phone = phone; + } + + public LocalDate getBirthDate() { + return birthDate; + } + + public void setBirthDate(LocalDate birthDate) { + this.birthDate = birthDate; + } + + public String getCitizenNumber() { + return citizenNumber; + } + + public void setCitizenNumber(String citizenNumber) { + this.citizenNumber = citizenNumber; + } + + @Override + public boolean equals(Object o) { + if (this == o) { + return true; + } + if (o == null || getClass() != o.getClass()) { + return false; + } + + PatientDTO patientDTO = (PatientDTO) o; + if (patientDTO.getId() == null || getId() == null) { + return false; + } + return Objects.equals(getId(), patientDTO.getId()); + } + + @Override + public int hashCode() { + return Objects.hashCode(getId()); + } + + @Override + public String toString() { + return "PatientDTO{" + + "id=" + getId() + + ", name='" + getName() + "'" + + ", phone='" + getPhone() + "'" + + ", birthDate='" + getBirthDate() + "'" + + ", citizenNumber='" + getCitizenNumber() + "'" + + "}"; + } +} diff --git a/src/main/java/tr/com/aurora/hbys/healthcare/service/dto/VisitDTO.java b/src/main/java/tr/com/aurora/hbys/healthcare/service/dto/VisitDTO.java new file mode 100644 index 0000000..da33e0a --- /dev/null +++ b/src/main/java/tr/com/aurora/hbys/healthcare/service/dto/VisitDTO.java @@ -0,0 +1,151 @@ +package tr.com.aurora.hbys.healthcare.service.dto; + +import java.time.Instant; +import java.io.Serializable; +import java.util.HashSet; +import java.util.Set; +import java.util.Objects; +import tr.com.aurora.hbys.healthcare.domain.enumeration.VisitType; + +/** + * A DTO for the {@link tr.com.aurora.hbys.healthcare.domain.Visit} entity. + */ +public class VisitDTO implements Serializable { + + private Long id; + + private Instant date; + + private VisitType type; + + + private Long patientId; + + private String patientName; + + private Long doctorId; + + private String doctorName; + + private Long departmentId; + + private String departmentName; + private Set visitServices = new HashSet<>(); + + public Long getId() { + return id; + } + + public void setId(Long id) { + this.id = id; + } + + public Instant getDate() { + return date; + } + + public void setDate(Instant date) { + this.date = date; + } + + public VisitType getType() { + return type; + } + + public void setType(VisitType type) { + this.type = type; + } + + public Long getPatientId() { + return patientId; + } + + public void setPatientId(Long patientId) { + this.patientId = patientId; + } + + public String getPatientName() { + return patientName; + } + + public void setPatientName(String patientName) { + this.patientName = patientName; + } + + public Long getDoctorId() { + return doctorId; + } + + public void setDoctorId(Long doctorId) { + this.doctorId = doctorId; + } + + public String getDoctorName() { + return doctorName; + } + + public void setDoctorName(String doctorName) { + this.doctorName = doctorName; + } + + public Long getDepartmentId() { + return departmentId; + } + + public void setDepartmentId(Long departmentId) { + this.departmentId = departmentId; + } + + public String getDepartmentName() { + return departmentName; + } + + public void setDepartmentName(String departmentName) { + this.departmentName = departmentName; + } + + public Set getVisitServices() { + return visitServices; + } + + public void setVisitServices(Set visitServices) { + this.visitServices = visitServices; + } + + @Override + public boolean equals(Object o) { + if (this == o) { + return true; + } + if (o == null || getClass() != o.getClass()) { + return false; + } + + VisitDTO visitDTO = (VisitDTO) o; + if (visitDTO.getId() == null || getId() == null) { + return false; + } + return Objects.equals(getId(), visitDTO.getId()); + } + + @Override + public int hashCode() { + return Objects.hashCode(getId()); + } + + @Override + public String toString() { + return "VisitDTO{" + + "id=" + getId() + + ", date='" + getDate() + "'" + + ", type='" + getType() + "'" + + ", patientId=" + getPatientId() + + ", patientName='" + getPatientName() + "'" + + ", doctorId=" + getDoctorId() + + ", doctorName='" + getDoctorName() + "'" + + ", departmentId=" + getDepartmentId() + + ", departmentName='" + getDepartmentName() + "'" + + ", visitServices='" + getVisitServices() + "'" + + "}"; + } +} diff --git a/src/main/java/tr/com/aurora/hbys/healthcare/service/dto/VisitServiceDTO.java b/src/main/java/tr/com/aurora/hbys/healthcare/service/dto/VisitServiceDTO.java new file mode 100644 index 0000000..b13d06c --- /dev/null +++ b/src/main/java/tr/com/aurora/hbys/healthcare/service/dto/VisitServiceDTO.java @@ -0,0 +1,97 @@ +package tr.com.aurora.hbys.healthcare.service.dto; + +import javax.validation.constraints.*; +import java.io.Serializable; +import java.util.Objects; + +/** + * A DTO for the {@link tr.com.aurora.hbys.healthcare.domain.VisitService} entity. + */ +public class VisitServiceDTO implements Serializable { + + private Long id; + + @NotNull + @Size(max = 200) + private String name; + + @Size(max = 1000) + private String description; + + private Boolean active; + + private Double price; + + + public Long getId() { + return id; + } + + public void setId(Long id) { + this.id = id; + } + + public String getName() { + return name; + } + + public void setName(String name) { + this.name = name; + } + + public String getDescription() { + return description; + } + + public void setDescription(String description) { + this.description = description; + } + + public Boolean isActive() { + return active; + } + + public void setActive(Boolean active) { + this.active = active; + } + + public Double getPrice() { + return price; + } + + public void setPrice(Double price) { + this.price = price; + } + + @Override + public boolean equals(Object o) { + if (this == o) { + return true; + } + if (o == null || getClass() != o.getClass()) { + return false; + } + + VisitServiceDTO visitServiceDTO = (VisitServiceDTO) o; + if (visitServiceDTO.getId() == null || getId() == null) { + return false; + } + return Objects.equals(getId(), visitServiceDTO.getId()); + } + + @Override + public int hashCode() { + return Objects.hashCode(getId()); + } + + @Override + public String toString() { + return "VisitServiceDTO{" + + "id=" + getId() + + ", name='" + getName() + "'" + + ", description='" + getDescription() + "'" + + ", active='" + isActive() + "'" + + ", price=" + getPrice() + + "}"; + } +} diff --git a/src/main/java/tr/com/aurora/hbys/healthcare/service/impl/DepartmentServiceImpl.java b/src/main/java/tr/com/aurora/hbys/healthcare/service/impl/DepartmentServiceImpl.java new file mode 100644 index 0000000..178860e --- /dev/null +++ b/src/main/java/tr/com/aurora/hbys/healthcare/service/impl/DepartmentServiceImpl.java @@ -0,0 +1,88 @@ +package tr.com.aurora.hbys.healthcare.service.impl; + +import tr.com.aurora.hbys.healthcare.service.DepartmentService; +import tr.com.aurora.hbys.healthcare.domain.Department; +import tr.com.aurora.hbys.healthcare.repository.DepartmentRepository; +import tr.com.aurora.hbys.healthcare.service.dto.DepartmentDTO; +import tr.com.aurora.hbys.healthcare.service.mapper.DepartmentMapper; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; + +import org.springframework.data.domain.Page; +import org.springframework.data.domain.Pageable; +import org.springframework.stereotype.Service; +import org.springframework.transaction.annotation.Transactional; + +import java.util.Optional; + +/** + * Service Implementation for managing {@link Department}. + */ +@Service +@Transactional +public class DepartmentServiceImpl implements DepartmentService { + + private final Logger log = LoggerFactory.getLogger(DepartmentServiceImpl.class); + + private final DepartmentRepository departmentRepository; + + private final DepartmentMapper departmentMapper; + + public DepartmentServiceImpl(DepartmentRepository departmentRepository, DepartmentMapper departmentMapper) { + this.departmentRepository = departmentRepository; + this.departmentMapper = departmentMapper; + } + + /** + * Save a department. + * + * @param departmentDTO the entity to save. + * @return the persisted entity. + */ + @Override + public DepartmentDTO save(DepartmentDTO departmentDTO) { + log.debug("Request to save Department : {}", departmentDTO); + Department department = departmentMapper.toEntity(departmentDTO); + department = departmentRepository.save(department); + return departmentMapper.toDto(department); + } + + /** + * Get all the departments. + * + * @param pageable the pagination information. + * @return the list of entities. + */ + @Override + @Transactional(readOnly = true) + public Page findAll(Pageable pageable) { + log.debug("Request to get all Departments"); + return departmentRepository.findAll(pageable) + .map(departmentMapper::toDto); + } + + /** + * Get one department by id. + * + * @param id the id of the entity. + * @return the entity. + */ + @Override + @Transactional(readOnly = true) + public Optional findOne(Long id) { + log.debug("Request to get Department : {}", id); + return departmentRepository.findById(id) + .map(departmentMapper::toDto); + } + + /** + * Delete the department by id. + * + * @param id the id of the entity. + */ + @Override + public void delete(Long id) { + log.debug("Request to delete Department : {}", id); + departmentRepository.deleteById(id); + } +} diff --git a/src/main/java/tr/com/aurora/hbys/healthcare/service/impl/DoctorServiceImpl.java b/src/main/java/tr/com/aurora/hbys/healthcare/service/impl/DoctorServiceImpl.java new file mode 100644 index 0000000..dd58b31 --- /dev/null +++ b/src/main/java/tr/com/aurora/hbys/healthcare/service/impl/DoctorServiceImpl.java @@ -0,0 +1,97 @@ +package tr.com.aurora.hbys.healthcare.service.impl; + +import tr.com.aurora.hbys.healthcare.service.DoctorService; +import tr.com.aurora.hbys.healthcare.domain.Doctor; +import tr.com.aurora.hbys.healthcare.repository.DoctorRepository; +import tr.com.aurora.hbys.healthcare.service.dto.DoctorDTO; +import tr.com.aurora.hbys.healthcare.service.mapper.DoctorMapper; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; + +import org.springframework.data.domain.Page; +import org.springframework.data.domain.Pageable; +import org.springframework.stereotype.Service; +import org.springframework.transaction.annotation.Transactional; + +import java.util.Optional; + +/** + * Service Implementation for managing {@link Doctor}. + */ +@Service +@Transactional +public class DoctorServiceImpl implements DoctorService { + + private final Logger log = LoggerFactory.getLogger(DoctorServiceImpl.class); + + private final DoctorRepository doctorRepository; + + private final DoctorMapper doctorMapper; + + public DoctorServiceImpl(DoctorRepository doctorRepository, DoctorMapper doctorMapper) { + this.doctorRepository = doctorRepository; + this.doctorMapper = doctorMapper; + } + + /** + * Save a doctor. + * + * @param doctorDTO the entity to save. + * @return the persisted entity. + */ + @Override + public DoctorDTO save(DoctorDTO doctorDTO) { + log.debug("Request to save Doctor : {}", doctorDTO); + Doctor doctor = doctorMapper.toEntity(doctorDTO); + doctor = doctorRepository.save(doctor); + return doctorMapper.toDto(doctor); + } + + /** + * Get all the doctors. + * + * @param pageable the pagination information. + * @return the list of entities. + */ + @Override + @Transactional(readOnly = true) + public Page findAll(Pageable pageable) { + log.debug("Request to get all Doctors"); + return doctorRepository.findAll(pageable) + .map(doctorMapper::toDto); + } + + /** + * Get all the doctors with eager load of many-to-many relationships. + * + * @return the list of entities. + */ + public Page findAllWithEagerRelationships(Pageable pageable) { + return doctorRepository.findAllWithEagerRelationships(pageable).map(doctorMapper::toDto); + } + + /** + * Get one doctor by id. + * + * @param id the id of the entity. + * @return the entity. + */ + @Override + @Transactional(readOnly = true) + public Optional findOne(Long id) { + log.debug("Request to get Doctor : {}", id); + return doctorRepository.findOneWithEagerRelationships(id) + .map(doctorMapper::toDto); + } + + /** + * Delete the doctor by id. + * + * @param id the id of the entity. + */ + @Override + public void delete(Long id) { + log.debug("Request to delete Doctor : {}", id); + doctorRepository.deleteById(id); + } +} diff --git a/src/main/java/tr/com/aurora/hbys/healthcare/service/impl/PatientServiceImpl.java b/src/main/java/tr/com/aurora/hbys/healthcare/service/impl/PatientServiceImpl.java new file mode 100644 index 0000000..8c8ba84 --- /dev/null +++ b/src/main/java/tr/com/aurora/hbys/healthcare/service/impl/PatientServiceImpl.java @@ -0,0 +1,88 @@ +package tr.com.aurora.hbys.healthcare.service.impl; + +import tr.com.aurora.hbys.healthcare.service.PatientService; +import tr.com.aurora.hbys.healthcare.domain.Patient; +import tr.com.aurora.hbys.healthcare.repository.PatientRepository; +import tr.com.aurora.hbys.healthcare.service.dto.PatientDTO; +import tr.com.aurora.hbys.healthcare.service.mapper.PatientMapper; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; + +import org.springframework.data.domain.Page; +import org.springframework.data.domain.Pageable; +import org.springframework.stereotype.Service; +import org.springframework.transaction.annotation.Transactional; + +import java.util.Optional; + +/** + * Service Implementation for managing {@link Patient}. + */ +@Service +@Transactional +public class PatientServiceImpl implements PatientService { + + private final Logger log = LoggerFactory.getLogger(PatientServiceImpl.class); + + private final PatientRepository patientRepository; + + private final PatientMapper patientMapper; + + public PatientServiceImpl(PatientRepository patientRepository, PatientMapper patientMapper) { + this.patientRepository = patientRepository; + this.patientMapper = patientMapper; + } + + /** + * Save a patient. + * + * @param patientDTO the entity to save. + * @return the persisted entity. + */ + @Override + public PatientDTO save(PatientDTO patientDTO) { + log.debug("Request to save Patient : {}", patientDTO); + Patient patient = patientMapper.toEntity(patientDTO); + patient = patientRepository.save(patient); + return patientMapper.toDto(patient); + } + + /** + * Get all the patients. + * + * @param pageable the pagination information. + * @return the list of entities. + */ + @Override + @Transactional(readOnly = true) + public Page findAll(Pageable pageable) { + log.debug("Request to get all Patients"); + return patientRepository.findAll(pageable) + .map(patientMapper::toDto); + } + + /** + * Get one patient by id. + * + * @param id the id of the entity. + * @return the entity. + */ + @Override + @Transactional(readOnly = true) + public Optional findOne(Long id) { + log.debug("Request to get Patient : {}", id); + return patientRepository.findById(id) + .map(patientMapper::toDto); + } + + /** + * Delete the patient by id. + * + * @param id the id of the entity. + */ + @Override + public void delete(Long id) { + log.debug("Request to delete Patient : {}", id); + patientRepository.deleteById(id); + } +} diff --git a/src/main/java/tr/com/aurora/hbys/healthcare/service/impl/VisitServiceImpl.java b/src/main/java/tr/com/aurora/hbys/healthcare/service/impl/VisitServiceImpl.java new file mode 100644 index 0000000..934e5e0 --- /dev/null +++ b/src/main/java/tr/com/aurora/hbys/healthcare/service/impl/VisitServiceImpl.java @@ -0,0 +1,97 @@ +package tr.com.aurora.hbys.healthcare.service.impl; + +import tr.com.aurora.hbys.healthcare.service.VisitService; +import tr.com.aurora.hbys.healthcare.domain.Visit; +import tr.com.aurora.hbys.healthcare.repository.VisitRepository; +import tr.com.aurora.hbys.healthcare.service.dto.VisitDTO; +import tr.com.aurora.hbys.healthcare.service.mapper.VisitMapper; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; + +import org.springframework.data.domain.Page; +import org.springframework.data.domain.Pageable; +import org.springframework.stereotype.Service; +import org.springframework.transaction.annotation.Transactional; + +import java.util.Optional; + +/** + * Service Implementation for managing {@link Visit}. + */ +@Service +@Transactional +public class VisitServiceImpl implements VisitService { + + private final Logger log = LoggerFactory.getLogger(VisitServiceImpl.class); + + private final VisitRepository visitRepository; + + private final VisitMapper visitMapper; + + public VisitServiceImpl(VisitRepository visitRepository, VisitMapper visitMapper) { + this.visitRepository = visitRepository; + this.visitMapper = visitMapper; + } + + /** + * Save a visit. + * + * @param visitDTO the entity to save. + * @return the persisted entity. + */ + @Override + public VisitDTO save(VisitDTO visitDTO) { + log.debug("Request to save Visit : {}", visitDTO); + Visit visit = visitMapper.toEntity(visitDTO); + visit = visitRepository.save(visit); + return visitMapper.toDto(visit); + } + + /** + * Get all the visits. + * + * @param pageable the pagination information. + * @return the list of entities. + */ + @Override + @Transactional(readOnly = true) + public Page findAll(Pageable pageable) { + log.debug("Request to get all Visits"); + return visitRepository.findAll(pageable) + .map(visitMapper::toDto); + } + + /** + * Get all the visits with eager load of many-to-many relationships. + * + * @return the list of entities. + */ + public Page findAllWithEagerRelationships(Pageable pageable) { + return visitRepository.findAllWithEagerRelationships(pageable).map(visitMapper::toDto); + } + + /** + * Get one visit by id. + * + * @param id the id of the entity. + * @return the entity. + */ + @Override + @Transactional(readOnly = true) + public Optional findOne(Long id) { + log.debug("Request to get Visit : {}", id); + return visitRepository.findOneWithEagerRelationships(id) + .map(visitMapper::toDto); + } + + /** + * Delete the visit by id. + * + * @param id the id of the entity. + */ + @Override + public void delete(Long id) { + log.debug("Request to delete Visit : {}", id); + visitRepository.deleteById(id); + } +} diff --git a/src/main/java/tr/com/aurora/hbys/healthcare/service/impl/VisitServiceServiceImpl.java b/src/main/java/tr/com/aurora/hbys/healthcare/service/impl/VisitServiceServiceImpl.java new file mode 100644 index 0000000..9985446 --- /dev/null +++ b/src/main/java/tr/com/aurora/hbys/healthcare/service/impl/VisitServiceServiceImpl.java @@ -0,0 +1,88 @@ +package tr.com.aurora.hbys.healthcare.service.impl; + +import tr.com.aurora.hbys.healthcare.service.VisitServiceService; +import tr.com.aurora.hbys.healthcare.domain.VisitService; +import tr.com.aurora.hbys.healthcare.repository.VisitServiceRepository; +import tr.com.aurora.hbys.healthcare.service.dto.VisitServiceDTO; +import tr.com.aurora.hbys.healthcare.service.mapper.VisitServiceMapper; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; + +import org.springframework.data.domain.Page; +import org.springframework.data.domain.Pageable; +import org.springframework.stereotype.Service; +import org.springframework.transaction.annotation.Transactional; + +import java.util.Optional; + +/** + * Service Implementation for managing {@link VisitService}. + */ +@Service +@Transactional +public class VisitServiceServiceImpl implements VisitServiceService { + + private final Logger log = LoggerFactory.getLogger(VisitServiceServiceImpl.class); + + private final VisitServiceRepository visitServiceRepository; + + private final VisitServiceMapper visitServiceMapper; + + public VisitServiceServiceImpl(VisitServiceRepository visitServiceRepository, VisitServiceMapper visitServiceMapper) { + this.visitServiceRepository = visitServiceRepository; + this.visitServiceMapper = visitServiceMapper; + } + + /** + * Save a visitService. + * + * @param visitServiceDTO the entity to save. + * @return the persisted entity. + */ + @Override + public VisitServiceDTO save(VisitServiceDTO visitServiceDTO) { + log.debug("Request to save VisitService : {}", visitServiceDTO); + VisitService visitService = visitServiceMapper.toEntity(visitServiceDTO); + visitService = visitServiceRepository.save(visitService); + return visitServiceMapper.toDto(visitService); + } + + /** + * Get all the visitServices. + * + * @param pageable the pagination information. + * @return the list of entities. + */ + @Override + @Transactional(readOnly = true) + public Page findAll(Pageable pageable) { + log.debug("Request to get all VisitServices"); + return visitServiceRepository.findAll(pageable) + .map(visitServiceMapper::toDto); + } + + /** + * Get one visitService by id. + * + * @param id the id of the entity. + * @return the entity. + */ + @Override + @Transactional(readOnly = true) + public Optional findOne(Long id) { + log.debug("Request to get VisitService : {}", id); + return visitServiceRepository.findById(id) + .map(visitServiceMapper::toDto); + } + + /** + * Delete the visitService by id. + * + * @param id the id of the entity. + */ + @Override + public void delete(Long id) { + log.debug("Request to delete VisitService : {}", id); + visitServiceRepository.deleteById(id); + } +} diff --git a/src/main/java/tr/com/aurora/hbys/healthcare/service/mapper/DepartmentMapper.java b/src/main/java/tr/com/aurora/hbys/healthcare/service/mapper/DepartmentMapper.java new file mode 100644 index 0000000..c61a65f --- /dev/null +++ b/src/main/java/tr/com/aurora/hbys/healthcare/service/mapper/DepartmentMapper.java @@ -0,0 +1,28 @@ +package tr.com.aurora.hbys.healthcare.service.mapper; + + +import tr.com.aurora.hbys.healthcare.domain.*; +import tr.com.aurora.hbys.healthcare.service.dto.DepartmentDTO; + +import org.mapstruct.*; + +/** + * Mapper for the entity {@link Department} and its DTO {@link DepartmentDTO}. + */ +@Mapper(componentModel = "spring", uses = {}) +public interface DepartmentMapper extends EntityMapper { + + + @Mapping(target = "doctors", ignore = true) + @Mapping(target = "removeDoctor", ignore = true) + Department toEntity(DepartmentDTO departmentDTO); + + default Department fromId(Long id) { + if (id == null) { + return null; + } + Department department = new Department(); + department.setId(id); + return department; + } +} diff --git a/src/main/java/tr/com/aurora/hbys/healthcare/service/mapper/DoctorMapper.java b/src/main/java/tr/com/aurora/hbys/healthcare/service/mapper/DoctorMapper.java new file mode 100644 index 0000000..2f6ef52 --- /dev/null +++ b/src/main/java/tr/com/aurora/hbys/healthcare/service/mapper/DoctorMapper.java @@ -0,0 +1,26 @@ +package tr.com.aurora.hbys.healthcare.service.mapper; + + +import tr.com.aurora.hbys.healthcare.domain.*; +import tr.com.aurora.hbys.healthcare.service.dto.DoctorDTO; + +import org.mapstruct.*; + +/** + * Mapper for the entity {@link Doctor} and its DTO {@link DoctorDTO}. + */ +@Mapper(componentModel = "spring", uses = {DepartmentMapper.class}) +public interface DoctorMapper extends EntityMapper { + + + @Mapping(target = "removeDepartment", ignore = true) + + default Doctor fromId(Long id) { + if (id == null) { + return null; + } + Doctor doctor = new Doctor(); + doctor.setId(id); + return doctor; + } +} diff --git a/src/main/java/tr/com/aurora/hbys/healthcare/service/mapper/EntityMapper.java b/src/main/java/tr/com/aurora/hbys/healthcare/service/mapper/EntityMapper.java new file mode 100644 index 0000000..0290f15 --- /dev/null +++ b/src/main/java/tr/com/aurora/hbys/healthcare/service/mapper/EntityMapper.java @@ -0,0 +1,21 @@ +package tr.com.aurora.hbys.healthcare.service.mapper; + +import java.util.List; + +/** + * Contract for a generic dto to entity mapper. + * + * @param - DTO type parameter. + * @param - Entity type parameter. + */ + +public interface EntityMapper { + + E toEntity(D dto); + + D toDto(E entity); + + List toEntity(List dtoList); + + List toDto(List entityList); +} diff --git a/src/main/java/tr/com/aurora/hbys/healthcare/service/mapper/PatientMapper.java b/src/main/java/tr/com/aurora/hbys/healthcare/service/mapper/PatientMapper.java new file mode 100644 index 0000000..37bf193 --- /dev/null +++ b/src/main/java/tr/com/aurora/hbys/healthcare/service/mapper/PatientMapper.java @@ -0,0 +1,25 @@ +package tr.com.aurora.hbys.healthcare.service.mapper; + + +import tr.com.aurora.hbys.healthcare.domain.*; +import tr.com.aurora.hbys.healthcare.service.dto.PatientDTO; + +import org.mapstruct.*; + +/** + * Mapper for the entity {@link Patient} and its DTO {@link PatientDTO}. + */ +@Mapper(componentModel = "spring", uses = {}) +public interface PatientMapper extends EntityMapper { + + + + default Patient fromId(Long id) { + if (id == null) { + return null; + } + Patient patient = new Patient(); + patient.setId(id); + return patient; + } +} diff --git a/src/main/java/tr/com/aurora/hbys/healthcare/service/mapper/VisitMapper.java b/src/main/java/tr/com/aurora/hbys/healthcare/service/mapper/VisitMapper.java new file mode 100644 index 0000000..23a464c --- /dev/null +++ b/src/main/java/tr/com/aurora/hbys/healthcare/service/mapper/VisitMapper.java @@ -0,0 +1,37 @@ +package tr.com.aurora.hbys.healthcare.service.mapper; + + +import tr.com.aurora.hbys.healthcare.domain.*; +import tr.com.aurora.hbys.healthcare.service.dto.VisitDTO; + +import org.mapstruct.*; + +/** + * Mapper for the entity {@link Visit} and its DTO {@link VisitDTO}. + */ +@Mapper(componentModel = "spring", uses = {PatientMapper.class, DoctorMapper.class, DepartmentMapper.class, VisitServiceMapper.class}) +public interface VisitMapper extends EntityMapper { + + @Mapping(source = "patient.id", target = "patientId") + @Mapping(source = "patient.name", target = "patientName") + @Mapping(source = "doctor.id", target = "doctorId") + @Mapping(source = "doctor.name", target = "doctorName") + @Mapping(source = "department.id", target = "departmentId") + @Mapping(source = "department.name", target = "departmentName") + VisitDTO toDto(Visit visit); + + @Mapping(source = "patientId", target = "patient") + @Mapping(source = "doctorId", target = "doctor") + @Mapping(source = "departmentId", target = "department") + @Mapping(target = "removeVisitService", ignore = true) + Visit toEntity(VisitDTO visitDTO); + + default Visit fromId(Long id) { + if (id == null) { + return null; + } + Visit visit = new Visit(); + visit.setId(id); + return visit; + } +} diff --git a/src/main/java/tr/com/aurora/hbys/healthcare/service/mapper/VisitServiceMapper.java b/src/main/java/tr/com/aurora/hbys/healthcare/service/mapper/VisitServiceMapper.java new file mode 100644 index 0000000..a810361 --- /dev/null +++ b/src/main/java/tr/com/aurora/hbys/healthcare/service/mapper/VisitServiceMapper.java @@ -0,0 +1,28 @@ +package tr.com.aurora.hbys.healthcare.service.mapper; + + +import tr.com.aurora.hbys.healthcare.domain.*; +import tr.com.aurora.hbys.healthcare.service.dto.VisitServiceDTO; + +import org.mapstruct.*; + +/** + * Mapper for the entity {@link VisitService} and its DTO {@link VisitServiceDTO}. + */ +@Mapper(componentModel = "spring", uses = {}) +public interface VisitServiceMapper extends EntityMapper { + + + @Mapping(target = "visits", ignore = true) + @Mapping(target = "removeVisit", ignore = true) + VisitService toEntity(VisitServiceDTO visitServiceDTO); + + default VisitService fromId(Long id) { + if (id == null) { + return null; + } + VisitService visitService = new VisitService(); + visitService.setId(id); + return visitService; + } +} diff --git a/src/main/java/tr/com/aurora/hbys/healthcare/web/rest/DepartmentResource.java b/src/main/java/tr/com/aurora/hbys/healthcare/web/rest/DepartmentResource.java new file mode 100644 index 0000000..a88c082 --- /dev/null +++ b/src/main/java/tr/com/aurora/hbys/healthcare/web/rest/DepartmentResource.java @@ -0,0 +1,126 @@ +package tr.com.aurora.hbys.healthcare.web.rest; + +import tr.com.aurora.hbys.healthcare.service.DepartmentService; +import tr.com.aurora.hbys.healthcare.web.rest.errors.BadRequestAlertException; +import tr.com.aurora.hbys.healthcare.service.dto.DepartmentDTO; + +import io.github.jhipster.web.util.HeaderUtil; +import io.github.jhipster.web.util.PaginationUtil; +import io.github.jhipster.web.util.ResponseUtil; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; +import org.springframework.beans.factory.annotation.Value; +import org.springframework.data.domain.Page; +import org.springframework.data.domain.Pageable; +import org.springframework.http.HttpHeaders; +import org.springframework.http.HttpStatus; +import org.springframework.web.servlet.support.ServletUriComponentsBuilder; +import org.springframework.http.ResponseEntity; +import org.springframework.web.bind.annotation.*; + +import javax.validation.Valid; +import java.net.URI; +import java.net.URISyntaxException; +import java.util.List; +import java.util.Optional; + +/** + * REST controller for managing {@link tr.com.aurora.hbys.healthcare.domain.Department}. + */ +@RestController +@RequestMapping("/api") +public class DepartmentResource { + + private final Logger log = LoggerFactory.getLogger(DepartmentResource.class); + + private static final String ENTITY_NAME = "department"; + + @Value("${jhipster.clientApp.name}") + private String applicationName; + + private final DepartmentService departmentService; + + public DepartmentResource(DepartmentService departmentService) { + this.departmentService = departmentService; + } + + /** + * {@code POST /departments} : Create a new department. + * + * @param departmentDTO the departmentDTO to create. + * @return the {@link ResponseEntity} with status {@code 201 (Created)} and with body the new departmentDTO, or with status {@code 400 (Bad Request)} if the department has already an ID. + * @throws URISyntaxException if the Location URI syntax is incorrect. + */ + @PostMapping("/departments") + public ResponseEntity createDepartment(@Valid @RequestBody DepartmentDTO departmentDTO) throws URISyntaxException { + log.debug("REST request to save Department : {}", departmentDTO); + if (departmentDTO.getId() != null) { + throw new BadRequestAlertException("A new department cannot already have an ID", ENTITY_NAME, "idexists"); + } + DepartmentDTO result = departmentService.save(departmentDTO); + return ResponseEntity.created(new URI("/api/departments/" + result.getId())) + .headers(HeaderUtil.createEntityCreationAlert(applicationName, true, ENTITY_NAME, result.getId().toString())) + .body(result); + } + + /** + * {@code PUT /departments} : Updates an existing department. + * + * @param departmentDTO the departmentDTO to update. + * @return the {@link ResponseEntity} with status {@code 200 (OK)} and with body the updated departmentDTO, + * or with status {@code 400 (Bad Request)} if the departmentDTO is not valid, + * or with status {@code 500 (Internal Server Error)} if the departmentDTO couldn't be updated. + * @throws URISyntaxException if the Location URI syntax is incorrect. + */ + @PutMapping("/departments") + public ResponseEntity updateDepartment(@Valid @RequestBody DepartmentDTO departmentDTO) throws URISyntaxException { + log.debug("REST request to update Department : {}", departmentDTO); + if (departmentDTO.getId() == null) { + throw new BadRequestAlertException("Invalid id", ENTITY_NAME, "idnull"); + } + DepartmentDTO result = departmentService.save(departmentDTO); + return ResponseEntity.ok() + .headers(HeaderUtil.createEntityUpdateAlert(applicationName, true, ENTITY_NAME, departmentDTO.getId().toString())) + .body(result); + } + + /** + * {@code GET /departments} : get all the departments. + * + * @param pageable the pagination information. + * @return the {@link ResponseEntity} with status {@code 200 (OK)} and the list of departments in body. + */ + @GetMapping("/departments") + public ResponseEntity> getAllDepartments(Pageable pageable) { + log.debug("REST request to get a page of Departments"); + Page page = departmentService.findAll(pageable); + HttpHeaders headers = PaginationUtil.generatePaginationHttpHeaders(ServletUriComponentsBuilder.fromCurrentRequest(), page); + return ResponseEntity.ok().headers(headers).body(page.getContent()); + } + + /** + * {@code GET /departments/:id} : get the "id" department. + * + * @param id the id of the departmentDTO to retrieve. + * @return the {@link ResponseEntity} with status {@code 200 (OK)} and with body the departmentDTO, or with status {@code 404 (Not Found)}. + */ + @GetMapping("/departments/{id}") + public ResponseEntity getDepartment(@PathVariable Long id) { + log.debug("REST request to get Department : {}", id); + Optional departmentDTO = departmentService.findOne(id); + return ResponseUtil.wrapOrNotFound(departmentDTO); + } + + /** + * {@code DELETE /departments/:id} : delete the "id" department. + * + * @param id the id of the departmentDTO to delete. + * @return the {@link ResponseEntity} with status {@code 204 (NO_CONTENT)}. + */ + @DeleteMapping("/departments/{id}") + public ResponseEntity deleteDepartment(@PathVariable Long id) { + log.debug("REST request to delete Department : {}", id); + departmentService.delete(id); + return ResponseEntity.noContent().headers(HeaderUtil.createEntityDeletionAlert(applicationName, true, ENTITY_NAME, id.toString())).build(); + } +} diff --git a/src/main/java/tr/com/aurora/hbys/healthcare/web/rest/DoctorResource.java b/src/main/java/tr/com/aurora/hbys/healthcare/web/rest/DoctorResource.java new file mode 100644 index 0000000..a94b8c4 --- /dev/null +++ b/src/main/java/tr/com/aurora/hbys/healthcare/web/rest/DoctorResource.java @@ -0,0 +1,132 @@ +package tr.com.aurora.hbys.healthcare.web.rest; + +import tr.com.aurora.hbys.healthcare.service.DoctorService; +import tr.com.aurora.hbys.healthcare.web.rest.errors.BadRequestAlertException; +import tr.com.aurora.hbys.healthcare.service.dto.DoctorDTO; + +import io.github.jhipster.web.util.HeaderUtil; +import io.github.jhipster.web.util.PaginationUtil; +import io.github.jhipster.web.util.ResponseUtil; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; +import org.springframework.beans.factory.annotation.Value; +import org.springframework.data.domain.Page; +import org.springframework.data.domain.Pageable; +import org.springframework.http.HttpHeaders; +import org.springframework.http.HttpStatus; +import org.springframework.web.servlet.support.ServletUriComponentsBuilder; +import org.springframework.http.ResponseEntity; +import org.springframework.web.bind.annotation.*; + +import javax.validation.Valid; +import java.net.URI; +import java.net.URISyntaxException; +import java.util.List; +import java.util.Optional; + +/** + * REST controller for managing {@link tr.com.aurora.hbys.healthcare.domain.Doctor}. + */ +@RestController +@RequestMapping("/api") +public class DoctorResource { + + private final Logger log = LoggerFactory.getLogger(DoctorResource.class); + + private static final String ENTITY_NAME = "doctor"; + + @Value("${jhipster.clientApp.name}") + private String applicationName; + + private final DoctorService doctorService; + + public DoctorResource(DoctorService doctorService) { + this.doctorService = doctorService; + } + + /** + * {@code POST /doctors} : Create a new doctor. + * + * @param doctorDTO the doctorDTO to create. + * @return the {@link ResponseEntity} with status {@code 201 (Created)} and with body the new doctorDTO, or with status {@code 400 (Bad Request)} if the doctor has already an ID. + * @throws URISyntaxException if the Location URI syntax is incorrect. + */ + @PostMapping("/doctors") + public ResponseEntity createDoctor(@Valid @RequestBody DoctorDTO doctorDTO) throws URISyntaxException { + log.debug("REST request to save Doctor : {}", doctorDTO); + if (doctorDTO.getId() != null) { + throw new BadRequestAlertException("A new doctor cannot already have an ID", ENTITY_NAME, "idexists"); + } + DoctorDTO result = doctorService.save(doctorDTO); + return ResponseEntity.created(new URI("/api/doctors/" + result.getId())) + .headers(HeaderUtil.createEntityCreationAlert(applicationName, true, ENTITY_NAME, result.getId().toString())) + .body(result); + } + + /** + * {@code PUT /doctors} : Updates an existing doctor. + * + * @param doctorDTO the doctorDTO to update. + * @return the {@link ResponseEntity} with status {@code 200 (OK)} and with body the updated doctorDTO, + * or with status {@code 400 (Bad Request)} if the doctorDTO is not valid, + * or with status {@code 500 (Internal Server Error)} if the doctorDTO couldn't be updated. + * @throws URISyntaxException if the Location URI syntax is incorrect. + */ + @PutMapping("/doctors") + public ResponseEntity updateDoctor(@Valid @RequestBody DoctorDTO doctorDTO) throws URISyntaxException { + log.debug("REST request to update Doctor : {}", doctorDTO); + if (doctorDTO.getId() == null) { + throw new BadRequestAlertException("Invalid id", ENTITY_NAME, "idnull"); + } + DoctorDTO result = doctorService.save(doctorDTO); + return ResponseEntity.ok() + .headers(HeaderUtil.createEntityUpdateAlert(applicationName, true, ENTITY_NAME, doctorDTO.getId().toString())) + .body(result); + } + + /** + * {@code GET /doctors} : get all the doctors. + * + * @param pageable the pagination information. + * @param eagerload flag to eager load entities from relationships (This is applicable for many-to-many). + * @return the {@link ResponseEntity} with status {@code 200 (OK)} and the list of doctors in body. + */ + @GetMapping("/doctors") + public ResponseEntity> getAllDoctors(Pageable pageable, @RequestParam(required = false, defaultValue = "false") boolean eagerload) { + log.debug("REST request to get a page of Doctors"); + Page page; + if (eagerload) { + page = doctorService.findAllWithEagerRelationships(pageable); + } else { + page = doctorService.findAll(pageable); + } + HttpHeaders headers = PaginationUtil.generatePaginationHttpHeaders(ServletUriComponentsBuilder.fromCurrentRequest(), page); + return ResponseEntity.ok().headers(headers).body(page.getContent()); + } + + /** + * {@code GET /doctors/:id} : get the "id" doctor. + * + * @param id the id of the doctorDTO to retrieve. + * @return the {@link ResponseEntity} with status {@code 200 (OK)} and with body the doctorDTO, or with status {@code 404 (Not Found)}. + */ + @GetMapping("/doctors/{id}") + public ResponseEntity getDoctor(@PathVariable Long id) { + log.debug("REST request to get Doctor : {}", id); + Optional doctorDTO = doctorService.findOne(id); + return ResponseUtil.wrapOrNotFound(doctorDTO); + } + + /** + * {@code DELETE /doctors/:id} : delete the "id" doctor. + * + * @param id the id of the doctorDTO to delete. + * @return the {@link ResponseEntity} with status {@code 204 (NO_CONTENT)}. + */ + @DeleteMapping("/doctors/{id}") + public ResponseEntity deleteDoctor(@PathVariable Long id) { + log.debug("REST request to delete Doctor : {}", id); + doctorService.delete(id); + return ResponseEntity.noContent().headers(HeaderUtil.createEntityDeletionAlert(applicationName, true, ENTITY_NAME, id.toString())).build(); + } +} diff --git a/src/main/java/tr/com/aurora/hbys/healthcare/web/rest/PatientResource.java b/src/main/java/tr/com/aurora/hbys/healthcare/web/rest/PatientResource.java new file mode 100644 index 0000000..0bc3f6a --- /dev/null +++ b/src/main/java/tr/com/aurora/hbys/healthcare/web/rest/PatientResource.java @@ -0,0 +1,126 @@ +package tr.com.aurora.hbys.healthcare.web.rest; + +import tr.com.aurora.hbys.healthcare.service.PatientService; +import tr.com.aurora.hbys.healthcare.web.rest.errors.BadRequestAlertException; +import tr.com.aurora.hbys.healthcare.service.dto.PatientDTO; + +import io.github.jhipster.web.util.HeaderUtil; +import io.github.jhipster.web.util.PaginationUtil; +import io.github.jhipster.web.util.ResponseUtil; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; +import org.springframework.beans.factory.annotation.Value; +import org.springframework.data.domain.Page; +import org.springframework.data.domain.Pageable; +import org.springframework.http.HttpHeaders; +import org.springframework.http.HttpStatus; +import org.springframework.web.servlet.support.ServletUriComponentsBuilder; +import org.springframework.http.ResponseEntity; +import org.springframework.web.bind.annotation.*; + +import javax.validation.Valid; +import java.net.URI; +import java.net.URISyntaxException; +import java.util.List; +import java.util.Optional; + +/** + * REST controller for managing {@link tr.com.aurora.hbys.healthcare.domain.Patient}. + */ +@RestController +@RequestMapping("/api") +public class PatientResource { + + private final Logger log = LoggerFactory.getLogger(PatientResource.class); + + private static final String ENTITY_NAME = "patient"; + + @Value("${jhipster.clientApp.name}") + private String applicationName; + + private final PatientService patientService; + + public PatientResource(PatientService patientService) { + this.patientService = patientService; + } + + /** + * {@code POST /patients} : Create a new patient. + * + * @param patientDTO the patientDTO to create. + * @return the {@link ResponseEntity} with status {@code 201 (Created)} and with body the new patientDTO, or with status {@code 400 (Bad Request)} if the patient has already an ID. + * @throws URISyntaxException if the Location URI syntax is incorrect. + */ + @PostMapping("/patients") + public ResponseEntity createPatient(@Valid @RequestBody PatientDTO patientDTO) throws URISyntaxException { + log.debug("REST request to save Patient : {}", patientDTO); + if (patientDTO.getId() != null) { + throw new BadRequestAlertException("A new patient cannot already have an ID", ENTITY_NAME, "idexists"); + } + PatientDTO result = patientService.save(patientDTO); + return ResponseEntity.created(new URI("/api/patients/" + result.getId())) + .headers(HeaderUtil.createEntityCreationAlert(applicationName, true, ENTITY_NAME, result.getId().toString())) + .body(result); + } + + /** + * {@code PUT /patients} : Updates an existing patient. + * + * @param patientDTO the patientDTO to update. + * @return the {@link ResponseEntity} with status {@code 200 (OK)} and with body the updated patientDTO, + * or with status {@code 400 (Bad Request)} if the patientDTO is not valid, + * or with status {@code 500 (Internal Server Error)} if the patientDTO couldn't be updated. + * @throws URISyntaxException if the Location URI syntax is incorrect. + */ + @PutMapping("/patients") + public ResponseEntity updatePatient(@Valid @RequestBody PatientDTO patientDTO) throws URISyntaxException { + log.debug("REST request to update Patient : {}", patientDTO); + if (patientDTO.getId() == null) { + throw new BadRequestAlertException("Invalid id", ENTITY_NAME, "idnull"); + } + PatientDTO result = patientService.save(patientDTO); + return ResponseEntity.ok() + .headers(HeaderUtil.createEntityUpdateAlert(applicationName, true, ENTITY_NAME, patientDTO.getId().toString())) + .body(result); + } + + /** + * {@code GET /patients} : get all the patients. + * + * @param pageable the pagination information. + * @return the {@link ResponseEntity} with status {@code 200 (OK)} and the list of patients in body. + */ + @GetMapping("/patients") + public ResponseEntity> getAllPatients(Pageable pageable) { + log.debug("REST request to get a page of Patients"); + Page page = patientService.findAll(pageable); + HttpHeaders headers = PaginationUtil.generatePaginationHttpHeaders(ServletUriComponentsBuilder.fromCurrentRequest(), page); + return ResponseEntity.ok().headers(headers).body(page.getContent()); + } + + /** + * {@code GET /patients/:id} : get the "id" patient. + * + * @param id the id of the patientDTO to retrieve. + * @return the {@link ResponseEntity} with status {@code 200 (OK)} and with body the patientDTO, or with status {@code 404 (Not Found)}. + */ + @GetMapping("/patients/{id}") + public ResponseEntity getPatient(@PathVariable Long id) { + log.debug("REST request to get Patient : {}", id); + Optional patientDTO = patientService.findOne(id); + return ResponseUtil.wrapOrNotFound(patientDTO); + } + + /** + * {@code DELETE /patients/:id} : delete the "id" patient. + * + * @param id the id of the patientDTO to delete. + * @return the {@link ResponseEntity} with status {@code 204 (NO_CONTENT)}. + */ + @DeleteMapping("/patients/{id}") + public ResponseEntity deletePatient(@PathVariable Long id) { + log.debug("REST request to delete Patient : {}", id); + patientService.delete(id); + return ResponseEntity.noContent().headers(HeaderUtil.createEntityDeletionAlert(applicationName, true, ENTITY_NAME, id.toString())).build(); + } +} diff --git a/src/main/java/tr/com/aurora/hbys/healthcare/web/rest/VisitResource.java b/src/main/java/tr/com/aurora/hbys/healthcare/web/rest/VisitResource.java new file mode 100644 index 0000000..d261481 --- /dev/null +++ b/src/main/java/tr/com/aurora/hbys/healthcare/web/rest/VisitResource.java @@ -0,0 +1,131 @@ +package tr.com.aurora.hbys.healthcare.web.rest; + +import tr.com.aurora.hbys.healthcare.service.VisitService; +import tr.com.aurora.hbys.healthcare.web.rest.errors.BadRequestAlertException; +import tr.com.aurora.hbys.healthcare.service.dto.VisitDTO; + +import io.github.jhipster.web.util.HeaderUtil; +import io.github.jhipster.web.util.PaginationUtil; +import io.github.jhipster.web.util.ResponseUtil; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; +import org.springframework.beans.factory.annotation.Value; +import org.springframework.data.domain.Page; +import org.springframework.data.domain.Pageable; +import org.springframework.http.HttpHeaders; +import org.springframework.http.HttpStatus; +import org.springframework.web.servlet.support.ServletUriComponentsBuilder; +import org.springframework.http.ResponseEntity; +import org.springframework.web.bind.annotation.*; + +import java.net.URI; +import java.net.URISyntaxException; +import java.util.List; +import java.util.Optional; + +/** + * REST controller for managing {@link tr.com.aurora.hbys.healthcare.domain.Visit}. + */ +@RestController +@RequestMapping("/api") +public class VisitResource { + + private final Logger log = LoggerFactory.getLogger(VisitResource.class); + + private static final String ENTITY_NAME = "visit"; + + @Value("${jhipster.clientApp.name}") + private String applicationName; + + private final VisitService visitService; + + public VisitResource(VisitService visitService) { + this.visitService = visitService; + } + + /** + * {@code POST /visits} : Create a new visit. + * + * @param visitDTO the visitDTO to create. + * @return the {@link ResponseEntity} with status {@code 201 (Created)} and with body the new visitDTO, or with status {@code 400 (Bad Request)} if the visit has already an ID. + * @throws URISyntaxException if the Location URI syntax is incorrect. + */ + @PostMapping("/visits") + public ResponseEntity createVisit(@RequestBody VisitDTO visitDTO) throws URISyntaxException { + log.debug("REST request to save Visit : {}", visitDTO); + if (visitDTO.getId() != null) { + throw new BadRequestAlertException("A new visit cannot already have an ID", ENTITY_NAME, "idexists"); + } + VisitDTO result = visitService.save(visitDTO); + return ResponseEntity.created(new URI("/api/visits/" + result.getId())) + .headers(HeaderUtil.createEntityCreationAlert(applicationName, true, ENTITY_NAME, result.getId().toString())) + .body(result); + } + + /** + * {@code PUT /visits} : Updates an existing visit. + * + * @param visitDTO the visitDTO to update. + * @return the {@link ResponseEntity} with status {@code 200 (OK)} and with body the updated visitDTO, + * or with status {@code 400 (Bad Request)} if the visitDTO is not valid, + * or with status {@code 500 (Internal Server Error)} if the visitDTO couldn't be updated. + * @throws URISyntaxException if the Location URI syntax is incorrect. + */ + @PutMapping("/visits") + public ResponseEntity updateVisit(@RequestBody VisitDTO visitDTO) throws URISyntaxException { + log.debug("REST request to update Visit : {}", visitDTO); + if (visitDTO.getId() == null) { + throw new BadRequestAlertException("Invalid id", ENTITY_NAME, "idnull"); + } + VisitDTO result = visitService.save(visitDTO); + return ResponseEntity.ok() + .headers(HeaderUtil.createEntityUpdateAlert(applicationName, true, ENTITY_NAME, visitDTO.getId().toString())) + .body(result); + } + + /** + * {@code GET /visits} : get all the visits. + * + * @param pageable the pagination information. + * @param eagerload flag to eager load entities from relationships (This is applicable for many-to-many). + * @return the {@link ResponseEntity} with status {@code 200 (OK)} and the list of visits in body. + */ + @GetMapping("/visits") + public ResponseEntity> getAllVisits(Pageable pageable, @RequestParam(required = false, defaultValue = "false") boolean eagerload) { + log.debug("REST request to get a page of Visits"); + Page page; + if (eagerload) { + page = visitService.findAllWithEagerRelationships(pageable); + } else { + page = visitService.findAll(pageable); + } + HttpHeaders headers = PaginationUtil.generatePaginationHttpHeaders(ServletUriComponentsBuilder.fromCurrentRequest(), page); + return ResponseEntity.ok().headers(headers).body(page.getContent()); + } + + /** + * {@code GET /visits/:id} : get the "id" visit. + * + * @param id the id of the visitDTO to retrieve. + * @return the {@link ResponseEntity} with status {@code 200 (OK)} and with body the visitDTO, or with status {@code 404 (Not Found)}. + */ + @GetMapping("/visits/{id}") + public ResponseEntity getVisit(@PathVariable Long id) { + log.debug("REST request to get Visit : {}", id); + Optional visitDTO = visitService.findOne(id); + return ResponseUtil.wrapOrNotFound(visitDTO); + } + + /** + * {@code DELETE /visits/:id} : delete the "id" visit. + * + * @param id the id of the visitDTO to delete. + * @return the {@link ResponseEntity} with status {@code 204 (NO_CONTENT)}. + */ + @DeleteMapping("/visits/{id}") + public ResponseEntity deleteVisit(@PathVariable Long id) { + log.debug("REST request to delete Visit : {}", id); + visitService.delete(id); + return ResponseEntity.noContent().headers(HeaderUtil.createEntityDeletionAlert(applicationName, true, ENTITY_NAME, id.toString())).build(); + } +} diff --git a/src/main/java/tr/com/aurora/hbys/healthcare/web/rest/VisitServiceResource.java b/src/main/java/tr/com/aurora/hbys/healthcare/web/rest/VisitServiceResource.java new file mode 100644 index 0000000..52e7f7f --- /dev/null +++ b/src/main/java/tr/com/aurora/hbys/healthcare/web/rest/VisitServiceResource.java @@ -0,0 +1,126 @@ +package tr.com.aurora.hbys.healthcare.web.rest; + +import tr.com.aurora.hbys.healthcare.service.VisitServiceService; +import tr.com.aurora.hbys.healthcare.web.rest.errors.BadRequestAlertException; +import tr.com.aurora.hbys.healthcare.service.dto.VisitServiceDTO; + +import io.github.jhipster.web.util.HeaderUtil; +import io.github.jhipster.web.util.PaginationUtil; +import io.github.jhipster.web.util.ResponseUtil; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; +import org.springframework.beans.factory.annotation.Value; +import org.springframework.data.domain.Page; +import org.springframework.data.domain.Pageable; +import org.springframework.http.HttpHeaders; +import org.springframework.http.HttpStatus; +import org.springframework.web.servlet.support.ServletUriComponentsBuilder; +import org.springframework.http.ResponseEntity; +import org.springframework.web.bind.annotation.*; + +import javax.validation.Valid; +import java.net.URI; +import java.net.URISyntaxException; +import java.util.List; +import java.util.Optional; + +/** + * REST controller for managing {@link tr.com.aurora.hbys.healthcare.domain.VisitService}. + */ +@RestController +@RequestMapping("/api") +public class VisitServiceResource { + + private final Logger log = LoggerFactory.getLogger(VisitServiceResource.class); + + private static final String ENTITY_NAME = "visitService"; + + @Value("${jhipster.clientApp.name}") + private String applicationName; + + private final VisitServiceService visitServiceService; + + public VisitServiceResource(VisitServiceService visitServiceService) { + this.visitServiceService = visitServiceService; + } + + /** + * {@code POST /visit-services} : Create a new visitService. + * + * @param visitServiceDTO the visitServiceDTO to create. + * @return the {@link ResponseEntity} with status {@code 201 (Created)} and with body the new visitServiceDTO, or with status {@code 400 (Bad Request)} if the visitService has already an ID. + * @throws URISyntaxException if the Location URI syntax is incorrect. + */ + @PostMapping("/visit-services") + public ResponseEntity createVisitService(@Valid @RequestBody VisitServiceDTO visitServiceDTO) throws URISyntaxException { + log.debug("REST request to save VisitService : {}", visitServiceDTO); + if (visitServiceDTO.getId() != null) { + throw new BadRequestAlertException("A new visitService cannot already have an ID", ENTITY_NAME, "idexists"); + } + VisitServiceDTO result = visitServiceService.save(visitServiceDTO); + return ResponseEntity.created(new URI("/api/visit-services/" + result.getId())) + .headers(HeaderUtil.createEntityCreationAlert(applicationName, true, ENTITY_NAME, result.getId().toString())) + .body(result); + } + + /** + * {@code PUT /visit-services} : Updates an existing visitService. + * + * @param visitServiceDTO the visitServiceDTO to update. + * @return the {@link ResponseEntity} with status {@code 200 (OK)} and with body the updated visitServiceDTO, + * or with status {@code 400 (Bad Request)} if the visitServiceDTO is not valid, + * or with status {@code 500 (Internal Server Error)} if the visitServiceDTO couldn't be updated. + * @throws URISyntaxException if the Location URI syntax is incorrect. + */ + @PutMapping("/visit-services") + public ResponseEntity updateVisitService(@Valid @RequestBody VisitServiceDTO visitServiceDTO) throws URISyntaxException { + log.debug("REST request to update VisitService : {}", visitServiceDTO); + if (visitServiceDTO.getId() == null) { + throw new BadRequestAlertException("Invalid id", ENTITY_NAME, "idnull"); + } + VisitServiceDTO result = visitServiceService.save(visitServiceDTO); + return ResponseEntity.ok() + .headers(HeaderUtil.createEntityUpdateAlert(applicationName, true, ENTITY_NAME, visitServiceDTO.getId().toString())) + .body(result); + } + + /** + * {@code GET /visit-services} : get all the visitServices. + * + * @param pageable the pagination information. + * @return the {@link ResponseEntity} with status {@code 200 (OK)} and the list of visitServices in body. + */ + @GetMapping("/visit-services") + public ResponseEntity> getAllVisitServices(Pageable pageable) { + log.debug("REST request to get a page of VisitServices"); + Page page = visitServiceService.findAll(pageable); + HttpHeaders headers = PaginationUtil.generatePaginationHttpHeaders(ServletUriComponentsBuilder.fromCurrentRequest(), page); + return ResponseEntity.ok().headers(headers).body(page.getContent()); + } + + /** + * {@code GET /visit-services/:id} : get the "id" visitService. + * + * @param id the id of the visitServiceDTO to retrieve. + * @return the {@link ResponseEntity} with status {@code 200 (OK)} and with body the visitServiceDTO, or with status {@code 404 (Not Found)}. + */ + @GetMapping("/visit-services/{id}") + public ResponseEntity getVisitService(@PathVariable Long id) { + log.debug("REST request to get VisitService : {}", id); + Optional visitServiceDTO = visitServiceService.findOne(id); + return ResponseUtil.wrapOrNotFound(visitServiceDTO); + } + + /** + * {@code DELETE /visit-services/:id} : delete the "id" visitService. + * + * @param id the id of the visitServiceDTO to delete. + * @return the {@link ResponseEntity} with status {@code 204 (NO_CONTENT)}. + */ + @DeleteMapping("/visit-services/{id}") + public ResponseEntity deleteVisitService(@PathVariable Long id) { + log.debug("REST request to delete VisitService : {}", id); + visitServiceService.delete(id); + return ResponseEntity.noContent().headers(HeaderUtil.createEntityDeletionAlert(applicationName, true, ENTITY_NAME, id.toString())).build(); + } +} diff --git a/src/main/resources/.h2.server.properties b/src/main/resources/.h2.server.properties index 080230e..8285e20 100644 --- a/src/main/resources/.h2.server.properties +++ b/src/main/resources/.h2.server.properties @@ -1,4 +1,5 @@ #H2 Server Properties +#Sat May 02 02:13:22 TRT 2020 0=JHipster H2 (Disk)|org.h2.Driver|jdbc\:h2\:file\:./target/h2db/db/healthcare|healthcare webAllowOthers=true webPort=8082 diff --git a/src/main/resources/config/liquibase/changelog/20200501230400_added_entity_Patient.xml b/src/main/resources/config/liquibase/changelog/20200501230400_added_entity_Patient.xml new file mode 100644 index 0000000..5831c37 --- /dev/null +++ b/src/main/resources/config/liquibase/changelog/20200501230400_added_entity_Patient.xml @@ -0,0 +1,61 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/src/main/resources/config/liquibase/changelog/20200501230500_added_entity_Department.xml b/src/main/resources/config/liquibase/changelog/20200501230500_added_entity_Department.xml new file mode 100644 index 0000000..913e768 --- /dev/null +++ b/src/main/resources/config/liquibase/changelog/20200501230500_added_entity_Department.xml @@ -0,0 +1,61 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/src/main/resources/config/liquibase/changelog/20200501230600_added_entity_Doctor.xml b/src/main/resources/config/liquibase/changelog/20200501230600_added_entity_Doctor.xml new file mode 100644 index 0000000..b474b9b --- /dev/null +++ b/src/main/resources/config/liquibase/changelog/20200501230600_added_entity_Doctor.xml @@ -0,0 +1,68 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/src/main/resources/config/liquibase/changelog/20200501230600_added_entity_constraints_Doctor.xml b/src/main/resources/config/liquibase/changelog/20200501230600_added_entity_constraints_Doctor.xml new file mode 100644 index 0000000..d2e08ea --- /dev/null +++ b/src/main/resources/config/liquibase/changelog/20200501230600_added_entity_constraints_Doctor.xml @@ -0,0 +1,24 @@ + + + + + + + + + + + diff --git a/src/main/resources/config/liquibase/changelog/20200501230700_added_entity_VisitService.xml b/src/main/resources/config/liquibase/changelog/20200501230700_added_entity_VisitService.xml new file mode 100644 index 0000000..c5fab03 --- /dev/null +++ b/src/main/resources/config/liquibase/changelog/20200501230700_added_entity_VisitService.xml @@ -0,0 +1,61 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/src/main/resources/config/liquibase/changelog/20200501230800_added_entity_Visit.xml b/src/main/resources/config/liquibase/changelog/20200501230800_added_entity_Visit.xml new file mode 100644 index 0000000..b9450e3 --- /dev/null +++ b/src/main/resources/config/liquibase/changelog/20200501230800_added_entity_Visit.xml @@ -0,0 +1,74 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/src/main/resources/config/liquibase/changelog/20200501230800_added_entity_constraints_Visit.xml b/src/main/resources/config/liquibase/changelog/20200501230800_added_entity_constraints_Visit.xml new file mode 100644 index 0000000..a7a97e2 --- /dev/null +++ b/src/main/resources/config/liquibase/changelog/20200501230800_added_entity_constraints_Visit.xml @@ -0,0 +1,42 @@ + + + + + + + + + + + + + + + + + diff --git a/src/main/resources/config/liquibase/fake-data/department.csv b/src/main/resources/config/liquibase/fake-data/department.csv new file mode 100644 index 0000000..3e538c0 --- /dev/null +++ b/src/main/resources/config/liquibase/fake-data/department.csv @@ -0,0 +1,11 @@ +id;name;type;description;active +1;Virtual;POLYCLINIC;3rd generation engage Louisiana;false +2;groupware;POLYCLINIC;Electronics Tasty Configuration;false +3;Hat;POLYCLINIC;France parsing instruction set;true +4;maximize;SERVICE;Sleek Soft Ball;false +5;channels bypassing Investment Account;SERVICE;Toys Home distributed;true +6;Principal;SERVICE;bypassing infrastructures;true +7;virtual Computer;SERVICE;1080p Cross-platform;false +8;Intelligent Investor;SERVICE;mint green back-end;false +9;Orchestrator;POLYCLINIC;Armenian Dram;true +10;USB Trafficway Frozen;SERVICE;program asymmetric Money Market Account;true diff --git a/src/main/resources/config/liquibase/fake-data/doctor.csv b/src/main/resources/config/liquibase/fake-data/doctor.csv new file mode 100644 index 0000000..1f95a3b --- /dev/null +++ b/src/main/resources/config/liquibase/fake-data/doctor.csv @@ -0,0 +1,11 @@ +id;name;phone;salary +1;program Yen SMS;1-044-136-1164;48178 +2;Savings Account Sharable;1-562-067-5283 x542;72487 +3;XSS;(391) 504-7193 x0702;11076 +4;monetize Berkshire Points;656.319.5550;89121 +5;Summit Table client-driven;664-602-3713 x1180;27596 +6;next-generation Avon;1-379-181-5751;11323 +7;Forint Coordinator purple;696-710-0161;13802 +8;Accounts;(160) 178-1642;6559 +9;Svalbard & Jan Mayen Islands frictionless disintermediate;571.816.0509 x638;39933 +10;functionalities feed Greece;(162) 312-8815;3842 diff --git a/src/main/resources/config/liquibase/fake-data/patient.csv b/src/main/resources/config/liquibase/fake-data/patient.csv new file mode 100644 index 0000000..323b7c9 --- /dev/null +++ b/src/main/resources/config/liquibase/fake-data/patient.csv @@ -0,0 +1,11 @@ +id;name;phone;birth_date;citizen_number +1;Steel Graphical User Interface;1-696-945-5934;2020-05-01;Buckinghams +2;Macedonia Towels backing up;(625) 406-4792;2020-05-01;Handmade +3;Money Market Account Tugrik FTP;588-464-6710;2020-05-01;Louisiana p +4;methodical Cambridgeshire;1-372-235-1913 x566;2020-05-01;Small Plast +5;Coordinator;811-382-7196 x10514;2020-05-01;synthesizin +6;Hat Incredible Fresh Hat Response;210.014.4192 x6842;2020-05-01;revolutioni +7;action-items human-resource;062.436.6142 x35032;2020-05-01;Track e-ena +8;Metal;(700) 270-0390;2020-05-01;Handcrafted +9;Maryland invoice HDD;1-943-256-0315;2020-05-01;Salad Auto +10;circuit Chief;722-306-4343 x74006;2020-05-01;channels diff --git a/src/main/resources/config/liquibase/fake-data/visit.csv b/src/main/resources/config/liquibase/fake-data/visit.csv new file mode 100644 index 0000000..1429bf1 --- /dev/null +++ b/src/main/resources/config/liquibase/fake-data/visit.csv @@ -0,0 +1,11 @@ +id;date;type +1;2020-05-01T22:40:50;ANALYSIS +2;2020-05-01T01:09:15;EXAMINATION +3;2020-05-01T07:10:29;ANALYSIS +4;2020-05-01T05:35:39;ANALYSIS +5;2020-05-01T17:09:13;EXAMINATION +6;2020-05-01T19:53:15;EXAMINATION +7;2020-05-01T11:34:15;EXAMINATION +8;2020-05-01T16:40:32;EXAMINATION +9;2020-05-01T10:17:03;ANALYSIS +10;2020-05-01T18:24:39;ANALYSIS diff --git a/src/main/resources/config/liquibase/fake-data/visit_service.csv b/src/main/resources/config/liquibase/fake-data/visit_service.csv new file mode 100644 index 0000000..c323c36 --- /dev/null +++ b/src/main/resources/config/liquibase/fake-data/visit_service.csv @@ -0,0 +1,11 @@ +id;name;description;active;price +1;programming backing up;black;true;28895 +2;Director;bypass;false;20279 +3;Buckinghamshire;Direct Maine Philippines;true;4977 +4;Personal Loan Account Steel;projection dynamic Switchable;false;99094 +5;Intelligent;Small Cotton Chips applications enable;false;38846 +6;Kansas white;Handmade Cotton Cheese Generic Plastic Hat;false;59536 +7;orchid Director;Incredible matrix;false;40284 +8;driver Cedi;Cotton Berkshire Corporate;true;80027 +9;Nepalese Rupee cross-platform;Mouse Mali;true;46277 +10;fresh-thinking;Strategist Generic Rubber Hat Maryland;true;62204 diff --git a/src/main/resources/config/liquibase/master.xml b/src/main/resources/config/liquibase/master.xml index f2d2ac6..9a27a97 100644 --- a/src/main/resources/config/liquibase/master.xml +++ b/src/main/resources/config/liquibase/master.xml @@ -14,6 +14,13 @@ + + + + + + + diff --git a/src/main/webapp/app/entities/department/department-delete-dialog.component.html b/src/main/webapp/app/entities/department/department-delete-dialog.component.html new file mode 100644 index 0000000..19cc3f2 --- /dev/null +++ b/src/main/webapp/app/entities/department/department-delete-dialog.component.html @@ -0,0 +1,24 @@ +
+ + + + + +
diff --git a/src/main/webapp/app/entities/department/department-delete-dialog.component.ts b/src/main/webapp/app/entities/department/department-delete-dialog.component.ts new file mode 100644 index 0000000..cec4231 --- /dev/null +++ b/src/main/webapp/app/entities/department/department-delete-dialog.component.ts @@ -0,0 +1,30 @@ +import { Component } from '@angular/core'; +import { NgbActiveModal } from '@ng-bootstrap/ng-bootstrap'; +import { JhiEventManager } from 'ng-jhipster'; + +import { IDepartment } from 'app/shared/model/department.model'; +import { DepartmentService } from './department.service'; + +@Component({ + templateUrl: './department-delete-dialog.component.html' +}) +export class DepartmentDeleteDialogComponent { + department?: IDepartment; + + constructor( + protected departmentService: DepartmentService, + public activeModal: NgbActiveModal, + protected eventManager: JhiEventManager + ) {} + + cancel(): void { + this.activeModal.dismiss(); + } + + confirmDelete(id: number): void { + this.departmentService.delete(id).subscribe(() => { + this.eventManager.broadcast('departmentListModification'); + this.activeModal.close(); + }); + } +} diff --git a/src/main/webapp/app/entities/department/department-detail.component.html b/src/main/webapp/app/entities/department/department-detail.component.html new file mode 100644 index 0000000..5b73014 --- /dev/null +++ b/src/main/webapp/app/entities/department/department-detail.component.html @@ -0,0 +1,42 @@ +
+
+
+

Department {{ department.id }}

+ +
+ + + +
+
Name
+
+ {{ department.name }} +
+
Type
+
+ {{ department.type }} +
+
Description
+
+ {{ department.description }} +
+
Active
+
+ {{ department.active }} +
+
+ + + + +
+
+
diff --git a/src/main/webapp/app/entities/department/department-detail.component.ts b/src/main/webapp/app/entities/department/department-detail.component.ts new file mode 100644 index 0000000..edc2c0a --- /dev/null +++ b/src/main/webapp/app/entities/department/department-detail.component.ts @@ -0,0 +1,22 @@ +import { Component, OnInit } from '@angular/core'; +import { ActivatedRoute } from '@angular/router'; + +import { IDepartment } from 'app/shared/model/department.model'; + +@Component({ + selector: 'jhi-department-detail', + templateUrl: './department-detail.component.html' +}) +export class DepartmentDetailComponent implements OnInit { + department: IDepartment | null = null; + + constructor(protected activatedRoute: ActivatedRoute) {} + + ngOnInit(): void { + this.activatedRoute.data.subscribe(({ department }) => (this.department = department)); + } + + previousState(): void { + window.history.back(); + } +} diff --git a/src/main/webapp/app/entities/department/department-update.component.html b/src/main/webapp/app/entities/department/department-update.component.html new file mode 100644 index 0000000..063df79 --- /dev/null +++ b/src/main/webapp/app/entities/department/department-update.component.html @@ -0,0 +1,68 @@ +
+
+
+

Create or edit a Department

+ +
+ + +
+ + +
+ +
+ + +
+ + This field is required. + + + This field cannot be longer than 200 characters. + +
+
+ +
+ + +
+ +
+ + +
+ + This field cannot be longer than 1000 characters. + +
+
+ +
+ + +
+
+ +
+ + + +
+
+
+
diff --git a/src/main/webapp/app/entities/department/department-update.component.ts b/src/main/webapp/app/entities/department/department-update.component.ts new file mode 100644 index 0000000..2fd8a44 --- /dev/null +++ b/src/main/webapp/app/entities/department/department-update.component.ts @@ -0,0 +1,84 @@ +import { Component, OnInit } from '@angular/core'; +import { HttpResponse } from '@angular/common/http'; +// eslint-disable-next-line @typescript-eslint/no-unused-vars +import { FormBuilder, Validators } from '@angular/forms'; +import { ActivatedRoute } from '@angular/router'; +import { Observable } from 'rxjs'; + +import { IDepartment, Department } from 'app/shared/model/department.model'; +import { DepartmentService } from './department.service'; + +@Component({ + selector: 'jhi-department-update', + templateUrl: './department-update.component.html' +}) +export class DepartmentUpdateComponent implements OnInit { + isSaving = false; + + editForm = this.fb.group({ + id: [], + name: [null, [Validators.required, Validators.maxLength(200)]], + type: [], + description: [null, [Validators.maxLength(1000)]], + active: [] + }); + + constructor(protected departmentService: DepartmentService, protected activatedRoute: ActivatedRoute, private fb: FormBuilder) {} + + ngOnInit(): void { + this.activatedRoute.data.subscribe(({ department }) => { + this.updateForm(department); + }); + } + + updateForm(department: IDepartment): void { + this.editForm.patchValue({ + id: department.id, + name: department.name, + type: department.type, + description: department.description, + active: department.active + }); + } + + previousState(): void { + window.history.back(); + } + + save(): void { + this.isSaving = true; + const department = this.createFromForm(); + if (department.id !== undefined) { + this.subscribeToSaveResponse(this.departmentService.update(department)); + } else { + this.subscribeToSaveResponse(this.departmentService.create(department)); + } + } + + private createFromForm(): IDepartment { + return { + ...new Department(), + id: this.editForm.get(['id'])!.value, + name: this.editForm.get(['name'])!.value, + type: this.editForm.get(['type'])!.value, + description: this.editForm.get(['description'])!.value, + active: this.editForm.get(['active'])!.value + }; + } + + protected subscribeToSaveResponse(result: Observable>): void { + result.subscribe( + () => this.onSaveSuccess(), + () => this.onSaveError() + ); + } + + protected onSaveSuccess(): void { + this.isSaving = false; + this.previousState(); + } + + protected onSaveError(): void { + this.isSaving = false; + } +} diff --git a/src/main/webapp/app/entities/department/department.component.html b/src/main/webapp/app/entities/department/department.component.html new file mode 100644 index 0000000..1685169 --- /dev/null +++ b/src/main/webapp/app/entities/department/department.component.html @@ -0,0 +1,77 @@ +
+

+ Departments + + +

+ + + + + +
+ No departments found +
+ +
+ + + + + + + + + + + + + + + + + + + + + +
ID Name Type Description Active
{{ department.id }}{{ department.name }}{{ department.type }}{{ department.description }}{{ department.active }} +
+ + + + + +
+
+
+ +
+
+ +
+ +
+ +
+
+
diff --git a/src/main/webapp/app/entities/department/department.component.ts b/src/main/webapp/app/entities/department/department.component.ts new file mode 100644 index 0000000..a89b2d6 --- /dev/null +++ b/src/main/webapp/app/entities/department/department.component.ts @@ -0,0 +1,106 @@ +import { Component, OnInit, OnDestroy } from '@angular/core'; +import { HttpHeaders, HttpResponse } from '@angular/common/http'; +import { ActivatedRoute, Router } from '@angular/router'; +import { Subscription } from 'rxjs'; +import { JhiEventManager } from 'ng-jhipster'; +import { NgbModal } from '@ng-bootstrap/ng-bootstrap'; + +import { IDepartment } from 'app/shared/model/department.model'; + +import { ITEMS_PER_PAGE } from 'app/shared/constants/pagination.constants'; +import { DepartmentService } from './department.service'; +import { DepartmentDeleteDialogComponent } from './department-delete-dialog.component'; + +@Component({ + selector: 'jhi-department', + templateUrl: './department.component.html' +}) +export class DepartmentComponent implements OnInit, OnDestroy { + departments?: IDepartment[]; + eventSubscriber?: Subscription; + totalItems = 0; + itemsPerPage = ITEMS_PER_PAGE; + page!: number; + predicate!: string; + ascending!: boolean; + ngbPaginationPage = 1; + + constructor( + protected departmentService: DepartmentService, + protected activatedRoute: ActivatedRoute, + protected router: Router, + protected eventManager: JhiEventManager, + protected modalService: NgbModal + ) {} + + loadPage(page?: number): void { + const pageToLoad: number = page || this.page; + + this.departmentService + .query({ + page: pageToLoad - 1, + size: this.itemsPerPage, + sort: this.sort() + }) + .subscribe( + (res: HttpResponse) => this.onSuccess(res.body, res.headers, pageToLoad), + () => this.onError() + ); + } + + ngOnInit(): void { + this.activatedRoute.data.subscribe(data => { + this.page = data.pagingParams.page; + this.ascending = data.pagingParams.ascending; + this.predicate = data.pagingParams.predicate; + this.ngbPaginationPage = data.pagingParams.page; + this.loadPage(); + }); + this.registerChangeInDepartments(); + } + + ngOnDestroy(): void { + if (this.eventSubscriber) { + this.eventManager.destroy(this.eventSubscriber); + } + } + + trackId(index: number, item: IDepartment): number { + // eslint-disable-next-line @typescript-eslint/no-unnecessary-type-assertion + return item.id!; + } + + registerChangeInDepartments(): void { + this.eventSubscriber = this.eventManager.subscribe('departmentListModification', () => this.loadPage()); + } + + delete(department: IDepartment): void { + const modalRef = this.modalService.open(DepartmentDeleteDialogComponent, { size: 'lg', backdrop: 'static' }); + modalRef.componentInstance.department = department; + } + + sort(): string[] { + const result = [this.predicate + ',' + (this.ascending ? 'asc' : 'desc')]; + if (this.predicate !== 'id') { + result.push('id'); + } + return result; + } + + protected onSuccess(data: IDepartment[] | null, headers: HttpHeaders, page: number): void { + this.totalItems = Number(headers.get('X-Total-Count')); + this.page = page; + this.router.navigate(['/department'], { + queryParams: { + page: this.page, + size: this.itemsPerPage, + sort: this.predicate + ',' + (this.ascending ? 'asc' : 'desc') + } + }); + this.departments = data || []; + } + + protected onError(): void { + this.ngbPaginationPage = this.page; + } +} diff --git a/src/main/webapp/app/entities/department/department.module.ts b/src/main/webapp/app/entities/department/department.module.ts new file mode 100644 index 0000000..c74b136 --- /dev/null +++ b/src/main/webapp/app/entities/department/department.module.ts @@ -0,0 +1,16 @@ +import { NgModule } from '@angular/core'; +import { RouterModule } from '@angular/router'; + +import { HealthcareSharedModule } from 'app/shared/shared.module'; +import { DepartmentComponent } from './department.component'; +import { DepartmentDetailComponent } from './department-detail.component'; +import { DepartmentUpdateComponent } from './department-update.component'; +import { DepartmentDeleteDialogComponent } from './department-delete-dialog.component'; +import { departmentRoute } from './department.route'; + +@NgModule({ + imports: [HealthcareSharedModule, RouterModule.forChild(departmentRoute)], + declarations: [DepartmentComponent, DepartmentDetailComponent, DepartmentUpdateComponent, DepartmentDeleteDialogComponent], + entryComponents: [DepartmentDeleteDialogComponent] +}) +export class HealthcareDepartmentModule {} diff --git a/src/main/webapp/app/entities/department/department.route.ts b/src/main/webapp/app/entities/department/department.route.ts new file mode 100644 index 0000000..e873819 --- /dev/null +++ b/src/main/webapp/app/entities/department/department.route.ts @@ -0,0 +1,88 @@ +import { Injectable } from '@angular/core'; +import { HttpResponse } from '@angular/common/http'; +import { Resolve, ActivatedRouteSnapshot, Routes, Router } from '@angular/router'; +import { JhiResolvePagingParams } from 'ng-jhipster'; +import { Observable, of, EMPTY } from 'rxjs'; +import { flatMap } from 'rxjs/operators'; + +import { Authority } from 'app/shared/constants/authority.constants'; +import { UserRouteAccessService } from 'app/core/auth/user-route-access-service'; +import { IDepartment, Department } from 'app/shared/model/department.model'; +import { DepartmentService } from './department.service'; +import { DepartmentComponent } from './department.component'; +import { DepartmentDetailComponent } from './department-detail.component'; +import { DepartmentUpdateComponent } from './department-update.component'; + +@Injectable({ providedIn: 'root' }) +export class DepartmentResolve implements Resolve { + constructor(private service: DepartmentService, private router: Router) {} + + resolve(route: ActivatedRouteSnapshot): Observable | Observable { + const id = route.params['id']; + if (id) { + return this.service.find(id).pipe( + flatMap((department: HttpResponse) => { + if (department.body) { + return of(department.body); + } else { + this.router.navigate(['404']); + return EMPTY; + } + }) + ); + } + return of(new Department()); + } +} + +export const departmentRoute: Routes = [ + { + path: '', + component: DepartmentComponent, + resolve: { + pagingParams: JhiResolvePagingParams + }, + data: { + authorities: [Authority.USER], + defaultSort: 'id,asc', + pageTitle: 'healthcareApp.department.home.title' + }, + canActivate: [UserRouteAccessService] + }, + { + path: ':id/view', + component: DepartmentDetailComponent, + resolve: { + department: DepartmentResolve + }, + data: { + authorities: [Authority.USER], + pageTitle: 'healthcareApp.department.home.title' + }, + canActivate: [UserRouteAccessService] + }, + { + path: 'new', + component: DepartmentUpdateComponent, + resolve: { + department: DepartmentResolve + }, + data: { + authorities: [Authority.USER], + pageTitle: 'healthcareApp.department.home.title' + }, + canActivate: [UserRouteAccessService] + }, + { + path: ':id/edit', + component: DepartmentUpdateComponent, + resolve: { + department: DepartmentResolve + }, + data: { + authorities: [Authority.USER], + pageTitle: 'healthcareApp.department.home.title' + }, + canActivate: [UserRouteAccessService] + } +]; diff --git a/src/main/webapp/app/entities/department/department.service.ts b/src/main/webapp/app/entities/department/department.service.ts new file mode 100644 index 0000000..52b4178 --- /dev/null +++ b/src/main/webapp/app/entities/department/department.service.ts @@ -0,0 +1,38 @@ +import { Injectable } from '@angular/core'; +import { HttpClient, HttpResponse } from '@angular/common/http'; +import { Observable } from 'rxjs'; + +import { SERVER_API_URL } from 'app/app.constants'; +import { createRequestOption } from 'app/shared/util/request-util'; +import { IDepartment } from 'app/shared/model/department.model'; + +type EntityResponseType = HttpResponse; +type EntityArrayResponseType = HttpResponse; + +@Injectable({ providedIn: 'root' }) +export class DepartmentService { + public resourceUrl = SERVER_API_URL + 'api/departments'; + + constructor(protected http: HttpClient) {} + + create(department: IDepartment): Observable { + return this.http.post(this.resourceUrl, department, { observe: 'response' }); + } + + update(department: IDepartment): Observable { + return this.http.put(this.resourceUrl, department, { observe: 'response' }); + } + + find(id: number): Observable { + return this.http.get(`${this.resourceUrl}/${id}`, { observe: 'response' }); + } + + query(req?: any): Observable { + const options = createRequestOption(req); + return this.http.get(this.resourceUrl, { params: options, observe: 'response' }); + } + + delete(id: number): Observable> { + return this.http.delete(`${this.resourceUrl}/${id}`, { observe: 'response' }); + } +} diff --git a/src/main/webapp/app/entities/doctor/doctor-delete-dialog.component.html b/src/main/webapp/app/entities/doctor/doctor-delete-dialog.component.html new file mode 100644 index 0000000..deb2c39 --- /dev/null +++ b/src/main/webapp/app/entities/doctor/doctor-delete-dialog.component.html @@ -0,0 +1,24 @@ +
+ + + + + +
diff --git a/src/main/webapp/app/entities/doctor/doctor-delete-dialog.component.ts b/src/main/webapp/app/entities/doctor/doctor-delete-dialog.component.ts new file mode 100644 index 0000000..e84e97f --- /dev/null +++ b/src/main/webapp/app/entities/doctor/doctor-delete-dialog.component.ts @@ -0,0 +1,26 @@ +import { Component } from '@angular/core'; +import { NgbActiveModal } from '@ng-bootstrap/ng-bootstrap'; +import { JhiEventManager } from 'ng-jhipster'; + +import { IDoctor } from 'app/shared/model/doctor.model'; +import { DoctorService } from './doctor.service'; + +@Component({ + templateUrl: './doctor-delete-dialog.component.html' +}) +export class DoctorDeleteDialogComponent { + doctor?: IDoctor; + + constructor(protected doctorService: DoctorService, public activeModal: NgbActiveModal, protected eventManager: JhiEventManager) {} + + cancel(): void { + this.activeModal.dismiss(); + } + + confirmDelete(id: number): void { + this.doctorService.delete(id).subscribe(() => { + this.eventManager.broadcast('doctorListModification'); + this.activeModal.close(); + }); + } +} diff --git a/src/main/webapp/app/entities/doctor/doctor-detail.component.html b/src/main/webapp/app/entities/doctor/doctor-detail.component.html new file mode 100644 index 0000000..a05ef7d --- /dev/null +++ b/src/main/webapp/app/entities/doctor/doctor-detail.component.html @@ -0,0 +1,44 @@ +
+
+
+

Doctor {{ doctor.id }}

+ +
+ + + +
+
Name
+
+ {{ doctor.name }} +
+
Phone
+
+ {{ doctor.phone }} +
+
Salary
+
+ {{ doctor.salary }} +
+
Department
+
+ + {{ department.name }}{{ last ? '' : ', ' }} + +
+
+ + + + +
+
+
diff --git a/src/main/webapp/app/entities/doctor/doctor-detail.component.ts b/src/main/webapp/app/entities/doctor/doctor-detail.component.ts new file mode 100644 index 0000000..6ee84e0 --- /dev/null +++ b/src/main/webapp/app/entities/doctor/doctor-detail.component.ts @@ -0,0 +1,22 @@ +import { Component, OnInit } from '@angular/core'; +import { ActivatedRoute } from '@angular/router'; + +import { IDoctor } from 'app/shared/model/doctor.model'; + +@Component({ + selector: 'jhi-doctor-detail', + templateUrl: './doctor-detail.component.html' +}) +export class DoctorDetailComponent implements OnInit { + doctor: IDoctor | null = null; + + constructor(protected activatedRoute: ActivatedRoute) {} + + ngOnInit(): void { + this.activatedRoute.data.subscribe(({ doctor }) => (this.doctor = doctor)); + } + + previousState(): void { + window.history.back(); + } +} diff --git a/src/main/webapp/app/entities/doctor/doctor-update.component.html b/src/main/webapp/app/entities/doctor/doctor-update.component.html new file mode 100644 index 0000000..f7b22b4 --- /dev/null +++ b/src/main/webapp/app/entities/doctor/doctor-update.component.html @@ -0,0 +1,67 @@ +
+
+
+

Create or edit a Doctor

+ +
+ + +
+ + +
+ +
+ + +
+ + This field is required. + + + This field cannot be longer than 100 characters. + +
+
+ +
+ + +
+ + This field cannot be longer than 20 characters. + +
+
+ +
+ + +
+ +
+ + +
+
+ +
+ + + +
+
+
+
diff --git a/src/main/webapp/app/entities/doctor/doctor-update.component.ts b/src/main/webapp/app/entities/doctor/doctor-update.component.ts new file mode 100644 index 0000000..d1eff02 --- /dev/null +++ b/src/main/webapp/app/entities/doctor/doctor-update.component.ts @@ -0,0 +1,109 @@ +import { Component, OnInit } from '@angular/core'; +import { HttpResponse } from '@angular/common/http'; +// eslint-disable-next-line @typescript-eslint/no-unused-vars +import { FormBuilder, Validators } from '@angular/forms'; +import { ActivatedRoute } from '@angular/router'; +import { Observable } from 'rxjs'; + +import { IDoctor, Doctor } from 'app/shared/model/doctor.model'; +import { DoctorService } from './doctor.service'; +import { IDepartment } from 'app/shared/model/department.model'; +import { DepartmentService } from 'app/entities/department/department.service'; + +@Component({ + selector: 'jhi-doctor-update', + templateUrl: './doctor-update.component.html' +}) +export class DoctorUpdateComponent implements OnInit { + isSaving = false; + departments: IDepartment[] = []; + + editForm = this.fb.group({ + id: [], + name: [null, [Validators.required, Validators.maxLength(100)]], + phone: [null, [Validators.maxLength(20)]], + salary: [], + departments: [] + }); + + constructor( + protected doctorService: DoctorService, + protected departmentService: DepartmentService, + protected activatedRoute: ActivatedRoute, + private fb: FormBuilder + ) {} + + ngOnInit(): void { + this.activatedRoute.data.subscribe(({ doctor }) => { + this.updateForm(doctor); + + this.departmentService.query().subscribe((res: HttpResponse) => (this.departments = res.body || [])); + }); + } + + updateForm(doctor: IDoctor): void { + this.editForm.patchValue({ + id: doctor.id, + name: doctor.name, + phone: doctor.phone, + salary: doctor.salary, + departments: doctor.departments + }); + } + + previousState(): void { + window.history.back(); + } + + save(): void { + this.isSaving = true; + const doctor = this.createFromForm(); + if (doctor.id !== undefined) { + this.subscribeToSaveResponse(this.doctorService.update(doctor)); + } else { + this.subscribeToSaveResponse(this.doctorService.create(doctor)); + } + } + + private createFromForm(): IDoctor { + return { + ...new Doctor(), + id: this.editForm.get(['id'])!.value, + name: this.editForm.get(['name'])!.value, + phone: this.editForm.get(['phone'])!.value, + salary: this.editForm.get(['salary'])!.value, + departments: this.editForm.get(['departments'])!.value + }; + } + + protected subscribeToSaveResponse(result: Observable>): void { + result.subscribe( + () => this.onSaveSuccess(), + () => this.onSaveError() + ); + } + + protected onSaveSuccess(): void { + this.isSaving = false; + this.previousState(); + } + + protected onSaveError(): void { + this.isSaving = false; + } + + trackById(index: number, item: IDepartment): any { + return item.id; + } + + getSelected(selectedVals: IDepartment[], option: IDepartment): IDepartment { + if (selectedVals) { + for (let i = 0; i < selectedVals.length; i++) { + if (option.id === selectedVals[i].id) { + return selectedVals[i]; + } + } + } + return option; + } +} diff --git a/src/main/webapp/app/entities/doctor/doctor.component.html b/src/main/webapp/app/entities/doctor/doctor.component.html new file mode 100644 index 0000000..75710c9 --- /dev/null +++ b/src/main/webapp/app/entities/doctor/doctor.component.html @@ -0,0 +1,75 @@ +
+

+ Doctors + + +

+ + + + + +
+ No doctors found +
+ +
+ + + + + + + + + + + + + + + + + + + +
ID Name Phone Salary
{{ doctor.id }}{{ doctor.name }}{{ doctor.phone }}{{ doctor.salary }} +
+ + + + + +
+
+
+ +
+
+ +
+ +
+ +
+
+
diff --git a/src/main/webapp/app/entities/doctor/doctor.component.ts b/src/main/webapp/app/entities/doctor/doctor.component.ts new file mode 100644 index 0000000..1c0914a --- /dev/null +++ b/src/main/webapp/app/entities/doctor/doctor.component.ts @@ -0,0 +1,106 @@ +import { Component, OnInit, OnDestroy } from '@angular/core'; +import { HttpHeaders, HttpResponse } from '@angular/common/http'; +import { ActivatedRoute, Router } from '@angular/router'; +import { Subscription } from 'rxjs'; +import { JhiEventManager } from 'ng-jhipster'; +import { NgbModal } from '@ng-bootstrap/ng-bootstrap'; + +import { IDoctor } from 'app/shared/model/doctor.model'; + +import { ITEMS_PER_PAGE } from 'app/shared/constants/pagination.constants'; +import { DoctorService } from './doctor.service'; +import { DoctorDeleteDialogComponent } from './doctor-delete-dialog.component'; + +@Component({ + selector: 'jhi-doctor', + templateUrl: './doctor.component.html' +}) +export class DoctorComponent implements OnInit, OnDestroy { + doctors?: IDoctor[]; + eventSubscriber?: Subscription; + totalItems = 0; + itemsPerPage = ITEMS_PER_PAGE; + page!: number; + predicate!: string; + ascending!: boolean; + ngbPaginationPage = 1; + + constructor( + protected doctorService: DoctorService, + protected activatedRoute: ActivatedRoute, + protected router: Router, + protected eventManager: JhiEventManager, + protected modalService: NgbModal + ) {} + + loadPage(page?: number): void { + const pageToLoad: number = page || this.page; + + this.doctorService + .query({ + page: pageToLoad - 1, + size: this.itemsPerPage, + sort: this.sort() + }) + .subscribe( + (res: HttpResponse) => this.onSuccess(res.body, res.headers, pageToLoad), + () => this.onError() + ); + } + + ngOnInit(): void { + this.activatedRoute.data.subscribe(data => { + this.page = data.pagingParams.page; + this.ascending = data.pagingParams.ascending; + this.predicate = data.pagingParams.predicate; + this.ngbPaginationPage = data.pagingParams.page; + this.loadPage(); + }); + this.registerChangeInDoctors(); + } + + ngOnDestroy(): void { + if (this.eventSubscriber) { + this.eventManager.destroy(this.eventSubscriber); + } + } + + trackId(index: number, item: IDoctor): number { + // eslint-disable-next-line @typescript-eslint/no-unnecessary-type-assertion + return item.id!; + } + + registerChangeInDoctors(): void { + this.eventSubscriber = this.eventManager.subscribe('doctorListModification', () => this.loadPage()); + } + + delete(doctor: IDoctor): void { + const modalRef = this.modalService.open(DoctorDeleteDialogComponent, { size: 'lg', backdrop: 'static' }); + modalRef.componentInstance.doctor = doctor; + } + + sort(): string[] { + const result = [this.predicate + ',' + (this.ascending ? 'asc' : 'desc')]; + if (this.predicate !== 'id') { + result.push('id'); + } + return result; + } + + protected onSuccess(data: IDoctor[] | null, headers: HttpHeaders, page: number): void { + this.totalItems = Number(headers.get('X-Total-Count')); + this.page = page; + this.router.navigate(['/doctor'], { + queryParams: { + page: this.page, + size: this.itemsPerPage, + sort: this.predicate + ',' + (this.ascending ? 'asc' : 'desc') + } + }); + this.doctors = data || []; + } + + protected onError(): void { + this.ngbPaginationPage = this.page; + } +} diff --git a/src/main/webapp/app/entities/doctor/doctor.module.ts b/src/main/webapp/app/entities/doctor/doctor.module.ts new file mode 100644 index 0000000..27853ef --- /dev/null +++ b/src/main/webapp/app/entities/doctor/doctor.module.ts @@ -0,0 +1,16 @@ +import { NgModule } from '@angular/core'; +import { RouterModule } from '@angular/router'; + +import { HealthcareSharedModule } from 'app/shared/shared.module'; +import { DoctorComponent } from './doctor.component'; +import { DoctorDetailComponent } from './doctor-detail.component'; +import { DoctorUpdateComponent } from './doctor-update.component'; +import { DoctorDeleteDialogComponent } from './doctor-delete-dialog.component'; +import { doctorRoute } from './doctor.route'; + +@NgModule({ + imports: [HealthcareSharedModule, RouterModule.forChild(doctorRoute)], + declarations: [DoctorComponent, DoctorDetailComponent, DoctorUpdateComponent, DoctorDeleteDialogComponent], + entryComponents: [DoctorDeleteDialogComponent] +}) +export class HealthcareDoctorModule {} diff --git a/src/main/webapp/app/entities/doctor/doctor.route.ts b/src/main/webapp/app/entities/doctor/doctor.route.ts new file mode 100644 index 0000000..eceec6b --- /dev/null +++ b/src/main/webapp/app/entities/doctor/doctor.route.ts @@ -0,0 +1,88 @@ +import { Injectable } from '@angular/core'; +import { HttpResponse } from '@angular/common/http'; +import { Resolve, ActivatedRouteSnapshot, Routes, Router } from '@angular/router'; +import { JhiResolvePagingParams } from 'ng-jhipster'; +import { Observable, of, EMPTY } from 'rxjs'; +import { flatMap } from 'rxjs/operators'; + +import { Authority } from 'app/shared/constants/authority.constants'; +import { UserRouteAccessService } from 'app/core/auth/user-route-access-service'; +import { IDoctor, Doctor } from 'app/shared/model/doctor.model'; +import { DoctorService } from './doctor.service'; +import { DoctorComponent } from './doctor.component'; +import { DoctorDetailComponent } from './doctor-detail.component'; +import { DoctorUpdateComponent } from './doctor-update.component'; + +@Injectable({ providedIn: 'root' }) +export class DoctorResolve implements Resolve { + constructor(private service: DoctorService, private router: Router) {} + + resolve(route: ActivatedRouteSnapshot): Observable | Observable { + const id = route.params['id']; + if (id) { + return this.service.find(id).pipe( + flatMap((doctor: HttpResponse) => { + if (doctor.body) { + return of(doctor.body); + } else { + this.router.navigate(['404']); + return EMPTY; + } + }) + ); + } + return of(new Doctor()); + } +} + +export const doctorRoute: Routes = [ + { + path: '', + component: DoctorComponent, + resolve: { + pagingParams: JhiResolvePagingParams + }, + data: { + authorities: [Authority.USER], + defaultSort: 'id,asc', + pageTitle: 'healthcareApp.doctor.home.title' + }, + canActivate: [UserRouteAccessService] + }, + { + path: ':id/view', + component: DoctorDetailComponent, + resolve: { + doctor: DoctorResolve + }, + data: { + authorities: [Authority.USER], + pageTitle: 'healthcareApp.doctor.home.title' + }, + canActivate: [UserRouteAccessService] + }, + { + path: 'new', + component: DoctorUpdateComponent, + resolve: { + doctor: DoctorResolve + }, + data: { + authorities: [Authority.USER], + pageTitle: 'healthcareApp.doctor.home.title' + }, + canActivate: [UserRouteAccessService] + }, + { + path: ':id/edit', + component: DoctorUpdateComponent, + resolve: { + doctor: DoctorResolve + }, + data: { + authorities: [Authority.USER], + pageTitle: 'healthcareApp.doctor.home.title' + }, + canActivate: [UserRouteAccessService] + } +]; diff --git a/src/main/webapp/app/entities/doctor/doctor.service.ts b/src/main/webapp/app/entities/doctor/doctor.service.ts new file mode 100644 index 0000000..184a9b9 --- /dev/null +++ b/src/main/webapp/app/entities/doctor/doctor.service.ts @@ -0,0 +1,38 @@ +import { Injectable } from '@angular/core'; +import { HttpClient, HttpResponse } from '@angular/common/http'; +import { Observable } from 'rxjs'; + +import { SERVER_API_URL } from 'app/app.constants'; +import { createRequestOption } from 'app/shared/util/request-util'; +import { IDoctor } from 'app/shared/model/doctor.model'; + +type EntityResponseType = HttpResponse; +type EntityArrayResponseType = HttpResponse; + +@Injectable({ providedIn: 'root' }) +export class DoctorService { + public resourceUrl = SERVER_API_URL + 'api/doctors'; + + constructor(protected http: HttpClient) {} + + create(doctor: IDoctor): Observable { + return this.http.post(this.resourceUrl, doctor, { observe: 'response' }); + } + + update(doctor: IDoctor): Observable { + return this.http.put(this.resourceUrl, doctor, { observe: 'response' }); + } + + find(id: number): Observable { + return this.http.get(`${this.resourceUrl}/${id}`, { observe: 'response' }); + } + + query(req?: any): Observable { + const options = createRequestOption(req); + return this.http.get(this.resourceUrl, { params: options, observe: 'response' }); + } + + delete(id: number): Observable> { + return this.http.delete(`${this.resourceUrl}/${id}`, { observe: 'response' }); + } +} diff --git a/src/main/webapp/app/entities/entity.module.ts b/src/main/webapp/app/entities/entity.module.ts index af70590..fdac012 100644 --- a/src/main/webapp/app/entities/entity.module.ts +++ b/src/main/webapp/app/entities/entity.module.ts @@ -4,6 +4,26 @@ import { RouterModule } from '@angular/router'; @NgModule({ imports: [ RouterModule.forChild([ + { + path: 'patient', + loadChildren: () => import('./patient/patient.module').then(m => m.HealthcarePatientModule) + }, + { + path: 'department', + loadChildren: () => import('./department/department.module').then(m => m.HealthcareDepartmentModule) + }, + { + path: 'doctor', + loadChildren: () => import('./doctor/doctor.module').then(m => m.HealthcareDoctorModule) + }, + { + path: 'visit-service', + loadChildren: () => import('./visit-service/visit-service.module').then(m => m.HealthcareVisitServiceModule) + }, + { + path: 'visit', + loadChildren: () => import('./visit/visit.module').then(m => m.HealthcareVisitModule) + } /* jhipster-needle-add-entity-route - JHipster will add entity modules routes here */ ]) ] diff --git a/src/main/webapp/app/entities/patient/patient-delete-dialog.component.html b/src/main/webapp/app/entities/patient/patient-delete-dialog.component.html new file mode 100644 index 0000000..d5b2aa0 --- /dev/null +++ b/src/main/webapp/app/entities/patient/patient-delete-dialog.component.html @@ -0,0 +1,24 @@ +
+ + + + + +
diff --git a/src/main/webapp/app/entities/patient/patient-delete-dialog.component.ts b/src/main/webapp/app/entities/patient/patient-delete-dialog.component.ts new file mode 100644 index 0000000..0cc939a --- /dev/null +++ b/src/main/webapp/app/entities/patient/patient-delete-dialog.component.ts @@ -0,0 +1,26 @@ +import { Component } from '@angular/core'; +import { NgbActiveModal } from '@ng-bootstrap/ng-bootstrap'; +import { JhiEventManager } from 'ng-jhipster'; + +import { IPatient } from 'app/shared/model/patient.model'; +import { PatientService } from './patient.service'; + +@Component({ + templateUrl: './patient-delete-dialog.component.html' +}) +export class PatientDeleteDialogComponent { + patient?: IPatient; + + constructor(protected patientService: PatientService, public activeModal: NgbActiveModal, protected eventManager: JhiEventManager) {} + + cancel(): void { + this.activeModal.dismiss(); + } + + confirmDelete(id: number): void { + this.patientService.delete(id).subscribe(() => { + this.eventManager.broadcast('patientListModification'); + this.activeModal.close(); + }); + } +} diff --git a/src/main/webapp/app/entities/patient/patient-detail.component.html b/src/main/webapp/app/entities/patient/patient-detail.component.html new file mode 100644 index 0000000..2c05350 --- /dev/null +++ b/src/main/webapp/app/entities/patient/patient-detail.component.html @@ -0,0 +1,42 @@ +
+
+
+

Patient {{ patient.id }}

+ +
+ + + +
+
Name
+
+ {{ patient.name }} +
+
Phone
+
+ {{ patient.phone }} +
+
Birth Date
+
+ {{ patient.birthDate }} +
+
Citizen Number
+
+ {{ patient.citizenNumber }} +
+
+ + + + +
+
+
diff --git a/src/main/webapp/app/entities/patient/patient-detail.component.ts b/src/main/webapp/app/entities/patient/patient-detail.component.ts new file mode 100644 index 0000000..2505dfa --- /dev/null +++ b/src/main/webapp/app/entities/patient/patient-detail.component.ts @@ -0,0 +1,22 @@ +import { Component, OnInit } from '@angular/core'; +import { ActivatedRoute } from '@angular/router'; + +import { IPatient } from 'app/shared/model/patient.model'; + +@Component({ + selector: 'jhi-patient-detail', + templateUrl: './patient-detail.component.html' +}) +export class PatientDetailComponent implements OnInit { + patient: IPatient | null = null; + + constructor(protected activatedRoute: ActivatedRoute) {} + + ngOnInit(): void { + this.activatedRoute.data.subscribe(({ patient }) => (this.patient = patient)); + } + + previousState(): void { + window.history.back(); + } +} diff --git a/src/main/webapp/app/entities/patient/patient-update.component.html b/src/main/webapp/app/entities/patient/patient-update.component.html new file mode 100644 index 0000000..6061c03 --- /dev/null +++ b/src/main/webapp/app/entities/patient/patient-update.component.html @@ -0,0 +1,80 @@ +
+
+
+

Create or edit a Patient

+ +
+ + +
+ + +
+ +
+ + +
+ + This field is required. + + + This field cannot be longer than 100 characters. + +
+
+ +
+ + +
+ + This field cannot be longer than 20 characters. + +
+
+ +
+ +
+ + + + +
+
+ +
+ + +
+ + This field is required. + + + This field cannot be longer than 11 characters. + +
+
+
+ +
+ + + +
+
+
+
diff --git a/src/main/webapp/app/entities/patient/patient-update.component.ts b/src/main/webapp/app/entities/patient/patient-update.component.ts new file mode 100644 index 0000000..0da024b --- /dev/null +++ b/src/main/webapp/app/entities/patient/patient-update.component.ts @@ -0,0 +1,85 @@ +import { Component, OnInit } from '@angular/core'; +import { HttpResponse } from '@angular/common/http'; +// eslint-disable-next-line @typescript-eslint/no-unused-vars +import { FormBuilder, Validators } from '@angular/forms'; +import { ActivatedRoute } from '@angular/router'; +import { Observable } from 'rxjs'; + +import { IPatient, Patient } from 'app/shared/model/patient.model'; +import { PatientService } from './patient.service'; + +@Component({ + selector: 'jhi-patient-update', + templateUrl: './patient-update.component.html' +}) +export class PatientUpdateComponent implements OnInit { + isSaving = false; + birthDateDp: any; + + editForm = this.fb.group({ + id: [], + name: [null, [Validators.required, Validators.maxLength(100)]], + phone: [null, [Validators.maxLength(20)]], + birthDate: [], + citizenNumber: [null, [Validators.required, Validators.maxLength(11)]] + }); + + constructor(protected patientService: PatientService, protected activatedRoute: ActivatedRoute, private fb: FormBuilder) {} + + ngOnInit(): void { + this.activatedRoute.data.subscribe(({ patient }) => { + this.updateForm(patient); + }); + } + + updateForm(patient: IPatient): void { + this.editForm.patchValue({ + id: patient.id, + name: patient.name, + phone: patient.phone, + birthDate: patient.birthDate, + citizenNumber: patient.citizenNumber + }); + } + + previousState(): void { + window.history.back(); + } + + save(): void { + this.isSaving = true; + const patient = this.createFromForm(); + if (patient.id !== undefined) { + this.subscribeToSaveResponse(this.patientService.update(patient)); + } else { + this.subscribeToSaveResponse(this.patientService.create(patient)); + } + } + + private createFromForm(): IPatient { + return { + ...new Patient(), + id: this.editForm.get(['id'])!.value, + name: this.editForm.get(['name'])!.value, + phone: this.editForm.get(['phone'])!.value, + birthDate: this.editForm.get(['birthDate'])!.value, + citizenNumber: this.editForm.get(['citizenNumber'])!.value + }; + } + + protected subscribeToSaveResponse(result: Observable>): void { + result.subscribe( + () => this.onSaveSuccess(), + () => this.onSaveError() + ); + } + + protected onSaveSuccess(): void { + this.isSaving = false; + this.previousState(); + } + + protected onSaveError(): void { + this.isSaving = false; + } +} diff --git a/src/main/webapp/app/entities/patient/patient.component.html b/src/main/webapp/app/entities/patient/patient.component.html new file mode 100644 index 0000000..42f9a13 --- /dev/null +++ b/src/main/webapp/app/entities/patient/patient.component.html @@ -0,0 +1,77 @@ +
+

+ Patients + + +

+ + + + + +
+ No patients found +
+ +
+ + + + + + + + + + + + + + + + + + + + + +
ID Name Phone Birth Date Citizen Number
{{ patient.id }}{{ patient.name }}{{ patient.phone }}{{ patient.birthDate | date:'mediumDate' }}{{ patient.citizenNumber }} +
+ + + + + +
+
+
+ +
+
+ +
+ +
+ +
+
+
diff --git a/src/main/webapp/app/entities/patient/patient.component.ts b/src/main/webapp/app/entities/patient/patient.component.ts new file mode 100644 index 0000000..71777be --- /dev/null +++ b/src/main/webapp/app/entities/patient/patient.component.ts @@ -0,0 +1,106 @@ +import { Component, OnInit, OnDestroy } from '@angular/core'; +import { HttpHeaders, HttpResponse } from '@angular/common/http'; +import { ActivatedRoute, Router } from '@angular/router'; +import { Subscription } from 'rxjs'; +import { JhiEventManager } from 'ng-jhipster'; +import { NgbModal } from '@ng-bootstrap/ng-bootstrap'; + +import { IPatient } from 'app/shared/model/patient.model'; + +import { ITEMS_PER_PAGE } from 'app/shared/constants/pagination.constants'; +import { PatientService } from './patient.service'; +import { PatientDeleteDialogComponent } from './patient-delete-dialog.component'; + +@Component({ + selector: 'jhi-patient', + templateUrl: './patient.component.html' +}) +export class PatientComponent implements OnInit, OnDestroy { + patients?: IPatient[]; + eventSubscriber?: Subscription; + totalItems = 0; + itemsPerPage = ITEMS_PER_PAGE; + page!: number; + predicate!: string; + ascending!: boolean; + ngbPaginationPage = 1; + + constructor( + protected patientService: PatientService, + protected activatedRoute: ActivatedRoute, + protected router: Router, + protected eventManager: JhiEventManager, + protected modalService: NgbModal + ) {} + + loadPage(page?: number): void { + const pageToLoad: number = page || this.page; + + this.patientService + .query({ + page: pageToLoad - 1, + size: this.itemsPerPage, + sort: this.sort() + }) + .subscribe( + (res: HttpResponse) => this.onSuccess(res.body, res.headers, pageToLoad), + () => this.onError() + ); + } + + ngOnInit(): void { + this.activatedRoute.data.subscribe(data => { + this.page = data.pagingParams.page; + this.ascending = data.pagingParams.ascending; + this.predicate = data.pagingParams.predicate; + this.ngbPaginationPage = data.pagingParams.page; + this.loadPage(); + }); + this.registerChangeInPatients(); + } + + ngOnDestroy(): void { + if (this.eventSubscriber) { + this.eventManager.destroy(this.eventSubscriber); + } + } + + trackId(index: number, item: IPatient): number { + // eslint-disable-next-line @typescript-eslint/no-unnecessary-type-assertion + return item.id!; + } + + registerChangeInPatients(): void { + this.eventSubscriber = this.eventManager.subscribe('patientListModification', () => this.loadPage()); + } + + delete(patient: IPatient): void { + const modalRef = this.modalService.open(PatientDeleteDialogComponent, { size: 'lg', backdrop: 'static' }); + modalRef.componentInstance.patient = patient; + } + + sort(): string[] { + const result = [this.predicate + ',' + (this.ascending ? 'asc' : 'desc')]; + if (this.predicate !== 'id') { + result.push('id'); + } + return result; + } + + protected onSuccess(data: IPatient[] | null, headers: HttpHeaders, page: number): void { + this.totalItems = Number(headers.get('X-Total-Count')); + this.page = page; + this.router.navigate(['/patient'], { + queryParams: { + page: this.page, + size: this.itemsPerPage, + sort: this.predicate + ',' + (this.ascending ? 'asc' : 'desc') + } + }); + this.patients = data || []; + } + + protected onError(): void { + this.ngbPaginationPage = this.page; + } +} diff --git a/src/main/webapp/app/entities/patient/patient.module.ts b/src/main/webapp/app/entities/patient/patient.module.ts new file mode 100644 index 0000000..8cb5ff1 --- /dev/null +++ b/src/main/webapp/app/entities/patient/patient.module.ts @@ -0,0 +1,16 @@ +import { NgModule } from '@angular/core'; +import { RouterModule } from '@angular/router'; + +import { HealthcareSharedModule } from 'app/shared/shared.module'; +import { PatientComponent } from './patient.component'; +import { PatientDetailComponent } from './patient-detail.component'; +import { PatientUpdateComponent } from './patient-update.component'; +import { PatientDeleteDialogComponent } from './patient-delete-dialog.component'; +import { patientRoute } from './patient.route'; + +@NgModule({ + imports: [HealthcareSharedModule, RouterModule.forChild(patientRoute)], + declarations: [PatientComponent, PatientDetailComponent, PatientUpdateComponent, PatientDeleteDialogComponent], + entryComponents: [PatientDeleteDialogComponent] +}) +export class HealthcarePatientModule {} diff --git a/src/main/webapp/app/entities/patient/patient.route.ts b/src/main/webapp/app/entities/patient/patient.route.ts new file mode 100644 index 0000000..c59c6ab --- /dev/null +++ b/src/main/webapp/app/entities/patient/patient.route.ts @@ -0,0 +1,88 @@ +import { Injectable } from '@angular/core'; +import { HttpResponse } from '@angular/common/http'; +import { Resolve, ActivatedRouteSnapshot, Routes, Router } from '@angular/router'; +import { JhiResolvePagingParams } from 'ng-jhipster'; +import { Observable, of, EMPTY } from 'rxjs'; +import { flatMap } from 'rxjs/operators'; + +import { Authority } from 'app/shared/constants/authority.constants'; +import { UserRouteAccessService } from 'app/core/auth/user-route-access-service'; +import { IPatient, Patient } from 'app/shared/model/patient.model'; +import { PatientService } from './patient.service'; +import { PatientComponent } from './patient.component'; +import { PatientDetailComponent } from './patient-detail.component'; +import { PatientUpdateComponent } from './patient-update.component'; + +@Injectable({ providedIn: 'root' }) +export class PatientResolve implements Resolve { + constructor(private service: PatientService, private router: Router) {} + + resolve(route: ActivatedRouteSnapshot): Observable | Observable { + const id = route.params['id']; + if (id) { + return this.service.find(id).pipe( + flatMap((patient: HttpResponse) => { + if (patient.body) { + return of(patient.body); + } else { + this.router.navigate(['404']); + return EMPTY; + } + }) + ); + } + return of(new Patient()); + } +} + +export const patientRoute: Routes = [ + { + path: '', + component: PatientComponent, + resolve: { + pagingParams: JhiResolvePagingParams + }, + data: { + authorities: [Authority.USER], + defaultSort: 'id,asc', + pageTitle: 'healthcareApp.patient.home.title' + }, + canActivate: [UserRouteAccessService] + }, + { + path: ':id/view', + component: PatientDetailComponent, + resolve: { + patient: PatientResolve + }, + data: { + authorities: [Authority.USER], + pageTitle: 'healthcareApp.patient.home.title' + }, + canActivate: [UserRouteAccessService] + }, + { + path: 'new', + component: PatientUpdateComponent, + resolve: { + patient: PatientResolve + }, + data: { + authorities: [Authority.USER], + pageTitle: 'healthcareApp.patient.home.title' + }, + canActivate: [UserRouteAccessService] + }, + { + path: ':id/edit', + component: PatientUpdateComponent, + resolve: { + patient: PatientResolve + }, + data: { + authorities: [Authority.USER], + pageTitle: 'healthcareApp.patient.home.title' + }, + canActivate: [UserRouteAccessService] + } +]; diff --git a/src/main/webapp/app/entities/patient/patient.service.ts b/src/main/webapp/app/entities/patient/patient.service.ts new file mode 100644 index 0000000..cfbe6dd --- /dev/null +++ b/src/main/webapp/app/entities/patient/patient.service.ts @@ -0,0 +1,74 @@ +import { Injectable } from '@angular/core'; +import { HttpClient, HttpResponse } from '@angular/common/http'; +import { Observable } from 'rxjs'; +import { map } from 'rxjs/operators'; +import * as moment from 'moment'; + +import { DATE_FORMAT } from 'app/shared/constants/input.constants'; +import { SERVER_API_URL } from 'app/app.constants'; +import { createRequestOption } from 'app/shared/util/request-util'; +import { IPatient } from 'app/shared/model/patient.model'; + +type EntityResponseType = HttpResponse; +type EntityArrayResponseType = HttpResponse; + +@Injectable({ providedIn: 'root' }) +export class PatientService { + public resourceUrl = SERVER_API_URL + 'api/patients'; + + constructor(protected http: HttpClient) {} + + create(patient: IPatient): Observable { + const copy = this.convertDateFromClient(patient); + return this.http + .post(this.resourceUrl, copy, { observe: 'response' }) + .pipe(map((res: EntityResponseType) => this.convertDateFromServer(res))); + } + + update(patient: IPatient): Observable { + const copy = this.convertDateFromClient(patient); + return this.http + .put(this.resourceUrl, copy, { observe: 'response' }) + .pipe(map((res: EntityResponseType) => this.convertDateFromServer(res))); + } + + find(id: number): Observable { + return this.http + .get(`${this.resourceUrl}/${id}`, { observe: 'response' }) + .pipe(map((res: EntityResponseType) => this.convertDateFromServer(res))); + } + + query(req?: any): Observable { + const options = createRequestOption(req); + return this.http + .get(this.resourceUrl, { params: options, observe: 'response' }) + .pipe(map((res: EntityArrayResponseType) => this.convertDateArrayFromServer(res))); + } + + delete(id: number): Observable> { + return this.http.delete(`${this.resourceUrl}/${id}`, { observe: 'response' }); + } + + protected convertDateFromClient(patient: IPatient): IPatient { + const copy: IPatient = Object.assign({}, patient, { + birthDate: patient.birthDate && patient.birthDate.isValid() ? patient.birthDate.format(DATE_FORMAT) : undefined + }); + return copy; + } + + protected convertDateFromServer(res: EntityResponseType): EntityResponseType { + if (res.body) { + res.body.birthDate = res.body.birthDate ? moment(res.body.birthDate) : undefined; + } + return res; + } + + protected convertDateArrayFromServer(res: EntityArrayResponseType): EntityArrayResponseType { + if (res.body) { + res.body.forEach((patient: IPatient) => { + patient.birthDate = patient.birthDate ? moment(patient.birthDate) : undefined; + }); + } + return res; + } +} diff --git a/src/main/webapp/app/entities/visit-service/visit-service-delete-dialog.component.html b/src/main/webapp/app/entities/visit-service/visit-service-delete-dialog.component.html new file mode 100644 index 0000000..3ef1f34 --- /dev/null +++ b/src/main/webapp/app/entities/visit-service/visit-service-delete-dialog.component.html @@ -0,0 +1,24 @@ +
+ + + + + +
diff --git a/src/main/webapp/app/entities/visit-service/visit-service-delete-dialog.component.ts b/src/main/webapp/app/entities/visit-service/visit-service-delete-dialog.component.ts new file mode 100644 index 0000000..9fab43e --- /dev/null +++ b/src/main/webapp/app/entities/visit-service/visit-service-delete-dialog.component.ts @@ -0,0 +1,30 @@ +import { Component } from '@angular/core'; +import { NgbActiveModal } from '@ng-bootstrap/ng-bootstrap'; +import { JhiEventManager } from 'ng-jhipster'; + +import { IVisitService } from 'app/shared/model/visit-service.model'; +import { VisitServiceService } from './visit-service.service'; + +@Component({ + templateUrl: './visit-service-delete-dialog.component.html' +}) +export class VisitServiceDeleteDialogComponent { + visitService?: IVisitService; + + constructor( + protected visitServiceService: VisitServiceService, + public activeModal: NgbActiveModal, + protected eventManager: JhiEventManager + ) {} + + cancel(): void { + this.activeModal.dismiss(); + } + + confirmDelete(id: number): void { + this.visitServiceService.delete(id).subscribe(() => { + this.eventManager.broadcast('visitServiceListModification'); + this.activeModal.close(); + }); + } +} diff --git a/src/main/webapp/app/entities/visit-service/visit-service-detail.component.html b/src/main/webapp/app/entities/visit-service/visit-service-detail.component.html new file mode 100644 index 0000000..279f573 --- /dev/null +++ b/src/main/webapp/app/entities/visit-service/visit-service-detail.component.html @@ -0,0 +1,42 @@ +
+
+
+

Visit Service {{ visitService.id }}

+ +
+ + + +
+
Name
+
+ {{ visitService.name }} +
+
Description
+
+ {{ visitService.description }} +
+
Active
+
+ {{ visitService.active }} +
+
Price
+
+ {{ visitService.price }} +
+
+ + + + +
+
+
diff --git a/src/main/webapp/app/entities/visit-service/visit-service-detail.component.ts b/src/main/webapp/app/entities/visit-service/visit-service-detail.component.ts new file mode 100644 index 0000000..7928cc4 --- /dev/null +++ b/src/main/webapp/app/entities/visit-service/visit-service-detail.component.ts @@ -0,0 +1,22 @@ +import { Component, OnInit } from '@angular/core'; +import { ActivatedRoute } from '@angular/router'; + +import { IVisitService } from 'app/shared/model/visit-service.model'; + +@Component({ + selector: 'jhi-visit-service-detail', + templateUrl: './visit-service-detail.component.html' +}) +export class VisitServiceDetailComponent implements OnInit { + visitService: IVisitService | null = null; + + constructor(protected activatedRoute: ActivatedRoute) {} + + ngOnInit(): void { + this.activatedRoute.data.subscribe(({ visitService }) => (this.visitService = visitService)); + } + + previousState(): void { + window.history.back(); + } +} diff --git a/src/main/webapp/app/entities/visit-service/visit-service-update.component.html b/src/main/webapp/app/entities/visit-service/visit-service-update.component.html new file mode 100644 index 0000000..8d76e82 --- /dev/null +++ b/src/main/webapp/app/entities/visit-service/visit-service-update.component.html @@ -0,0 +1,66 @@ +
+
+
+

Create or edit a Visit Service

+ +
+ + +
+ + +
+ +
+ + +
+ + This field is required. + + + This field cannot be longer than 200 characters. + +
+
+ +
+ + +
+ + This field cannot be longer than 1000 characters. + +
+
+ +
+ + +
+ +
+ + +
+
+ +
+ + + +
+
+
+
diff --git a/src/main/webapp/app/entities/visit-service/visit-service-update.component.ts b/src/main/webapp/app/entities/visit-service/visit-service-update.component.ts new file mode 100644 index 0000000..a15c880 --- /dev/null +++ b/src/main/webapp/app/entities/visit-service/visit-service-update.component.ts @@ -0,0 +1,84 @@ +import { Component, OnInit } from '@angular/core'; +import { HttpResponse } from '@angular/common/http'; +// eslint-disable-next-line @typescript-eslint/no-unused-vars +import { FormBuilder, Validators } from '@angular/forms'; +import { ActivatedRoute } from '@angular/router'; +import { Observable } from 'rxjs'; + +import { IVisitService, VisitService } from 'app/shared/model/visit-service.model'; +import { VisitServiceService } from './visit-service.service'; + +@Component({ + selector: 'jhi-visit-service-update', + templateUrl: './visit-service-update.component.html' +}) +export class VisitServiceUpdateComponent implements OnInit { + isSaving = false; + + editForm = this.fb.group({ + id: [], + name: [null, [Validators.required, Validators.maxLength(200)]], + description: [null, [Validators.maxLength(1000)]], + active: [], + price: [] + }); + + constructor(protected visitServiceService: VisitServiceService, protected activatedRoute: ActivatedRoute, private fb: FormBuilder) {} + + ngOnInit(): void { + this.activatedRoute.data.subscribe(({ visitService }) => { + this.updateForm(visitService); + }); + } + + updateForm(visitService: IVisitService): void { + this.editForm.patchValue({ + id: visitService.id, + name: visitService.name, + description: visitService.description, + active: visitService.active, + price: visitService.price + }); + } + + previousState(): void { + window.history.back(); + } + + save(): void { + this.isSaving = true; + const visitService = this.createFromForm(); + if (visitService.id !== undefined) { + this.subscribeToSaveResponse(this.visitServiceService.update(visitService)); + } else { + this.subscribeToSaveResponse(this.visitServiceService.create(visitService)); + } + } + + private createFromForm(): IVisitService { + return { + ...new VisitService(), + id: this.editForm.get(['id'])!.value, + name: this.editForm.get(['name'])!.value, + description: this.editForm.get(['description'])!.value, + active: this.editForm.get(['active'])!.value, + price: this.editForm.get(['price'])!.value + }; + } + + protected subscribeToSaveResponse(result: Observable>): void { + result.subscribe( + () => this.onSaveSuccess(), + () => this.onSaveError() + ); + } + + protected onSaveSuccess(): void { + this.isSaving = false; + this.previousState(); + } + + protected onSaveError(): void { + this.isSaving = false; + } +} diff --git a/src/main/webapp/app/entities/visit-service/visit-service.component.html b/src/main/webapp/app/entities/visit-service/visit-service.component.html new file mode 100644 index 0000000..cec704a --- /dev/null +++ b/src/main/webapp/app/entities/visit-service/visit-service.component.html @@ -0,0 +1,77 @@ +
+

+ Visit Services + + +

+ + + + + +
+ No visitServices found +
+ +
+ + + + + + + + + + + + + + + + + + + + + +
ID Name Description Active Price
{{ visitService.id }}{{ visitService.name }}{{ visitService.description }}{{ visitService.active }}{{ visitService.price }} +
+ + + + + +
+
+
+ +
+
+ +
+ +
+ +
+
+
diff --git a/src/main/webapp/app/entities/visit-service/visit-service.component.ts b/src/main/webapp/app/entities/visit-service/visit-service.component.ts new file mode 100644 index 0000000..e594cf2 --- /dev/null +++ b/src/main/webapp/app/entities/visit-service/visit-service.component.ts @@ -0,0 +1,106 @@ +import { Component, OnInit, OnDestroy } from '@angular/core'; +import { HttpHeaders, HttpResponse } from '@angular/common/http'; +import { ActivatedRoute, Router } from '@angular/router'; +import { Subscription } from 'rxjs'; +import { JhiEventManager } from 'ng-jhipster'; +import { NgbModal } from '@ng-bootstrap/ng-bootstrap'; + +import { IVisitService } from 'app/shared/model/visit-service.model'; + +import { ITEMS_PER_PAGE } from 'app/shared/constants/pagination.constants'; +import { VisitServiceService } from './visit-service.service'; +import { VisitServiceDeleteDialogComponent } from './visit-service-delete-dialog.component'; + +@Component({ + selector: 'jhi-visit-service', + templateUrl: './visit-service.component.html' +}) +export class VisitServiceComponent implements OnInit, OnDestroy { + visitServices?: IVisitService[]; + eventSubscriber?: Subscription; + totalItems = 0; + itemsPerPage = ITEMS_PER_PAGE; + page!: number; + predicate!: string; + ascending!: boolean; + ngbPaginationPage = 1; + + constructor( + protected visitServiceService: VisitServiceService, + protected activatedRoute: ActivatedRoute, + protected router: Router, + protected eventManager: JhiEventManager, + protected modalService: NgbModal + ) {} + + loadPage(page?: number): void { + const pageToLoad: number = page || this.page; + + this.visitServiceService + .query({ + page: pageToLoad - 1, + size: this.itemsPerPage, + sort: this.sort() + }) + .subscribe( + (res: HttpResponse) => this.onSuccess(res.body, res.headers, pageToLoad), + () => this.onError() + ); + } + + ngOnInit(): void { + this.activatedRoute.data.subscribe(data => { + this.page = data.pagingParams.page; + this.ascending = data.pagingParams.ascending; + this.predicate = data.pagingParams.predicate; + this.ngbPaginationPage = data.pagingParams.page; + this.loadPage(); + }); + this.registerChangeInVisitServices(); + } + + ngOnDestroy(): void { + if (this.eventSubscriber) { + this.eventManager.destroy(this.eventSubscriber); + } + } + + trackId(index: number, item: IVisitService): number { + // eslint-disable-next-line @typescript-eslint/no-unnecessary-type-assertion + return item.id!; + } + + registerChangeInVisitServices(): void { + this.eventSubscriber = this.eventManager.subscribe('visitServiceListModification', () => this.loadPage()); + } + + delete(visitService: IVisitService): void { + const modalRef = this.modalService.open(VisitServiceDeleteDialogComponent, { size: 'lg', backdrop: 'static' }); + modalRef.componentInstance.visitService = visitService; + } + + sort(): string[] { + const result = [this.predicate + ',' + (this.ascending ? 'asc' : 'desc')]; + if (this.predicate !== 'id') { + result.push('id'); + } + return result; + } + + protected onSuccess(data: IVisitService[] | null, headers: HttpHeaders, page: number): void { + this.totalItems = Number(headers.get('X-Total-Count')); + this.page = page; + this.router.navigate(['/visit-service'], { + queryParams: { + page: this.page, + size: this.itemsPerPage, + sort: this.predicate + ',' + (this.ascending ? 'asc' : 'desc') + } + }); + this.visitServices = data || []; + } + + protected onError(): void { + this.ngbPaginationPage = this.page; + } +} diff --git a/src/main/webapp/app/entities/visit-service/visit-service.module.ts b/src/main/webapp/app/entities/visit-service/visit-service.module.ts new file mode 100644 index 0000000..8545ad8 --- /dev/null +++ b/src/main/webapp/app/entities/visit-service/visit-service.module.ts @@ -0,0 +1,16 @@ +import { NgModule } from '@angular/core'; +import { RouterModule } from '@angular/router'; + +import { HealthcareSharedModule } from 'app/shared/shared.module'; +import { VisitServiceComponent } from './visit-service.component'; +import { VisitServiceDetailComponent } from './visit-service-detail.component'; +import { VisitServiceUpdateComponent } from './visit-service-update.component'; +import { VisitServiceDeleteDialogComponent } from './visit-service-delete-dialog.component'; +import { visitServiceRoute } from './visit-service.route'; + +@NgModule({ + imports: [HealthcareSharedModule, RouterModule.forChild(visitServiceRoute)], + declarations: [VisitServiceComponent, VisitServiceDetailComponent, VisitServiceUpdateComponent, VisitServiceDeleteDialogComponent], + entryComponents: [VisitServiceDeleteDialogComponent] +}) +export class HealthcareVisitServiceModule {} diff --git a/src/main/webapp/app/entities/visit-service/visit-service.route.ts b/src/main/webapp/app/entities/visit-service/visit-service.route.ts new file mode 100644 index 0000000..c6266e0 --- /dev/null +++ b/src/main/webapp/app/entities/visit-service/visit-service.route.ts @@ -0,0 +1,88 @@ +import { Injectable } from '@angular/core'; +import { HttpResponse } from '@angular/common/http'; +import { Resolve, ActivatedRouteSnapshot, Routes, Router } from '@angular/router'; +import { JhiResolvePagingParams } from 'ng-jhipster'; +import { Observable, of, EMPTY } from 'rxjs'; +import { flatMap } from 'rxjs/operators'; + +import { Authority } from 'app/shared/constants/authority.constants'; +import { UserRouteAccessService } from 'app/core/auth/user-route-access-service'; +import { IVisitService, VisitService } from 'app/shared/model/visit-service.model'; +import { VisitServiceService } from './visit-service.service'; +import { VisitServiceComponent } from './visit-service.component'; +import { VisitServiceDetailComponent } from './visit-service-detail.component'; +import { VisitServiceUpdateComponent } from './visit-service-update.component'; + +@Injectable({ providedIn: 'root' }) +export class VisitServiceResolve implements Resolve { + constructor(private service: VisitServiceService, private router: Router) {} + + resolve(route: ActivatedRouteSnapshot): Observable | Observable { + const id = route.params['id']; + if (id) { + return this.service.find(id).pipe( + flatMap((visitService: HttpResponse) => { + if (visitService.body) { + return of(visitService.body); + } else { + this.router.navigate(['404']); + return EMPTY; + } + }) + ); + } + return of(new VisitService()); + } +} + +export const visitServiceRoute: Routes = [ + { + path: '', + component: VisitServiceComponent, + resolve: { + pagingParams: JhiResolvePagingParams + }, + data: { + authorities: [Authority.USER], + defaultSort: 'id,asc', + pageTitle: 'healthcareApp.visitService.home.title' + }, + canActivate: [UserRouteAccessService] + }, + { + path: ':id/view', + component: VisitServiceDetailComponent, + resolve: { + visitService: VisitServiceResolve + }, + data: { + authorities: [Authority.USER], + pageTitle: 'healthcareApp.visitService.home.title' + }, + canActivate: [UserRouteAccessService] + }, + { + path: 'new', + component: VisitServiceUpdateComponent, + resolve: { + visitService: VisitServiceResolve + }, + data: { + authorities: [Authority.USER], + pageTitle: 'healthcareApp.visitService.home.title' + }, + canActivate: [UserRouteAccessService] + }, + { + path: ':id/edit', + component: VisitServiceUpdateComponent, + resolve: { + visitService: VisitServiceResolve + }, + data: { + authorities: [Authority.USER], + pageTitle: 'healthcareApp.visitService.home.title' + }, + canActivate: [UserRouteAccessService] + } +]; diff --git a/src/main/webapp/app/entities/visit-service/visit-service.service.ts b/src/main/webapp/app/entities/visit-service/visit-service.service.ts new file mode 100644 index 0000000..24ab37d --- /dev/null +++ b/src/main/webapp/app/entities/visit-service/visit-service.service.ts @@ -0,0 +1,38 @@ +import { Injectable } from '@angular/core'; +import { HttpClient, HttpResponse } from '@angular/common/http'; +import { Observable } from 'rxjs'; + +import { SERVER_API_URL } from 'app/app.constants'; +import { createRequestOption } from 'app/shared/util/request-util'; +import { IVisitService } from 'app/shared/model/visit-service.model'; + +type EntityResponseType = HttpResponse; +type EntityArrayResponseType = HttpResponse; + +@Injectable({ providedIn: 'root' }) +export class VisitServiceService { + public resourceUrl = SERVER_API_URL + 'api/visit-services'; + + constructor(protected http: HttpClient) {} + + create(visitService: IVisitService): Observable { + return this.http.post(this.resourceUrl, visitService, { observe: 'response' }); + } + + update(visitService: IVisitService): Observable { + return this.http.put(this.resourceUrl, visitService, { observe: 'response' }); + } + + find(id: number): Observable { + return this.http.get(`${this.resourceUrl}/${id}`, { observe: 'response' }); + } + + query(req?: any): Observable { + const options = createRequestOption(req); + return this.http.get(this.resourceUrl, { params: options, observe: 'response' }); + } + + delete(id: number): Observable> { + return this.http.delete(`${this.resourceUrl}/${id}`, { observe: 'response' }); + } +} diff --git a/src/main/webapp/app/entities/visit/visit-delete-dialog.component.html b/src/main/webapp/app/entities/visit/visit-delete-dialog.component.html new file mode 100644 index 0000000..6ae7dc1 --- /dev/null +++ b/src/main/webapp/app/entities/visit/visit-delete-dialog.component.html @@ -0,0 +1,24 @@ +
+ + + + + +
diff --git a/src/main/webapp/app/entities/visit/visit-delete-dialog.component.ts b/src/main/webapp/app/entities/visit/visit-delete-dialog.component.ts new file mode 100644 index 0000000..66c02d6 --- /dev/null +++ b/src/main/webapp/app/entities/visit/visit-delete-dialog.component.ts @@ -0,0 +1,26 @@ +import { Component } from '@angular/core'; +import { NgbActiveModal } from '@ng-bootstrap/ng-bootstrap'; +import { JhiEventManager } from 'ng-jhipster'; + +import { IVisit } from 'app/shared/model/visit.model'; +import { VisitService } from './visit.service'; + +@Component({ + templateUrl: './visit-delete-dialog.component.html' +}) +export class VisitDeleteDialogComponent { + visit?: IVisit; + + constructor(protected visitService: VisitService, public activeModal: NgbActiveModal, protected eventManager: JhiEventManager) {} + + cancel(): void { + this.activeModal.dismiss(); + } + + confirmDelete(id: number): void { + this.visitService.delete(id).subscribe(() => { + this.eventManager.broadcast('visitListModification'); + this.activeModal.close(); + }); + } +} diff --git a/src/main/webapp/app/entities/visit/visit-detail.component.html b/src/main/webapp/app/entities/visit/visit-detail.component.html new file mode 100644 index 0000000..7f0f82f --- /dev/null +++ b/src/main/webapp/app/entities/visit/visit-detail.component.html @@ -0,0 +1,58 @@ +
+
+
+

Visit {{ visit.id }}

+ +
+ + + +
+
Date
+
+ {{ visit.date }} +
+
Type
+
+ {{ visit.type }} +
+
Patient
+
+ +
+
Doctor
+
+ +
+
Department
+
+ +
+
Visit Service
+
+ + {{ visitService.name }}{{ last ? '' : ', ' }} + +
+
+ + + + +
+
+
diff --git a/src/main/webapp/app/entities/visit/visit-detail.component.ts b/src/main/webapp/app/entities/visit/visit-detail.component.ts new file mode 100644 index 0000000..ebe7689 --- /dev/null +++ b/src/main/webapp/app/entities/visit/visit-detail.component.ts @@ -0,0 +1,22 @@ +import { Component, OnInit } from '@angular/core'; +import { ActivatedRoute } from '@angular/router'; + +import { IVisit } from 'app/shared/model/visit.model'; + +@Component({ + selector: 'jhi-visit-detail', + templateUrl: './visit-detail.component.html' +}) +export class VisitDetailComponent implements OnInit { + visit: IVisit | null = null; + + constructor(protected activatedRoute: ActivatedRoute) {} + + ngOnInit(): void { + this.activatedRoute.data.subscribe(({ visit }) => (this.visit = visit)); + } + + previousState(): void { + window.history.back(); + } +} diff --git a/src/main/webapp/app/entities/visit/visit-update.component.html b/src/main/webapp/app/entities/visit/visit-update.component.html new file mode 100644 index 0000000..a40838f --- /dev/null +++ b/src/main/webapp/app/entities/visit/visit-update.component.html @@ -0,0 +1,72 @@ +
+
+
+

Create or edit a Visit

+ +
+ + +
+ + +
+ +
+ +
+ +
+
+ +
+ + +
+ +
+ + +
+ +
+ + +
+ +
+ + +
+ +
+ + +
+
+ +
+ + + +
+
+
+
diff --git a/src/main/webapp/app/entities/visit/visit-update.component.ts b/src/main/webapp/app/entities/visit/visit-update.component.ts new file mode 100644 index 0000000..cd8c7a5 --- /dev/null +++ b/src/main/webapp/app/entities/visit/visit-update.component.ts @@ -0,0 +1,142 @@ +import { Component, OnInit } from '@angular/core'; +import { HttpResponse } from '@angular/common/http'; +// eslint-disable-next-line @typescript-eslint/no-unused-vars +import { FormBuilder, Validators } from '@angular/forms'; +import { ActivatedRoute } from '@angular/router'; +import { Observable } from 'rxjs'; +import * as moment from 'moment'; +import { DATE_TIME_FORMAT } from 'app/shared/constants/input.constants'; + +import { IVisit, Visit } from 'app/shared/model/visit.model'; +import { VisitService } from './visit.service'; +import { IPatient } from 'app/shared/model/patient.model'; +import { PatientService } from 'app/entities/patient/patient.service'; +import { IDoctor } from 'app/shared/model/doctor.model'; +import { DoctorService } from 'app/entities/doctor/doctor.service'; +import { IDepartment } from 'app/shared/model/department.model'; +import { DepartmentService } from 'app/entities/department/department.service'; +import { IVisitService } from 'app/shared/model/visit-service.model'; +import { VisitServiceService } from 'app/entities/visit-service/visit-service.service'; + +type SelectableEntity = IPatient | IDoctor | IDepartment | IVisitService; + +@Component({ + selector: 'jhi-visit-update', + templateUrl: './visit-update.component.html' +}) +export class VisitUpdateComponent implements OnInit { + isSaving = false; + patients: IPatient[] = []; + doctors: IDoctor[] = []; + departments: IDepartment[] = []; + visitservices: IVisitService[] = []; + + editForm = this.fb.group({ + id: [], + date: [], + type: [], + patientId: [], + doctorId: [], + departmentId: [], + visitServices: [] + }); + + constructor( + protected visitService: VisitService, + protected patientService: PatientService, + protected doctorService: DoctorService, + protected departmentService: DepartmentService, + protected visitServiceService: VisitServiceService, + protected activatedRoute: ActivatedRoute, + private fb: FormBuilder + ) {} + + ngOnInit(): void { + this.activatedRoute.data.subscribe(({ visit }) => { + if (!visit.id) { + const today = moment().startOf('day'); + visit.date = today; + } + + this.updateForm(visit); + + this.patientService.query().subscribe((res: HttpResponse) => (this.patients = res.body || [])); + + this.doctorService.query().subscribe((res: HttpResponse) => (this.doctors = res.body || [])); + + this.departmentService.query().subscribe((res: HttpResponse) => (this.departments = res.body || [])); + + this.visitServiceService.query().subscribe((res: HttpResponse) => (this.visitservices = res.body || [])); + }); + } + + updateForm(visit: IVisit): void { + this.editForm.patchValue({ + id: visit.id, + date: visit.date ? visit.date.format(DATE_TIME_FORMAT) : null, + type: visit.type, + patientId: visit.patientId, + doctorId: visit.doctorId, + departmentId: visit.departmentId, + visitServices: visit.visitServices + }); + } + + previousState(): void { + window.history.back(); + } + + save(): void { + this.isSaving = true; + const visit = this.createFromForm(); + if (visit.id !== undefined) { + this.subscribeToSaveResponse(this.visitService.update(visit)); + } else { + this.subscribeToSaveResponse(this.visitService.create(visit)); + } + } + + private createFromForm(): IVisit { + return { + ...new Visit(), + id: this.editForm.get(['id'])!.value, + date: this.editForm.get(['date'])!.value ? moment(this.editForm.get(['date'])!.value, DATE_TIME_FORMAT) : undefined, + type: this.editForm.get(['type'])!.value, + patientId: this.editForm.get(['patientId'])!.value, + doctorId: this.editForm.get(['doctorId'])!.value, + departmentId: this.editForm.get(['departmentId'])!.value, + visitServices: this.editForm.get(['visitServices'])!.value + }; + } + + protected subscribeToSaveResponse(result: Observable>): void { + result.subscribe( + () => this.onSaveSuccess(), + () => this.onSaveError() + ); + } + + protected onSaveSuccess(): void { + this.isSaving = false; + this.previousState(); + } + + protected onSaveError(): void { + this.isSaving = false; + } + + trackById(index: number, item: SelectableEntity): any { + return item.id; + } + + getSelected(selectedVals: IVisitService[], option: IVisitService): IVisitService { + if (selectedVals) { + for (let i = 0; i < selectedVals.length; i++) { + if (option.id === selectedVals[i].id) { + return selectedVals[i]; + } + } + } + return option; + } +} diff --git a/src/main/webapp/app/entities/visit/visit.component.html b/src/main/webapp/app/entities/visit/visit.component.html new file mode 100644 index 0000000..e59423d --- /dev/null +++ b/src/main/webapp/app/entities/visit/visit.component.html @@ -0,0 +1,91 @@ +
+

+ Visits + + +

+ + + + + +
+ No visits found +
+ +
+ + + + + + + + + + + + + + + + + + + + + + + +
ID Date Type Patient Doctor Department
{{ visit.id }}{{ visit.date | date:'medium' }}{{ visit.type }} + + + + + + +
+ + + + + +
+
+
+ +
+
+ +
+ +
+ +
+
+
diff --git a/src/main/webapp/app/entities/visit/visit.component.ts b/src/main/webapp/app/entities/visit/visit.component.ts new file mode 100644 index 0000000..564109b --- /dev/null +++ b/src/main/webapp/app/entities/visit/visit.component.ts @@ -0,0 +1,106 @@ +import { Component, OnInit, OnDestroy } from '@angular/core'; +import { HttpHeaders, HttpResponse } from '@angular/common/http'; +import { ActivatedRoute, Router } from '@angular/router'; +import { Subscription } from 'rxjs'; +import { JhiEventManager } from 'ng-jhipster'; +import { NgbModal } from '@ng-bootstrap/ng-bootstrap'; + +import { IVisit } from 'app/shared/model/visit.model'; + +import { ITEMS_PER_PAGE } from 'app/shared/constants/pagination.constants'; +import { VisitService } from './visit.service'; +import { VisitDeleteDialogComponent } from './visit-delete-dialog.component'; + +@Component({ + selector: 'jhi-visit', + templateUrl: './visit.component.html' +}) +export class VisitComponent implements OnInit, OnDestroy { + visits?: IVisit[]; + eventSubscriber?: Subscription; + totalItems = 0; + itemsPerPage = ITEMS_PER_PAGE; + page!: number; + predicate!: string; + ascending!: boolean; + ngbPaginationPage = 1; + + constructor( + protected visitService: VisitService, + protected activatedRoute: ActivatedRoute, + protected router: Router, + protected eventManager: JhiEventManager, + protected modalService: NgbModal + ) {} + + loadPage(page?: number): void { + const pageToLoad: number = page || this.page; + + this.visitService + .query({ + page: pageToLoad - 1, + size: this.itemsPerPage, + sort: this.sort() + }) + .subscribe( + (res: HttpResponse) => this.onSuccess(res.body, res.headers, pageToLoad), + () => this.onError() + ); + } + + ngOnInit(): void { + this.activatedRoute.data.subscribe(data => { + this.page = data.pagingParams.page; + this.ascending = data.pagingParams.ascending; + this.predicate = data.pagingParams.predicate; + this.ngbPaginationPage = data.pagingParams.page; + this.loadPage(); + }); + this.registerChangeInVisits(); + } + + ngOnDestroy(): void { + if (this.eventSubscriber) { + this.eventManager.destroy(this.eventSubscriber); + } + } + + trackId(index: number, item: IVisit): number { + // eslint-disable-next-line @typescript-eslint/no-unnecessary-type-assertion + return item.id!; + } + + registerChangeInVisits(): void { + this.eventSubscriber = this.eventManager.subscribe('visitListModification', () => this.loadPage()); + } + + delete(visit: IVisit): void { + const modalRef = this.modalService.open(VisitDeleteDialogComponent, { size: 'lg', backdrop: 'static' }); + modalRef.componentInstance.visit = visit; + } + + sort(): string[] { + const result = [this.predicate + ',' + (this.ascending ? 'asc' : 'desc')]; + if (this.predicate !== 'id') { + result.push('id'); + } + return result; + } + + protected onSuccess(data: IVisit[] | null, headers: HttpHeaders, page: number): void { + this.totalItems = Number(headers.get('X-Total-Count')); + this.page = page; + this.router.navigate(['/visit'], { + queryParams: { + page: this.page, + size: this.itemsPerPage, + sort: this.predicate + ',' + (this.ascending ? 'asc' : 'desc') + } + }); + this.visits = data || []; + } + + protected onError(): void { + this.ngbPaginationPage = this.page; + } +} diff --git a/src/main/webapp/app/entities/visit/visit.module.ts b/src/main/webapp/app/entities/visit/visit.module.ts new file mode 100644 index 0000000..23a8636 --- /dev/null +++ b/src/main/webapp/app/entities/visit/visit.module.ts @@ -0,0 +1,16 @@ +import { NgModule } from '@angular/core'; +import { RouterModule } from '@angular/router'; + +import { HealthcareSharedModule } from 'app/shared/shared.module'; +import { VisitComponent } from './visit.component'; +import { VisitDetailComponent } from './visit-detail.component'; +import { VisitUpdateComponent } from './visit-update.component'; +import { VisitDeleteDialogComponent } from './visit-delete-dialog.component'; +import { visitRoute } from './visit.route'; + +@NgModule({ + imports: [HealthcareSharedModule, RouterModule.forChild(visitRoute)], + declarations: [VisitComponent, VisitDetailComponent, VisitUpdateComponent, VisitDeleteDialogComponent], + entryComponents: [VisitDeleteDialogComponent] +}) +export class HealthcareVisitModule {} diff --git a/src/main/webapp/app/entities/visit/visit.route.ts b/src/main/webapp/app/entities/visit/visit.route.ts new file mode 100644 index 0000000..5299a91 --- /dev/null +++ b/src/main/webapp/app/entities/visit/visit.route.ts @@ -0,0 +1,88 @@ +import { Injectable } from '@angular/core'; +import { HttpResponse } from '@angular/common/http'; +import { Resolve, ActivatedRouteSnapshot, Routes, Router } from '@angular/router'; +import { JhiResolvePagingParams } from 'ng-jhipster'; +import { Observable, of, EMPTY } from 'rxjs'; +import { flatMap } from 'rxjs/operators'; + +import { Authority } from 'app/shared/constants/authority.constants'; +import { UserRouteAccessService } from 'app/core/auth/user-route-access-service'; +import { IVisit, Visit } from 'app/shared/model/visit.model'; +import { VisitService } from './visit.service'; +import { VisitComponent } from './visit.component'; +import { VisitDetailComponent } from './visit-detail.component'; +import { VisitUpdateComponent } from './visit-update.component'; + +@Injectable({ providedIn: 'root' }) +export class VisitResolve implements Resolve { + constructor(private service: VisitService, private router: Router) {} + + resolve(route: ActivatedRouteSnapshot): Observable | Observable { + const id = route.params['id']; + if (id) { + return this.service.find(id).pipe( + flatMap((visit: HttpResponse) => { + if (visit.body) { + return of(visit.body); + } else { + this.router.navigate(['404']); + return EMPTY; + } + }) + ); + } + return of(new Visit()); + } +} + +export const visitRoute: Routes = [ + { + path: '', + component: VisitComponent, + resolve: { + pagingParams: JhiResolvePagingParams + }, + data: { + authorities: [Authority.USER], + defaultSort: 'id,asc', + pageTitle: 'healthcareApp.visit.home.title' + }, + canActivate: [UserRouteAccessService] + }, + { + path: ':id/view', + component: VisitDetailComponent, + resolve: { + visit: VisitResolve + }, + data: { + authorities: [Authority.USER], + pageTitle: 'healthcareApp.visit.home.title' + }, + canActivate: [UserRouteAccessService] + }, + { + path: 'new', + component: VisitUpdateComponent, + resolve: { + visit: VisitResolve + }, + data: { + authorities: [Authority.USER], + pageTitle: 'healthcareApp.visit.home.title' + }, + canActivate: [UserRouteAccessService] + }, + { + path: ':id/edit', + component: VisitUpdateComponent, + resolve: { + visit: VisitResolve + }, + data: { + authorities: [Authority.USER], + pageTitle: 'healthcareApp.visit.home.title' + }, + canActivate: [UserRouteAccessService] + } +]; diff --git a/src/main/webapp/app/entities/visit/visit.service.ts b/src/main/webapp/app/entities/visit/visit.service.ts new file mode 100644 index 0000000..38ffb67 --- /dev/null +++ b/src/main/webapp/app/entities/visit/visit.service.ts @@ -0,0 +1,73 @@ +import { Injectable } from '@angular/core'; +import { HttpClient, HttpResponse } from '@angular/common/http'; +import { Observable } from 'rxjs'; +import { map } from 'rxjs/operators'; +import * as moment from 'moment'; + +import { SERVER_API_URL } from 'app/app.constants'; +import { createRequestOption } from 'app/shared/util/request-util'; +import { IVisit } from 'app/shared/model/visit.model'; + +type EntityResponseType = HttpResponse; +type EntityArrayResponseType = HttpResponse; + +@Injectable({ providedIn: 'root' }) +export class VisitService { + public resourceUrl = SERVER_API_URL + 'api/visits'; + + constructor(protected http: HttpClient) {} + + create(visit: IVisit): Observable { + const copy = this.convertDateFromClient(visit); + return this.http + .post(this.resourceUrl, copy, { observe: 'response' }) + .pipe(map((res: EntityResponseType) => this.convertDateFromServer(res))); + } + + update(visit: IVisit): Observable { + const copy = this.convertDateFromClient(visit); + return this.http + .put(this.resourceUrl, copy, { observe: 'response' }) + .pipe(map((res: EntityResponseType) => this.convertDateFromServer(res))); + } + + find(id: number): Observable { + return this.http + .get(`${this.resourceUrl}/${id}`, { observe: 'response' }) + .pipe(map((res: EntityResponseType) => this.convertDateFromServer(res))); + } + + query(req?: any): Observable { + const options = createRequestOption(req); + return this.http + .get(this.resourceUrl, { params: options, observe: 'response' }) + .pipe(map((res: EntityArrayResponseType) => this.convertDateArrayFromServer(res))); + } + + delete(id: number): Observable> { + return this.http.delete(`${this.resourceUrl}/${id}`, { observe: 'response' }); + } + + protected convertDateFromClient(visit: IVisit): IVisit { + const copy: IVisit = Object.assign({}, visit, { + date: visit.date && visit.date.isValid() ? visit.date.toJSON() : undefined + }); + return copy; + } + + protected convertDateFromServer(res: EntityResponseType): EntityResponseType { + if (res.body) { + res.body.date = res.body.date ? moment(res.body.date) : undefined; + } + return res; + } + + protected convertDateArrayFromServer(res: EntityArrayResponseType): EntityArrayResponseType { + if (res.body) { + res.body.forEach((visit: IVisit) => { + visit.date = visit.date ? moment(visit.date) : undefined; + }); + } + return res; + } +} diff --git a/src/main/webapp/app/layouts/navbar/navbar.component.html b/src/main/webapp/app/layouts/navbar/navbar.component.html index 9557487..55e0b62 100644 --- a/src/main/webapp/app/layouts/navbar/navbar.component.html +++ b/src/main/webapp/app/layouts/navbar/navbar.component.html @@ -27,6 +27,36 @@ diff --git a/src/main/webapp/app/shared/model/department.model.ts b/src/main/webapp/app/shared/model/department.model.ts new file mode 100644 index 0000000..bdf7204 --- /dev/null +++ b/src/main/webapp/app/shared/model/department.model.ts @@ -0,0 +1,24 @@ +import { IDoctor } from 'app/shared/model/doctor.model'; +import { DepartmentType } from 'app/shared/model/enumerations/department-type.model'; + +export interface IDepartment { + id?: number; + name?: string; + type?: DepartmentType; + description?: string; + active?: boolean; + doctors?: IDoctor[]; +} + +export class Department implements IDepartment { + constructor( + public id?: number, + public name?: string, + public type?: DepartmentType, + public description?: string, + public active?: boolean, + public doctors?: IDoctor[] + ) { + this.active = this.active || false; + } +} diff --git a/src/main/webapp/app/shared/model/doctor.model.ts b/src/main/webapp/app/shared/model/doctor.model.ts new file mode 100644 index 0000000..58bd49c --- /dev/null +++ b/src/main/webapp/app/shared/model/doctor.model.ts @@ -0,0 +1,19 @@ +import { IDepartment } from 'app/shared/model/department.model'; + +export interface IDoctor { + id?: number; + name?: string; + phone?: string; + salary?: number; + departments?: IDepartment[]; +} + +export class Doctor implements IDoctor { + constructor( + public id?: number, + public name?: string, + public phone?: string, + public salary?: number, + public departments?: IDepartment[] + ) {} +} diff --git a/src/main/webapp/app/shared/model/enumerations/department-type.model.ts b/src/main/webapp/app/shared/model/enumerations/department-type.model.ts new file mode 100644 index 0000000..b898b53 --- /dev/null +++ b/src/main/webapp/app/shared/model/enumerations/department-type.model.ts @@ -0,0 +1,4 @@ +export const enum DepartmentType { + SERVICE = 'SERVICE', + POLYCLINIC = 'POLYCLINIC' +} diff --git a/src/main/webapp/app/shared/model/enumerations/visit-type.model.ts b/src/main/webapp/app/shared/model/enumerations/visit-type.model.ts new file mode 100644 index 0000000..413f84b --- /dev/null +++ b/src/main/webapp/app/shared/model/enumerations/visit-type.model.ts @@ -0,0 +1,4 @@ +export const enum VisitType { + EXAMINATION = 'EXAMINATION', + ANALYSIS = 'ANALYSIS' +} diff --git a/src/main/webapp/app/shared/model/patient.model.ts b/src/main/webapp/app/shared/model/patient.model.ts new file mode 100644 index 0000000..f533190 --- /dev/null +++ b/src/main/webapp/app/shared/model/patient.model.ts @@ -0,0 +1,13 @@ +import { Moment } from 'moment'; + +export interface IPatient { + id?: number; + name?: string; + phone?: string; + birthDate?: Moment; + citizenNumber?: string; +} + +export class Patient implements IPatient { + constructor(public id?: number, public name?: string, public phone?: string, public birthDate?: Moment, public citizenNumber?: string) {} +} diff --git a/src/main/webapp/app/shared/model/visit-service.model.ts b/src/main/webapp/app/shared/model/visit-service.model.ts new file mode 100644 index 0000000..a7a4b5e --- /dev/null +++ b/src/main/webapp/app/shared/model/visit-service.model.ts @@ -0,0 +1,23 @@ +import { IVisit } from 'app/shared/model/visit.model'; + +export interface IVisitService { + id?: number; + name?: string; + description?: string; + active?: boolean; + price?: number; + visits?: IVisit[]; +} + +export class VisitService implements IVisitService { + constructor( + public id?: number, + public name?: string, + public description?: string, + public active?: boolean, + public price?: number, + public visits?: IVisit[] + ) { + this.active = this.active || false; + } +} diff --git a/src/main/webapp/app/shared/model/visit.model.ts b/src/main/webapp/app/shared/model/visit.model.ts new file mode 100644 index 0000000..4031f86 --- /dev/null +++ b/src/main/webapp/app/shared/model/visit.model.ts @@ -0,0 +1,31 @@ +import { Moment } from 'moment'; +import { IVisitService } from 'app/shared/model/visit-service.model'; +import { VisitType } from 'app/shared/model/enumerations/visit-type.model'; + +export interface IVisit { + id?: number; + date?: Moment; + type?: VisitType; + patientName?: string; + patientId?: number; + doctorName?: string; + doctorId?: number; + departmentName?: string; + departmentId?: number; + visitServices?: IVisitService[]; +} + +export class Visit implements IVisit { + constructor( + public id?: number, + public date?: Moment, + public type?: VisitType, + public patientName?: string, + public patientId?: number, + public doctorName?: string, + public doctorId?: number, + public departmentName?: string, + public departmentId?: number, + public visitServices?: IVisitService[] + ) {} +} diff --git a/src/main/webapp/i18n/en/department.json b/src/main/webapp/i18n/en/department.json new file mode 100644 index 0000000..1dc3c82 --- /dev/null +++ b/src/main/webapp/i18n/en/department.json @@ -0,0 +1,26 @@ +{ + "healthcareApp": { + "department": { + "home": { + "title": "Departments", + "createLabel": "Create a new Department", + "createOrEditLabel": "Create or edit a Department", + "notFound": "No Departments found" + }, + "created": "A new Department is created with identifier {{ param }}", + "updated": "A Department is updated with identifier {{ param }}", + "deleted": "A Department is deleted with identifier {{ param }}", + "delete": { + "question": "Are you sure you want to delete Department {{ id }}?" + }, + "detail": { + "title": "Department" + }, + "name": "Name", + "type": "Type", + "description": "Description", + "active": "Active", + "doctor": "Doctor" + } + } +} diff --git a/src/main/webapp/i18n/en/departmentType.json b/src/main/webapp/i18n/en/departmentType.json new file mode 100644 index 0000000..82d3d70 --- /dev/null +++ b/src/main/webapp/i18n/en/departmentType.json @@ -0,0 +1,9 @@ +{ + "healthcareApp": { + "DepartmentType": { + "null": "", + "SERVICE": "SERVICE", + "POLYCLINIC": "POLYCLINIC" + } + } +} diff --git a/src/main/webapp/i18n/en/doctor.json b/src/main/webapp/i18n/en/doctor.json new file mode 100644 index 0000000..06a7d5f --- /dev/null +++ b/src/main/webapp/i18n/en/doctor.json @@ -0,0 +1,25 @@ +{ + "healthcareApp": { + "doctor": { + "home": { + "title": "Doctors", + "createLabel": "Create a new Doctor", + "createOrEditLabel": "Create or edit a Doctor", + "notFound": "No Doctors found" + }, + "created": "A new Doctor is created with identifier {{ param }}", + "updated": "A Doctor is updated with identifier {{ param }}", + "deleted": "A Doctor is deleted with identifier {{ param }}", + "delete": { + "question": "Are you sure you want to delete Doctor {{ id }}?" + }, + "detail": { + "title": "Doctor" + }, + "name": "Name", + "phone": "Phone", + "salary": "Salary", + "department": "Department" + } + } +} diff --git a/src/main/webapp/i18n/en/global.json b/src/main/webapp/i18n/en/global.json index 73225da..04c954a 100644 --- a/src/main/webapp/i18n/en/global.json +++ b/src/main/webapp/i18n/en/global.json @@ -7,6 +7,11 @@ "jhipster-needle-menu-add-element": "JHipster will add additional menu entries here (do not translate!)", "entities": { "main": "Entities", + "patient": "Patient", + "department": "Department", + "doctor": "Doctor", + "visitService": "Visit Service", + "visit": "Visit", "jhipster-needle-menu-add-entry": "JHipster will add additional entities here (do not translate!)" }, "account": { diff --git a/src/main/webapp/i18n/en/patient.json b/src/main/webapp/i18n/en/patient.json new file mode 100644 index 0000000..0f26650 --- /dev/null +++ b/src/main/webapp/i18n/en/patient.json @@ -0,0 +1,25 @@ +{ + "healthcareApp": { + "patient": { + "home": { + "title": "Patients", + "createLabel": "Create a new Patient", + "createOrEditLabel": "Create or edit a Patient", + "notFound": "No Patients found" + }, + "created": "A new Patient is created with identifier {{ param }}", + "updated": "A Patient is updated with identifier {{ param }}", + "deleted": "A Patient is deleted with identifier {{ param }}", + "delete": { + "question": "Are you sure you want to delete Patient {{ id }}?" + }, + "detail": { + "title": "Patient" + }, + "name": "Name", + "phone": "Phone", + "birthDate": "Birth Date", + "citizenNumber": "Citizen Number" + } + } +} diff --git a/src/main/webapp/i18n/en/visit.json b/src/main/webapp/i18n/en/visit.json new file mode 100644 index 0000000..d9c18ec --- /dev/null +++ b/src/main/webapp/i18n/en/visit.json @@ -0,0 +1,27 @@ +{ + "healthcareApp": { + "visit": { + "home": { + "title": "Visits", + "createLabel": "Create a new Visit", + "createOrEditLabel": "Create or edit a Visit", + "notFound": "No Visits found" + }, + "created": "A new Visit is created with identifier {{ param }}", + "updated": "A Visit is updated with identifier {{ param }}", + "deleted": "A Visit is deleted with identifier {{ param }}", + "delete": { + "question": "Are you sure you want to delete Visit {{ id }}?" + }, + "detail": { + "title": "Visit" + }, + "date": "Date", + "type": "Type", + "patient": "Patient", + "doctor": "Doctor", + "department": "Department", + "visitService": "Visit Service" + } + } +} diff --git a/src/main/webapp/i18n/en/visitService.json b/src/main/webapp/i18n/en/visitService.json new file mode 100644 index 0000000..87eff4b --- /dev/null +++ b/src/main/webapp/i18n/en/visitService.json @@ -0,0 +1,26 @@ +{ + "healthcareApp": { + "visitService": { + "home": { + "title": "Visit Services", + "createLabel": "Create a new Visit Service", + "createOrEditLabel": "Create or edit a Visit Service", + "notFound": "No Visit Services found" + }, + "created": "A new Visit Service is created with identifier {{ param }}", + "updated": "A Visit Service is updated with identifier {{ param }}", + "deleted": "A Visit Service is deleted with identifier {{ param }}", + "delete": { + "question": "Are you sure you want to delete Visit Service {{ id }}?" + }, + "detail": { + "title": "Visit Service" + }, + "name": "Name", + "description": "Description", + "active": "Active", + "price": "Price", + "visit": "Visit" + } + } +} diff --git a/src/main/webapp/i18n/en/visitType.json b/src/main/webapp/i18n/en/visitType.json new file mode 100644 index 0000000..2c710f5 --- /dev/null +++ b/src/main/webapp/i18n/en/visitType.json @@ -0,0 +1,9 @@ +{ + "healthcareApp": { + "VisitType": { + "null": "", + "EXAMINATION": "EXAMINATION", + "ANALYSIS": "ANALYSIS" + } + } +} diff --git a/src/main/webapp/i18n/tr/department.json b/src/main/webapp/i18n/tr/department.json new file mode 100644 index 0000000..1dc3c82 --- /dev/null +++ b/src/main/webapp/i18n/tr/department.json @@ -0,0 +1,26 @@ +{ + "healthcareApp": { + "department": { + "home": { + "title": "Departments", + "createLabel": "Create a new Department", + "createOrEditLabel": "Create or edit a Department", + "notFound": "No Departments found" + }, + "created": "A new Department is created with identifier {{ param }}", + "updated": "A Department is updated with identifier {{ param }}", + "deleted": "A Department is deleted with identifier {{ param }}", + "delete": { + "question": "Are you sure you want to delete Department {{ id }}?" + }, + "detail": { + "title": "Department" + }, + "name": "Name", + "type": "Type", + "description": "Description", + "active": "Active", + "doctor": "Doctor" + } + } +} diff --git a/src/main/webapp/i18n/tr/departmentType.json b/src/main/webapp/i18n/tr/departmentType.json new file mode 100644 index 0000000..82d3d70 --- /dev/null +++ b/src/main/webapp/i18n/tr/departmentType.json @@ -0,0 +1,9 @@ +{ + "healthcareApp": { + "DepartmentType": { + "null": "", + "SERVICE": "SERVICE", + "POLYCLINIC": "POLYCLINIC" + } + } +} diff --git a/src/main/webapp/i18n/tr/doctor.json b/src/main/webapp/i18n/tr/doctor.json new file mode 100644 index 0000000..06a7d5f --- /dev/null +++ b/src/main/webapp/i18n/tr/doctor.json @@ -0,0 +1,25 @@ +{ + "healthcareApp": { + "doctor": { + "home": { + "title": "Doctors", + "createLabel": "Create a new Doctor", + "createOrEditLabel": "Create or edit a Doctor", + "notFound": "No Doctors found" + }, + "created": "A new Doctor is created with identifier {{ param }}", + "updated": "A Doctor is updated with identifier {{ param }}", + "deleted": "A Doctor is deleted with identifier {{ param }}", + "delete": { + "question": "Are you sure you want to delete Doctor {{ id }}?" + }, + "detail": { + "title": "Doctor" + }, + "name": "Name", + "phone": "Phone", + "salary": "Salary", + "department": "Department" + } + } +} diff --git a/src/main/webapp/i18n/tr/global.json b/src/main/webapp/i18n/tr/global.json index af657c8..80fe1fe 100644 --- a/src/main/webapp/i18n/tr/global.json +++ b/src/main/webapp/i18n/tr/global.json @@ -7,6 +7,11 @@ "jhipster-needle-menu-add-element": "JHipster will add additional menu entries here (do not translate!)", "entities": { "main": "Varlıklar", + "patient": "Patient", + "department": "Department", + "doctor": "Doctor", + "visitService": "Visit Service", + "visit": "Visit", "jhipster-needle-menu-add-entry": "JHipster will add additional entities here (do not translate!)" }, "account": { diff --git a/src/main/webapp/i18n/tr/patient.json b/src/main/webapp/i18n/tr/patient.json new file mode 100644 index 0000000..0f26650 --- /dev/null +++ b/src/main/webapp/i18n/tr/patient.json @@ -0,0 +1,25 @@ +{ + "healthcareApp": { + "patient": { + "home": { + "title": "Patients", + "createLabel": "Create a new Patient", + "createOrEditLabel": "Create or edit a Patient", + "notFound": "No Patients found" + }, + "created": "A new Patient is created with identifier {{ param }}", + "updated": "A Patient is updated with identifier {{ param }}", + "deleted": "A Patient is deleted with identifier {{ param }}", + "delete": { + "question": "Are you sure you want to delete Patient {{ id }}?" + }, + "detail": { + "title": "Patient" + }, + "name": "Name", + "phone": "Phone", + "birthDate": "Birth Date", + "citizenNumber": "Citizen Number" + } + } +} diff --git a/src/main/webapp/i18n/tr/visit.json b/src/main/webapp/i18n/tr/visit.json new file mode 100644 index 0000000..d9c18ec --- /dev/null +++ b/src/main/webapp/i18n/tr/visit.json @@ -0,0 +1,27 @@ +{ + "healthcareApp": { + "visit": { + "home": { + "title": "Visits", + "createLabel": "Create a new Visit", + "createOrEditLabel": "Create or edit a Visit", + "notFound": "No Visits found" + }, + "created": "A new Visit is created with identifier {{ param }}", + "updated": "A Visit is updated with identifier {{ param }}", + "deleted": "A Visit is deleted with identifier {{ param }}", + "delete": { + "question": "Are you sure you want to delete Visit {{ id }}?" + }, + "detail": { + "title": "Visit" + }, + "date": "Date", + "type": "Type", + "patient": "Patient", + "doctor": "Doctor", + "department": "Department", + "visitService": "Visit Service" + } + } +} diff --git a/src/main/webapp/i18n/tr/visitService.json b/src/main/webapp/i18n/tr/visitService.json new file mode 100644 index 0000000..87eff4b --- /dev/null +++ b/src/main/webapp/i18n/tr/visitService.json @@ -0,0 +1,26 @@ +{ + "healthcareApp": { + "visitService": { + "home": { + "title": "Visit Services", + "createLabel": "Create a new Visit Service", + "createOrEditLabel": "Create or edit a Visit Service", + "notFound": "No Visit Services found" + }, + "created": "A new Visit Service is created with identifier {{ param }}", + "updated": "A Visit Service is updated with identifier {{ param }}", + "deleted": "A Visit Service is deleted with identifier {{ param }}", + "delete": { + "question": "Are you sure you want to delete Visit Service {{ id }}?" + }, + "detail": { + "title": "Visit Service" + }, + "name": "Name", + "description": "Description", + "active": "Active", + "price": "Price", + "visit": "Visit" + } + } +} diff --git a/src/main/webapp/i18n/tr/visitType.json b/src/main/webapp/i18n/tr/visitType.json new file mode 100644 index 0000000..2c710f5 --- /dev/null +++ b/src/main/webapp/i18n/tr/visitType.json @@ -0,0 +1,9 @@ +{ + "healthcareApp": { + "VisitType": { + "null": "", + "EXAMINATION": "EXAMINATION", + "ANALYSIS": "ANALYSIS" + } + } +} diff --git a/src/test/java/tr/com/aurora/hbys/healthcare/domain/DepartmentTest.java b/src/test/java/tr/com/aurora/hbys/healthcare/domain/DepartmentTest.java new file mode 100644 index 0000000..9e2afb5 --- /dev/null +++ b/src/test/java/tr/com/aurora/hbys/healthcare/domain/DepartmentTest.java @@ -0,0 +1,22 @@ +package tr.com.aurora.hbys.healthcare.domain; + +import org.junit.jupiter.api.Test; +import static org.assertj.core.api.Assertions.assertThat; +import tr.com.aurora.hbys.healthcare.web.rest.TestUtil; + +public class DepartmentTest { + + @Test + public void equalsVerifier() throws Exception { + TestUtil.equalsVerifier(Department.class); + Department department1 = new Department(); + department1.setId(1L); + Department department2 = new Department(); + department2.setId(department1.getId()); + assertThat(department1).isEqualTo(department2); + department2.setId(2L); + assertThat(department1).isNotEqualTo(department2); + department1.setId(null); + assertThat(department1).isNotEqualTo(department2); + } +} diff --git a/src/test/java/tr/com/aurora/hbys/healthcare/domain/DoctorTest.java b/src/test/java/tr/com/aurora/hbys/healthcare/domain/DoctorTest.java new file mode 100644 index 0000000..812d683 --- /dev/null +++ b/src/test/java/tr/com/aurora/hbys/healthcare/domain/DoctorTest.java @@ -0,0 +1,22 @@ +package tr.com.aurora.hbys.healthcare.domain; + +import org.junit.jupiter.api.Test; +import static org.assertj.core.api.Assertions.assertThat; +import tr.com.aurora.hbys.healthcare.web.rest.TestUtil; + +public class DoctorTest { + + @Test + public void equalsVerifier() throws Exception { + TestUtil.equalsVerifier(Doctor.class); + Doctor doctor1 = new Doctor(); + doctor1.setId(1L); + Doctor doctor2 = new Doctor(); + doctor2.setId(doctor1.getId()); + assertThat(doctor1).isEqualTo(doctor2); + doctor2.setId(2L); + assertThat(doctor1).isNotEqualTo(doctor2); + doctor1.setId(null); + assertThat(doctor1).isNotEqualTo(doctor2); + } +} diff --git a/src/test/java/tr/com/aurora/hbys/healthcare/domain/PatientTest.java b/src/test/java/tr/com/aurora/hbys/healthcare/domain/PatientTest.java new file mode 100644 index 0000000..8aaed69 --- /dev/null +++ b/src/test/java/tr/com/aurora/hbys/healthcare/domain/PatientTest.java @@ -0,0 +1,22 @@ +package tr.com.aurora.hbys.healthcare.domain; + +import org.junit.jupiter.api.Test; +import static org.assertj.core.api.Assertions.assertThat; +import tr.com.aurora.hbys.healthcare.web.rest.TestUtil; + +public class PatientTest { + + @Test + public void equalsVerifier() throws Exception { + TestUtil.equalsVerifier(Patient.class); + Patient patient1 = new Patient(); + patient1.setId(1L); + Patient patient2 = new Patient(); + patient2.setId(patient1.getId()); + assertThat(patient1).isEqualTo(patient2); + patient2.setId(2L); + assertThat(patient1).isNotEqualTo(patient2); + patient1.setId(null); + assertThat(patient1).isNotEqualTo(patient2); + } +} diff --git a/src/test/java/tr/com/aurora/hbys/healthcare/domain/VisitServiceTest.java b/src/test/java/tr/com/aurora/hbys/healthcare/domain/VisitServiceTest.java new file mode 100644 index 0000000..d4fd1c2 --- /dev/null +++ b/src/test/java/tr/com/aurora/hbys/healthcare/domain/VisitServiceTest.java @@ -0,0 +1,22 @@ +package tr.com.aurora.hbys.healthcare.domain; + +import org.junit.jupiter.api.Test; +import static org.assertj.core.api.Assertions.assertThat; +import tr.com.aurora.hbys.healthcare.web.rest.TestUtil; + +public class VisitServiceTest { + + @Test + public void equalsVerifier() throws Exception { + TestUtil.equalsVerifier(VisitService.class); + VisitService visitService1 = new VisitService(); + visitService1.setId(1L); + VisitService visitService2 = new VisitService(); + visitService2.setId(visitService1.getId()); + assertThat(visitService1).isEqualTo(visitService2); + visitService2.setId(2L); + assertThat(visitService1).isNotEqualTo(visitService2); + visitService1.setId(null); + assertThat(visitService1).isNotEqualTo(visitService2); + } +} diff --git a/src/test/java/tr/com/aurora/hbys/healthcare/domain/VisitTest.java b/src/test/java/tr/com/aurora/hbys/healthcare/domain/VisitTest.java new file mode 100644 index 0000000..1460431 --- /dev/null +++ b/src/test/java/tr/com/aurora/hbys/healthcare/domain/VisitTest.java @@ -0,0 +1,22 @@ +package tr.com.aurora.hbys.healthcare.domain; + +import org.junit.jupiter.api.Test; +import static org.assertj.core.api.Assertions.assertThat; +import tr.com.aurora.hbys.healthcare.web.rest.TestUtil; + +public class VisitTest { + + @Test + public void equalsVerifier() throws Exception { + TestUtil.equalsVerifier(Visit.class); + Visit visit1 = new Visit(); + visit1.setId(1L); + Visit visit2 = new Visit(); + visit2.setId(visit1.getId()); + assertThat(visit1).isEqualTo(visit2); + visit2.setId(2L); + assertThat(visit1).isNotEqualTo(visit2); + visit1.setId(null); + assertThat(visit1).isNotEqualTo(visit2); + } +} diff --git a/src/test/java/tr/com/aurora/hbys/healthcare/service/dto/DepartmentDTOTest.java b/src/test/java/tr/com/aurora/hbys/healthcare/service/dto/DepartmentDTOTest.java new file mode 100644 index 0000000..f721ee9 --- /dev/null +++ b/src/test/java/tr/com/aurora/hbys/healthcare/service/dto/DepartmentDTOTest.java @@ -0,0 +1,23 @@ +package tr.com.aurora.hbys.healthcare.service.dto; + +import org.junit.jupiter.api.Test; +import static org.assertj.core.api.Assertions.assertThat; +import tr.com.aurora.hbys.healthcare.web.rest.TestUtil; + +public class DepartmentDTOTest { + + @Test + public void dtoEqualsVerifier() throws Exception { + TestUtil.equalsVerifier(DepartmentDTO.class); + DepartmentDTO departmentDTO1 = new DepartmentDTO(); + departmentDTO1.setId(1L); + DepartmentDTO departmentDTO2 = new DepartmentDTO(); + assertThat(departmentDTO1).isNotEqualTo(departmentDTO2); + departmentDTO2.setId(departmentDTO1.getId()); + assertThat(departmentDTO1).isEqualTo(departmentDTO2); + departmentDTO2.setId(2L); + assertThat(departmentDTO1).isNotEqualTo(departmentDTO2); + departmentDTO1.setId(null); + assertThat(departmentDTO1).isNotEqualTo(departmentDTO2); + } +} diff --git a/src/test/java/tr/com/aurora/hbys/healthcare/service/dto/DoctorDTOTest.java b/src/test/java/tr/com/aurora/hbys/healthcare/service/dto/DoctorDTOTest.java new file mode 100644 index 0000000..5a05ea2 --- /dev/null +++ b/src/test/java/tr/com/aurora/hbys/healthcare/service/dto/DoctorDTOTest.java @@ -0,0 +1,23 @@ +package tr.com.aurora.hbys.healthcare.service.dto; + +import org.junit.jupiter.api.Test; +import static org.assertj.core.api.Assertions.assertThat; +import tr.com.aurora.hbys.healthcare.web.rest.TestUtil; + +public class DoctorDTOTest { + + @Test + public void dtoEqualsVerifier() throws Exception { + TestUtil.equalsVerifier(DoctorDTO.class); + DoctorDTO doctorDTO1 = new DoctorDTO(); + doctorDTO1.setId(1L); + DoctorDTO doctorDTO2 = new DoctorDTO(); + assertThat(doctorDTO1).isNotEqualTo(doctorDTO2); + doctorDTO2.setId(doctorDTO1.getId()); + assertThat(doctorDTO1).isEqualTo(doctorDTO2); + doctorDTO2.setId(2L); + assertThat(doctorDTO1).isNotEqualTo(doctorDTO2); + doctorDTO1.setId(null); + assertThat(doctorDTO1).isNotEqualTo(doctorDTO2); + } +} diff --git a/src/test/java/tr/com/aurora/hbys/healthcare/service/dto/PatientDTOTest.java b/src/test/java/tr/com/aurora/hbys/healthcare/service/dto/PatientDTOTest.java new file mode 100644 index 0000000..e6f72e7 --- /dev/null +++ b/src/test/java/tr/com/aurora/hbys/healthcare/service/dto/PatientDTOTest.java @@ -0,0 +1,23 @@ +package tr.com.aurora.hbys.healthcare.service.dto; + +import org.junit.jupiter.api.Test; +import static org.assertj.core.api.Assertions.assertThat; +import tr.com.aurora.hbys.healthcare.web.rest.TestUtil; + +public class PatientDTOTest { + + @Test + public void dtoEqualsVerifier() throws Exception { + TestUtil.equalsVerifier(PatientDTO.class); + PatientDTO patientDTO1 = new PatientDTO(); + patientDTO1.setId(1L); + PatientDTO patientDTO2 = new PatientDTO(); + assertThat(patientDTO1).isNotEqualTo(patientDTO2); + patientDTO2.setId(patientDTO1.getId()); + assertThat(patientDTO1).isEqualTo(patientDTO2); + patientDTO2.setId(2L); + assertThat(patientDTO1).isNotEqualTo(patientDTO2); + patientDTO1.setId(null); + assertThat(patientDTO1).isNotEqualTo(patientDTO2); + } +} diff --git a/src/test/java/tr/com/aurora/hbys/healthcare/service/dto/VisitDTOTest.java b/src/test/java/tr/com/aurora/hbys/healthcare/service/dto/VisitDTOTest.java new file mode 100644 index 0000000..6e54c4f --- /dev/null +++ b/src/test/java/tr/com/aurora/hbys/healthcare/service/dto/VisitDTOTest.java @@ -0,0 +1,23 @@ +package tr.com.aurora.hbys.healthcare.service.dto; + +import org.junit.jupiter.api.Test; +import static org.assertj.core.api.Assertions.assertThat; +import tr.com.aurora.hbys.healthcare.web.rest.TestUtil; + +public class VisitDTOTest { + + @Test + public void dtoEqualsVerifier() throws Exception { + TestUtil.equalsVerifier(VisitDTO.class); + VisitDTO visitDTO1 = new VisitDTO(); + visitDTO1.setId(1L); + VisitDTO visitDTO2 = new VisitDTO(); + assertThat(visitDTO1).isNotEqualTo(visitDTO2); + visitDTO2.setId(visitDTO1.getId()); + assertThat(visitDTO1).isEqualTo(visitDTO2); + visitDTO2.setId(2L); + assertThat(visitDTO1).isNotEqualTo(visitDTO2); + visitDTO1.setId(null); + assertThat(visitDTO1).isNotEqualTo(visitDTO2); + } +} diff --git a/src/test/java/tr/com/aurora/hbys/healthcare/service/dto/VisitServiceDTOTest.java b/src/test/java/tr/com/aurora/hbys/healthcare/service/dto/VisitServiceDTOTest.java new file mode 100644 index 0000000..add80df --- /dev/null +++ b/src/test/java/tr/com/aurora/hbys/healthcare/service/dto/VisitServiceDTOTest.java @@ -0,0 +1,23 @@ +package tr.com.aurora.hbys.healthcare.service.dto; + +import org.junit.jupiter.api.Test; +import static org.assertj.core.api.Assertions.assertThat; +import tr.com.aurora.hbys.healthcare.web.rest.TestUtil; + +public class VisitServiceDTOTest { + + @Test + public void dtoEqualsVerifier() throws Exception { + TestUtil.equalsVerifier(VisitServiceDTO.class); + VisitServiceDTO visitServiceDTO1 = new VisitServiceDTO(); + visitServiceDTO1.setId(1L); + VisitServiceDTO visitServiceDTO2 = new VisitServiceDTO(); + assertThat(visitServiceDTO1).isNotEqualTo(visitServiceDTO2); + visitServiceDTO2.setId(visitServiceDTO1.getId()); + assertThat(visitServiceDTO1).isEqualTo(visitServiceDTO2); + visitServiceDTO2.setId(2L); + assertThat(visitServiceDTO1).isNotEqualTo(visitServiceDTO2); + visitServiceDTO1.setId(null); + assertThat(visitServiceDTO1).isNotEqualTo(visitServiceDTO2); + } +} diff --git a/src/test/java/tr/com/aurora/hbys/healthcare/service/mapper/DepartmentMapperTest.java b/src/test/java/tr/com/aurora/hbys/healthcare/service/mapper/DepartmentMapperTest.java new file mode 100644 index 0000000..eaf4631 --- /dev/null +++ b/src/test/java/tr/com/aurora/hbys/healthcare/service/mapper/DepartmentMapperTest.java @@ -0,0 +1,22 @@ +package tr.com.aurora.hbys.healthcare.service.mapper; + +import org.junit.jupiter.api.BeforeEach; +import org.junit.jupiter.api.Test; +import static org.assertj.core.api.Assertions.assertThat; + +public class DepartmentMapperTest { + + private DepartmentMapper departmentMapper; + + @BeforeEach + public void setUp() { + departmentMapper = new DepartmentMapperImpl(); + } + + @Test + public void testEntityFromId() { + Long id = 1L; + assertThat(departmentMapper.fromId(id).getId()).isEqualTo(id); + assertThat(departmentMapper.fromId(null)).isNull(); + } +} diff --git a/src/test/java/tr/com/aurora/hbys/healthcare/service/mapper/DoctorMapperTest.java b/src/test/java/tr/com/aurora/hbys/healthcare/service/mapper/DoctorMapperTest.java new file mode 100644 index 0000000..00bdcf4 --- /dev/null +++ b/src/test/java/tr/com/aurora/hbys/healthcare/service/mapper/DoctorMapperTest.java @@ -0,0 +1,22 @@ +package tr.com.aurora.hbys.healthcare.service.mapper; + +import org.junit.jupiter.api.BeforeEach; +import org.junit.jupiter.api.Test; +import static org.assertj.core.api.Assertions.assertThat; + +public class DoctorMapperTest { + + private DoctorMapper doctorMapper; + + @BeforeEach + public void setUp() { + doctorMapper = new DoctorMapperImpl(); + } + + @Test + public void testEntityFromId() { + Long id = 1L; + assertThat(doctorMapper.fromId(id).getId()).isEqualTo(id); + assertThat(doctorMapper.fromId(null)).isNull(); + } +} diff --git a/src/test/java/tr/com/aurora/hbys/healthcare/service/mapper/PatientMapperTest.java b/src/test/java/tr/com/aurora/hbys/healthcare/service/mapper/PatientMapperTest.java new file mode 100644 index 0000000..5ba0e87 --- /dev/null +++ b/src/test/java/tr/com/aurora/hbys/healthcare/service/mapper/PatientMapperTest.java @@ -0,0 +1,22 @@ +package tr.com.aurora.hbys.healthcare.service.mapper; + +import org.junit.jupiter.api.BeforeEach; +import org.junit.jupiter.api.Test; +import static org.assertj.core.api.Assertions.assertThat; + +public class PatientMapperTest { + + private PatientMapper patientMapper; + + @BeforeEach + public void setUp() { + patientMapper = new PatientMapperImpl(); + } + + @Test + public void testEntityFromId() { + Long id = 1L; + assertThat(patientMapper.fromId(id).getId()).isEqualTo(id); + assertThat(patientMapper.fromId(null)).isNull(); + } +} diff --git a/src/test/java/tr/com/aurora/hbys/healthcare/service/mapper/VisitMapperTest.java b/src/test/java/tr/com/aurora/hbys/healthcare/service/mapper/VisitMapperTest.java new file mode 100644 index 0000000..e94c5e5 --- /dev/null +++ b/src/test/java/tr/com/aurora/hbys/healthcare/service/mapper/VisitMapperTest.java @@ -0,0 +1,22 @@ +package tr.com.aurora.hbys.healthcare.service.mapper; + +import org.junit.jupiter.api.BeforeEach; +import org.junit.jupiter.api.Test; +import static org.assertj.core.api.Assertions.assertThat; + +public class VisitMapperTest { + + private VisitMapper visitMapper; + + @BeforeEach + public void setUp() { + visitMapper = new VisitMapperImpl(); + } + + @Test + public void testEntityFromId() { + Long id = 1L; + assertThat(visitMapper.fromId(id).getId()).isEqualTo(id); + assertThat(visitMapper.fromId(null)).isNull(); + } +} diff --git a/src/test/java/tr/com/aurora/hbys/healthcare/service/mapper/VisitServiceMapperTest.java b/src/test/java/tr/com/aurora/hbys/healthcare/service/mapper/VisitServiceMapperTest.java new file mode 100644 index 0000000..1a7fad8 --- /dev/null +++ b/src/test/java/tr/com/aurora/hbys/healthcare/service/mapper/VisitServiceMapperTest.java @@ -0,0 +1,22 @@ +package tr.com.aurora.hbys.healthcare.service.mapper; + +import org.junit.jupiter.api.BeforeEach; +import org.junit.jupiter.api.Test; +import static org.assertj.core.api.Assertions.assertThat; + +public class VisitServiceMapperTest { + + private VisitServiceMapper visitServiceMapper; + + @BeforeEach + public void setUp() { + visitServiceMapper = new VisitServiceMapperImpl(); + } + + @Test + public void testEntityFromId() { + Long id = 1L; + assertThat(visitServiceMapper.fromId(id).getId()).isEqualTo(id); + assertThat(visitServiceMapper.fromId(null)).isNull(); + } +} diff --git a/src/test/java/tr/com/aurora/hbys/healthcare/web/rest/DepartmentResourceIT.java b/src/test/java/tr/com/aurora/hbys/healthcare/web/rest/DepartmentResourceIT.java new file mode 100644 index 0000000..8c014a1 --- /dev/null +++ b/src/test/java/tr/com/aurora/hbys/healthcare/web/rest/DepartmentResourceIT.java @@ -0,0 +1,274 @@ +package tr.com.aurora.hbys.healthcare.web.rest; + +import tr.com.aurora.hbys.healthcare.HealthcareApp; +import tr.com.aurora.hbys.healthcare.domain.Department; +import tr.com.aurora.hbys.healthcare.repository.DepartmentRepository; +import tr.com.aurora.hbys.healthcare.service.DepartmentService; +import tr.com.aurora.hbys.healthcare.service.dto.DepartmentDTO; +import tr.com.aurora.hbys.healthcare.service.mapper.DepartmentMapper; + +import org.junit.jupiter.api.BeforeEach; +import org.junit.jupiter.api.Test; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.boot.test.autoconfigure.web.servlet.AutoConfigureMockMvc; +import org.springframework.boot.test.context.SpringBootTest; +import org.springframework.http.MediaType; +import org.springframework.security.test.context.support.WithMockUser; +import org.springframework.test.web.servlet.MockMvc; +import org.springframework.transaction.annotation.Transactional; +import javax.persistence.EntityManager; +import java.util.List; + +import static org.assertj.core.api.Assertions.assertThat; +import static org.hamcrest.Matchers.hasItem; +import static org.springframework.test.web.servlet.request.MockMvcRequestBuilders.*; +import static org.springframework.test.web.servlet.result.MockMvcResultMatchers.*; + +import tr.com.aurora.hbys.healthcare.domain.enumeration.DepartmentType; +/** + * Integration tests for the {@link DepartmentResource} REST controller. + */ +@SpringBootTest(classes = HealthcareApp.class) + +@AutoConfigureMockMvc +@WithMockUser +public class DepartmentResourceIT { + + private static final String DEFAULT_NAME = "AAAAAAAAAA"; + private static final String UPDATED_NAME = "BBBBBBBBBB"; + + private static final DepartmentType DEFAULT_TYPE = DepartmentType.SERVICE; + private static final DepartmentType UPDATED_TYPE = DepartmentType.POLYCLINIC; + + private static final String DEFAULT_DESCRIPTION = "AAAAAAAAAA"; + private static final String UPDATED_DESCRIPTION = "BBBBBBBBBB"; + + private static final Boolean DEFAULT_ACTIVE = false; + private static final Boolean UPDATED_ACTIVE = true; + + @Autowired + private DepartmentRepository departmentRepository; + + @Autowired + private DepartmentMapper departmentMapper; + + @Autowired + private DepartmentService departmentService; + + @Autowired + private EntityManager em; + + @Autowired + private MockMvc restDepartmentMockMvc; + + private Department department; + + /** + * Create an entity for this test. + * + * This is a static method, as tests for other entities might also need it, + * if they test an entity which requires the current entity. + */ + public static Department createEntity(EntityManager em) { + Department department = new Department() + .name(DEFAULT_NAME) + .type(DEFAULT_TYPE) + .description(DEFAULT_DESCRIPTION) + .active(DEFAULT_ACTIVE); + return department; + } + /** + * Create an updated entity for this test. + * + * This is a static method, as tests for other entities might also need it, + * if they test an entity which requires the current entity. + */ + public static Department createUpdatedEntity(EntityManager em) { + Department department = new Department() + .name(UPDATED_NAME) + .type(UPDATED_TYPE) + .description(UPDATED_DESCRIPTION) + .active(UPDATED_ACTIVE); + return department; + } + + @BeforeEach + public void initTest() { + department = createEntity(em); + } + + @Test + @Transactional + public void createDepartment() throws Exception { + int databaseSizeBeforeCreate = departmentRepository.findAll().size(); + + // Create the Department + DepartmentDTO departmentDTO = departmentMapper.toDto(department); + restDepartmentMockMvc.perform(post("/api/departments") + .contentType(MediaType.APPLICATION_JSON) + .content(TestUtil.convertObjectToJsonBytes(departmentDTO))) + .andExpect(status().isCreated()); + + // Validate the Department in the database + List departmentList = departmentRepository.findAll(); + assertThat(departmentList).hasSize(databaseSizeBeforeCreate + 1); + Department testDepartment = departmentList.get(departmentList.size() - 1); + assertThat(testDepartment.getName()).isEqualTo(DEFAULT_NAME); + assertThat(testDepartment.getType()).isEqualTo(DEFAULT_TYPE); + assertThat(testDepartment.getDescription()).isEqualTo(DEFAULT_DESCRIPTION); + assertThat(testDepartment.isActive()).isEqualTo(DEFAULT_ACTIVE); + } + + @Test + @Transactional + public void createDepartmentWithExistingId() throws Exception { + int databaseSizeBeforeCreate = departmentRepository.findAll().size(); + + // Create the Department with an existing ID + department.setId(1L); + DepartmentDTO departmentDTO = departmentMapper.toDto(department); + + // An entity with an existing ID cannot be created, so this API call must fail + restDepartmentMockMvc.perform(post("/api/departments") + .contentType(MediaType.APPLICATION_JSON) + .content(TestUtil.convertObjectToJsonBytes(departmentDTO))) + .andExpect(status().isBadRequest()); + + // Validate the Department in the database + List departmentList = departmentRepository.findAll(); + assertThat(departmentList).hasSize(databaseSizeBeforeCreate); + } + + + @Test + @Transactional + public void checkNameIsRequired() throws Exception { + int databaseSizeBeforeTest = departmentRepository.findAll().size(); + // set the field null + department.setName(null); + + // Create the Department, which fails. + DepartmentDTO departmentDTO = departmentMapper.toDto(department); + + restDepartmentMockMvc.perform(post("/api/departments") + .contentType(MediaType.APPLICATION_JSON) + .content(TestUtil.convertObjectToJsonBytes(departmentDTO))) + .andExpect(status().isBadRequest()); + + List departmentList = departmentRepository.findAll(); + assertThat(departmentList).hasSize(databaseSizeBeforeTest); + } + + @Test + @Transactional + public void getAllDepartments() throws Exception { + // Initialize the database + departmentRepository.saveAndFlush(department); + + // Get all the departmentList + restDepartmentMockMvc.perform(get("/api/departments?sort=id,desc")) + .andExpect(status().isOk()) + .andExpect(content().contentType(MediaType.APPLICATION_JSON_VALUE)) + .andExpect(jsonPath("$.[*].id").value(hasItem(department.getId().intValue()))) + .andExpect(jsonPath("$.[*].name").value(hasItem(DEFAULT_NAME))) + .andExpect(jsonPath("$.[*].type").value(hasItem(DEFAULT_TYPE.toString()))) + .andExpect(jsonPath("$.[*].description").value(hasItem(DEFAULT_DESCRIPTION))) + .andExpect(jsonPath("$.[*].active").value(hasItem(DEFAULT_ACTIVE.booleanValue()))); + } + + @Test + @Transactional + public void getDepartment() throws Exception { + // Initialize the database + departmentRepository.saveAndFlush(department); + + // Get the department + restDepartmentMockMvc.perform(get("/api/departments/{id}", department.getId())) + .andExpect(status().isOk()) + .andExpect(content().contentType(MediaType.APPLICATION_JSON_VALUE)) + .andExpect(jsonPath("$.id").value(department.getId().intValue())) + .andExpect(jsonPath("$.name").value(DEFAULT_NAME)) + .andExpect(jsonPath("$.type").value(DEFAULT_TYPE.toString())) + .andExpect(jsonPath("$.description").value(DEFAULT_DESCRIPTION)) + .andExpect(jsonPath("$.active").value(DEFAULT_ACTIVE.booleanValue())); + } + + @Test + @Transactional + public void getNonExistingDepartment() throws Exception { + // Get the department + restDepartmentMockMvc.perform(get("/api/departments/{id}", Long.MAX_VALUE)) + .andExpect(status().isNotFound()); + } + + @Test + @Transactional + public void updateDepartment() throws Exception { + // Initialize the database + departmentRepository.saveAndFlush(department); + + int databaseSizeBeforeUpdate = departmentRepository.findAll().size(); + + // Update the department + Department updatedDepartment = departmentRepository.findById(department.getId()).get(); + // Disconnect from session so that the updates on updatedDepartment are not directly saved in db + em.detach(updatedDepartment); + updatedDepartment + .name(UPDATED_NAME) + .type(UPDATED_TYPE) + .description(UPDATED_DESCRIPTION) + .active(UPDATED_ACTIVE); + DepartmentDTO departmentDTO = departmentMapper.toDto(updatedDepartment); + + restDepartmentMockMvc.perform(put("/api/departments") + .contentType(MediaType.APPLICATION_JSON) + .content(TestUtil.convertObjectToJsonBytes(departmentDTO))) + .andExpect(status().isOk()); + + // Validate the Department in the database + List departmentList = departmentRepository.findAll(); + assertThat(departmentList).hasSize(databaseSizeBeforeUpdate); + Department testDepartment = departmentList.get(departmentList.size() - 1); + assertThat(testDepartment.getName()).isEqualTo(UPDATED_NAME); + assertThat(testDepartment.getType()).isEqualTo(UPDATED_TYPE); + assertThat(testDepartment.getDescription()).isEqualTo(UPDATED_DESCRIPTION); + assertThat(testDepartment.isActive()).isEqualTo(UPDATED_ACTIVE); + } + + @Test + @Transactional + public void updateNonExistingDepartment() throws Exception { + int databaseSizeBeforeUpdate = departmentRepository.findAll().size(); + + // Create the Department + DepartmentDTO departmentDTO = departmentMapper.toDto(department); + + // If the entity doesn't have an ID, it will throw BadRequestAlertException + restDepartmentMockMvc.perform(put("/api/departments") + .contentType(MediaType.APPLICATION_JSON) + .content(TestUtil.convertObjectToJsonBytes(departmentDTO))) + .andExpect(status().isBadRequest()); + + // Validate the Department in the database + List departmentList = departmentRepository.findAll(); + assertThat(departmentList).hasSize(databaseSizeBeforeUpdate); + } + + @Test + @Transactional + public void deleteDepartment() throws Exception { + // Initialize the database + departmentRepository.saveAndFlush(department); + + int databaseSizeBeforeDelete = departmentRepository.findAll().size(); + + // Delete the department + restDepartmentMockMvc.perform(delete("/api/departments/{id}", department.getId()) + .accept(MediaType.APPLICATION_JSON)) + .andExpect(status().isNoContent()); + + // Validate the database contains one less item + List departmentList = departmentRepository.findAll(); + assertThat(departmentList).hasSize(databaseSizeBeforeDelete - 1); + } +} diff --git a/src/test/java/tr/com/aurora/hbys/healthcare/web/rest/DoctorResourceIT.java b/src/test/java/tr/com/aurora/hbys/healthcare/web/rest/DoctorResourceIT.java new file mode 100644 index 0000000..9a9d09d --- /dev/null +++ b/src/test/java/tr/com/aurora/hbys/healthcare/web/rest/DoctorResourceIT.java @@ -0,0 +1,296 @@ +package tr.com.aurora.hbys.healthcare.web.rest; + +import tr.com.aurora.hbys.healthcare.HealthcareApp; +import tr.com.aurora.hbys.healthcare.domain.Doctor; +import tr.com.aurora.hbys.healthcare.repository.DoctorRepository; +import tr.com.aurora.hbys.healthcare.service.DoctorService; +import tr.com.aurora.hbys.healthcare.service.dto.DoctorDTO; +import tr.com.aurora.hbys.healthcare.service.mapper.DoctorMapper; + +import org.junit.jupiter.api.BeforeEach; +import org.junit.jupiter.api.Test; +import org.mockito.Mock; +import org.junit.jupiter.api.extension.ExtendWith; +import org.mockito.junit.jupiter.MockitoExtension; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.boot.test.autoconfigure.web.servlet.AutoConfigureMockMvc; +import org.springframework.boot.test.context.SpringBootTest; +import org.springframework.data.domain.PageImpl; +import org.springframework.data.domain.PageRequest; +import org.springframework.http.MediaType; +import org.springframework.security.test.context.support.WithMockUser; +import org.springframework.test.web.servlet.MockMvc; +import org.springframework.transaction.annotation.Transactional; +import javax.persistence.EntityManager; +import java.util.ArrayList; +import java.util.List; + +import static org.assertj.core.api.Assertions.assertThat; +import static org.hamcrest.Matchers.hasItem; +import static org.mockito.Mockito.*; +import static org.springframework.test.web.servlet.request.MockMvcRequestBuilders.*; +import static org.springframework.test.web.servlet.result.MockMvcResultMatchers.*; + +/** + * Integration tests for the {@link DoctorResource} REST controller. + */ +@SpringBootTest(classes = HealthcareApp.class) +@ExtendWith(MockitoExtension.class) +@AutoConfigureMockMvc +@WithMockUser +public class DoctorResourceIT { + + private static final String DEFAULT_NAME = "AAAAAAAAAA"; + private static final String UPDATED_NAME = "BBBBBBBBBB"; + + private static final String DEFAULT_PHONE = "AAAAAAAAAA"; + private static final String UPDATED_PHONE = "BBBBBBBBBB"; + + private static final Long DEFAULT_SALARY = 1L; + private static final Long UPDATED_SALARY = 2L; + + @Autowired + private DoctorRepository doctorRepository; + + @Mock + private DoctorRepository doctorRepositoryMock; + + @Autowired + private DoctorMapper doctorMapper; + + @Mock + private DoctorService doctorServiceMock; + + @Autowired + private DoctorService doctorService; + + @Autowired + private EntityManager em; + + @Autowired + private MockMvc restDoctorMockMvc; + + private Doctor doctor; + + /** + * Create an entity for this test. + * + * This is a static method, as tests for other entities might also need it, + * if they test an entity which requires the current entity. + */ + public static Doctor createEntity(EntityManager em) { + Doctor doctor = new Doctor() + .name(DEFAULT_NAME) + .phone(DEFAULT_PHONE) + .salary(DEFAULT_SALARY); + return doctor; + } + /** + * Create an updated entity for this test. + * + * This is a static method, as tests for other entities might also need it, + * if they test an entity which requires the current entity. + */ + public static Doctor createUpdatedEntity(EntityManager em) { + Doctor doctor = new Doctor() + .name(UPDATED_NAME) + .phone(UPDATED_PHONE) + .salary(UPDATED_SALARY); + return doctor; + } + + @BeforeEach + public void initTest() { + doctor = createEntity(em); + } + + @Test + @Transactional + public void createDoctor() throws Exception { + int databaseSizeBeforeCreate = doctorRepository.findAll().size(); + + // Create the Doctor + DoctorDTO doctorDTO = doctorMapper.toDto(doctor); + restDoctorMockMvc.perform(post("/api/doctors") + .contentType(MediaType.APPLICATION_JSON) + .content(TestUtil.convertObjectToJsonBytes(doctorDTO))) + .andExpect(status().isCreated()); + + // Validate the Doctor in the database + List doctorList = doctorRepository.findAll(); + assertThat(doctorList).hasSize(databaseSizeBeforeCreate + 1); + Doctor testDoctor = doctorList.get(doctorList.size() - 1); + assertThat(testDoctor.getName()).isEqualTo(DEFAULT_NAME); + assertThat(testDoctor.getPhone()).isEqualTo(DEFAULT_PHONE); + assertThat(testDoctor.getSalary()).isEqualTo(DEFAULT_SALARY); + } + + @Test + @Transactional + public void createDoctorWithExistingId() throws Exception { + int databaseSizeBeforeCreate = doctorRepository.findAll().size(); + + // Create the Doctor with an existing ID + doctor.setId(1L); + DoctorDTO doctorDTO = doctorMapper.toDto(doctor); + + // An entity with an existing ID cannot be created, so this API call must fail + restDoctorMockMvc.perform(post("/api/doctors") + .contentType(MediaType.APPLICATION_JSON) + .content(TestUtil.convertObjectToJsonBytes(doctorDTO))) + .andExpect(status().isBadRequest()); + + // Validate the Doctor in the database + List doctorList = doctorRepository.findAll(); + assertThat(doctorList).hasSize(databaseSizeBeforeCreate); + } + + + @Test + @Transactional + public void checkNameIsRequired() throws Exception { + int databaseSizeBeforeTest = doctorRepository.findAll().size(); + // set the field null + doctor.setName(null); + + // Create the Doctor, which fails. + DoctorDTO doctorDTO = doctorMapper.toDto(doctor); + + restDoctorMockMvc.perform(post("/api/doctors") + .contentType(MediaType.APPLICATION_JSON) + .content(TestUtil.convertObjectToJsonBytes(doctorDTO))) + .andExpect(status().isBadRequest()); + + List doctorList = doctorRepository.findAll(); + assertThat(doctorList).hasSize(databaseSizeBeforeTest); + } + + @Test + @Transactional + public void getAllDoctors() throws Exception { + // Initialize the database + doctorRepository.saveAndFlush(doctor); + + // Get all the doctorList + restDoctorMockMvc.perform(get("/api/doctors?sort=id,desc")) + .andExpect(status().isOk()) + .andExpect(content().contentType(MediaType.APPLICATION_JSON_VALUE)) + .andExpect(jsonPath("$.[*].id").value(hasItem(doctor.getId().intValue()))) + .andExpect(jsonPath("$.[*].name").value(hasItem(DEFAULT_NAME))) + .andExpect(jsonPath("$.[*].phone").value(hasItem(DEFAULT_PHONE))) + .andExpect(jsonPath("$.[*].salary").value(hasItem(DEFAULT_SALARY.intValue()))); + } + + @SuppressWarnings({"unchecked"}) + public void getAllDoctorsWithEagerRelationshipsIsEnabled() throws Exception { + when(doctorServiceMock.findAllWithEagerRelationships(any())).thenReturn(new PageImpl(new ArrayList<>())); + + restDoctorMockMvc.perform(get("/api/doctors?eagerload=true")) + .andExpect(status().isOk()); + + verify(doctorServiceMock, times(1)).findAllWithEagerRelationships(any()); + } + + @SuppressWarnings({"unchecked"}) + public void getAllDoctorsWithEagerRelationshipsIsNotEnabled() throws Exception { + when(doctorServiceMock.findAllWithEagerRelationships(any())).thenReturn(new PageImpl(new ArrayList<>())); + + restDoctorMockMvc.perform(get("/api/doctors?eagerload=true")) + .andExpect(status().isOk()); + + verify(doctorServiceMock, times(1)).findAllWithEagerRelationships(any()); + } + + @Test + @Transactional + public void getDoctor() throws Exception { + // Initialize the database + doctorRepository.saveAndFlush(doctor); + + // Get the doctor + restDoctorMockMvc.perform(get("/api/doctors/{id}", doctor.getId())) + .andExpect(status().isOk()) + .andExpect(content().contentType(MediaType.APPLICATION_JSON_VALUE)) + .andExpect(jsonPath("$.id").value(doctor.getId().intValue())) + .andExpect(jsonPath("$.name").value(DEFAULT_NAME)) + .andExpect(jsonPath("$.phone").value(DEFAULT_PHONE)) + .andExpect(jsonPath("$.salary").value(DEFAULT_SALARY.intValue())); + } + + @Test + @Transactional + public void getNonExistingDoctor() throws Exception { + // Get the doctor + restDoctorMockMvc.perform(get("/api/doctors/{id}", Long.MAX_VALUE)) + .andExpect(status().isNotFound()); + } + + @Test + @Transactional + public void updateDoctor() throws Exception { + // Initialize the database + doctorRepository.saveAndFlush(doctor); + + int databaseSizeBeforeUpdate = doctorRepository.findAll().size(); + + // Update the doctor + Doctor updatedDoctor = doctorRepository.findById(doctor.getId()).get(); + // Disconnect from session so that the updates on updatedDoctor are not directly saved in db + em.detach(updatedDoctor); + updatedDoctor + .name(UPDATED_NAME) + .phone(UPDATED_PHONE) + .salary(UPDATED_SALARY); + DoctorDTO doctorDTO = doctorMapper.toDto(updatedDoctor); + + restDoctorMockMvc.perform(put("/api/doctors") + .contentType(MediaType.APPLICATION_JSON) + .content(TestUtil.convertObjectToJsonBytes(doctorDTO))) + .andExpect(status().isOk()); + + // Validate the Doctor in the database + List doctorList = doctorRepository.findAll(); + assertThat(doctorList).hasSize(databaseSizeBeforeUpdate); + Doctor testDoctor = doctorList.get(doctorList.size() - 1); + assertThat(testDoctor.getName()).isEqualTo(UPDATED_NAME); + assertThat(testDoctor.getPhone()).isEqualTo(UPDATED_PHONE); + assertThat(testDoctor.getSalary()).isEqualTo(UPDATED_SALARY); + } + + @Test + @Transactional + public void updateNonExistingDoctor() throws Exception { + int databaseSizeBeforeUpdate = doctorRepository.findAll().size(); + + // Create the Doctor + DoctorDTO doctorDTO = doctorMapper.toDto(doctor); + + // If the entity doesn't have an ID, it will throw BadRequestAlertException + restDoctorMockMvc.perform(put("/api/doctors") + .contentType(MediaType.APPLICATION_JSON) + .content(TestUtil.convertObjectToJsonBytes(doctorDTO))) + .andExpect(status().isBadRequest()); + + // Validate the Doctor in the database + List doctorList = doctorRepository.findAll(); + assertThat(doctorList).hasSize(databaseSizeBeforeUpdate); + } + + @Test + @Transactional + public void deleteDoctor() throws Exception { + // Initialize the database + doctorRepository.saveAndFlush(doctor); + + int databaseSizeBeforeDelete = doctorRepository.findAll().size(); + + // Delete the doctor + restDoctorMockMvc.perform(delete("/api/doctors/{id}", doctor.getId()) + .accept(MediaType.APPLICATION_JSON)) + .andExpect(status().isNoContent()); + + // Validate the database contains one less item + List doctorList = doctorRepository.findAll(); + assertThat(doctorList).hasSize(databaseSizeBeforeDelete - 1); + } +} diff --git a/src/test/java/tr/com/aurora/hbys/healthcare/web/rest/PatientResourceIT.java b/src/test/java/tr/com/aurora/hbys/healthcare/web/rest/PatientResourceIT.java new file mode 100644 index 0000000..7f8382c --- /dev/null +++ b/src/test/java/tr/com/aurora/hbys/healthcare/web/rest/PatientResourceIT.java @@ -0,0 +1,294 @@ +package tr.com.aurora.hbys.healthcare.web.rest; + +import tr.com.aurora.hbys.healthcare.HealthcareApp; +import tr.com.aurora.hbys.healthcare.domain.Patient; +import tr.com.aurora.hbys.healthcare.repository.PatientRepository; +import tr.com.aurora.hbys.healthcare.service.PatientService; +import tr.com.aurora.hbys.healthcare.service.dto.PatientDTO; +import tr.com.aurora.hbys.healthcare.service.mapper.PatientMapper; + +import org.junit.jupiter.api.BeforeEach; +import org.junit.jupiter.api.Test; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.boot.test.autoconfigure.web.servlet.AutoConfigureMockMvc; +import org.springframework.boot.test.context.SpringBootTest; +import org.springframework.http.MediaType; +import org.springframework.security.test.context.support.WithMockUser; +import org.springframework.test.web.servlet.MockMvc; +import org.springframework.transaction.annotation.Transactional; +import javax.persistence.EntityManager; +import java.time.LocalDate; +import java.time.ZoneId; +import java.util.List; + +import static org.assertj.core.api.Assertions.assertThat; +import static org.hamcrest.Matchers.hasItem; +import static org.springframework.test.web.servlet.request.MockMvcRequestBuilders.*; +import static org.springframework.test.web.servlet.result.MockMvcResultMatchers.*; + +/** + * Integration tests for the {@link PatientResource} REST controller. + */ +@SpringBootTest(classes = HealthcareApp.class) + +@AutoConfigureMockMvc +@WithMockUser +public class PatientResourceIT { + + private static final String DEFAULT_NAME = "AAAAAAAAAA"; + private static final String UPDATED_NAME = "BBBBBBBBBB"; + + private static final String DEFAULT_PHONE = "AAAAAAAAAA"; + private static final String UPDATED_PHONE = "BBBBBBBBBB"; + + private static final LocalDate DEFAULT_BIRTH_DATE = LocalDate.ofEpochDay(0L); + private static final LocalDate UPDATED_BIRTH_DATE = LocalDate.now(ZoneId.systemDefault()); + + private static final String DEFAULT_CITIZEN_NUMBER = "AAAAAAAAAA"; + private static final String UPDATED_CITIZEN_NUMBER = "BBBBBBBBBB"; + + @Autowired + private PatientRepository patientRepository; + + @Autowired + private PatientMapper patientMapper; + + @Autowired + private PatientService patientService; + + @Autowired + private EntityManager em; + + @Autowired + private MockMvc restPatientMockMvc; + + private Patient patient; + + /** + * Create an entity for this test. + * + * This is a static method, as tests for other entities might also need it, + * if they test an entity which requires the current entity. + */ + public static Patient createEntity(EntityManager em) { + Patient patient = new Patient() + .name(DEFAULT_NAME) + .phone(DEFAULT_PHONE) + .birthDate(DEFAULT_BIRTH_DATE) + .citizenNumber(DEFAULT_CITIZEN_NUMBER); + return patient; + } + /** + * Create an updated entity for this test. + * + * This is a static method, as tests for other entities might also need it, + * if they test an entity which requires the current entity. + */ + public static Patient createUpdatedEntity(EntityManager em) { + Patient patient = new Patient() + .name(UPDATED_NAME) + .phone(UPDATED_PHONE) + .birthDate(UPDATED_BIRTH_DATE) + .citizenNumber(UPDATED_CITIZEN_NUMBER); + return patient; + } + + @BeforeEach + public void initTest() { + patient = createEntity(em); + } + + @Test + @Transactional + public void createPatient() throws Exception { + int databaseSizeBeforeCreate = patientRepository.findAll().size(); + + // Create the Patient + PatientDTO patientDTO = patientMapper.toDto(patient); + restPatientMockMvc.perform(post("/api/patients") + .contentType(MediaType.APPLICATION_JSON) + .content(TestUtil.convertObjectToJsonBytes(patientDTO))) + .andExpect(status().isCreated()); + + // Validate the Patient in the database + List patientList = patientRepository.findAll(); + assertThat(patientList).hasSize(databaseSizeBeforeCreate + 1); + Patient testPatient = patientList.get(patientList.size() - 1); + assertThat(testPatient.getName()).isEqualTo(DEFAULT_NAME); + assertThat(testPatient.getPhone()).isEqualTo(DEFAULT_PHONE); + assertThat(testPatient.getBirthDate()).isEqualTo(DEFAULT_BIRTH_DATE); + assertThat(testPatient.getCitizenNumber()).isEqualTo(DEFAULT_CITIZEN_NUMBER); + } + + @Test + @Transactional + public void createPatientWithExistingId() throws Exception { + int databaseSizeBeforeCreate = patientRepository.findAll().size(); + + // Create the Patient with an existing ID + patient.setId(1L); + PatientDTO patientDTO = patientMapper.toDto(patient); + + // An entity with an existing ID cannot be created, so this API call must fail + restPatientMockMvc.perform(post("/api/patients") + .contentType(MediaType.APPLICATION_JSON) + .content(TestUtil.convertObjectToJsonBytes(patientDTO))) + .andExpect(status().isBadRequest()); + + // Validate the Patient in the database + List patientList = patientRepository.findAll(); + assertThat(patientList).hasSize(databaseSizeBeforeCreate); + } + + + @Test + @Transactional + public void checkNameIsRequired() throws Exception { + int databaseSizeBeforeTest = patientRepository.findAll().size(); + // set the field null + patient.setName(null); + + // Create the Patient, which fails. + PatientDTO patientDTO = patientMapper.toDto(patient); + + restPatientMockMvc.perform(post("/api/patients") + .contentType(MediaType.APPLICATION_JSON) + .content(TestUtil.convertObjectToJsonBytes(patientDTO))) + .andExpect(status().isBadRequest()); + + List patientList = patientRepository.findAll(); + assertThat(patientList).hasSize(databaseSizeBeforeTest); + } + + @Test + @Transactional + public void checkCitizenNumberIsRequired() throws Exception { + int databaseSizeBeforeTest = patientRepository.findAll().size(); + // set the field null + patient.setCitizenNumber(null); + + // Create the Patient, which fails. + PatientDTO patientDTO = patientMapper.toDto(patient); + + restPatientMockMvc.perform(post("/api/patients") + .contentType(MediaType.APPLICATION_JSON) + .content(TestUtil.convertObjectToJsonBytes(patientDTO))) + .andExpect(status().isBadRequest()); + + List patientList = patientRepository.findAll(); + assertThat(patientList).hasSize(databaseSizeBeforeTest); + } + + @Test + @Transactional + public void getAllPatients() throws Exception { + // Initialize the database + patientRepository.saveAndFlush(patient); + + // Get all the patientList + restPatientMockMvc.perform(get("/api/patients?sort=id,desc")) + .andExpect(status().isOk()) + .andExpect(content().contentType(MediaType.APPLICATION_JSON_VALUE)) + .andExpect(jsonPath("$.[*].id").value(hasItem(patient.getId().intValue()))) + .andExpect(jsonPath("$.[*].name").value(hasItem(DEFAULT_NAME))) + .andExpect(jsonPath("$.[*].phone").value(hasItem(DEFAULT_PHONE))) + .andExpect(jsonPath("$.[*].birthDate").value(hasItem(DEFAULT_BIRTH_DATE.toString()))) + .andExpect(jsonPath("$.[*].citizenNumber").value(hasItem(DEFAULT_CITIZEN_NUMBER))); + } + + @Test + @Transactional + public void getPatient() throws Exception { + // Initialize the database + patientRepository.saveAndFlush(patient); + + // Get the patient + restPatientMockMvc.perform(get("/api/patients/{id}", patient.getId())) + .andExpect(status().isOk()) + .andExpect(content().contentType(MediaType.APPLICATION_JSON_VALUE)) + .andExpect(jsonPath("$.id").value(patient.getId().intValue())) + .andExpect(jsonPath("$.name").value(DEFAULT_NAME)) + .andExpect(jsonPath("$.phone").value(DEFAULT_PHONE)) + .andExpect(jsonPath("$.birthDate").value(DEFAULT_BIRTH_DATE.toString())) + .andExpect(jsonPath("$.citizenNumber").value(DEFAULT_CITIZEN_NUMBER)); + } + + @Test + @Transactional + public void getNonExistingPatient() throws Exception { + // Get the patient + restPatientMockMvc.perform(get("/api/patients/{id}", Long.MAX_VALUE)) + .andExpect(status().isNotFound()); + } + + @Test + @Transactional + public void updatePatient() throws Exception { + // Initialize the database + patientRepository.saveAndFlush(patient); + + int databaseSizeBeforeUpdate = patientRepository.findAll().size(); + + // Update the patient + Patient updatedPatient = patientRepository.findById(patient.getId()).get(); + // Disconnect from session so that the updates on updatedPatient are not directly saved in db + em.detach(updatedPatient); + updatedPatient + .name(UPDATED_NAME) + .phone(UPDATED_PHONE) + .birthDate(UPDATED_BIRTH_DATE) + .citizenNumber(UPDATED_CITIZEN_NUMBER); + PatientDTO patientDTO = patientMapper.toDto(updatedPatient); + + restPatientMockMvc.perform(put("/api/patients") + .contentType(MediaType.APPLICATION_JSON) + .content(TestUtil.convertObjectToJsonBytes(patientDTO))) + .andExpect(status().isOk()); + + // Validate the Patient in the database + List patientList = patientRepository.findAll(); + assertThat(patientList).hasSize(databaseSizeBeforeUpdate); + Patient testPatient = patientList.get(patientList.size() - 1); + assertThat(testPatient.getName()).isEqualTo(UPDATED_NAME); + assertThat(testPatient.getPhone()).isEqualTo(UPDATED_PHONE); + assertThat(testPatient.getBirthDate()).isEqualTo(UPDATED_BIRTH_DATE); + assertThat(testPatient.getCitizenNumber()).isEqualTo(UPDATED_CITIZEN_NUMBER); + } + + @Test + @Transactional + public void updateNonExistingPatient() throws Exception { + int databaseSizeBeforeUpdate = patientRepository.findAll().size(); + + // Create the Patient + PatientDTO patientDTO = patientMapper.toDto(patient); + + // If the entity doesn't have an ID, it will throw BadRequestAlertException + restPatientMockMvc.perform(put("/api/patients") + .contentType(MediaType.APPLICATION_JSON) + .content(TestUtil.convertObjectToJsonBytes(patientDTO))) + .andExpect(status().isBadRequest()); + + // Validate the Patient in the database + List patientList = patientRepository.findAll(); + assertThat(patientList).hasSize(databaseSizeBeforeUpdate); + } + + @Test + @Transactional + public void deletePatient() throws Exception { + // Initialize the database + patientRepository.saveAndFlush(patient); + + int databaseSizeBeforeDelete = patientRepository.findAll().size(); + + // Delete the patient + restPatientMockMvc.perform(delete("/api/patients/{id}", patient.getId()) + .accept(MediaType.APPLICATION_JSON)) + .andExpect(status().isNoContent()); + + // Validate the database contains one less item + List patientList = patientRepository.findAll(); + assertThat(patientList).hasSize(databaseSizeBeforeDelete - 1); + } +} diff --git a/src/test/java/tr/com/aurora/hbys/healthcare/web/rest/VisitResourceIT.java b/src/test/java/tr/com/aurora/hbys/healthcare/web/rest/VisitResourceIT.java new file mode 100644 index 0000000..c2aafb9 --- /dev/null +++ b/src/test/java/tr/com/aurora/hbys/healthcare/web/rest/VisitResourceIT.java @@ -0,0 +1,270 @@ +package tr.com.aurora.hbys.healthcare.web.rest; + +import tr.com.aurora.hbys.healthcare.HealthcareApp; +import tr.com.aurora.hbys.healthcare.domain.Visit; +import tr.com.aurora.hbys.healthcare.repository.VisitRepository; +import tr.com.aurora.hbys.healthcare.service.VisitService; +import tr.com.aurora.hbys.healthcare.service.dto.VisitDTO; +import tr.com.aurora.hbys.healthcare.service.mapper.VisitMapper; + +import org.junit.jupiter.api.BeforeEach; +import org.junit.jupiter.api.Test; +import org.mockito.Mock; +import org.junit.jupiter.api.extension.ExtendWith; +import org.mockito.junit.jupiter.MockitoExtension; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.boot.test.autoconfigure.web.servlet.AutoConfigureMockMvc; +import org.springframework.boot.test.context.SpringBootTest; +import org.springframework.data.domain.PageImpl; +import org.springframework.data.domain.PageRequest; +import org.springframework.http.MediaType; +import org.springframework.security.test.context.support.WithMockUser; +import org.springframework.test.web.servlet.MockMvc; +import org.springframework.transaction.annotation.Transactional; +import javax.persistence.EntityManager; +import java.time.Instant; +import java.time.temporal.ChronoUnit; +import java.util.ArrayList; +import java.util.List; + +import static org.assertj.core.api.Assertions.assertThat; +import static org.hamcrest.Matchers.hasItem; +import static org.mockito.Mockito.*; +import static org.springframework.test.web.servlet.request.MockMvcRequestBuilders.*; +import static org.springframework.test.web.servlet.result.MockMvcResultMatchers.*; + +import tr.com.aurora.hbys.healthcare.domain.enumeration.VisitType; +/** + * Integration tests for the {@link VisitResource} REST controller. + */ +@SpringBootTest(classes = HealthcareApp.class) +@ExtendWith(MockitoExtension.class) +@AutoConfigureMockMvc +@WithMockUser +public class VisitResourceIT { + + private static final Instant DEFAULT_DATE = Instant.ofEpochMilli(0L); + private static final Instant UPDATED_DATE = Instant.now().truncatedTo(ChronoUnit.MILLIS); + + private static final VisitType DEFAULT_TYPE = VisitType.EXAMINATION; + private static final VisitType UPDATED_TYPE = VisitType.ANALYSIS; + + @Autowired + private VisitRepository visitRepository; + + @Mock + private VisitRepository visitRepositoryMock; + + @Autowired + private VisitMapper visitMapper; + + @Mock + private VisitService visitServiceMock; + + @Autowired + private VisitService visitService; + + @Autowired + private EntityManager em; + + @Autowired + private MockMvc restVisitMockMvc; + + private Visit visit; + + /** + * Create an entity for this test. + * + * This is a static method, as tests for other entities might also need it, + * if they test an entity which requires the current entity. + */ + public static Visit createEntity(EntityManager em) { + Visit visit = new Visit() + .date(DEFAULT_DATE) + .type(DEFAULT_TYPE); + return visit; + } + /** + * Create an updated entity for this test. + * + * This is a static method, as tests for other entities might also need it, + * if they test an entity which requires the current entity. + */ + public static Visit createUpdatedEntity(EntityManager em) { + Visit visit = new Visit() + .date(UPDATED_DATE) + .type(UPDATED_TYPE); + return visit; + } + + @BeforeEach + public void initTest() { + visit = createEntity(em); + } + + @Test + @Transactional + public void createVisit() throws Exception { + int databaseSizeBeforeCreate = visitRepository.findAll().size(); + + // Create the Visit + VisitDTO visitDTO = visitMapper.toDto(visit); + restVisitMockMvc.perform(post("/api/visits") + .contentType(MediaType.APPLICATION_JSON) + .content(TestUtil.convertObjectToJsonBytes(visitDTO))) + .andExpect(status().isCreated()); + + // Validate the Visit in the database + List visitList = visitRepository.findAll(); + assertThat(visitList).hasSize(databaseSizeBeforeCreate + 1); + Visit testVisit = visitList.get(visitList.size() - 1); + assertThat(testVisit.getDate()).isEqualTo(DEFAULT_DATE); + assertThat(testVisit.getType()).isEqualTo(DEFAULT_TYPE); + } + + @Test + @Transactional + public void createVisitWithExistingId() throws Exception { + int databaseSizeBeforeCreate = visitRepository.findAll().size(); + + // Create the Visit with an existing ID + visit.setId(1L); + VisitDTO visitDTO = visitMapper.toDto(visit); + + // An entity with an existing ID cannot be created, so this API call must fail + restVisitMockMvc.perform(post("/api/visits") + .contentType(MediaType.APPLICATION_JSON) + .content(TestUtil.convertObjectToJsonBytes(visitDTO))) + .andExpect(status().isBadRequest()); + + // Validate the Visit in the database + List visitList = visitRepository.findAll(); + assertThat(visitList).hasSize(databaseSizeBeforeCreate); + } + + + @Test + @Transactional + public void getAllVisits() throws Exception { + // Initialize the database + visitRepository.saveAndFlush(visit); + + // Get all the visitList + restVisitMockMvc.perform(get("/api/visits?sort=id,desc")) + .andExpect(status().isOk()) + .andExpect(content().contentType(MediaType.APPLICATION_JSON_VALUE)) + .andExpect(jsonPath("$.[*].id").value(hasItem(visit.getId().intValue()))) + .andExpect(jsonPath("$.[*].date").value(hasItem(DEFAULT_DATE.toString()))) + .andExpect(jsonPath("$.[*].type").value(hasItem(DEFAULT_TYPE.toString()))); + } + + @SuppressWarnings({"unchecked"}) + public void getAllVisitsWithEagerRelationshipsIsEnabled() throws Exception { + when(visitServiceMock.findAllWithEagerRelationships(any())).thenReturn(new PageImpl(new ArrayList<>())); + + restVisitMockMvc.perform(get("/api/visits?eagerload=true")) + .andExpect(status().isOk()); + + verify(visitServiceMock, times(1)).findAllWithEagerRelationships(any()); + } + + @SuppressWarnings({"unchecked"}) + public void getAllVisitsWithEagerRelationshipsIsNotEnabled() throws Exception { + when(visitServiceMock.findAllWithEagerRelationships(any())).thenReturn(new PageImpl(new ArrayList<>())); + + restVisitMockMvc.perform(get("/api/visits?eagerload=true")) + .andExpect(status().isOk()); + + verify(visitServiceMock, times(1)).findAllWithEagerRelationships(any()); + } + + @Test + @Transactional + public void getVisit() throws Exception { + // Initialize the database + visitRepository.saveAndFlush(visit); + + // Get the visit + restVisitMockMvc.perform(get("/api/visits/{id}", visit.getId())) + .andExpect(status().isOk()) + .andExpect(content().contentType(MediaType.APPLICATION_JSON_VALUE)) + .andExpect(jsonPath("$.id").value(visit.getId().intValue())) + .andExpect(jsonPath("$.date").value(DEFAULT_DATE.toString())) + .andExpect(jsonPath("$.type").value(DEFAULT_TYPE.toString())); + } + + @Test + @Transactional + public void getNonExistingVisit() throws Exception { + // Get the visit + restVisitMockMvc.perform(get("/api/visits/{id}", Long.MAX_VALUE)) + .andExpect(status().isNotFound()); + } + + @Test + @Transactional + public void updateVisit() throws Exception { + // Initialize the database + visitRepository.saveAndFlush(visit); + + int databaseSizeBeforeUpdate = visitRepository.findAll().size(); + + // Update the visit + Visit updatedVisit = visitRepository.findById(visit.getId()).get(); + // Disconnect from session so that the updates on updatedVisit are not directly saved in db + em.detach(updatedVisit); + updatedVisit + .date(UPDATED_DATE) + .type(UPDATED_TYPE); + VisitDTO visitDTO = visitMapper.toDto(updatedVisit); + + restVisitMockMvc.perform(put("/api/visits") + .contentType(MediaType.APPLICATION_JSON) + .content(TestUtil.convertObjectToJsonBytes(visitDTO))) + .andExpect(status().isOk()); + + // Validate the Visit in the database + List visitList = visitRepository.findAll(); + assertThat(visitList).hasSize(databaseSizeBeforeUpdate); + Visit testVisit = visitList.get(visitList.size() - 1); + assertThat(testVisit.getDate()).isEqualTo(UPDATED_DATE); + assertThat(testVisit.getType()).isEqualTo(UPDATED_TYPE); + } + + @Test + @Transactional + public void updateNonExistingVisit() throws Exception { + int databaseSizeBeforeUpdate = visitRepository.findAll().size(); + + // Create the Visit + VisitDTO visitDTO = visitMapper.toDto(visit); + + // If the entity doesn't have an ID, it will throw BadRequestAlertException + restVisitMockMvc.perform(put("/api/visits") + .contentType(MediaType.APPLICATION_JSON) + .content(TestUtil.convertObjectToJsonBytes(visitDTO))) + .andExpect(status().isBadRequest()); + + // Validate the Visit in the database + List visitList = visitRepository.findAll(); + assertThat(visitList).hasSize(databaseSizeBeforeUpdate); + } + + @Test + @Transactional + public void deleteVisit() throws Exception { + // Initialize the database + visitRepository.saveAndFlush(visit); + + int databaseSizeBeforeDelete = visitRepository.findAll().size(); + + // Delete the visit + restVisitMockMvc.perform(delete("/api/visits/{id}", visit.getId()) + .accept(MediaType.APPLICATION_JSON)) + .andExpect(status().isNoContent()); + + // Validate the database contains one less item + List visitList = visitRepository.findAll(); + assertThat(visitList).hasSize(databaseSizeBeforeDelete - 1); + } +} diff --git a/src/test/java/tr/com/aurora/hbys/healthcare/web/rest/VisitServiceResourceIT.java b/src/test/java/tr/com/aurora/hbys/healthcare/web/rest/VisitServiceResourceIT.java new file mode 100644 index 0000000..45e4794 --- /dev/null +++ b/src/test/java/tr/com/aurora/hbys/healthcare/web/rest/VisitServiceResourceIT.java @@ -0,0 +1,273 @@ +package tr.com.aurora.hbys.healthcare.web.rest; + +import tr.com.aurora.hbys.healthcare.HealthcareApp; +import tr.com.aurora.hbys.healthcare.domain.VisitService; +import tr.com.aurora.hbys.healthcare.repository.VisitServiceRepository; +import tr.com.aurora.hbys.healthcare.service.VisitServiceService; +import tr.com.aurora.hbys.healthcare.service.dto.VisitServiceDTO; +import tr.com.aurora.hbys.healthcare.service.mapper.VisitServiceMapper; + +import org.junit.jupiter.api.BeforeEach; +import org.junit.jupiter.api.Test; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.boot.test.autoconfigure.web.servlet.AutoConfigureMockMvc; +import org.springframework.boot.test.context.SpringBootTest; +import org.springframework.http.MediaType; +import org.springframework.security.test.context.support.WithMockUser; +import org.springframework.test.web.servlet.MockMvc; +import org.springframework.transaction.annotation.Transactional; +import javax.persistence.EntityManager; +import java.util.List; + +import static org.assertj.core.api.Assertions.assertThat; +import static org.hamcrest.Matchers.hasItem; +import static org.springframework.test.web.servlet.request.MockMvcRequestBuilders.*; +import static org.springframework.test.web.servlet.result.MockMvcResultMatchers.*; + +/** + * Integration tests for the {@link VisitServiceResource} REST controller. + */ +@SpringBootTest(classes = HealthcareApp.class) + +@AutoConfigureMockMvc +@WithMockUser +public class VisitServiceResourceIT { + + private static final String DEFAULT_NAME = "AAAAAAAAAA"; + private static final String UPDATED_NAME = "BBBBBBBBBB"; + + private static final String DEFAULT_DESCRIPTION = "AAAAAAAAAA"; + private static final String UPDATED_DESCRIPTION = "BBBBBBBBBB"; + + private static final Boolean DEFAULT_ACTIVE = false; + private static final Boolean UPDATED_ACTIVE = true; + + private static final Double DEFAULT_PRICE = 1D; + private static final Double UPDATED_PRICE = 2D; + + @Autowired + private VisitServiceRepository visitServiceRepository; + + @Autowired + private VisitServiceMapper visitServiceMapper; + + @Autowired + private VisitServiceService visitServiceService; + + @Autowired + private EntityManager em; + + @Autowired + private MockMvc restVisitServiceMockMvc; + + private VisitService visitService; + + /** + * Create an entity for this test. + * + * This is a static method, as tests for other entities might also need it, + * if they test an entity which requires the current entity. + */ + public static VisitService createEntity(EntityManager em) { + VisitService visitService = new VisitService() + .name(DEFAULT_NAME) + .description(DEFAULT_DESCRIPTION) + .active(DEFAULT_ACTIVE) + .price(DEFAULT_PRICE); + return visitService; + } + /** + * Create an updated entity for this test. + * + * This is a static method, as tests for other entities might also need it, + * if they test an entity which requires the current entity. + */ + public static VisitService createUpdatedEntity(EntityManager em) { + VisitService visitService = new VisitService() + .name(UPDATED_NAME) + .description(UPDATED_DESCRIPTION) + .active(UPDATED_ACTIVE) + .price(UPDATED_PRICE); + return visitService; + } + + @BeforeEach + public void initTest() { + visitService = createEntity(em); + } + + @Test + @Transactional + public void createVisitService() throws Exception { + int databaseSizeBeforeCreate = visitServiceRepository.findAll().size(); + + // Create the VisitService + VisitServiceDTO visitServiceDTO = visitServiceMapper.toDto(visitService); + restVisitServiceMockMvc.perform(post("/api/visit-services") + .contentType(MediaType.APPLICATION_JSON) + .content(TestUtil.convertObjectToJsonBytes(visitServiceDTO))) + .andExpect(status().isCreated()); + + // Validate the VisitService in the database + List visitServiceList = visitServiceRepository.findAll(); + assertThat(visitServiceList).hasSize(databaseSizeBeforeCreate + 1); + VisitService testVisitService = visitServiceList.get(visitServiceList.size() - 1); + assertThat(testVisitService.getName()).isEqualTo(DEFAULT_NAME); + assertThat(testVisitService.getDescription()).isEqualTo(DEFAULT_DESCRIPTION); + assertThat(testVisitService.isActive()).isEqualTo(DEFAULT_ACTIVE); + assertThat(testVisitService.getPrice()).isEqualTo(DEFAULT_PRICE); + } + + @Test + @Transactional + public void createVisitServiceWithExistingId() throws Exception { + int databaseSizeBeforeCreate = visitServiceRepository.findAll().size(); + + // Create the VisitService with an existing ID + visitService.setId(1L); + VisitServiceDTO visitServiceDTO = visitServiceMapper.toDto(visitService); + + // An entity with an existing ID cannot be created, so this API call must fail + restVisitServiceMockMvc.perform(post("/api/visit-services") + .contentType(MediaType.APPLICATION_JSON) + .content(TestUtil.convertObjectToJsonBytes(visitServiceDTO))) + .andExpect(status().isBadRequest()); + + // Validate the VisitService in the database + List visitServiceList = visitServiceRepository.findAll(); + assertThat(visitServiceList).hasSize(databaseSizeBeforeCreate); + } + + + @Test + @Transactional + public void checkNameIsRequired() throws Exception { + int databaseSizeBeforeTest = visitServiceRepository.findAll().size(); + // set the field null + visitService.setName(null); + + // Create the VisitService, which fails. + VisitServiceDTO visitServiceDTO = visitServiceMapper.toDto(visitService); + + restVisitServiceMockMvc.perform(post("/api/visit-services") + .contentType(MediaType.APPLICATION_JSON) + .content(TestUtil.convertObjectToJsonBytes(visitServiceDTO))) + .andExpect(status().isBadRequest()); + + List visitServiceList = visitServiceRepository.findAll(); + assertThat(visitServiceList).hasSize(databaseSizeBeforeTest); + } + + @Test + @Transactional + public void getAllVisitServices() throws Exception { + // Initialize the database + visitServiceRepository.saveAndFlush(visitService); + + // Get all the visitServiceList + restVisitServiceMockMvc.perform(get("/api/visit-services?sort=id,desc")) + .andExpect(status().isOk()) + .andExpect(content().contentType(MediaType.APPLICATION_JSON_VALUE)) + .andExpect(jsonPath("$.[*].id").value(hasItem(visitService.getId().intValue()))) + .andExpect(jsonPath("$.[*].name").value(hasItem(DEFAULT_NAME))) + .andExpect(jsonPath("$.[*].description").value(hasItem(DEFAULT_DESCRIPTION))) + .andExpect(jsonPath("$.[*].active").value(hasItem(DEFAULT_ACTIVE.booleanValue()))) + .andExpect(jsonPath("$.[*].price").value(hasItem(DEFAULT_PRICE.doubleValue()))); + } + + @Test + @Transactional + public void getVisitService() throws Exception { + // Initialize the database + visitServiceRepository.saveAndFlush(visitService); + + // Get the visitService + restVisitServiceMockMvc.perform(get("/api/visit-services/{id}", visitService.getId())) + .andExpect(status().isOk()) + .andExpect(content().contentType(MediaType.APPLICATION_JSON_VALUE)) + .andExpect(jsonPath("$.id").value(visitService.getId().intValue())) + .andExpect(jsonPath("$.name").value(DEFAULT_NAME)) + .andExpect(jsonPath("$.description").value(DEFAULT_DESCRIPTION)) + .andExpect(jsonPath("$.active").value(DEFAULT_ACTIVE.booleanValue())) + .andExpect(jsonPath("$.price").value(DEFAULT_PRICE.doubleValue())); + } + + @Test + @Transactional + public void getNonExistingVisitService() throws Exception { + // Get the visitService + restVisitServiceMockMvc.perform(get("/api/visit-services/{id}", Long.MAX_VALUE)) + .andExpect(status().isNotFound()); + } + + @Test + @Transactional + public void updateVisitService() throws Exception { + // Initialize the database + visitServiceRepository.saveAndFlush(visitService); + + int databaseSizeBeforeUpdate = visitServiceRepository.findAll().size(); + + // Update the visitService + VisitService updatedVisitService = visitServiceRepository.findById(visitService.getId()).get(); + // Disconnect from session so that the updates on updatedVisitService are not directly saved in db + em.detach(updatedVisitService); + updatedVisitService + .name(UPDATED_NAME) + .description(UPDATED_DESCRIPTION) + .active(UPDATED_ACTIVE) + .price(UPDATED_PRICE); + VisitServiceDTO visitServiceDTO = visitServiceMapper.toDto(updatedVisitService); + + restVisitServiceMockMvc.perform(put("/api/visit-services") + .contentType(MediaType.APPLICATION_JSON) + .content(TestUtil.convertObjectToJsonBytes(visitServiceDTO))) + .andExpect(status().isOk()); + + // Validate the VisitService in the database + List visitServiceList = visitServiceRepository.findAll(); + assertThat(visitServiceList).hasSize(databaseSizeBeforeUpdate); + VisitService testVisitService = visitServiceList.get(visitServiceList.size() - 1); + assertThat(testVisitService.getName()).isEqualTo(UPDATED_NAME); + assertThat(testVisitService.getDescription()).isEqualTo(UPDATED_DESCRIPTION); + assertThat(testVisitService.isActive()).isEqualTo(UPDATED_ACTIVE); + assertThat(testVisitService.getPrice()).isEqualTo(UPDATED_PRICE); + } + + @Test + @Transactional + public void updateNonExistingVisitService() throws Exception { + int databaseSizeBeforeUpdate = visitServiceRepository.findAll().size(); + + // Create the VisitService + VisitServiceDTO visitServiceDTO = visitServiceMapper.toDto(visitService); + + // If the entity doesn't have an ID, it will throw BadRequestAlertException + restVisitServiceMockMvc.perform(put("/api/visit-services") + .contentType(MediaType.APPLICATION_JSON) + .content(TestUtil.convertObjectToJsonBytes(visitServiceDTO))) + .andExpect(status().isBadRequest()); + + // Validate the VisitService in the database + List visitServiceList = visitServiceRepository.findAll(); + assertThat(visitServiceList).hasSize(databaseSizeBeforeUpdate); + } + + @Test + @Transactional + public void deleteVisitService() throws Exception { + // Initialize the database + visitServiceRepository.saveAndFlush(visitService); + + int databaseSizeBeforeDelete = visitServiceRepository.findAll().size(); + + // Delete the visitService + restVisitServiceMockMvc.perform(delete("/api/visit-services/{id}", visitService.getId()) + .accept(MediaType.APPLICATION_JSON)) + .andExpect(status().isNoContent()); + + // Validate the database contains one less item + List visitServiceList = visitServiceRepository.findAll(); + assertThat(visitServiceList).hasSize(databaseSizeBeforeDelete - 1); + } +} diff --git a/src/test/javascript/spec/app/entities/department/department-delete-dialog.component.spec.ts b/src/test/javascript/spec/app/entities/department/department-delete-dialog.component.spec.ts new file mode 100644 index 0000000..452e204 --- /dev/null +++ b/src/test/javascript/spec/app/entities/department/department-delete-dialog.component.spec.ts @@ -0,0 +1,65 @@ +import { ComponentFixture, TestBed, inject, fakeAsync, tick } from '@angular/core/testing'; +import { NgbActiveModal } from '@ng-bootstrap/ng-bootstrap'; +import { of } from 'rxjs'; +import { JhiEventManager } from 'ng-jhipster'; + +import { HealthcareTestModule } from '../../../test.module'; +import { MockEventManager } from '../../../helpers/mock-event-manager.service'; +import { MockActiveModal } from '../../../helpers/mock-active-modal.service'; +import { DepartmentDeleteDialogComponent } from 'app/entities/department/department-delete-dialog.component'; +import { DepartmentService } from 'app/entities/department/department.service'; + +describe('Component Tests', () => { + describe('Department Management Delete Component', () => { + let comp: DepartmentDeleteDialogComponent; + let fixture: ComponentFixture; + let service: DepartmentService; + let mockEventManager: MockEventManager; + let mockActiveModal: MockActiveModal; + + beforeEach(() => { + TestBed.configureTestingModule({ + imports: [HealthcareTestModule], + declarations: [DepartmentDeleteDialogComponent] + }) + .overrideTemplate(DepartmentDeleteDialogComponent, '') + .compileComponents(); + fixture = TestBed.createComponent(DepartmentDeleteDialogComponent); + comp = fixture.componentInstance; + service = fixture.debugElement.injector.get(DepartmentService); + mockEventManager = TestBed.get(JhiEventManager); + mockActiveModal = TestBed.get(NgbActiveModal); + }); + + describe('confirmDelete', () => { + it('Should call delete service on confirmDelete', inject( + [], + fakeAsync(() => { + // GIVEN + spyOn(service, 'delete').and.returnValue(of({})); + + // WHEN + comp.confirmDelete(123); + tick(); + + // THEN + expect(service.delete).toHaveBeenCalledWith(123); + expect(mockActiveModal.closeSpy).toHaveBeenCalled(); + expect(mockEventManager.broadcastSpy).toHaveBeenCalled(); + }) + )); + + it('Should not call delete service on clear', () => { + // GIVEN + spyOn(service, 'delete'); + + // WHEN + comp.cancel(); + + // THEN + expect(service.delete).not.toHaveBeenCalled(); + expect(mockActiveModal.dismissSpy).toHaveBeenCalled(); + }); + }); + }); +}); diff --git a/src/test/javascript/spec/app/entities/department/department-detail.component.spec.ts b/src/test/javascript/spec/app/entities/department/department-detail.component.spec.ts new file mode 100644 index 0000000..8dd3bc2 --- /dev/null +++ b/src/test/javascript/spec/app/entities/department/department-detail.component.spec.ts @@ -0,0 +1,37 @@ +import { ComponentFixture, TestBed } from '@angular/core/testing'; +import { ActivatedRoute } from '@angular/router'; +import { of } from 'rxjs'; + +import { HealthcareTestModule } from '../../../test.module'; +import { DepartmentDetailComponent } from 'app/entities/department/department-detail.component'; +import { Department } from 'app/shared/model/department.model'; + +describe('Component Tests', () => { + describe('Department Management Detail Component', () => { + let comp: DepartmentDetailComponent; + let fixture: ComponentFixture; + const route = ({ data: of({ department: new Department(123) }) } as any) as ActivatedRoute; + + beforeEach(() => { + TestBed.configureTestingModule({ + imports: [HealthcareTestModule], + declarations: [DepartmentDetailComponent], + providers: [{ provide: ActivatedRoute, useValue: route }] + }) + .overrideTemplate(DepartmentDetailComponent, '') + .compileComponents(); + fixture = TestBed.createComponent(DepartmentDetailComponent); + comp = fixture.componentInstance; + }); + + describe('OnInit', () => { + it('Should load department on init', () => { + // WHEN + comp.ngOnInit(); + + // THEN + expect(comp.department).toEqual(jasmine.objectContaining({ id: 123 })); + }); + }); + }); +}); diff --git a/src/test/javascript/spec/app/entities/department/department-update.component.spec.ts b/src/test/javascript/spec/app/entities/department/department-update.component.spec.ts new file mode 100644 index 0000000..90fe9e0 --- /dev/null +++ b/src/test/javascript/spec/app/entities/department/department-update.component.spec.ts @@ -0,0 +1,61 @@ +import { ComponentFixture, TestBed, fakeAsync, tick } from '@angular/core/testing'; +import { HttpResponse } from '@angular/common/http'; +import { FormBuilder } from '@angular/forms'; +import { of } from 'rxjs'; + +import { HealthcareTestModule } from '../../../test.module'; +import { DepartmentUpdateComponent } from 'app/entities/department/department-update.component'; +import { DepartmentService } from 'app/entities/department/department.service'; +import { Department } from 'app/shared/model/department.model'; + +describe('Component Tests', () => { + describe('Department Management Update Component', () => { + let comp: DepartmentUpdateComponent; + let fixture: ComponentFixture; + let service: DepartmentService; + + beforeEach(() => { + TestBed.configureTestingModule({ + imports: [HealthcareTestModule], + declarations: [DepartmentUpdateComponent], + providers: [FormBuilder] + }) + .overrideTemplate(DepartmentUpdateComponent, '') + .compileComponents(); + + fixture = TestBed.createComponent(DepartmentUpdateComponent); + comp = fixture.componentInstance; + service = fixture.debugElement.injector.get(DepartmentService); + }); + + describe('save', () => { + it('Should call update service on save for existing entity', fakeAsync(() => { + // GIVEN + const entity = new Department(123); + spyOn(service, 'update').and.returnValue(of(new HttpResponse({ body: entity }))); + comp.updateForm(entity); + // WHEN + comp.save(); + tick(); // simulate async + + // THEN + expect(service.update).toHaveBeenCalledWith(entity); + expect(comp.isSaving).toEqual(false); + })); + + it('Should call create service on save for new entity', fakeAsync(() => { + // GIVEN + const entity = new Department(); + spyOn(service, 'create').and.returnValue(of(new HttpResponse({ body: entity }))); + comp.updateForm(entity); + // WHEN + comp.save(); + tick(); // simulate async + + // THEN + expect(service.create).toHaveBeenCalledWith(entity); + expect(comp.isSaving).toEqual(false); + })); + }); + }); +}); diff --git a/src/test/javascript/spec/app/entities/department/department.component.spec.ts b/src/test/javascript/spec/app/entities/department/department.component.spec.ts new file mode 100644 index 0000000..fb072eb --- /dev/null +++ b/src/test/javascript/spec/app/entities/department/department.component.spec.ts @@ -0,0 +1,110 @@ +import { ComponentFixture, TestBed } from '@angular/core/testing'; +import { of } from 'rxjs'; +import { HttpHeaders, HttpResponse } from '@angular/common/http'; +import { ActivatedRoute, Data } from '@angular/router'; + +import { HealthcareTestModule } from '../../../test.module'; +import { DepartmentComponent } from 'app/entities/department/department.component'; +import { DepartmentService } from 'app/entities/department/department.service'; +import { Department } from 'app/shared/model/department.model'; + +describe('Component Tests', () => { + describe('Department Management Component', () => { + let comp: DepartmentComponent; + let fixture: ComponentFixture; + let service: DepartmentService; + + beforeEach(() => { + TestBed.configureTestingModule({ + imports: [HealthcareTestModule], + declarations: [DepartmentComponent], + providers: [ + { + provide: ActivatedRoute, + useValue: { + data: { + subscribe: (fn: (value: Data) => void) => + fn({ + pagingParams: { + predicate: 'id', + reverse: false, + page: 0 + } + }) + } + } + } + ] + }) + .overrideTemplate(DepartmentComponent, '') + .compileComponents(); + + fixture = TestBed.createComponent(DepartmentComponent); + comp = fixture.componentInstance; + service = fixture.debugElement.injector.get(DepartmentService); + }); + + it('Should call load all on init', () => { + // GIVEN + const headers = new HttpHeaders().append('link', 'link;link'); + spyOn(service, 'query').and.returnValue( + of( + new HttpResponse({ + body: [new Department(123)], + headers + }) + ) + ); + + // WHEN + comp.ngOnInit(); + + // THEN + expect(service.query).toHaveBeenCalled(); + expect(comp.departments && comp.departments[0]).toEqual(jasmine.objectContaining({ id: 123 })); + }); + + it('should load a page', () => { + // GIVEN + const headers = new HttpHeaders().append('link', 'link;link'); + spyOn(service, 'query').and.returnValue( + of( + new HttpResponse({ + body: [new Department(123)], + headers + }) + ) + ); + + // WHEN + comp.loadPage(1); + + // THEN + expect(service.query).toHaveBeenCalled(); + expect(comp.departments && comp.departments[0]).toEqual(jasmine.objectContaining({ id: 123 })); + }); + + it('should calculate the sort attribute for an id', () => { + // WHEN + comp.ngOnInit(); + const result = comp.sort(); + + // THEN + expect(result).toEqual(['id,desc']); + }); + + it('should calculate the sort attribute for a non-id attribute', () => { + // INIT + comp.ngOnInit(); + + // GIVEN + comp.predicate = 'name'; + + // WHEN + const result = comp.sort(); + + // THEN + expect(result).toEqual(['name,desc', 'id']); + }); + }); +}); diff --git a/src/test/javascript/spec/app/entities/department/department.service.spec.ts b/src/test/javascript/spec/app/entities/department/department.service.spec.ts new file mode 100644 index 0000000..bfd8019 --- /dev/null +++ b/src/test/javascript/spec/app/entities/department/department.service.spec.ts @@ -0,0 +1,109 @@ +import { TestBed, getTestBed } from '@angular/core/testing'; +import { HttpClientTestingModule, HttpTestingController } from '@angular/common/http/testing'; +import { DepartmentService } from 'app/entities/department/department.service'; +import { IDepartment, Department } from 'app/shared/model/department.model'; +import { DepartmentType } from 'app/shared/model/enumerations/department-type.model'; + +describe('Service Tests', () => { + describe('Department Service', () => { + let injector: TestBed; + let service: DepartmentService; + let httpMock: HttpTestingController; + let elemDefault: IDepartment; + let expectedResult: IDepartment | IDepartment[] | boolean | null; + + beforeEach(() => { + TestBed.configureTestingModule({ + imports: [HttpClientTestingModule] + }); + expectedResult = null; + injector = getTestBed(); + service = injector.get(DepartmentService); + httpMock = injector.get(HttpTestingController); + + elemDefault = new Department(0, 'AAAAAAA', DepartmentType.SERVICE, 'AAAAAAA', false); + }); + + describe('Service methods', () => { + it('should find an element', () => { + const returnedFromService = Object.assign({}, elemDefault); + + service.find(123).subscribe(resp => (expectedResult = resp.body)); + + const req = httpMock.expectOne({ method: 'GET' }); + req.flush(returnedFromService); + expect(expectedResult).toMatchObject(elemDefault); + }); + + it('should create a Department', () => { + const returnedFromService = Object.assign( + { + id: 0 + }, + elemDefault + ); + + const expected = Object.assign({}, returnedFromService); + + service.create(new Department()).subscribe(resp => (expectedResult = resp.body)); + + const req = httpMock.expectOne({ method: 'POST' }); + req.flush(returnedFromService); + expect(expectedResult).toMatchObject(expected); + }); + + it('should update a Department', () => { + const returnedFromService = Object.assign( + { + name: 'BBBBBB', + type: 'BBBBBB', + description: 'BBBBBB', + active: true + }, + elemDefault + ); + + const expected = Object.assign({}, returnedFromService); + + service.update(expected).subscribe(resp => (expectedResult = resp.body)); + + const req = httpMock.expectOne({ method: 'PUT' }); + req.flush(returnedFromService); + expect(expectedResult).toMatchObject(expected); + }); + + it('should return a list of Department', () => { + const returnedFromService = Object.assign( + { + name: 'BBBBBB', + type: 'BBBBBB', + description: 'BBBBBB', + active: true + }, + elemDefault + ); + + const expected = Object.assign({}, returnedFromService); + + service.query().subscribe(resp => (expectedResult = resp.body)); + + const req = httpMock.expectOne({ method: 'GET' }); + req.flush([returnedFromService]); + httpMock.verify(); + expect(expectedResult).toContainEqual(expected); + }); + + it('should delete a Department', () => { + service.delete(123).subscribe(resp => (expectedResult = resp.ok)); + + const req = httpMock.expectOne({ method: 'DELETE' }); + req.flush({ status: 200 }); + expect(expectedResult); + }); + }); + + afterEach(() => { + httpMock.verify(); + }); + }); +}); diff --git a/src/test/javascript/spec/app/entities/doctor/doctor-delete-dialog.component.spec.ts b/src/test/javascript/spec/app/entities/doctor/doctor-delete-dialog.component.spec.ts new file mode 100644 index 0000000..ea01907 --- /dev/null +++ b/src/test/javascript/spec/app/entities/doctor/doctor-delete-dialog.component.spec.ts @@ -0,0 +1,65 @@ +import { ComponentFixture, TestBed, inject, fakeAsync, tick } from '@angular/core/testing'; +import { NgbActiveModal } from '@ng-bootstrap/ng-bootstrap'; +import { of } from 'rxjs'; +import { JhiEventManager } from 'ng-jhipster'; + +import { HealthcareTestModule } from '../../../test.module'; +import { MockEventManager } from '../../../helpers/mock-event-manager.service'; +import { MockActiveModal } from '../../../helpers/mock-active-modal.service'; +import { DoctorDeleteDialogComponent } from 'app/entities/doctor/doctor-delete-dialog.component'; +import { DoctorService } from 'app/entities/doctor/doctor.service'; + +describe('Component Tests', () => { + describe('Doctor Management Delete Component', () => { + let comp: DoctorDeleteDialogComponent; + let fixture: ComponentFixture; + let service: DoctorService; + let mockEventManager: MockEventManager; + let mockActiveModal: MockActiveModal; + + beforeEach(() => { + TestBed.configureTestingModule({ + imports: [HealthcareTestModule], + declarations: [DoctorDeleteDialogComponent] + }) + .overrideTemplate(DoctorDeleteDialogComponent, '') + .compileComponents(); + fixture = TestBed.createComponent(DoctorDeleteDialogComponent); + comp = fixture.componentInstance; + service = fixture.debugElement.injector.get(DoctorService); + mockEventManager = TestBed.get(JhiEventManager); + mockActiveModal = TestBed.get(NgbActiveModal); + }); + + describe('confirmDelete', () => { + it('Should call delete service on confirmDelete', inject( + [], + fakeAsync(() => { + // GIVEN + spyOn(service, 'delete').and.returnValue(of({})); + + // WHEN + comp.confirmDelete(123); + tick(); + + // THEN + expect(service.delete).toHaveBeenCalledWith(123); + expect(mockActiveModal.closeSpy).toHaveBeenCalled(); + expect(mockEventManager.broadcastSpy).toHaveBeenCalled(); + }) + )); + + it('Should not call delete service on clear', () => { + // GIVEN + spyOn(service, 'delete'); + + // WHEN + comp.cancel(); + + // THEN + expect(service.delete).not.toHaveBeenCalled(); + expect(mockActiveModal.dismissSpy).toHaveBeenCalled(); + }); + }); + }); +}); diff --git a/src/test/javascript/spec/app/entities/doctor/doctor-detail.component.spec.ts b/src/test/javascript/spec/app/entities/doctor/doctor-detail.component.spec.ts new file mode 100644 index 0000000..23fc29f --- /dev/null +++ b/src/test/javascript/spec/app/entities/doctor/doctor-detail.component.spec.ts @@ -0,0 +1,37 @@ +import { ComponentFixture, TestBed } from '@angular/core/testing'; +import { ActivatedRoute } from '@angular/router'; +import { of } from 'rxjs'; + +import { HealthcareTestModule } from '../../../test.module'; +import { DoctorDetailComponent } from 'app/entities/doctor/doctor-detail.component'; +import { Doctor } from 'app/shared/model/doctor.model'; + +describe('Component Tests', () => { + describe('Doctor Management Detail Component', () => { + let comp: DoctorDetailComponent; + let fixture: ComponentFixture; + const route = ({ data: of({ doctor: new Doctor(123) }) } as any) as ActivatedRoute; + + beforeEach(() => { + TestBed.configureTestingModule({ + imports: [HealthcareTestModule], + declarations: [DoctorDetailComponent], + providers: [{ provide: ActivatedRoute, useValue: route }] + }) + .overrideTemplate(DoctorDetailComponent, '') + .compileComponents(); + fixture = TestBed.createComponent(DoctorDetailComponent); + comp = fixture.componentInstance; + }); + + describe('OnInit', () => { + it('Should load doctor on init', () => { + // WHEN + comp.ngOnInit(); + + // THEN + expect(comp.doctor).toEqual(jasmine.objectContaining({ id: 123 })); + }); + }); + }); +}); diff --git a/src/test/javascript/spec/app/entities/doctor/doctor-update.component.spec.ts b/src/test/javascript/spec/app/entities/doctor/doctor-update.component.spec.ts new file mode 100644 index 0000000..07116ca --- /dev/null +++ b/src/test/javascript/spec/app/entities/doctor/doctor-update.component.spec.ts @@ -0,0 +1,61 @@ +import { ComponentFixture, TestBed, fakeAsync, tick } from '@angular/core/testing'; +import { HttpResponse } from '@angular/common/http'; +import { FormBuilder } from '@angular/forms'; +import { of } from 'rxjs'; + +import { HealthcareTestModule } from '../../../test.module'; +import { DoctorUpdateComponent } from 'app/entities/doctor/doctor-update.component'; +import { DoctorService } from 'app/entities/doctor/doctor.service'; +import { Doctor } from 'app/shared/model/doctor.model'; + +describe('Component Tests', () => { + describe('Doctor Management Update Component', () => { + let comp: DoctorUpdateComponent; + let fixture: ComponentFixture; + let service: DoctorService; + + beforeEach(() => { + TestBed.configureTestingModule({ + imports: [HealthcareTestModule], + declarations: [DoctorUpdateComponent], + providers: [FormBuilder] + }) + .overrideTemplate(DoctorUpdateComponent, '') + .compileComponents(); + + fixture = TestBed.createComponent(DoctorUpdateComponent); + comp = fixture.componentInstance; + service = fixture.debugElement.injector.get(DoctorService); + }); + + describe('save', () => { + it('Should call update service on save for existing entity', fakeAsync(() => { + // GIVEN + const entity = new Doctor(123); + spyOn(service, 'update').and.returnValue(of(new HttpResponse({ body: entity }))); + comp.updateForm(entity); + // WHEN + comp.save(); + tick(); // simulate async + + // THEN + expect(service.update).toHaveBeenCalledWith(entity); + expect(comp.isSaving).toEqual(false); + })); + + it('Should call create service on save for new entity', fakeAsync(() => { + // GIVEN + const entity = new Doctor(); + spyOn(service, 'create').and.returnValue(of(new HttpResponse({ body: entity }))); + comp.updateForm(entity); + // WHEN + comp.save(); + tick(); // simulate async + + // THEN + expect(service.create).toHaveBeenCalledWith(entity); + expect(comp.isSaving).toEqual(false); + })); + }); + }); +}); diff --git a/src/test/javascript/spec/app/entities/doctor/doctor.component.spec.ts b/src/test/javascript/spec/app/entities/doctor/doctor.component.spec.ts new file mode 100644 index 0000000..f9252f1 --- /dev/null +++ b/src/test/javascript/spec/app/entities/doctor/doctor.component.spec.ts @@ -0,0 +1,110 @@ +import { ComponentFixture, TestBed } from '@angular/core/testing'; +import { of } from 'rxjs'; +import { HttpHeaders, HttpResponse } from '@angular/common/http'; +import { ActivatedRoute, Data } from '@angular/router'; + +import { HealthcareTestModule } from '../../../test.module'; +import { DoctorComponent } from 'app/entities/doctor/doctor.component'; +import { DoctorService } from 'app/entities/doctor/doctor.service'; +import { Doctor } from 'app/shared/model/doctor.model'; + +describe('Component Tests', () => { + describe('Doctor Management Component', () => { + let comp: DoctorComponent; + let fixture: ComponentFixture; + let service: DoctorService; + + beforeEach(() => { + TestBed.configureTestingModule({ + imports: [HealthcareTestModule], + declarations: [DoctorComponent], + providers: [ + { + provide: ActivatedRoute, + useValue: { + data: { + subscribe: (fn: (value: Data) => void) => + fn({ + pagingParams: { + predicate: 'id', + reverse: false, + page: 0 + } + }) + } + } + } + ] + }) + .overrideTemplate(DoctorComponent, '') + .compileComponents(); + + fixture = TestBed.createComponent(DoctorComponent); + comp = fixture.componentInstance; + service = fixture.debugElement.injector.get(DoctorService); + }); + + it('Should call load all on init', () => { + // GIVEN + const headers = new HttpHeaders().append('link', 'link;link'); + spyOn(service, 'query').and.returnValue( + of( + new HttpResponse({ + body: [new Doctor(123)], + headers + }) + ) + ); + + // WHEN + comp.ngOnInit(); + + // THEN + expect(service.query).toHaveBeenCalled(); + expect(comp.doctors && comp.doctors[0]).toEqual(jasmine.objectContaining({ id: 123 })); + }); + + it('should load a page', () => { + // GIVEN + const headers = new HttpHeaders().append('link', 'link;link'); + spyOn(service, 'query').and.returnValue( + of( + new HttpResponse({ + body: [new Doctor(123)], + headers + }) + ) + ); + + // WHEN + comp.loadPage(1); + + // THEN + expect(service.query).toHaveBeenCalled(); + expect(comp.doctors && comp.doctors[0]).toEqual(jasmine.objectContaining({ id: 123 })); + }); + + it('should calculate the sort attribute for an id', () => { + // WHEN + comp.ngOnInit(); + const result = comp.sort(); + + // THEN + expect(result).toEqual(['id,desc']); + }); + + it('should calculate the sort attribute for a non-id attribute', () => { + // INIT + comp.ngOnInit(); + + // GIVEN + comp.predicate = 'name'; + + // WHEN + const result = comp.sort(); + + // THEN + expect(result).toEqual(['name,desc', 'id']); + }); + }); +}); diff --git a/src/test/javascript/spec/app/entities/doctor/doctor.service.spec.ts b/src/test/javascript/spec/app/entities/doctor/doctor.service.spec.ts new file mode 100644 index 0000000..691cbaf --- /dev/null +++ b/src/test/javascript/spec/app/entities/doctor/doctor.service.spec.ts @@ -0,0 +1,106 @@ +import { TestBed, getTestBed } from '@angular/core/testing'; +import { HttpClientTestingModule, HttpTestingController } from '@angular/common/http/testing'; +import { DoctorService } from 'app/entities/doctor/doctor.service'; +import { IDoctor, Doctor } from 'app/shared/model/doctor.model'; + +describe('Service Tests', () => { + describe('Doctor Service', () => { + let injector: TestBed; + let service: DoctorService; + let httpMock: HttpTestingController; + let elemDefault: IDoctor; + let expectedResult: IDoctor | IDoctor[] | boolean | null; + + beforeEach(() => { + TestBed.configureTestingModule({ + imports: [HttpClientTestingModule] + }); + expectedResult = null; + injector = getTestBed(); + service = injector.get(DoctorService); + httpMock = injector.get(HttpTestingController); + + elemDefault = new Doctor(0, 'AAAAAAA', 'AAAAAAA', 0); + }); + + describe('Service methods', () => { + it('should find an element', () => { + const returnedFromService = Object.assign({}, elemDefault); + + service.find(123).subscribe(resp => (expectedResult = resp.body)); + + const req = httpMock.expectOne({ method: 'GET' }); + req.flush(returnedFromService); + expect(expectedResult).toMatchObject(elemDefault); + }); + + it('should create a Doctor', () => { + const returnedFromService = Object.assign( + { + id: 0 + }, + elemDefault + ); + + const expected = Object.assign({}, returnedFromService); + + service.create(new Doctor()).subscribe(resp => (expectedResult = resp.body)); + + const req = httpMock.expectOne({ method: 'POST' }); + req.flush(returnedFromService); + expect(expectedResult).toMatchObject(expected); + }); + + it('should update a Doctor', () => { + const returnedFromService = Object.assign( + { + name: 'BBBBBB', + phone: 'BBBBBB', + salary: 1 + }, + elemDefault + ); + + const expected = Object.assign({}, returnedFromService); + + service.update(expected).subscribe(resp => (expectedResult = resp.body)); + + const req = httpMock.expectOne({ method: 'PUT' }); + req.flush(returnedFromService); + expect(expectedResult).toMatchObject(expected); + }); + + it('should return a list of Doctor', () => { + const returnedFromService = Object.assign( + { + name: 'BBBBBB', + phone: 'BBBBBB', + salary: 1 + }, + elemDefault + ); + + const expected = Object.assign({}, returnedFromService); + + service.query().subscribe(resp => (expectedResult = resp.body)); + + const req = httpMock.expectOne({ method: 'GET' }); + req.flush([returnedFromService]); + httpMock.verify(); + expect(expectedResult).toContainEqual(expected); + }); + + it('should delete a Doctor', () => { + service.delete(123).subscribe(resp => (expectedResult = resp.ok)); + + const req = httpMock.expectOne({ method: 'DELETE' }); + req.flush({ status: 200 }); + expect(expectedResult); + }); + }); + + afterEach(() => { + httpMock.verify(); + }); + }); +}); diff --git a/src/test/javascript/spec/app/entities/patient/patient-delete-dialog.component.spec.ts b/src/test/javascript/spec/app/entities/patient/patient-delete-dialog.component.spec.ts new file mode 100644 index 0000000..737a361 --- /dev/null +++ b/src/test/javascript/spec/app/entities/patient/patient-delete-dialog.component.spec.ts @@ -0,0 +1,65 @@ +import { ComponentFixture, TestBed, inject, fakeAsync, tick } from '@angular/core/testing'; +import { NgbActiveModal } from '@ng-bootstrap/ng-bootstrap'; +import { of } from 'rxjs'; +import { JhiEventManager } from 'ng-jhipster'; + +import { HealthcareTestModule } from '../../../test.module'; +import { MockEventManager } from '../../../helpers/mock-event-manager.service'; +import { MockActiveModal } from '../../../helpers/mock-active-modal.service'; +import { PatientDeleteDialogComponent } from 'app/entities/patient/patient-delete-dialog.component'; +import { PatientService } from 'app/entities/patient/patient.service'; + +describe('Component Tests', () => { + describe('Patient Management Delete Component', () => { + let comp: PatientDeleteDialogComponent; + let fixture: ComponentFixture; + let service: PatientService; + let mockEventManager: MockEventManager; + let mockActiveModal: MockActiveModal; + + beforeEach(() => { + TestBed.configureTestingModule({ + imports: [HealthcareTestModule], + declarations: [PatientDeleteDialogComponent] + }) + .overrideTemplate(PatientDeleteDialogComponent, '') + .compileComponents(); + fixture = TestBed.createComponent(PatientDeleteDialogComponent); + comp = fixture.componentInstance; + service = fixture.debugElement.injector.get(PatientService); + mockEventManager = TestBed.get(JhiEventManager); + mockActiveModal = TestBed.get(NgbActiveModal); + }); + + describe('confirmDelete', () => { + it('Should call delete service on confirmDelete', inject( + [], + fakeAsync(() => { + // GIVEN + spyOn(service, 'delete').and.returnValue(of({})); + + // WHEN + comp.confirmDelete(123); + tick(); + + // THEN + expect(service.delete).toHaveBeenCalledWith(123); + expect(mockActiveModal.closeSpy).toHaveBeenCalled(); + expect(mockEventManager.broadcastSpy).toHaveBeenCalled(); + }) + )); + + it('Should not call delete service on clear', () => { + // GIVEN + spyOn(service, 'delete'); + + // WHEN + comp.cancel(); + + // THEN + expect(service.delete).not.toHaveBeenCalled(); + expect(mockActiveModal.dismissSpy).toHaveBeenCalled(); + }); + }); + }); +}); diff --git a/src/test/javascript/spec/app/entities/patient/patient-detail.component.spec.ts b/src/test/javascript/spec/app/entities/patient/patient-detail.component.spec.ts new file mode 100644 index 0000000..3619c85 --- /dev/null +++ b/src/test/javascript/spec/app/entities/patient/patient-detail.component.spec.ts @@ -0,0 +1,37 @@ +import { ComponentFixture, TestBed } from '@angular/core/testing'; +import { ActivatedRoute } from '@angular/router'; +import { of } from 'rxjs'; + +import { HealthcareTestModule } from '../../../test.module'; +import { PatientDetailComponent } from 'app/entities/patient/patient-detail.component'; +import { Patient } from 'app/shared/model/patient.model'; + +describe('Component Tests', () => { + describe('Patient Management Detail Component', () => { + let comp: PatientDetailComponent; + let fixture: ComponentFixture; + const route = ({ data: of({ patient: new Patient(123) }) } as any) as ActivatedRoute; + + beforeEach(() => { + TestBed.configureTestingModule({ + imports: [HealthcareTestModule], + declarations: [PatientDetailComponent], + providers: [{ provide: ActivatedRoute, useValue: route }] + }) + .overrideTemplate(PatientDetailComponent, '') + .compileComponents(); + fixture = TestBed.createComponent(PatientDetailComponent); + comp = fixture.componentInstance; + }); + + describe('OnInit', () => { + it('Should load patient on init', () => { + // WHEN + comp.ngOnInit(); + + // THEN + expect(comp.patient).toEqual(jasmine.objectContaining({ id: 123 })); + }); + }); + }); +}); diff --git a/src/test/javascript/spec/app/entities/patient/patient-update.component.spec.ts b/src/test/javascript/spec/app/entities/patient/patient-update.component.spec.ts new file mode 100644 index 0000000..7840028 --- /dev/null +++ b/src/test/javascript/spec/app/entities/patient/patient-update.component.spec.ts @@ -0,0 +1,61 @@ +import { ComponentFixture, TestBed, fakeAsync, tick } from '@angular/core/testing'; +import { HttpResponse } from '@angular/common/http'; +import { FormBuilder } from '@angular/forms'; +import { of } from 'rxjs'; + +import { HealthcareTestModule } from '../../../test.module'; +import { PatientUpdateComponent } from 'app/entities/patient/patient-update.component'; +import { PatientService } from 'app/entities/patient/patient.service'; +import { Patient } from 'app/shared/model/patient.model'; + +describe('Component Tests', () => { + describe('Patient Management Update Component', () => { + let comp: PatientUpdateComponent; + let fixture: ComponentFixture; + let service: PatientService; + + beforeEach(() => { + TestBed.configureTestingModule({ + imports: [HealthcareTestModule], + declarations: [PatientUpdateComponent], + providers: [FormBuilder] + }) + .overrideTemplate(PatientUpdateComponent, '') + .compileComponents(); + + fixture = TestBed.createComponent(PatientUpdateComponent); + comp = fixture.componentInstance; + service = fixture.debugElement.injector.get(PatientService); + }); + + describe('save', () => { + it('Should call update service on save for existing entity', fakeAsync(() => { + // GIVEN + const entity = new Patient(123); + spyOn(service, 'update').and.returnValue(of(new HttpResponse({ body: entity }))); + comp.updateForm(entity); + // WHEN + comp.save(); + tick(); // simulate async + + // THEN + expect(service.update).toHaveBeenCalledWith(entity); + expect(comp.isSaving).toEqual(false); + })); + + it('Should call create service on save for new entity', fakeAsync(() => { + // GIVEN + const entity = new Patient(); + spyOn(service, 'create').and.returnValue(of(new HttpResponse({ body: entity }))); + comp.updateForm(entity); + // WHEN + comp.save(); + tick(); // simulate async + + // THEN + expect(service.create).toHaveBeenCalledWith(entity); + expect(comp.isSaving).toEqual(false); + })); + }); + }); +}); diff --git a/src/test/javascript/spec/app/entities/patient/patient.component.spec.ts b/src/test/javascript/spec/app/entities/patient/patient.component.spec.ts new file mode 100644 index 0000000..b1eb3c2 --- /dev/null +++ b/src/test/javascript/spec/app/entities/patient/patient.component.spec.ts @@ -0,0 +1,110 @@ +import { ComponentFixture, TestBed } from '@angular/core/testing'; +import { of } from 'rxjs'; +import { HttpHeaders, HttpResponse } from '@angular/common/http'; +import { ActivatedRoute, Data } from '@angular/router'; + +import { HealthcareTestModule } from '../../../test.module'; +import { PatientComponent } from 'app/entities/patient/patient.component'; +import { PatientService } from 'app/entities/patient/patient.service'; +import { Patient } from 'app/shared/model/patient.model'; + +describe('Component Tests', () => { + describe('Patient Management Component', () => { + let comp: PatientComponent; + let fixture: ComponentFixture; + let service: PatientService; + + beforeEach(() => { + TestBed.configureTestingModule({ + imports: [HealthcareTestModule], + declarations: [PatientComponent], + providers: [ + { + provide: ActivatedRoute, + useValue: { + data: { + subscribe: (fn: (value: Data) => void) => + fn({ + pagingParams: { + predicate: 'id', + reverse: false, + page: 0 + } + }) + } + } + } + ] + }) + .overrideTemplate(PatientComponent, '') + .compileComponents(); + + fixture = TestBed.createComponent(PatientComponent); + comp = fixture.componentInstance; + service = fixture.debugElement.injector.get(PatientService); + }); + + it('Should call load all on init', () => { + // GIVEN + const headers = new HttpHeaders().append('link', 'link;link'); + spyOn(service, 'query').and.returnValue( + of( + new HttpResponse({ + body: [new Patient(123)], + headers + }) + ) + ); + + // WHEN + comp.ngOnInit(); + + // THEN + expect(service.query).toHaveBeenCalled(); + expect(comp.patients && comp.patients[0]).toEqual(jasmine.objectContaining({ id: 123 })); + }); + + it('should load a page', () => { + // GIVEN + const headers = new HttpHeaders().append('link', 'link;link'); + spyOn(service, 'query').and.returnValue( + of( + new HttpResponse({ + body: [new Patient(123)], + headers + }) + ) + ); + + // WHEN + comp.loadPage(1); + + // THEN + expect(service.query).toHaveBeenCalled(); + expect(comp.patients && comp.patients[0]).toEqual(jasmine.objectContaining({ id: 123 })); + }); + + it('should calculate the sort attribute for an id', () => { + // WHEN + comp.ngOnInit(); + const result = comp.sort(); + + // THEN + expect(result).toEqual(['id,desc']); + }); + + it('should calculate the sort attribute for a non-id attribute', () => { + // INIT + comp.ngOnInit(); + + // GIVEN + comp.predicate = 'name'; + + // WHEN + const result = comp.sort(); + + // THEN + expect(result).toEqual(['name,desc', 'id']); + }); + }); +}); diff --git a/src/test/javascript/spec/app/entities/patient/patient.service.spec.ts b/src/test/javascript/spec/app/entities/patient/patient.service.spec.ts new file mode 100644 index 0000000..69367e3 --- /dev/null +++ b/src/test/javascript/spec/app/entities/patient/patient.service.spec.ts @@ -0,0 +1,133 @@ +import { TestBed, getTestBed } from '@angular/core/testing'; +import { HttpClientTestingModule, HttpTestingController } from '@angular/common/http/testing'; +import * as moment from 'moment'; +import { DATE_FORMAT } from 'app/shared/constants/input.constants'; +import { PatientService } from 'app/entities/patient/patient.service'; +import { IPatient, Patient } from 'app/shared/model/patient.model'; + +describe('Service Tests', () => { + describe('Patient Service', () => { + let injector: TestBed; + let service: PatientService; + let httpMock: HttpTestingController; + let elemDefault: IPatient; + let expectedResult: IPatient | IPatient[] | boolean | null; + let currentDate: moment.Moment; + + beforeEach(() => { + TestBed.configureTestingModule({ + imports: [HttpClientTestingModule] + }); + expectedResult = null; + injector = getTestBed(); + service = injector.get(PatientService); + httpMock = injector.get(HttpTestingController); + currentDate = moment(); + + elemDefault = new Patient(0, 'AAAAAAA', 'AAAAAAA', currentDate, 'AAAAAAA'); + }); + + describe('Service methods', () => { + it('should find an element', () => { + const returnedFromService = Object.assign( + { + birthDate: currentDate.format(DATE_FORMAT) + }, + elemDefault + ); + + service.find(123).subscribe(resp => (expectedResult = resp.body)); + + const req = httpMock.expectOne({ method: 'GET' }); + req.flush(returnedFromService); + expect(expectedResult).toMatchObject(elemDefault); + }); + + it('should create a Patient', () => { + const returnedFromService = Object.assign( + { + id: 0, + birthDate: currentDate.format(DATE_FORMAT) + }, + elemDefault + ); + + const expected = Object.assign( + { + birthDate: currentDate + }, + returnedFromService + ); + + service.create(new Patient()).subscribe(resp => (expectedResult = resp.body)); + + const req = httpMock.expectOne({ method: 'POST' }); + req.flush(returnedFromService); + expect(expectedResult).toMatchObject(expected); + }); + + it('should update a Patient', () => { + const returnedFromService = Object.assign( + { + name: 'BBBBBB', + phone: 'BBBBBB', + birthDate: currentDate.format(DATE_FORMAT), + citizenNumber: 'BBBBBB' + }, + elemDefault + ); + + const expected = Object.assign( + { + birthDate: currentDate + }, + returnedFromService + ); + + service.update(expected).subscribe(resp => (expectedResult = resp.body)); + + const req = httpMock.expectOne({ method: 'PUT' }); + req.flush(returnedFromService); + expect(expectedResult).toMatchObject(expected); + }); + + it('should return a list of Patient', () => { + const returnedFromService = Object.assign( + { + name: 'BBBBBB', + phone: 'BBBBBB', + birthDate: currentDate.format(DATE_FORMAT), + citizenNumber: 'BBBBBB' + }, + elemDefault + ); + + const expected = Object.assign( + { + birthDate: currentDate + }, + returnedFromService + ); + + service.query().subscribe(resp => (expectedResult = resp.body)); + + const req = httpMock.expectOne({ method: 'GET' }); + req.flush([returnedFromService]); + httpMock.verify(); + expect(expectedResult).toContainEqual(expected); + }); + + it('should delete a Patient', () => { + service.delete(123).subscribe(resp => (expectedResult = resp.ok)); + + const req = httpMock.expectOne({ method: 'DELETE' }); + req.flush({ status: 200 }); + expect(expectedResult); + }); + }); + + afterEach(() => { + httpMock.verify(); + }); + }); +}); diff --git a/src/test/javascript/spec/app/entities/visit-service/visit-service-delete-dialog.component.spec.ts b/src/test/javascript/spec/app/entities/visit-service/visit-service-delete-dialog.component.spec.ts new file mode 100644 index 0000000..f86645d --- /dev/null +++ b/src/test/javascript/spec/app/entities/visit-service/visit-service-delete-dialog.component.spec.ts @@ -0,0 +1,65 @@ +import { ComponentFixture, TestBed, inject, fakeAsync, tick } from '@angular/core/testing'; +import { NgbActiveModal } from '@ng-bootstrap/ng-bootstrap'; +import { of } from 'rxjs'; +import { JhiEventManager } from 'ng-jhipster'; + +import { HealthcareTestModule } from '../../../test.module'; +import { MockEventManager } from '../../../helpers/mock-event-manager.service'; +import { MockActiveModal } from '../../../helpers/mock-active-modal.service'; +import { VisitServiceDeleteDialogComponent } from 'app/entities/visit-service/visit-service-delete-dialog.component'; +import { VisitServiceService } from 'app/entities/visit-service/visit-service.service'; + +describe('Component Tests', () => { + describe('VisitService Management Delete Component', () => { + let comp: VisitServiceDeleteDialogComponent; + let fixture: ComponentFixture; + let service: VisitServiceService; + let mockEventManager: MockEventManager; + let mockActiveModal: MockActiveModal; + + beforeEach(() => { + TestBed.configureTestingModule({ + imports: [HealthcareTestModule], + declarations: [VisitServiceDeleteDialogComponent] + }) + .overrideTemplate(VisitServiceDeleteDialogComponent, '') + .compileComponents(); + fixture = TestBed.createComponent(VisitServiceDeleteDialogComponent); + comp = fixture.componentInstance; + service = fixture.debugElement.injector.get(VisitServiceService); + mockEventManager = TestBed.get(JhiEventManager); + mockActiveModal = TestBed.get(NgbActiveModal); + }); + + describe('confirmDelete', () => { + it('Should call delete service on confirmDelete', inject( + [], + fakeAsync(() => { + // GIVEN + spyOn(service, 'delete').and.returnValue(of({})); + + // WHEN + comp.confirmDelete(123); + tick(); + + // THEN + expect(service.delete).toHaveBeenCalledWith(123); + expect(mockActiveModal.closeSpy).toHaveBeenCalled(); + expect(mockEventManager.broadcastSpy).toHaveBeenCalled(); + }) + )); + + it('Should not call delete service on clear', () => { + // GIVEN + spyOn(service, 'delete'); + + // WHEN + comp.cancel(); + + // THEN + expect(service.delete).not.toHaveBeenCalled(); + expect(mockActiveModal.dismissSpy).toHaveBeenCalled(); + }); + }); + }); +}); diff --git a/src/test/javascript/spec/app/entities/visit-service/visit-service-detail.component.spec.ts b/src/test/javascript/spec/app/entities/visit-service/visit-service-detail.component.spec.ts new file mode 100644 index 0000000..c666e27 --- /dev/null +++ b/src/test/javascript/spec/app/entities/visit-service/visit-service-detail.component.spec.ts @@ -0,0 +1,37 @@ +import { ComponentFixture, TestBed } from '@angular/core/testing'; +import { ActivatedRoute } from '@angular/router'; +import { of } from 'rxjs'; + +import { HealthcareTestModule } from '../../../test.module'; +import { VisitServiceDetailComponent } from 'app/entities/visit-service/visit-service-detail.component'; +import { VisitService } from 'app/shared/model/visit-service.model'; + +describe('Component Tests', () => { + describe('VisitService Management Detail Component', () => { + let comp: VisitServiceDetailComponent; + let fixture: ComponentFixture; + const route = ({ data: of({ visitService: new VisitService(123) }) } as any) as ActivatedRoute; + + beforeEach(() => { + TestBed.configureTestingModule({ + imports: [HealthcareTestModule], + declarations: [VisitServiceDetailComponent], + providers: [{ provide: ActivatedRoute, useValue: route }] + }) + .overrideTemplate(VisitServiceDetailComponent, '') + .compileComponents(); + fixture = TestBed.createComponent(VisitServiceDetailComponent); + comp = fixture.componentInstance; + }); + + describe('OnInit', () => { + it('Should load visitService on init', () => { + // WHEN + comp.ngOnInit(); + + // THEN + expect(comp.visitService).toEqual(jasmine.objectContaining({ id: 123 })); + }); + }); + }); +}); diff --git a/src/test/javascript/spec/app/entities/visit-service/visit-service-update.component.spec.ts b/src/test/javascript/spec/app/entities/visit-service/visit-service-update.component.spec.ts new file mode 100644 index 0000000..6668117 --- /dev/null +++ b/src/test/javascript/spec/app/entities/visit-service/visit-service-update.component.spec.ts @@ -0,0 +1,61 @@ +import { ComponentFixture, TestBed, fakeAsync, tick } from '@angular/core/testing'; +import { HttpResponse } from '@angular/common/http'; +import { FormBuilder } from '@angular/forms'; +import { of } from 'rxjs'; + +import { HealthcareTestModule } from '../../../test.module'; +import { VisitServiceUpdateComponent } from 'app/entities/visit-service/visit-service-update.component'; +import { VisitServiceService } from 'app/entities/visit-service/visit-service.service'; +import { VisitService } from 'app/shared/model/visit-service.model'; + +describe('Component Tests', () => { + describe('VisitService Management Update Component', () => { + let comp: VisitServiceUpdateComponent; + let fixture: ComponentFixture; + let service: VisitServiceService; + + beforeEach(() => { + TestBed.configureTestingModule({ + imports: [HealthcareTestModule], + declarations: [VisitServiceUpdateComponent], + providers: [FormBuilder] + }) + .overrideTemplate(VisitServiceUpdateComponent, '') + .compileComponents(); + + fixture = TestBed.createComponent(VisitServiceUpdateComponent); + comp = fixture.componentInstance; + service = fixture.debugElement.injector.get(VisitServiceService); + }); + + describe('save', () => { + it('Should call update service on save for existing entity', fakeAsync(() => { + // GIVEN + const entity = new VisitService(123); + spyOn(service, 'update').and.returnValue(of(new HttpResponse({ body: entity }))); + comp.updateForm(entity); + // WHEN + comp.save(); + tick(); // simulate async + + // THEN + expect(service.update).toHaveBeenCalledWith(entity); + expect(comp.isSaving).toEqual(false); + })); + + it('Should call create service on save for new entity', fakeAsync(() => { + // GIVEN + const entity = new VisitService(); + spyOn(service, 'create').and.returnValue(of(new HttpResponse({ body: entity }))); + comp.updateForm(entity); + // WHEN + comp.save(); + tick(); // simulate async + + // THEN + expect(service.create).toHaveBeenCalledWith(entity); + expect(comp.isSaving).toEqual(false); + })); + }); + }); +}); diff --git a/src/test/javascript/spec/app/entities/visit-service/visit-service.component.spec.ts b/src/test/javascript/spec/app/entities/visit-service/visit-service.component.spec.ts new file mode 100644 index 0000000..10c31eb --- /dev/null +++ b/src/test/javascript/spec/app/entities/visit-service/visit-service.component.spec.ts @@ -0,0 +1,110 @@ +import { ComponentFixture, TestBed } from '@angular/core/testing'; +import { of } from 'rxjs'; +import { HttpHeaders, HttpResponse } from '@angular/common/http'; +import { ActivatedRoute, Data } from '@angular/router'; + +import { HealthcareTestModule } from '../../../test.module'; +import { VisitServiceComponent } from 'app/entities/visit-service/visit-service.component'; +import { VisitServiceService } from 'app/entities/visit-service/visit-service.service'; +import { VisitService } from 'app/shared/model/visit-service.model'; + +describe('Component Tests', () => { + describe('VisitService Management Component', () => { + let comp: VisitServiceComponent; + let fixture: ComponentFixture; + let service: VisitServiceService; + + beforeEach(() => { + TestBed.configureTestingModule({ + imports: [HealthcareTestModule], + declarations: [VisitServiceComponent], + providers: [ + { + provide: ActivatedRoute, + useValue: { + data: { + subscribe: (fn: (value: Data) => void) => + fn({ + pagingParams: { + predicate: 'id', + reverse: false, + page: 0 + } + }) + } + } + } + ] + }) + .overrideTemplate(VisitServiceComponent, '') + .compileComponents(); + + fixture = TestBed.createComponent(VisitServiceComponent); + comp = fixture.componentInstance; + service = fixture.debugElement.injector.get(VisitServiceService); + }); + + it('Should call load all on init', () => { + // GIVEN + const headers = new HttpHeaders().append('link', 'link;link'); + spyOn(service, 'query').and.returnValue( + of( + new HttpResponse({ + body: [new VisitService(123)], + headers + }) + ) + ); + + // WHEN + comp.ngOnInit(); + + // THEN + expect(service.query).toHaveBeenCalled(); + expect(comp.visitServices && comp.visitServices[0]).toEqual(jasmine.objectContaining({ id: 123 })); + }); + + it('should load a page', () => { + // GIVEN + const headers = new HttpHeaders().append('link', 'link;link'); + spyOn(service, 'query').and.returnValue( + of( + new HttpResponse({ + body: [new VisitService(123)], + headers + }) + ) + ); + + // WHEN + comp.loadPage(1); + + // THEN + expect(service.query).toHaveBeenCalled(); + expect(comp.visitServices && comp.visitServices[0]).toEqual(jasmine.objectContaining({ id: 123 })); + }); + + it('should calculate the sort attribute for an id', () => { + // WHEN + comp.ngOnInit(); + const result = comp.sort(); + + // THEN + expect(result).toEqual(['id,desc']); + }); + + it('should calculate the sort attribute for a non-id attribute', () => { + // INIT + comp.ngOnInit(); + + // GIVEN + comp.predicate = 'name'; + + // WHEN + const result = comp.sort(); + + // THEN + expect(result).toEqual(['name,desc', 'id']); + }); + }); +}); diff --git a/src/test/javascript/spec/app/entities/visit-service/visit-service.service.spec.ts b/src/test/javascript/spec/app/entities/visit-service/visit-service.service.spec.ts new file mode 100644 index 0000000..3533a52 --- /dev/null +++ b/src/test/javascript/spec/app/entities/visit-service/visit-service.service.spec.ts @@ -0,0 +1,108 @@ +import { TestBed, getTestBed } from '@angular/core/testing'; +import { HttpClientTestingModule, HttpTestingController } from '@angular/common/http/testing'; +import { VisitServiceService } from 'app/entities/visit-service/visit-service.service'; +import { IVisitService, VisitService } from 'app/shared/model/visit-service.model'; + +describe('Service Tests', () => { + describe('VisitService Service', () => { + let injector: TestBed; + let service: VisitServiceService; + let httpMock: HttpTestingController; + let elemDefault: IVisitService; + let expectedResult: IVisitService | IVisitService[] | boolean | null; + + beforeEach(() => { + TestBed.configureTestingModule({ + imports: [HttpClientTestingModule] + }); + expectedResult = null; + injector = getTestBed(); + service = injector.get(VisitServiceService); + httpMock = injector.get(HttpTestingController); + + elemDefault = new VisitService(0, 'AAAAAAA', 'AAAAAAA', false, 0); + }); + + describe('Service methods', () => { + it('should find an element', () => { + const returnedFromService = Object.assign({}, elemDefault); + + service.find(123).subscribe(resp => (expectedResult = resp.body)); + + const req = httpMock.expectOne({ method: 'GET' }); + req.flush(returnedFromService); + expect(expectedResult).toMatchObject(elemDefault); + }); + + it('should create a VisitService', () => { + const returnedFromService = Object.assign( + { + id: 0 + }, + elemDefault + ); + + const expected = Object.assign({}, returnedFromService); + + service.create(new VisitService()).subscribe(resp => (expectedResult = resp.body)); + + const req = httpMock.expectOne({ method: 'POST' }); + req.flush(returnedFromService); + expect(expectedResult).toMatchObject(expected); + }); + + it('should update a VisitService', () => { + const returnedFromService = Object.assign( + { + name: 'BBBBBB', + description: 'BBBBBB', + active: true, + price: 1 + }, + elemDefault + ); + + const expected = Object.assign({}, returnedFromService); + + service.update(expected).subscribe(resp => (expectedResult = resp.body)); + + const req = httpMock.expectOne({ method: 'PUT' }); + req.flush(returnedFromService); + expect(expectedResult).toMatchObject(expected); + }); + + it('should return a list of VisitService', () => { + const returnedFromService = Object.assign( + { + name: 'BBBBBB', + description: 'BBBBBB', + active: true, + price: 1 + }, + elemDefault + ); + + const expected = Object.assign({}, returnedFromService); + + service.query().subscribe(resp => (expectedResult = resp.body)); + + const req = httpMock.expectOne({ method: 'GET' }); + req.flush([returnedFromService]); + httpMock.verify(); + expect(expectedResult).toContainEqual(expected); + }); + + it('should delete a VisitService', () => { + service.delete(123).subscribe(resp => (expectedResult = resp.ok)); + + const req = httpMock.expectOne({ method: 'DELETE' }); + req.flush({ status: 200 }); + expect(expectedResult); + }); + }); + + afterEach(() => { + httpMock.verify(); + }); + }); +}); diff --git a/src/test/javascript/spec/app/entities/visit/visit-delete-dialog.component.spec.ts b/src/test/javascript/spec/app/entities/visit/visit-delete-dialog.component.spec.ts new file mode 100644 index 0000000..ba74193 --- /dev/null +++ b/src/test/javascript/spec/app/entities/visit/visit-delete-dialog.component.spec.ts @@ -0,0 +1,65 @@ +import { ComponentFixture, TestBed, inject, fakeAsync, tick } from '@angular/core/testing'; +import { NgbActiveModal } from '@ng-bootstrap/ng-bootstrap'; +import { of } from 'rxjs'; +import { JhiEventManager } from 'ng-jhipster'; + +import { HealthcareTestModule } from '../../../test.module'; +import { MockEventManager } from '../../../helpers/mock-event-manager.service'; +import { MockActiveModal } from '../../../helpers/mock-active-modal.service'; +import { VisitDeleteDialogComponent } from 'app/entities/visit/visit-delete-dialog.component'; +import { VisitService } from 'app/entities/visit/visit.service'; + +describe('Component Tests', () => { + describe('Visit Management Delete Component', () => { + let comp: VisitDeleteDialogComponent; + let fixture: ComponentFixture; + let service: VisitService; + let mockEventManager: MockEventManager; + let mockActiveModal: MockActiveModal; + + beforeEach(() => { + TestBed.configureTestingModule({ + imports: [HealthcareTestModule], + declarations: [VisitDeleteDialogComponent] + }) + .overrideTemplate(VisitDeleteDialogComponent, '') + .compileComponents(); + fixture = TestBed.createComponent(VisitDeleteDialogComponent); + comp = fixture.componentInstance; + service = fixture.debugElement.injector.get(VisitService); + mockEventManager = TestBed.get(JhiEventManager); + mockActiveModal = TestBed.get(NgbActiveModal); + }); + + describe('confirmDelete', () => { + it('Should call delete service on confirmDelete', inject( + [], + fakeAsync(() => { + // GIVEN + spyOn(service, 'delete').and.returnValue(of({})); + + // WHEN + comp.confirmDelete(123); + tick(); + + // THEN + expect(service.delete).toHaveBeenCalledWith(123); + expect(mockActiveModal.closeSpy).toHaveBeenCalled(); + expect(mockEventManager.broadcastSpy).toHaveBeenCalled(); + }) + )); + + it('Should not call delete service on clear', () => { + // GIVEN + spyOn(service, 'delete'); + + // WHEN + comp.cancel(); + + // THEN + expect(service.delete).not.toHaveBeenCalled(); + expect(mockActiveModal.dismissSpy).toHaveBeenCalled(); + }); + }); + }); +}); diff --git a/src/test/javascript/spec/app/entities/visit/visit-detail.component.spec.ts b/src/test/javascript/spec/app/entities/visit/visit-detail.component.spec.ts new file mode 100644 index 0000000..c2e050d --- /dev/null +++ b/src/test/javascript/spec/app/entities/visit/visit-detail.component.spec.ts @@ -0,0 +1,37 @@ +import { ComponentFixture, TestBed } from '@angular/core/testing'; +import { ActivatedRoute } from '@angular/router'; +import { of } from 'rxjs'; + +import { HealthcareTestModule } from '../../../test.module'; +import { VisitDetailComponent } from 'app/entities/visit/visit-detail.component'; +import { Visit } from 'app/shared/model/visit.model'; + +describe('Component Tests', () => { + describe('Visit Management Detail Component', () => { + let comp: VisitDetailComponent; + let fixture: ComponentFixture; + const route = ({ data: of({ visit: new Visit(123) }) } as any) as ActivatedRoute; + + beforeEach(() => { + TestBed.configureTestingModule({ + imports: [HealthcareTestModule], + declarations: [VisitDetailComponent], + providers: [{ provide: ActivatedRoute, useValue: route }] + }) + .overrideTemplate(VisitDetailComponent, '') + .compileComponents(); + fixture = TestBed.createComponent(VisitDetailComponent); + comp = fixture.componentInstance; + }); + + describe('OnInit', () => { + it('Should load visit on init', () => { + // WHEN + comp.ngOnInit(); + + // THEN + expect(comp.visit).toEqual(jasmine.objectContaining({ id: 123 })); + }); + }); + }); +}); diff --git a/src/test/javascript/spec/app/entities/visit/visit-update.component.spec.ts b/src/test/javascript/spec/app/entities/visit/visit-update.component.spec.ts new file mode 100644 index 0000000..8e5f741 --- /dev/null +++ b/src/test/javascript/spec/app/entities/visit/visit-update.component.spec.ts @@ -0,0 +1,61 @@ +import { ComponentFixture, TestBed, fakeAsync, tick } from '@angular/core/testing'; +import { HttpResponse } from '@angular/common/http'; +import { FormBuilder } from '@angular/forms'; +import { of } from 'rxjs'; + +import { HealthcareTestModule } from '../../../test.module'; +import { VisitUpdateComponent } from 'app/entities/visit/visit-update.component'; +import { VisitService } from 'app/entities/visit/visit.service'; +import { Visit } from 'app/shared/model/visit.model'; + +describe('Component Tests', () => { + describe('Visit Management Update Component', () => { + let comp: VisitUpdateComponent; + let fixture: ComponentFixture; + let service: VisitService; + + beforeEach(() => { + TestBed.configureTestingModule({ + imports: [HealthcareTestModule], + declarations: [VisitUpdateComponent], + providers: [FormBuilder] + }) + .overrideTemplate(VisitUpdateComponent, '') + .compileComponents(); + + fixture = TestBed.createComponent(VisitUpdateComponent); + comp = fixture.componentInstance; + service = fixture.debugElement.injector.get(VisitService); + }); + + describe('save', () => { + it('Should call update service on save for existing entity', fakeAsync(() => { + // GIVEN + const entity = new Visit(123); + spyOn(service, 'update').and.returnValue(of(new HttpResponse({ body: entity }))); + comp.updateForm(entity); + // WHEN + comp.save(); + tick(); // simulate async + + // THEN + expect(service.update).toHaveBeenCalledWith(entity); + expect(comp.isSaving).toEqual(false); + })); + + it('Should call create service on save for new entity', fakeAsync(() => { + // GIVEN + const entity = new Visit(); + spyOn(service, 'create').and.returnValue(of(new HttpResponse({ body: entity }))); + comp.updateForm(entity); + // WHEN + comp.save(); + tick(); // simulate async + + // THEN + expect(service.create).toHaveBeenCalledWith(entity); + expect(comp.isSaving).toEqual(false); + })); + }); + }); +}); diff --git a/src/test/javascript/spec/app/entities/visit/visit.component.spec.ts b/src/test/javascript/spec/app/entities/visit/visit.component.spec.ts new file mode 100644 index 0000000..db711f2 --- /dev/null +++ b/src/test/javascript/spec/app/entities/visit/visit.component.spec.ts @@ -0,0 +1,110 @@ +import { ComponentFixture, TestBed } from '@angular/core/testing'; +import { of } from 'rxjs'; +import { HttpHeaders, HttpResponse } from '@angular/common/http'; +import { ActivatedRoute, Data } from '@angular/router'; + +import { HealthcareTestModule } from '../../../test.module'; +import { VisitComponent } from 'app/entities/visit/visit.component'; +import { VisitService } from 'app/entities/visit/visit.service'; +import { Visit } from 'app/shared/model/visit.model'; + +describe('Component Tests', () => { + describe('Visit Management Component', () => { + let comp: VisitComponent; + let fixture: ComponentFixture; + let service: VisitService; + + beforeEach(() => { + TestBed.configureTestingModule({ + imports: [HealthcareTestModule], + declarations: [VisitComponent], + providers: [ + { + provide: ActivatedRoute, + useValue: { + data: { + subscribe: (fn: (value: Data) => void) => + fn({ + pagingParams: { + predicate: 'id', + reverse: false, + page: 0 + } + }) + } + } + } + ] + }) + .overrideTemplate(VisitComponent, '') + .compileComponents(); + + fixture = TestBed.createComponent(VisitComponent); + comp = fixture.componentInstance; + service = fixture.debugElement.injector.get(VisitService); + }); + + it('Should call load all on init', () => { + // GIVEN + const headers = new HttpHeaders().append('link', 'link;link'); + spyOn(service, 'query').and.returnValue( + of( + new HttpResponse({ + body: [new Visit(123)], + headers + }) + ) + ); + + // WHEN + comp.ngOnInit(); + + // THEN + expect(service.query).toHaveBeenCalled(); + expect(comp.visits && comp.visits[0]).toEqual(jasmine.objectContaining({ id: 123 })); + }); + + it('should load a page', () => { + // GIVEN + const headers = new HttpHeaders().append('link', 'link;link'); + spyOn(service, 'query').and.returnValue( + of( + new HttpResponse({ + body: [new Visit(123)], + headers + }) + ) + ); + + // WHEN + comp.loadPage(1); + + // THEN + expect(service.query).toHaveBeenCalled(); + expect(comp.visits && comp.visits[0]).toEqual(jasmine.objectContaining({ id: 123 })); + }); + + it('should calculate the sort attribute for an id', () => { + // WHEN + comp.ngOnInit(); + const result = comp.sort(); + + // THEN + expect(result).toEqual(['id,desc']); + }); + + it('should calculate the sort attribute for a non-id attribute', () => { + // INIT + comp.ngOnInit(); + + // GIVEN + comp.predicate = 'name'; + + // WHEN + const result = comp.sort(); + + // THEN + expect(result).toEqual(['name,desc', 'id']); + }); + }); +}); diff --git a/src/test/javascript/spec/app/entities/visit/visit.service.spec.ts b/src/test/javascript/spec/app/entities/visit/visit.service.spec.ts new file mode 100644 index 0000000..c1a6b83 --- /dev/null +++ b/src/test/javascript/spec/app/entities/visit/visit.service.spec.ts @@ -0,0 +1,130 @@ +import { TestBed, getTestBed } from '@angular/core/testing'; +import { HttpClientTestingModule, HttpTestingController } from '@angular/common/http/testing'; +import * as moment from 'moment'; +import { DATE_TIME_FORMAT } from 'app/shared/constants/input.constants'; +import { VisitService } from 'app/entities/visit/visit.service'; +import { IVisit, Visit } from 'app/shared/model/visit.model'; +import { VisitType } from 'app/shared/model/enumerations/visit-type.model'; + +describe('Service Tests', () => { + describe('Visit Service', () => { + let injector: TestBed; + let service: VisitService; + let httpMock: HttpTestingController; + let elemDefault: IVisit; + let expectedResult: IVisit | IVisit[] | boolean | null; + let currentDate: moment.Moment; + + beforeEach(() => { + TestBed.configureTestingModule({ + imports: [HttpClientTestingModule] + }); + expectedResult = null; + injector = getTestBed(); + service = injector.get(VisitService); + httpMock = injector.get(HttpTestingController); + currentDate = moment(); + + elemDefault = new Visit(0, currentDate, VisitType.EXAMINATION); + }); + + describe('Service methods', () => { + it('should find an element', () => { + const returnedFromService = Object.assign( + { + date: currentDate.format(DATE_TIME_FORMAT) + }, + elemDefault + ); + + service.find(123).subscribe(resp => (expectedResult = resp.body)); + + const req = httpMock.expectOne({ method: 'GET' }); + req.flush(returnedFromService); + expect(expectedResult).toMatchObject(elemDefault); + }); + + it('should create a Visit', () => { + const returnedFromService = Object.assign( + { + id: 0, + date: currentDate.format(DATE_TIME_FORMAT) + }, + elemDefault + ); + + const expected = Object.assign( + { + date: currentDate + }, + returnedFromService + ); + + service.create(new Visit()).subscribe(resp => (expectedResult = resp.body)); + + const req = httpMock.expectOne({ method: 'POST' }); + req.flush(returnedFromService); + expect(expectedResult).toMatchObject(expected); + }); + + it('should update a Visit', () => { + const returnedFromService = Object.assign( + { + date: currentDate.format(DATE_TIME_FORMAT), + type: 'BBBBBB' + }, + elemDefault + ); + + const expected = Object.assign( + { + date: currentDate + }, + returnedFromService + ); + + service.update(expected).subscribe(resp => (expectedResult = resp.body)); + + const req = httpMock.expectOne({ method: 'PUT' }); + req.flush(returnedFromService); + expect(expectedResult).toMatchObject(expected); + }); + + it('should return a list of Visit', () => { + const returnedFromService = Object.assign( + { + date: currentDate.format(DATE_TIME_FORMAT), + type: 'BBBBBB' + }, + elemDefault + ); + + const expected = Object.assign( + { + date: currentDate + }, + returnedFromService + ); + + service.query().subscribe(resp => (expectedResult = resp.body)); + + const req = httpMock.expectOne({ method: 'GET' }); + req.flush([returnedFromService]); + httpMock.verify(); + expect(expectedResult).toContainEqual(expected); + }); + + it('should delete a Visit', () => { + service.delete(123).subscribe(resp => (expectedResult = resp.ok)); + + const req = httpMock.expectOne({ method: 'DELETE' }); + req.flush({ status: 200 }); + expect(expectedResult); + }); + }); + + afterEach(() => { + httpMock.verify(); + }); + }); +});