Build modified streamline images

The official image from streamline does not currently work for the arm64
platform. As a temporary measure, the source code and docker build scripts
have been lifted from the official images and are used to build locally.

Some additional modifications are made to reduce overall image size, these
are documented in docker/README.md
This commit is contained in:
2024-03-10 16:17:50 -07:00
parent 2ffc3c408a
commit a424394109
13506 changed files with 1860172 additions and 6 deletions
@@ -0,0 +1,245 @@
<?php
namespace Modules\Patients\Http\Controllers;
use Illuminate\Http\Request;
use Streamline\Models\TriageNutrition;
class NutritionController extends Controller {
public function get_nutrition_status(Request $request): string {
$age_diff_months = round($request->age_diff_months);
$weight = $request->weight;
$height = $request->height * 100;
$bmi = $request->bmi;
$gender = $request->gender;
$patient_id = $request->patient_id;
$episode_id = $request->episode_id;
$muac = $request->muac;
$oedema = $request->oedema;
$reference_age = NULL;
$reference_bmi = NULL;
$reference_height = NULL;
$reference_weight = NULL;
$texts_array = ["Normal" => 1, "Risk of overweight" => 2, "MAM" => 3,
"SAM without oedema" => 4, "SAM with oedema" => 5];
if (!is_null($request->weight) && !is_null($request->height) && !is_null($request->bmi)) {
if ($age_diff_months > 5 && $age_diff_months < 60) {
if ($gender == 2){
$data = file(base_path('public/uploads/nutrition_csv_lookup/female_6_60.csv'));
} else {
$data = file(base_path('public/uploads/nutrition_csv_lookup/male_6_60.csv'));
}
$formatted_data = [];
$lengths = [];
foreach($data as $item) {
$split_item = explode(',', $item);
$lengths[] = +$split_item[0];
$formatted_data[+$split_item[0]] = [+$split_item[1], +$split_item[2], +$split_item[3], +$split_item[4], +str_replace(["\r", "\n"], "", $split_item[5])];
}
$reference_height = get_closest_element_in_array($lengths, $height);
$reference_weight = get_closest_element_in_array($formatted_data[$reference_height], $weight);
$weight_key = array_search($reference_weight, $formatted_data[$reference_height]);
if ($weight_key == 0) {
$text = "SAM without oedema";
$reason = "Weight for height < -3 SD";
$text_color = "red";
} elseif ($weight_key == 1) {
$text = "MAM";
$reason = "Weight for height between -3 SD and -2 SD";
$text_color = "darkorange";
} elseif ($weight_key == 2 || $weight_key == 3) {
$text = "Normal";
$reason = "Weight for height between -2 SD and 2 SD";
$text_color = "black";
} else {
$text = "Risk of overweight";
$reason = "Weight for height > 2 SD";
$text_color = "black";
}
} elseif ($age_diff_months > 59 && $age_diff_months < 228) {
if ($age_diff_months < 120) {
if ($gender == 2){
$data = file(base_path('public/uploads/nutrition_csv_lookup/female_60_120.csv'));
} else {
$data = file(base_path('public/uploads/nutrition_csv_lookup/male_60_120.csv'));
}
} else {
if ($gender == 2){
$data = file(base_path('public/uploads/nutrition_csv_lookup/female_120_228.csv'));
} else {
$data = file(base_path('public/uploads/nutrition_csv_lookup/male_120_228.csv'));
}
}
$formatted_data = [];
$ages_in_months = [];
foreach($data as $item) {
$split_item = explode(',', $item);
$ages_in_months[] = +$split_item[0];
$formatted_data[+$split_item[0]] = [+$split_item[1], +$split_item[2], +$split_item[3], +$split_item[4], +str_replace(["\r", "\n"], "", $split_item[5])];
}
$reference_age = get_closest_element_in_array($ages_in_months, $age_diff_months);
$reference_bmi = get_closest_element_in_array($formatted_data[$reference_age], $bmi);
$bmi_key = array_search($reference_bmi, $formatted_data[$reference_age]);
if ($bmi_key == 0) {
$text = "SAM without oedema";
$reason = "BMI < -3 SD";
$text_color = "red";
} elseif ($bmi_key == 1) {
$text = "MAM";
$reason = "BMI between -3 SD and -2 SD";
$text_color = "darkorange";
} elseif ($bmi_key == 2 || $bmi_key == 3) {
$text = "Normal";
$reason = "BMI between -2 SD and 1 SD";
$text_color = "black";
} else {
$text = "Risk of overweight";
$reason = "BMI > 1 SD";
$text_color = "black";
}
} elseif ($age_diff_months > 227 && $age_diff_months < 1200) {
if ($bmi < 16) {
$text = "SAM without oedema";
$reason = "BMI < 16";
$text_color = "red";
} elseif ($bmi > 15.9 && $bmi < 17) {
$text = "MAM";
$reason = "BMI between 16 and 17";
$text_color = "darkorange";
} elseif ($bmi > 16.9 && $bmi < 25) {
$text = "Normal";
$reason = "BMI between 17 and 25";
$text_color = "black";
} else {
$text = "Risk of overweight";
$reason = "BMI ≥ 25";
$text_color = "black";
}
} else {
return "0";
}
} else {
$text = "Normal";
$reason = "Normal";
$text_color = 'black';
}
// check for oedema status
if ($oedema == 1) {
$oedema = "Yes";
$oedema_text = "SAM with oedema";
$oedema_reason = "Oedema of both feet";
$oedema_text_color = "red";
} else {
$oedema = "No";
$oedema_text = "Normal";
$oedema_reason = "";
$oedema_text_color = "black";
}
// check if oedema has a higher category
if (($texts_array[$oedema_text] > $texts_array[$text])) {
$text = $oedema_text;
$reason = $oedema_reason;
$text_color = $oedema_text_color;
}
if ($age_diff_months < 1.59 && $muac < 11.0) {
$muac_text = "SAM without oedema";
$muac_reason = "MUAC below 11.0";
$muac_text_color = 'red';
} else if(between($age_diff_months, 1.6, 5) && $muac < 11.5) {
$muac_text = "SAM without oedema";
$muac_reason = "MUAC below 11.5";
$muac_text_color = 'red';
} else if(between($age_diff_months, 6, 59) && between($muac, 11.5, 12.4)) {
$muac_text = "MAM";
$muac_reason = "MUAC between 11.5 and 12.4";
$muac_text_color = 'darkorange';
} else if(between($age_diff_months, 6, 59) && $muac < 11.5) {
$muac_text = "SAM without oedema";
$muac_reason = "MUAC below 11.5";
$muac_text_color = 'red';
} else if(between($age_diff_months, 60, 119) && between($muac, 13.5, 14.4)) {
$muac_text = "MAM";
$muac_reason = "MUAC between 13.5 and 14.4";
$muac_text_color = 'darkorange';
} else if(between($age_diff_months, 60, 119) && $muac < 13.5) {
$muac_text = "SAM without oedema";
$muac_reason = "MUAC below 13.5";
$muac_text_color = 'red';
} else if(between($age_diff_months, 120, 179) && between($muac, 16.0, 18.4)) {
$muac_text = "MAM";
$muac_reason = "MUAC between 16.0 and 18.4";
$muac_text_color = 'darkorange';
} else if(between($age_diff_months, 120, 179) && $muac < 16.0) {
$muac_text = "SAM without oedema";
$muac_reason = "MUAC below 16.0";
$muac_text_color = 'red';
} else if(between($age_diff_months, 180, 215) && between($muac, 18.5, 20.9)) {
$muac_text = "MAM";
$muac_reason = "MUAC between 18.5 and 21.0";
$muac_text_color = 'darkorange';
} else if(between($age_diff_months, 180, 215) && $muac < 18.5) {
$muac_text = "SAM without oedema";
$muac_reason = "MUAC below 18.5";
$muac_text_color = 'red';
} else if($age_diff_months > 215 && between($muac, 19.0, 21.9)) {
$muac_text = "MAM";
$muac_reason = "MUAC between 19.0 and 21.9";
$muac_text_color = 'darkorange';
} else if($age_diff_months > 215 && $muac < 19.0) {
$muac_text = "SAM without oedema";
$muac_reason = "MUAC below 19.0";
$muac_text_color = 'red';
} else {
$muac_text = "Normal";
$muac_reason = "Normal";
$muac_text_color = 'black';
}
if (($texts_array[$muac_text] > $texts_array[$text])) {
$text = $muac_text;
$reason = $muac_reason;
$text_color = $muac_text_color;
}
// save data to the nutrition table
$nutrition = TriageNutrition::where(['patient_id' => $patient_id, 'episode_id' => $episode_id])->first();
if (!$nutrition) {
$nutrition = new TriageNutrition();
}
$nutrition->patient_id = $patient_id;
$nutrition->episode_id = $episode_id;
$nutrition->age_diff_months = $age_diff_months;
$nutrition->weight = $weight;
$nutrition->height = $height;
$nutrition->bmi = $bmi;
$nutrition->muac = $muac;
$nutrition->oedema = $oedema;
$nutrition->gender = $gender;
$nutrition->reference_height = $reference_height;
$nutrition->reference_weight = $reference_weight;
$nutrition->text = $text;
$nutrition->reason = $reason;
$nutrition->reference_age = $reference_age;
$nutrition->reference_bmi = $reference_bmi;
$nutrition->updated_at = now();
$nutrition->save();
return $text . "&&&&" . $reason . "&&&&" . $text_color;
}
}