Skip to content
Merged

Dev #62

Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
163 changes: 81 additions & 82 deletions src/fhir/models.ts
Original file line number Diff line number Diff line change
@@ -1,101 +1,100 @@
import { Document, Schema, model } from 'mongoose';

interface Medication extends Document{
name: string,
codeSystem: string,
code: string,
requirements: any
interface Medication extends Document {
name: string;
codeSystem: string;
code: string;
requirements: any;
}

interface MetRequirements extends Document{
completed: boolean,
completedQuestionnaire: any,
requirementName: string,
requirementDescription: string,
drugName: string,
stakeholderId: string,
case_numbers: any
interface MetRequirements extends Document {
completed: boolean;
completedQuestionnaire: any;
requirementName: string;
requirementDescription: string;
drugName: string;
stakeholderId: string;
case_numbers: any;
}

interface RemsCase extends Document{
case_number: string,
status: string,
drugName: string,
drugCode: string
patientFirstName: string,
patientLastName: string,
patientDOB: string,
metRequirements: any
interface RemsCase extends Document {
case_number: string;
status: string;
drugName: string;
drugCode: string;
patientFirstName: string;
patientLastName: string;
patientDOB: string;
metRequirements: any;
}

const medicationCollectionSchema = new Schema<Medication>(
{
'name': { 'type': 'String' },
'codeSystem': { 'type': 'string' },
'code': { 'type': 'string' },
'requirements': {
'type': 'array',
'items': {
'type': 'object',
'properties': {
'name': { 'type': 'string' },
'description': { 'type': 'string' },
'questionnaire': { 'type': 'object' },
'stakeholderType': { 'type': 'string' },
'createNewCase': { 'type': 'boolean' },
'resourceId': { 'type': 'string' }
}
}
}
const medicationCollectionSchema = new Schema<Medication>({
name: { type: 'String' },
codeSystem: { type: 'string' },
code: { type: 'string' },
requirements: {
type: 'array',
items: {
type: 'object',
properties: {
name: { type: 'string' },
description: { type: 'string' },
questionnaire: { type: 'object' },
stakeholderType: { type: 'string' },
createNewCase: { type: 'boolean' },
resourceId: { type: 'string' }
}
}
);
}
});

medicationCollectionSchema.index({ name: 1 }, { unique: true });

export const medicationCollection = model<Medication>(
'medicationCollection',
medicationCollectionSchema
);

export const medicationCollection = model<Medication>('medicationCollection', medicationCollectionSchema);

const metRequirementsSchema = new Schema<MetRequirements>(
{
'completed': { 'type': 'boolean' },
'completedQuestionnaire': { 'type': 'object' },
'requirementName': { 'type': 'string' },
'requirementDescription': {'type': 'string'},
'drugName': { 'type': 'string' },
'stakeholderId': { 'type': 'string' },
'case_numbers': { 'type': 'array', 'items': { 'type': 'string' } }
}
);
metRequirementsSchema.index(
{ drugName: 1, requirementName: 1, stakeholderId: 1 },
{ unique: true }
);
const metRequirementsSchema = new Schema<MetRequirements>({
completed: { type: 'boolean' },
completedQuestionnaire: { type: 'object' },
requirementName: { type: 'string' },
requirementDescription: { type: 'string' },
drugName: { type: 'string' },
stakeholderId: { type: 'string' },
case_numbers: { type: 'array', items: { type: 'string' } }
});
metRequirementsSchema.index(
{ drugName: 1, requirementName: 1, stakeholderId: 1 },
{ unique: true }
);

export const metRequirementsCollection = model<MetRequirements>('metRequirementsCollection', metRequirementsSchema);
export const metRequirementsCollection = model<MetRequirements>(
'metRequirementsCollection',
metRequirementsSchema
);

const remsCaseCollectionSchema = new Schema<RemsCase>(
{
'case_number': { 'type': 'string' },
'status': { 'type': 'string' },
'drugName': { 'type': 'string' },
'patientFirstName': { 'type': 'string' },
'patientLastName': { 'type': 'string' },
'patientDOB': { 'type': 'string' },
'drugCode': { 'type': 'string' },
'metRequirements': {
'type': 'array',
'items': {
'type': 'object',
'properties': {
'metRequirementId': { 'type': 'number' },
'completed': { 'type': 'boolean' },
'stakeholderId': { 'type': 'string' },
'requirementName': { 'type': 'string' },
'requirementDescription': {'type': 'string'},
}
const remsCaseCollectionSchema = new Schema<RemsCase>({
case_number: { type: 'string' },
status: { type: 'string' },
drugName: { type: 'string' },
patientFirstName: { type: 'string' },
patientLastName: { type: 'string' },
patientDOB: { type: 'string' },
drugCode: { type: 'string' },
metRequirements: {
type: 'array',
items: {
type: 'object',
properties: {
metRequirementId: { type: 'number' },
completed: { type: 'boolean' },
stakeholderId: { type: 'string' },
requirementName: { type: 'string' },
requirementDescription: { type: 'string' }
}
}
}
);
});

export const remsCaseCollection = model<RemsCase>('RemsCaseCollection', remsCaseCollectionSchema);
export const remsCaseCollection = model<RemsCase>('RemsCaseCollection', remsCaseCollectionSchema);
1 change: 0 additions & 1 deletion src/fhir/utilities.ts
Original file line number Diff line number Diff line change
Expand Up @@ -268,7 +268,6 @@ export class FhirUtilities {
}

static async populateDB() {

// prepopulateDB
medicationCollection.insertMany(
[
Expand Down
31 changes: 31 additions & 0 deletions src/lib/schemas/models/Extension.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,9 @@
import mongoose from 'mongoose';
import { Extension } from 'fhir/r4';
import Expression from './Expression';
import CodeableConcept from './CodeableConcept';
import Coding from './Coding';
import Reference from './Reference';
export default new mongoose.Schema<Extension>(
{
url: {
Expand All @@ -14,6 +17,34 @@ export default new mongoose.Schema<Extension>(
valueExpression: {
type: Expression,
default: void 0
},
valueCodeableConcept: {
type: CodeableConcept,
default: void 0
},
valueInteger: {
type: Number,
default: void 0
},
valueDate: {
type: String,
default: void 0
},
valueTime: {
type: String,
default: void 0
},
valueString: {
type: String,
default: void 0
},
valueCoding: {
type: Coding,
default: void 0
},
valueReference: {
type: Reference,
default: void 0
}
},
{ _id: false }
Expand Down
Loading