Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Kyle Chin
committed
Jun 22, 2021
1 parent
edc7b5f
commit 0f71662
Showing
4 changed files
with
64 additions
and
6 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
39 changes: 39 additions & 0 deletions
39
src/main/java/com/example/fhirserver/entities/PatientEntity.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,39 @@ | ||
package com.example.fhirserver.entities; | ||
|
||
import com.vladmihalcea.hibernate.type.json.JsonType; | ||
import org.hibernate.annotations.TypeDef; | ||
import org.hibernate.annotations.TypeDefs; | ||
import org.hl7.fhir.r4.model.Patient; | ||
import org.springframework.data.jpa.domain.support.AuditingEntityListener; | ||
|
||
import javax.persistence.*; | ||
import java.io.Serializable; | ||
|
||
@TypeDefs({ @TypeDef(name = "json", typeClass = JsonType.class) }) | ||
@Entity | ||
@Table(name = "fhir_patient") | ||
@EntityListeners(AuditingEntityListener.class) | ||
public class PatientEntity implements Serializable { | ||
|
||
// we need _id to be generated safely in conjunction with other clients of | ||
// the postgres table. | ||
// To find your table's sequence, run: | ||
// select c.relname from pg_class c where c.relkind = 'S'; | ||
@Id | ||
@Column(name = "_id") | ||
@GeneratedValue(strategy = GenerationType.SEQUENCE, generator = "patient_id_generator") | ||
@SequenceGenerator(name = "patient_id_generator", sequenceName = "fhir_patient__id_seq", allocationSize = 1) | ||
private long id; | ||
|
||
@Type(type = "json") | ||
@Column(name = "resource", nullable = false, columnDefinition = "jsonb") | ||
private Patient resource; | ||
|
||
public long getId() { | ||
return id; | ||
} | ||
|
||
public Patient getResource() { | ||
return resource; | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
6 changes: 6 additions & 0 deletions
6
src/main/java/com/example/fhirserver/repositories/PatientRepository.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
package com.example.fhirserver.repositories; | ||
|
||
import com.example.fhirserver.entities.PatientEntity; | ||
import org.springframework.data.jpa.repository.JpaRepository; | ||
|
||
public interface PatientRepository extends JpaRepository<PatientEntity, Long> {} |