Skip to content

Commit

Permalink
added Medication model
Browse files Browse the repository at this point in the history
  • Loading branch information
ivanwilliammd committed Nov 30, 2024
1 parent b12e654 commit cf25727
Showing 1 changed file with 29 additions and 1 deletion.
30 changes: 29 additions & 1 deletion src/FHIR/Medication.php
Original file line number Diff line number Diff line change
Expand Up @@ -361,7 +361,7 @@ public function setAmount($numerator = null, $numerator_unit = null, $denominato
$amount['numerator']['code'] = $numerator_unit;

$amount['denominator']['value'] = $denominator;
$amount['denominator']['system'] = 'http://terminology.hl7.org/CodeSystem/v3-orderableDrugForm';
$amount['denominator']['system'] = $this->drug_form[$denominator_unit]['system'];
$amount['denominator']['code'] = $denominator_unit;
}

Expand All @@ -388,6 +388,10 @@ public function addIngredient($itemCode = null, $itemDisplay = null, $numerator
$ingredient['strength']['numerator']['system'] = 'http://unitsofmeasure.org';
$ingredient['strength']['numerator']['code'] = $numerator_unit;

$ingredient['strength']['denominator']['value'] = $denominator;
$ingredient['strength']['denominator']['system'] = $this->drug_form[$denominator_unit]['system'];
$ingredient['strength']['denominator']['code'] = $denominator_unit;

$this->medication['ingredient'][] = $ingredient;
}

Expand Down Expand Up @@ -425,4 +429,28 @@ public function setMedicationType($code = 'NC')

$this->medication['extension'][] = $medicationType;
}

public function json()
{
return json_encode($this->medication, JSON_UNESCAPED_SLASHES | JSON_PRETTY_PRINT);
}

public function post()
{
$payload = $this->json();
[$statusCode, $res] = $this->ss_post('Medication', $payload);

return [$statusCode, $res];
}

public function put($id)
{
$this->medication['id'] = $id;

$payload = $this->json();
[$statusCode, $res] = $this->ss_put('Medication', $id, $payload);

return [$statusCode, $res];
}

}

0 comments on commit cf25727

Please sign in to comment.