diff --git a/prisma/address.prisma b/prisma/address.prisma index c14c56f..11150cb 100644 --- a/prisma/address.prisma +++ b/prisma/address.prisma @@ -1,45 +1,45 @@ -// model Country { -// id String @id @map("_id") -// name String @unique -// } +model MasterCountry { + id String @id @map("_id") + name String @unique +} -// model Address { -// id String @id @map("_id") -// name String @unique -// alt_name String? -// latitude Float? -// longitude Float? -// regencies Regency[] -// } +model MasterAddress { + id String @id @map("_id") + name String @unique + alt_name String? + latitude Float? + longitude Float? + regencies Regency[] +} -// type Regency { -// id String @map("_id") -// province_id String -// name String -// alt_name String? -// latitude Float? -// longitude Float? -// districts District[] -// } +type Regency { + id String @map("_id") + province_id String + name String + alt_name String? + latitude Float? + longitude Float? + districts District[] +} -// type District { -// id String @map("_id") -// regency_id String -// name String -// alt_name String? -// latitude Float? -// longitude Float? -// villages Village[] -// } +type District { + id String @map("_id") + regency_id String + name String + alt_name String? + latitude Float? + longitude Float? + villages Village[] +} -// type Village { -// id String @map("_id") -// district_id String -// name String -// } +type Village { + id String @map("_id") + district_id String + name String +} -// model Postal { -// id Int @id @map("_id") -// name String? -// postal Int[] -// } +model Postal { + id Int @id @map("_id") + name String? + postal Int[] +} diff --git a/prisma/encounter.prisma b/prisma/encounter.prisma new file mode 100644 index 0000000..da7e666 --- /dev/null +++ b/prisma/encounter.prisma @@ -0,0 +1,74 @@ +// FHIR Encounter Resource Prisma Schema +// Based on https://www.hl7.org/fhir/encounter.html + +// Reusing composite types defined previously + +model Encounter { + id String @id @map("_id") + identifier Identifier[] + status String // planned | arrived | triaged | in-progress | onleave | finished | cancelled + statusHistory EncounterStatusHistory[] + class Coding + classHistory EncounterClassHistory[] + type CodeableConcept[] + serviceType CodeableConcept? + priority CodeableConcept? + subject Reference? // Reference to Patient, Group, Device, etc. + episodeOfCare Reference[] // Reference to EpisodeOfCare + basedOn Reference[] // Reference to ServiceRequest + participant EncounterParticipant[] + appointment Reference[] // Reference to Appointment + period Period? + length Duration? + reasonCode CodeableConcept[] + reasonReference Reference[] // Reference to Condition, Procedure, etc. + diagnosis EncounterDiagnosis[] + account Reference[] // Reference to Account + hospitalization EncounterHospitalization? + location EncounterLocation[] + serviceProvider Reference? // Reference to Organization + partOf Reference? // Reference to another Encounter +} + +// Encounter-specific composite types + +type EncounterStatusHistory { + status String // planned | arrived | triaged | in-progress | onleave | finished | cancelled + period Period +} + +type EncounterClassHistory { + class Coding + period Period +} + +type EncounterParticipant { + type CodeableConcept[] + period Period? + individual Reference? // Reference to Practitioner, PractitionerRole, RelatedPerson +} + +type EncounterDiagnosis { + condition Reference // Reference to Condition, Procedure + use CodeableConcept? + rank Int? +} + +type EncounterHospitalization { + preAdmissionIdentifier Identifier? + origin Reference? // Reference to Location, Organization + admitSource CodeableConcept? + reAdmission CodeableConcept? + dietPreference CodeableConcept[] + specialCourtesy CodeableConcept[] + specialArrangement CodeableConcept[] + destination Reference? // Reference to Location, Organization + dischargeDisposition CodeableConcept? +} + +type EncounterLocation { + location Reference // Reference to Location + status String? // planned | active | reserved | completed + physicalType CodeableConcept? + period Period? +} diff --git a/prisma/patient.prisma b/prisma/patient.prisma new file mode 100644 index 0000000..44bce43 --- /dev/null +++ b/prisma/patient.prisma @@ -0,0 +1,79 @@ +// FHIR Patient Resource as Prisma Model +// Based on https://www.hl7.org/fhir/patient.html +// Using the previously defined composite types + +// First including all the composite types needed for Patient resource +// (Abbreviated - in production you would include the full definitions from the previous schema) + +// PatientCommunication type +type PatientCommunication { + language CodeableConcept + preferred Boolean? +} + +// PatientContact type +type PatientContact { + relationship CodeableConcept[] + name HumanName? + telecom ContactPoint[] + address Address? + gender String? // male | female | other | unknown + organization Reference? + period Period? +} + +// PatientLink type +type PatientLink { + other Reference + type String // replaced-by | replaces | refer | seealso +} + +// Main Patient Model +model Patient { + id String @id @default(auto()) @map("_id") @db.ObjectId + resourceType String @default("Patient") + + // Metadata + meta Json? + implicitRules String? + language String? + + // Identifiers and administrative information + identifier Identifier[] // An identifier for this patient + active Boolean? // Whether this patient's record is in active use + + // Name, gender, birth, deceased + name HumanName[] // A name associated with the patient + telecom ContactPoint[] // A contact detail for the individual + gender String? // male | female | other | unknown + birthDate DateTime? // The date of birth for the individual + deceasedBoolean Boolean? // Indicates if the individual is deceased or not + deceasedDateTime DateTime? // Indicates if the individual is deceased or not + + // Address information + address Address[] // An address for the individual + + // Patient demographic information + maritalStatus CodeableConcept? // Marital (civil) status of a patient + multipleBirthBoolean Boolean? // Whether patient is part of a multiple birth + multipleBirthInteger Int? // Whether patient is part of a multiple birth + photo Attachment[] // Image of the patient + + // Contact information + contact PatientContact[] // A contact party (e.g. guardian, partner, friend) for the patient + + // Care provider and communications + communication PatientCommunication[] // A language which may be used to communicate with the patient + generalPractitioner Reference[] // Patient's nominated primary care provider + managingOrganization Reference? // Organization that is the custodian of the patient record + + // Link to other patient records + link PatientLink[] // Link to another patient resource that concerns the same actual person + + // Extension mechanism + extension Json? // Additional information not captured in other defined elements + + // Required for most models + createdAt DateTime @default(now()) + updatedAt DateTime @updatedAt +} diff --git a/prisma/schema.prisma b/prisma/schema.prisma index e69de29..7e0c2df 100644 --- a/prisma/schema.prisma +++ b/prisma/schema.prisma @@ -0,0 +1,129 @@ +generator client { + provider = "prisma-client-js" + previewFeatures = ["prismaSchemaFolder"] +} + +datasource db { + provider = "mongodb" + url = env("MONGODB_URL") +} + +model Test { + id String @id @default(auto()) @map("_id") @db.ObjectId + name String @unique +} + +// model MasterCountry { +// id String @id @map("_id") +// name String @unique +// } + +// model MasterAddress { +// id String @id @map("_id") +// name String @unique +// alt_name String? +// latitude Float? +// longitude Float? +// regencies Regency[] +// } + +// type Regency { +// id String @map("_id") +// province_id String +// name String +// alt_name String? +// latitude Float? +// longitude Float? +// districts District[] +// } + +// type District { +// id String @map("_id") +// regency_id String +// name String +// alt_name String? +// latitude Float? +// longitude Float? +// villages Village[] +// } + +// type Village { +// id String @map("_id") +// district_id String +// name String +// } + +// model Postal { +// id Int @id @map("_id") +// name String? +// postal Int[] +// } + +// model Practitioner { +// id String @id @default(auto()) @map("_id") @db.ObjectId +// active Boolean @default(true) +// identifier Identifier[] +// name HumanName[] +// telecom ContactPoint[] +// gender String @default("unknown") +// birthDate DateTime? +// birthPlace String? +// // deceased Deceased? +// address AddressType[] +// communication BackboneElementCommunication[] +// } + +// type Identifier { +// name String +// value String +// } + +// type HumanName { +// use String @default("usual") +// text String? +// family String? +// given String[] +// prefix String[] +// suffix String[] +// period Period? +// } + +// type Period { +// start DateTime @default(now()) +// end DateTime? +// } + +// type ContactPoint { +// system String @default("phone") +// use String @default("home") +// value String +// period Period? +// } + +// type Deceased { +// deceasedBoolean Boolean? +// deceasedDateTime DateTime? +// } + +// type AddressType { +// use String @default("home") +// type String @default("physical") +// text String? +// line String[] +// village String? +// district String? +// city String? +// state String? +// country String? +// postalCode String +// period Period? +// } + +// type BackboneElementCommunication { +// language CodeableConceptLanguage +// preferred Boolean? +// } + +// type CodeableConceptLanguage { +// text String? +// }