Skip to content

Commit

Permalink
Initial objects outlined in todos
Browse files Browse the repository at this point in the history
  • Loading branch information
reshmakh committed Jul 13, 2022
1 parent 035e00d commit c95d5f1
Show file tree
Hide file tree
Showing 2 changed files with 36 additions and 74 deletions.
8 changes: 4 additions & 4 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -13,10 +13,10 @@
"author": "Medplum <[email protected]>",
"license": "Apache-2.0",
"devDependencies": {
"@medplum/cli": "0.9.15",
"@medplum/core": "0.9.15",
"@medplum/fhirtypes": "0.9.15",
"@medplum/mock": "0.9.15",
"@medplum/cli": "0.9.22",
"@medplum/core": "0.9.22",
"@medplum/fhirtypes": "0.9.22",
"@medplum/mock": "0.9.22",
"@types/node": "17.0.33",
"c8": "7.11.2",
"eslint": "8.15.0",
Expand Down
102 changes: 32 additions & 70 deletions src/sample-account-setup.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,16 +4,6 @@ import { AccessPolicy, DiagnosticReport, Observation, Patient, Practitioner, Sch
export async function handler(medplum: MedplumClient, event: BotEvent): Promise<any> {
const patient = event.input as Patient;

//Create access policy for patient
const patientAccessPolicy = await medplum.createResource<AccessPolicy>({
resourceType: 'AccessPolicy',
name: 'Example Access Policy',
compartment: {
reference: createReference(patient).reference,
display: getDisplayString(patient) + ' Access Policy',
},
});

//Create a practitioner if if isn't already created
const practitioner = await medplum.createResourceIfNoneExist<Practitioner>(
{
Expand Down Expand Up @@ -72,69 +62,41 @@ export async function handler(medplum: MedplumClient, event: BotEvent): Promise<
slotDate.setDate(slotDate.getDate() + 1);
}

//Create observations for DiagnosticReport
const observation1 = await medplum.createResource<Observation>({
resourceType: 'Observation',
subject: {
reference: createReference(patient).reference,
display: getDisplayString(patient),
},
code: {
text: 'Hemoglobin A1c',
},
valueQuantity: {
value: 5.4,
unit: 'mmol/L',
},
referenceRange: [
{
high: {
value: 7.0,
},
//Create observations for DiagnosticReport if not exits
const observation1 = await medplum.createResourceIfNoneExist<Observation>(
{
resourceType: 'Observation',
subject: {
reference: createReference(patient).reference,
display: getDisplayString(patient),
},
],
});

//Create observations for DiagnosticReport
const observation2 = await medplum.createResource<Observation>({
resourceType: 'Observation',
subject: {
reference: createReference(patient).reference,
display: getDisplayString(patient),
},
code: {
text: 'LDL',
},
valueQuantity: {
value: 99,
unit: 'mg/dL',
},
referenceRange: [
{
high: {
value: 100,
},
code: {
text: 'Hemoglobin A1c',
},
],
});
//Create a diagnostic report for the patient
const diagnosticReport = await medplum.createResource<DiagnosticReport>({
resourceType: 'DiagnosticReport',
subject: {
reference: createReference(patient).reference,
display: getDisplayString(patient),
},
resultsInterpreter: [
{
reference: createReference(practitioner).reference,
display: getDisplayString(practitioner),
valueQuantity: {
value: 5.4,
unit: 'mmol/L',
},
],
result: [
{ reference: createReference(observation1).reference },
{ reference: createReference(observation2).reference },
],
});
referenceRange: [
{
high: {
value: 7.0,
},
},
],
},
'Observation/patient-' + patient.id + '-observation-1'
);

//All of these resources are created in the same transaction if they don't exist

//Add CarePlan - create 2, 1 active and one completed
//Add Task and assign to patient
//Add DiagnosticReport with Observations (Lab Result)
//Add Medications
//Add Immunizations
//Add Vitals - Blood Pressure, height, weight, respiratory rate, temperature, etc.
//Make a default message "Hello and welcome to our practice"

return true;
}

0 comments on commit c95d5f1

Please sign in to comment.