Browse Source

Merge branch 'dev' into dev-vj

Vijayakrishnan 3 years ago
parent
commit
b16934c846
84 changed files with 6726 additions and 495 deletions
  1. 1 0
      app/Http/Controllers/PracticeManagementController.php
  2. 4 0
      public/css/style.css
  3. 48 47
      resources/views/app/patient/care-month/put-rm-reasons.blade.php
  4. 13 13
      resources/views/app/patient/care-month/rm-reasons.blade.php
  5. 1 1
      resources/views/app/patient/note/_OLD_segment.blade.php
  6. 12 12
      resources/views/app/patient/note/dashboard.blade.php
  7. 348 313
      resources/views/app/patient/note/rm-setup.blade.php
  8. 1 1
      resources/views/app/patient/note/section.blade.php
  9. 2 2
      resources/views/app/patient/note/segment-slim.blade.php
  10. 1 1
      resources/views/app/patient/note/segment.blade.php
  11. 47 47
      resources/views/app/patient/partials/put-rm-reasons.blade.php
  12. 44 0
      resources/views/app/patient/partials/rm-reasons-display.blade.php
  13. 4 47
      resources/views/app/patient/partials/rm-setup.blade.php
  14. 233 0
      resources/views/app/patient/segment-templates/biopsychosocial_assessment/edit.blade.php
  15. 222 0
      resources/views/app/patient/segment-templates/biopsychosocial_assessment/summary.blade.php
  16. 370 0
      resources/views/app/patient/segment-templates/psych_intake_current_mental-status/edit.blade.php
  17. 265 0
      resources/views/app/patient/segment-templates/psych_intake_current_mental-status/summary.blade.php
  18. 27 0
      resources/views/app/patient/segment-templates/sigma_allergies/active-linear-summary.blade.php
  19. 0 0
      resources/views/app/patient/segment-templates/sigma_allergies/edit.blade.php
  20. 70 0
      resources/views/app/patient/segment-templates/sigma_allergies/summary.blade.php
  21. 4 0
      resources/views/app/patient/segment-templates/sigma_assessment_free_text/edit.blade.php
  22. 3 0
      resources/views/app/patient/segment-templates/sigma_assessment_free_text/summary.blade.php
  23. 0 0
      resources/views/app/patient/segment-templates/sigma_assessment_system/edit.blade.php
  24. 59 0
      resources/views/app/patient/segment-templates/sigma_assessment_system/summary.blade.php
  25. 0 0
      resources/views/app/patient/segment-templates/sigma_care_team/edit.blade.php
  26. 64 0
      resources/views/app/patient/segment-templates/sigma_care_team/summary.blade.php
  27. 64 0
      resources/views/app/patient/segment-templates/sigma_cc/edit.blade.php
  28. 55 0
      resources/views/app/patient/segment-templates/sigma_cc/summary.blade.php
  29. 0 0
      resources/views/app/patient/segment-templates/sigma_goals/edit.blade.php
  30. 59 0
      resources/views/app/patient/segment-templates/sigma_goals/summary.blade.php
  31. 426 0
      resources/views/app/patient/segment-templates/sigma_history_family/edit.blade.php
  32. 92 0
      resources/views/app/patient/segment-templates/sigma_history_family/log.blade.php
  33. 100 0
      resources/views/app/patient/segment-templates/sigma_history_family/summary.blade.php
  34. 281 0
      resources/views/app/patient/segment-templates/sigma_history_past_medical/edit.blade.php
  35. 130 0
      resources/views/app/patient/segment-templates/sigma_history_past_medical/summary.blade.php
  36. 239 0
      resources/views/app/patient/segment-templates/sigma_history_social/edit.blade.php
  37. 89 0
      resources/views/app/patient/segment-templates/sigma_history_social/log.blade.php
  38. 94 0
      resources/views/app/patient/segment-templates/sigma_history_social/summary.blade.php
  39. 239 0
      resources/views/app/patient/segment-templates/sigma_history_surgical/edit.blade.php
  40. 88 0
      resources/views/app/patient/segment-templates/sigma_history_surgical/log.blade.php
  41. 91 0
      resources/views/app/patient/segment-templates/sigma_history_surgical/summary.blade.php
  42. 50 0
      resources/views/app/patient/segment-templates/sigma_informed_consent/edit.blade.php
  43. 38 0
      resources/views/app/patient/segment-templates/sigma_informed_consent/summary.blade.php
  44. 24 0
      resources/views/app/patient/segment-templates/sigma_medications/active-linear-summary.blade.php
  45. 0 0
      resources/views/app/patient/segment-templates/sigma_medications/edit.blade.php
  46. 65 0
      resources/views/app/patient/segment-templates/sigma_medications/summary.blade.php
  47. 4 0
      resources/views/app/patient/segment-templates/sigma_objective_free_text/edit.blade.php
  48. 3 0
      resources/views/app/patient/segment-templates/sigma_objective_free_text/summary.blade.php
  49. 114 0
      resources/views/app/patient/segment-templates/sigma_objective_system/edit.blade.php
  50. 37 0
      resources/views/app/patient/segment-templates/sigma_objective_system/summary.blade.php
  51. 0 0
      resources/views/app/patient/segment-templates/sigma_plan_allergies/edit.blade.php
  52. 80 0
      resources/views/app/patient/segment-templates/sigma_plan_allergies/summary.blade.php
  53. 0 0
      resources/views/app/patient/segment-templates/sigma_plan_care_team/edit.blade.php
  54. 75 0
      resources/views/app/patient/segment-templates/sigma_plan_care_team/summary.blade.php
  55. 4 0
      resources/views/app/patient/segment-templates/sigma_plan_free_text/edit.blade.php
  56. 3 0
      resources/views/app/patient/segment-templates/sigma_plan_free_text/summary.blade.php
  57. 0 0
      resources/views/app/patient/segment-templates/sigma_plan_goals/edit.blade.php
  58. 70 0
      resources/views/app/patient/segment-templates/sigma_plan_goals/summary.blade.php
  59. 0 0
      resources/views/app/patient/segment-templates/sigma_plan_medications/edit.blade.php
  60. 76 0
      resources/views/app/patient/segment-templates/sigma_plan_medications/summary.blade.php
  61. 0 0
      resources/views/app/patient/segment-templates/sigma_plan_problems/edit.blade.php
  62. 71 0
      resources/views/app/patient/segment-templates/sigma_plan_problems/summary.blade.php
  63. 0 0
      resources/views/app/patient/segment-templates/sigma_plan_system/edit.blade.php
  64. 74 0
      resources/views/app/patient/segment-templates/sigma_plan_system/summary.blade.php
  65. 0 0
      resources/views/app/patient/segment-templates/sigma_problems/edit.blade.php
  66. 60 0
      resources/views/app/patient/segment-templates/sigma_problems/summary.blade.php
  67. 416 0
      resources/views/app/patient/segment-templates/sigma_ros/edit.blade.php
  68. 261 0
      resources/views/app/patient/segment-templates/sigma_ros/log.blade.php
  69. 254 0
      resources/views/app/patient/segment-templates/sigma_ros/summary.blade.php
  70. 4 0
      resources/views/app/patient/segment-templates/sigma_subjective_free_text/edit.blade.php
  71. 3 0
      resources/views/app/patient/segment-templates/sigma_subjective_free_text/summary.blade.php
  72. 0 0
      resources/views/app/patient/segment-templates/sigma_subjective_system/edit.blade.php
  73. 156 0
      resources/views/app/patient/segment-templates/sigma_subjective_system/summary.blade.php
  74. 288 0
      resources/views/app/patient/segment-templates/sigma_typical_day_lifestyle/edit.blade.php
  75. 73 0
      resources/views/app/patient/segment-templates/sigma_typical_day_lifestyle/log.blade.php
  76. 98 0
      resources/views/app/patient/segment-templates/sigma_typical_day_lifestyle/summary.blade.php
  77. 327 0
      resources/views/app/patient/segment-templates/sigma_vitals/edit.blade.php
  78. 101 0
      resources/views/app/patient/segment-templates/sigma_vitals/summary.blade.php
  79. 1 1
      resources/views/app/practice-management/process-notes.blade.php
  80. 1 1
      resources/views/layouts/confirm-hours-of-availability-notification.blade.php
  81. 1 1
      resources/views/layouts/no-mc-template.blade.php
  82. 2 6
      resources/views/layouts/patient-header.blade.php
  83. 1 1
      resources/views/layouts/template-no-mc.blade.php
  84. 1 1
      resources/views/layouts/template.blade.php

+ 1 - 0
app/Http/Controllers/PracticeManagementController.php

@@ -2022,6 +2022,7 @@ SELECT claim.uid AS uid,
        note.method,
        note.new_or_fu_or_na,
        care_month.uid AS care_month_uid,
+       care_month.start_date as care_month_start__date, 
        -- claim.status_updated_at,
        (DATE(claim.status_updated_at) || ' ' ||
             LPAD(EXTRACT(hour FROM claim.status_updated_at)::text, 2, '0') || ':' ||

+ 4 - 0
public/css/style.css

@@ -3437,3 +3437,7 @@ body.forced-masking #mask {
 .mcp-theme-1 .point-table [if-read-mode] .inline-html-container {
     cursor: pointer;
 }
+table.v-top td, 
+table.v-top th {
+    vertical-align:top;
+}

+ 48 - 47
resources/views/app/patient/care-month/put-rm-reasons.blade.php

@@ -1,54 +1,55 @@
-<div moe>
+<div moe relative>
 	<a start show><i class="fas fa-edit"></i></a>
-	<form url="/api/careMonth/putRmReasons" class="mcp-theme-1">
+	<form url="/api/careMonth/putRmReasons" class="mcp-theme-1" right>
 		<input type="hidden" name="uid" value="{{$careMonth->uid}}">
-		<div class="bg-light p-3 mb-2">
-			<div class="mb-2">
-				<label class="text-sm mb-1 text-secondary">RM Reason Icd 1</label>
-				<input type="text" class="form-control form-control-sm" icd-autocomplete-code data-target="input[name=rmReasonIcd1Description]" name="rmReasonIcd1" value="{{ $careMonth->rm_reason_icd1 }}" />
-			</div>
-			<div class="mb-2">
-				<label class="text-sm mb-1 text-secondary">RM Reason Icd 1 Description</label>
-				<input id="" type="text" class="form-control form-control-sm" icd-autocomplete-description name="rmReasonIcd1Description" value="{{ $careMonth->rm_reason_icd1description }}">
-			</div>
-		</div>
-
-		<div class="bg-light p-3 mb-2">
-			<div class="mb-2">
-				<label class="text-sm mb-1 text-secondary">RM Reason Icd 2</label>
-				<input type="text" class="form-control form-control-sm" icd-autocomplete-code name="rmReasonIcd2" data-target="input[name=rmReasonIcd2Description]" value="{{ $careMonth->rm_reason_icd2 }}" />
-			</div>
-			<div class="mb-2">
-				<label class="text-sm mb-1 text-secondary">RM Reason Icd 2 Description</label>
-				<input type="text" class="form-control form-control-sm" icd-autocomplete-description name="rmReasonIcd2Description" value="{{ $careMonth->rm_reason_icd2description }}">
-			</div>
+		<div>
+			<table class="table table-sm table-bordered">
+				<thead class="bg-light">
+					<tr>
+						<th class="border-bottom-0">ICD</th>
+						<th class="border-bottom-0">Description</th>
+					</tr>
+				</thead>
+				<tbody>
+					<tr>
+						<td>
+							<input type="text" class="form-control form-control-sm" icd-autocomplete-code data-target="input[name=rmReasonIcd1Description]" name="rmReasonIcd1" value="{{ $careMonth->rm_reason_icd1 }}" placeholder="ICD 1" />
+						</td>
+						<td>
+							<input id="" type="text" class="form-control form-control-sm" icd-autocomplete-description name="rmReasonIcd1Description" value="{{ $careMonth->rm_reason_icd1description }}">
+						</td>
+					</tr>
+					<tr>
+						<td>
+							<input type="text" class="form-control form-control-sm" icd-autocomplete-code name="rmReasonIcd2" data-target="input[name=rmReasonIcd2Description]" value="{{ $careMonth->rm_reason_icd2 }}" placeholder="ICD 2" />
+						</td>
+						<td>
+							<input type="text" class="form-control form-control-sm" icd-autocomplete-description name="rmReasonIcd2Description" value="{{ $careMonth->rm_reason_icd2description }}">
+						</td>
+					</tr>
+					<tr>
+						<td>
+							<input type="text" class="form-control form-control-sm" icd-autocomplete-code name="rmReasonIcd3" data-target="input[name=rmReasonIcd3Description]" value="{{ $careMonth->rm_reason_icd3 }}" placeholder="ICD 3" />
+						</td>
+						<td>
+							<input type="text" class="form-control form-control-sm" icd-autocomplete-description name="rmReasonIcd3Description" value="{{ $careMonth->rm_reason_icd3description }}">
+						</td>
+					</tr>
+					<tr>
+						<td>
+							<input type="text" class="form-control form-control-sm" icd-autocomplete-code name="rmReasonIcd4" data-target="input[name=rmReasonIcd4Description]" value="{{ $careMonth->rm_reason_icd4 }}" />
+						</td>
+						<td>
+							<input type="text" class="form-control form-control-sm" icd-autocomplete-description name="rmReasonIcd4Description" value="{{ $careMonth->rm_reason_icd4description }}">
+						</td>
+					</tr>
+				</tbody>
+			</table>
 		</div>
 
-		<div class="bg-light p-3 mb-2">
-			<div class="mb-2">
-				<label class="text-sm mb-1 text-secondary">RM Reason Icd 3</label>
-				<input type="text" class="form-control form-control-sm" icd-autocomplete-code name="rmReasonIcd3" data-target="input[name=rmReasonIcd3Description]" value="{{ $careMonth->rm_reason_icd3 }}" />
-			</div>
-			<div class="mb-2">
-				<label class="text-sm mb-1 text-secondary">RM Reason Icd 3 Description</label>
-				<input type="text" class="form-control form-control-sm" icd-autocomplete-description name="rmReasonIcd3Description" value="{{ $careMonth->rm_reason_icd3description }}">
-			</div>
-		</div>
-		<div class="bg-light p-3 mb-2">
-			<div class="mb-2">
-				<label class="text-sm mb-1 text-secondary">RM Reason Icd 4</label>
-				<input type="text" class="form-control form-control-sm" icd-autocomplete-code name="rmReasonIcd4" data-target="input[name=rmReasonIcd4Description]" value="{{ $careMonth->rm_reason_icd4 }}" />
-			</div>
-			<div class="mb-2">
-				<label class="text-sm mb-1 text-secondary">RM Reason Icd 4 Description</label>
-				<input type="text" class="form-control form-control-sm" icd-autocomplete-description name="rmReasonIcd4Description" value="{{ $careMonth->rm_reason_icd4description }}">
-			</div>
-		</div>
-		<div class="bg-light p-3 mb-2">
-			<div class="mb-2">
-				<label class="text-sm mb-1 text-secondary">RM Reason Memo</label>
-				<input type="text" class="form-control form-control-sm" name="rmReasonMemo" value="{{ $careMonth->rm_reason_memo }}">
-			</div>
+		<div class="mb-3">
+			<label class="font-weight-bold">RM Reason Memo</label>
+			<input type="text" class="form-control form-control-sm" name="rmReasonMemo" value="{{ $careMonth->rm_reason_memo }}">
 		</div>
 		<div>
 			<button submit class="btn btn-sm btn-primary mr-1">Submit</button>

+ 13 - 13
resources/views/app/patient/care-month/rm-reasons.blade.php

@@ -8,42 +8,42 @@
             <tr>
                 <td class="text-nowrap">RM Reason Icd 1</td>
                 <td>
-                    <div class="d-flex flex-column">
-                        <span class="font-weight-bold">{{ $careMonth->rm_reason_icd1 }}</span>
-                        <small class="text-muted">{{ $careMonth->rm_reason_icd1description }}</small>
+                    <div class="d-flex">
+                        <span class="font-weight-bold text-sm mr-2" style="min-width:60px;">{{ $careMonth->rm_reason_icd1 ? $careMonth->rm_reason_icd1 . ':' : '' }}</span>
+                        <small class="text-muted text-sm">{{ $careMonth->rm_reason_icd1description }}</small>
                     </div>
                 </td>
             </tr>
             <tr>
                 <td class="text-nowrap">RM Reason Icd 2</td>
                 <td>
-                    <div class="d-flex flex-column">
-                        <span class="font-weight-bold">{{ $careMonth->rm_reason_icd2 }}</span>
-                        <small class="text-muted">{{ $careMonth->rm_reason_icd2description }}</small>
+                    <div class="d-flex">
+                        <span class="font-weight-bold text-sm mr-2" style="min-width:60px;">{{ $careMonth->rm_reason_icd2 ? $careMonth->rm_reason_icd2 . ':' :'' }}</span>
+                        <small class="text-muted text-sm">{{ $careMonth->rm_reason_icd2description }}</small>
                     </div>
                 </td>
             </tr>
             <tr>
                 <td class="text-nowrap">RM Reason Icd 3</td>
                 <td>
-                    <div class="d-flex flex-column">
-                        <span class="font-weight-bold">{{ $careMonth->rm_reason_icd3 }}</span>
-                        <small class="text-muted">{{ $careMonth->rm_reason_icd3description }}</small>
+                    <div class="d-flex">
+                        <span class="font-weight-bold text-sm mr-2" style="min-width:60px;">{{ $careMonth->rm_reason_icd3 ? $careMonth->rm_reason_icd3 . ':' : '' }}</span>
+                        <small class="text-muted text-sm">{{ $careMonth->rm_reason_icd3description }}</small>
                     </div>
                 </td>
             </tr>
             <tr>
                 <td class="text-nowrap">RM Reason Icd 4</td>
                 <td>
-                    <div class="d-flex flex-column">
-                        <span class="font-weight-bold">{{ $careMonth->rm_reason_icd4 }}</span>
-                        <small class="text-muted">{{ $careMonth->rm_reason_icd4description }}</small>
+                    <div class="d-flex">
+                        <span class="font-weight-bold text-sm mr-2" style="min-width:60px;">{{ $careMonth->rm_reason_icd4 ? $careMonth->rm_reason_icd4 . ':' : '' }}</span>
+                        <small class="text-muted text-sm">{{ $careMonth->rm_reason_icd4description }}</small>
                     </div>
                 </td>
             </tr>
             <tr>
                 <td class="text-nowrap">RM Reason Memo</td>
-                <td>{{ $careMonth->rm_reason_memo }}</td>
+                <td class="text-muted text-sm">{{ $careMonth->rm_reason_memo }}</td>
             </tr>
         </tbody>
     </table>

+ 1 - 1
resources/views/app/patient/note/_OLD_segment.blade.php

@@ -68,7 +68,7 @@
             <a class="ml-3 font-weight-normal refresh-segment c-pointer {{$iName === 'medrisk_vigilence' ? 'on-hover-only' : ''}}"
                data-segment-uid="{{$segment->uid}}"
                title="Update with latest patient data">
-                <i class="fa fa-sync"></i>
+                <i class="fa fa-sync on-hover-opaque"></i>
             </a>
 
             <!-- if intake - link to plan segment-->

+ 12 - 12
resources/views/app/patient/note/dashboard.blade.php

@@ -809,6 +809,14 @@ use App\Models\Handout;
                     @include('app.patient.handouts-list', compact('patient', 'clientHandouts', 'handouts', 'note'))
                 </div>
 
+                @if($pro->pro_type === 'ADMIN' && $note->hcpPro)
+                <div class="p-3 border-bottom mt-2 screen-only">
+                    <div class="">
+                        @include('app/patient/partials/company-pro-documents')
+                    </div>
+                </div>
+                @endif
+
                 <div class="p-3 border-bottom screen-only" data-non-segment-section="Prescriptions">
                     @include('app.patient.prescriptions.list', compact('patient', 'note'))
                 </div>
@@ -1070,16 +1078,16 @@ use App\Models\Handout;
                     </script>
                 </div>
 
-                <div class="p-3 border-bottom" data-non-segment-section="ICDs">
-                    <div class="">
-                        <div class="d-flex align-items-center mb-2">
+                <div class="p-2 border-bottom" data-non-segment-section="ICDs">
+                    <div class="d-flex alignt-items-start">
+                        <div class="d-flex {{ count($note->reasons) > 2 ? '':'align-items-center' }} mr-2">
                             <p class="font-weight-bold text-secondary m-0 mr-2">ICDs</p>
                             @include('app/patient/note/_create-note-reason')
                         </div>
                         <div class="d-flex align-items-start flex-wrap">
                         @if(count($note->reasons))
                              @foreach ($note->reasons as $reason)
-                                <span class="badge badge-info p-2 mb-2 mr-2">
+                                <span class="badge badge-info p-2 mb-1 mr-2">
                                     {{ $reason->description}} ({{ $reason->code }})
                                 </span>
                             @endforeach
@@ -2454,14 +2462,6 @@ use App\Models\Handout;
                     @include('app/patient/note/_cancel-signed-note')
                 </div>
 
-                @if($pro->pro_type === 'ADMIN' && $note->hcpPro)
-                <div class="screen-only">
-                    <div class="border-top p3">
-                        @include('app/patient/partials/company-pro-documents')
-                    </div>
-                </div>
-                @endif
-
                 </div>
 
                 @if($isVisitTemplateBased && !$note->is_signed_by_hcp)

+ 348 - 313
resources/views/app/patient/note/rm-setup.blade.php

@@ -1,166 +1,188 @@
 <div class="row" id="rm-setup">
     <div class="col-6">
         @if($pro->pro_type === 'ADMIN')
-            <div class="d-flex align-items-baseline mb-3">
-                <span class="min-width-140px">Is Eligible for RM?</span>
-                <div class="">
-                    <div class="d-inline-flex align-items-start">
-                        <b>{{ ucwords($patient->is_eligible_for_rm ? $patient->is_eligible_for_rm : '-') }}</b>
-                        <div moe class="ml-2">
-                            <a start show><i class="fa fa-edit"></i></a>
-                            <form url="/api/client/updateRmEligibility" class="mcp-theme-1">
-                                <input type="hidden" name="uid" value="{{$patient->uid}}">
-                                <div class="mb-2">
-                                    <label class="text-sm mb-1 text-secondary">Is Eligible?</label>
-                                    <select name="isEligibleForRm"
-                                            class="form-control form-control-sm"
-                                            onchange="toggleDisabledAsNeeded(this, 'NO', 'not-eligible-for-rm')">
-                                        <option value="">-- Select Status --</option>
-                                        <option value="YES" {{ $patient->is_eligible_for_rm === 'YES' ? 'selected' : '' }}>YES</option>
-                                        <option value="NO" {{ $patient->is_eligible_for_rm === 'NO' ? 'selected' : '' }}>NO</option>
-                                        <option value="UNKNOWN" {{ $patient->is_eligible_for_rm === 'UNKNOWN' ? 'selected' : '' }}>UNKNOWN</option>
-                                    </select>
-                                </div>
-                                <div class="mb-2">
-                                    <label class="text-sm mb-1 text-secondary">Why not eligible category</label>
-                                    <input type="text" class="not-eligible-for-rm form-control form-control-sm"
-                                           {{$patient->is_eligible_for_rm === 'NO' ? '' : 'disabled' }}
-                                           name="whyNotEligibleForRmCategory" value="{{$patient->why_not_eligible_for_rm_category}}">
-                                </div>
-                                <div class="mb-2">
-                                    <label class="text-sm mb-1 text-secondary">Why not eligible memo</label>
-                                    <input type="text" class="not-eligible-for-rm form-control form-control-sm"
-                                           {{$patient->is_eligible_for_rm === 'NO' ? '' : 'disabled' }}
-                                           name="whyNotEligibleForRmMemo" value="{{$patient->why_not_eligible_for_rm_memo}}">
-                                </div>
-                                <div>
-                                    <button submit class="btn btn-sm btn-primary mr-1">Submit</button>
-                                    <button cancel class="btn btn-sm btn-default border">Cancel</button>
+            <div>
+                <table class="table table-sm table-striped table-bordered mb-1">
+                    <tr>
+                        <td>Is Eligible for RM?</td>
+                        <td>
+                            <div class="">
+                                <div class="d-inline-flex align-items-start">
+                                    <b>{{ ucwords($patient->is_eligible_for_rm ? $patient->is_eligible_for_rm : '-') }}</b>
+                                    <div moe class="ml-2">
+                                        <a start show><i class="fa fa-edit on-hover-opaque"></i></a>
+                                        <form url="/api/client/updateRmEligibility" class="mcp-theme-1">
+                                            <input type="hidden" name="uid" value="{{$patient->uid}}">
+                                            <div class="mb-2">
+                                                <label class="text-sm mb-1 text-secondary">Is Eligible?</label>
+                                                <select name="isEligibleForRm"
+                                                        class="form-control form-control-sm"
+                                                        onchange="toggleDisabledAsNeeded(this, 'NO', 'not-eligible-for-rm')">
+                                                    <option value="">-- Select Status --</option>
+                                                    <option value="YES" {{ $patient->is_eligible_for_rm === 'YES' ? 'selected' : '' }}>YES</option>
+                                                    <option value="NO" {{ $patient->is_eligible_for_rm === 'NO' ? 'selected' : '' }}>NO</option>
+                                                    <option value="UNKNOWN" {{ $patient->is_eligible_for_rm === 'UNKNOWN' ? 'selected' : '' }}>UNKNOWN</option>
+                                                </select>
+                                            </div>
+                                            <div class="mb-2">
+                                                <label class="text-sm mb-1 text-secondary">Why not eligible category</label>
+                                                <input type="text" class="not-eligible-for-rm form-control form-control-sm"
+                                                    {{$patient->is_eligible_for_rm === 'NO' ? '' : 'disabled' }}
+                                                    name="whyNotEligibleForRmCategory" value="{{$patient->why_not_eligible_for_rm_category}}">
+                                            </div>
+                                            <div class="mb-2">
+                                                <label class="text-sm mb-1 text-secondary">Why not eligible memo</label>
+                                                <input type="text" class="not-eligible-for-rm form-control form-control-sm"
+                                                    {{$patient->is_eligible_for_rm === 'NO' ? '' : 'disabled' }}
+                                                    name="whyNotEligibleForRmMemo" value="{{$patient->why_not_eligible_for_rm_memo}}">
+                                            </div>
+                                            <div>
+                                                <button submit class="btn btn-sm btn-primary mr-1">Submit</button>
+                                                <button cancel class="btn btn-sm btn-default border">Cancel</button>
+                                            </div>
+                                        </form>
+                                    </div>
                                 </div>
-                            </form>
-                        </div>
-                    </div>
-                    @if($patient->is_eligible_for_rm === 'NO')
-                        <div class="mt-1">
-                            <span>{{$patient->why_not_eligible_for_rm_category ?: '-'}}</span>
-                            /
-                            <span class="text-secondary">{{$patient->why_not_eligible_for_rm_memo ?: '-'}}</span>
-                        </div>
-                    @endif
-                </div>
-            </div>
-        @endif
-
-        <?php $currentCareMonth = $patient->currentCareMonth(); ?>
-        @if($currentCareMonth && $pro->id === $currentCareMonth->mcp_pro_id)
-            <div class="d-flex align-items-baseline mb-3">
-                <?php $spoken = $currentCareMonth->has_anyone_interacted_with_client_about_rm_outside_note; ?>
-                <span class="min-width-140px">Comm. this month:</span>
-                <b class="{{$spoken ? 'text-success' : ''}}">
-                    {{$spoken ? 'Yes' : 'No'}}
-                    @if(!$spoken)
-                        <i class="fa fa-exclamation-triangle"></i>
-                    @else
-                        <i class="fa fa-check"></i>
+                                @if($patient->is_eligible_for_rm === 'NO')
+                                    <div class="mt-1">
+                                        <span>{{$patient->why_not_eligible_for_rm_category ?: '-'}}</span>
+                                        /
+                                        <span class="text-secondary">{{$patient->why_not_eligible_for_rm_memo ?: '-'}}</span>
+                                    </div>
+                                @endif
+                            </div>
+                        </td>
+                    </tr>
+                    <?php $currentCareMonth = $patient->currentCareMonth(); ?>
+                    @if($currentCareMonth && $pro->id === $currentCareMonth->mcp_pro_id)
+                    <?php $spoken = $currentCareMonth->has_anyone_interacted_with_client_about_rm_outside_note; ?>
+                        <tr>
+                            <td>
+                            Comm. this month:
+                            </td>
+                            <td>
+                                <b class="{{$spoken ? 'text-success' : ''}}">
+                                    {{$spoken ? 'Yes' : 'No'}}
+                                    @if(!$spoken)
+                                        <i class="fa fa-exclamation-triangle"></i>
+                                    @else
+                                        <i class="fa fa-check"></i>
+                                    @endif
+                                </b>
+                                @if($currentCareMonth->mcp && $pro->id === $currentCareMonth->mcp->id)
+                                    <div moe relative class="ml-2">
+                                        <a href="#" start show class="">Toggle</a>
+                                        <form url="/api/careMonth/setHasAnyoneInteractedWithClientAboutRmOutsideNoteTo{{$spoken ? 'False' : 'True'}}" right>
+                                            <input type="hidden" name="uid" value="{{$currentCareMonth->uid}}">
+                                            <p>Set to {{$spoken ? 'No' : 'Yes'}}?</p>
+                                            <div class="d-flex align-items-center">
+                                                <button class="btn btn-sm btn-primary mr-2" submit>Save</button>
+                                                <button class="btn btn-sm btn-default mr-2 border" cancel>Cancel</button>
+                                            </div>
+                                        </form>
+                                    </div>
+                                @endif
+                            </td>
+                        </tr>
                     @endif
-                </b>
-                @if($currentCareMonth->mcp && $pro->id === $currentCareMonth->mcp->id)
-                    <div moe relative class="ml-2">
-                        <a href="#" start show class="">Toggle</a>
-                        <form url="/api/careMonth/setHasAnyoneInteractedWithClientAboutRmOutsideNoteTo{{$spoken ? 'False' : 'True'}}" right>
-                            <input type="hidden" name="uid" value="{{$currentCareMonth->uid}}">
-                            <p>Set to {{$spoken ? 'No' : 'Yes'}}?</p>
-                            <div class="d-flex align-items-center">
-                                <button class="btn btn-sm btn-primary mr-2" submit>Save</button>
-                                <button class="btn btn-sm btn-default mr-2 border" cancel>Cancel</button>
+                    <tr>
+                        <td>Enrollment:</td>
+                        <td>
+                            <div class="">
+                                <div class="d-inline-flex align-items-start">
+                                    <b>{{ ucwords($patient->is_enrolled_in_rm ? $patient->is_enrolled_in_rm : '-') }}</b>
+                                    @if($patient->is_enrolled_in_rm === 'YES')
+                                        <div moe class="ml-2">
+                                            <a start show>Toggle</a>
+                                            <form url="/api/client/setIsEnrolledInRmToFalse" class="mcp-theme-1">
+                                                <input type="hidden" name="uid" value="{{$patient->uid}}">
+                                                <p>Un-enroll from RPM?</p>
+                                                <div>
+                                                    <button submit class="btn btn-sm btn-primary mr-1">Submit</button>
+                                                    <button cancel class="btn btn-sm btn-default border">Cancel</button>
+                                                </div>
+                                            </form>
+                                        </div>
+                                    @else
+                                        <a native target="_blank"
+                                        class="screen-only ml-2"
+                                        open-in-stag-popup
+                                        popup-style="medium overflow-visible"
+                                        mc-initer="rpm-agreement-{{$note->id}}"
+                                        title="Leadership Health Remote Patient Monitoring Consent Form"
+                                        href="/note/rpm-agreement/{{$note->uid}}?popupmode=1">
+                                            Mark as enrolled
+                                        </a>
+                                    @endif
+                                </div>
                             </div>
-                        </form>
-                    </div>
-                @endif
-            </div>
+                        </td>
+                    </tr>
+                </table>
+            </div> 
         @endif
+        
 
         <div class="d-flex align-items-baseline mb-3">
-            <span class="min-width-140px">Enrollment:</span>
-            <div class="">
-                <div class="d-inline-flex align-items-start">
-                    <b>{{ ucwords($patient->is_enrolled_in_rm ? $patient->is_enrolled_in_rm : '-') }}</b>
-                    @if($patient->is_enrolled_in_rm === 'YES')
-                        <div moe class="ml-2">
-                            <a start show>Toggle</a>
-                            <form url="/api/client/setIsEnrolledInRmToFalse" class="mcp-theme-1">
-                                <input type="hidden" name="uid" value="{{$patient->uid}}">
-                                <p>Un-enroll from RPM?</p>
-                                <div>
-                                    <button submit class="btn btn-sm btn-primary mr-1">Submit</button>
-                                    <button cancel class="btn btn-sm btn-default border">Cancel</button>
+            <div class="flex-grow-1">
+                <div>
+                    <div class="d-flex align-items-center mb-1">
+                        <span class="mr-2">RM Reasons:</span>
+                        @include('app.patient.partials.put-rm-reasons')
+                    </div>
+                    <div class="">
+                        @include('app.patient.partials.rm-reasons-display')
+                    </div>
+                </div>
+                {{--<div>
+                    @if(!$patient->rmReasons || !count($patient->rmReasons))
+                        <span class="text-secondary">None</span>
+                    @else
+                        <div>
+                            @foreach($patient->rmReasons as $reason)
+                                <div class="border-bottom pb-1 mb-1 d-flex align-items-start">
+                                    <b class="min-width-70px">{{$reason->code}}</b>
+                                    <span class="max-width-200px mr-3">{{$reason->description}}</span>
+                                    <div moe relative class="ml-auto">
+                                        <a start show><i class="fa fa-edit on-hover-opaque"></i></a>
+                                        <form url="/api/clientCmRmReason/updateBasic" class="mcp-theme-1" right target='[data-non-segment-section="RM Setup"]'>
+                                            <input type="hidden" name="uid" value="{{$reason->uid}}">
+                                            <div class="mb-2">
+                                                <label class="text-sm mb-1 text-secondary">Code *</label>
+                                                <input type="text" class="form-control form-control-sm"
+                                                    icd-autocomplete-code
+                                                    name="code" value="{{$reason->code}}" required>
+                                            </div>
+                                            <div class="mb-2">
+                                                <label class="text-sm mb-1 text-secondary">Description</label>
+                                                <input type="text" class="form-control form-control-sm"
+                                                    icd-autocomplete-description
+                                                    name="description" value="{{$reason->description}}">
+                                            </div>
+                                            <div>
+                                                <button submit class="btn btn-sm btn-primary mr-1">Submit</button>
+                                                <button cancel class="btn btn-sm btn-default border">Cancel</button>
+                                            </div>
+                                        </form>
+                                    </div>
+                                    <div moe relative class="ml-2">
+                                        <a start show><i class="fa fa-trash-alt text-danger on-hover-opaque"></i></a>
+                                        <form url="/api/clientCmRmReason/remove" class="mcp-theme-1" right target='[data-non-segment-section="RM Setup"]'>
+                                            <input type="hidden" name="uid" value="{{$reason->uid}}">
+                                            <p>Remove this RM reason?</p>
+                                            <div>
+                                                <button submit class="btn btn-sm btn-primary mr-1">Submit</button>
+                                                <button cancel class="btn btn-sm btn-default border">Cancel</button>
+                                            </div>
+                                        </form>
+                                    </div>
                                 </div>
-                            </form>
+                            @endforeach
                         </div>
-                    @else
-                        <a native target="_blank"
-                           class="screen-only ml-2"
-                           open-in-stag-popup
-                           popup-style="medium overflow-visible"
-                           mc-initer="rpm-agreement-{{$note->id}}"
-                           title="Leadership Health Remote Patient Monitoring Consent Form"
-                           href="/note/rpm-agreement/{{$note->uid}}?popupmode=1">
-                            Mark as enrolled
-                        </a>
                     @endif
-                </div>
-            </div>
-        </div>
+                </div>--}}
 
-        <div class="d-flex align-items-baseline mb-3">
-            <span class="min-width-140px">Reasons:</span>
-            <div class="flex-grow-1">
-                @if(!$patient->rmReasons || !count($patient->rmReasons))
-                    <span class="text-secondary">None</span>
-                @else
-                    <div>
-                        @foreach($patient->rmReasons as $reason)
-                            <div class="border-bottom pb-1 mb-1 d-flex align-items-start">
-                                <b class="min-width-70px">{{$reason->code}}</b>
-                                <span class="max-width-200px mr-3">{{$reason->description}}</span>
-                                <div moe relative class="ml-auto">
-                                    <a start show><i class="fa fa-edit"></i></a>
-                                    <form url="/api/clientCmRmReason/updateBasic" class="mcp-theme-1" right target='[data-non-segment-section="RM Setup"]'>
-                                        <input type="hidden" name="uid" value="{{$reason->uid}}">
-                                        <div class="mb-2">
-                                            <label class="text-sm mb-1 text-secondary">Code *</label>
-                                            <input type="text" class="form-control form-control-sm"
-                                                   icd-autocomplete-code
-                                                   name="code" value="{{$reason->code}}" required>
-                                        </div>
-                                        <div class="mb-2">
-                                            <label class="text-sm mb-1 text-secondary">Description</label>
-                                            <input type="text" class="form-control form-control-sm"
-                                                   icd-autocomplete-description
-                                                   name="description" value="{{$reason->description}}">
-                                        </div>
-                                        <div>
-                                            <button submit class="btn btn-sm btn-primary mr-1">Submit</button>
-                                            <button cancel class="btn btn-sm btn-default border">Cancel</button>
-                                        </div>
-                                    </form>
-                                </div>
-                                <div moe relative class="ml-2">
-                                    <a start show><i class="fa fa-trash-alt text-danger on-hover-opaque"></i></a>
-                                    <form url="/api/clientCmRmReason/remove" class="mcp-theme-1" right target='[data-non-segment-section="RM Setup"]'>
-                                        <input type="hidden" name="uid" value="{{$reason->uid}}">
-                                        <p>Remove this RM reason?</p>
-                                        <div>
-                                            <button submit class="btn btn-sm btn-primary mr-1">Submit</button>
-                                            <button cancel class="btn btn-sm btn-default border">Cancel</button>
-                                        </div>
-                                    </form>
-                                </div>
-                            </div>
-                        @endforeach
-                    </div>
-                @endif
-                <div class="d-flex align-items-baseline">
+                {{--<div class="d-flex align-items-baseline">
                     <div moe>
                         <a start show>+ Add From Dx</a>
                         <form url="/api/clientCmRmReason/create" class="mcp-theme-1" target='[data-non-segment-section="RM Setup"]'>
@@ -210,180 +232,193 @@
                             </div>
                         </form>
                     </div>
-                </div>
+                </div>--}}
             </div>
         </div>
-
-        <div class="mb-3 d-flex align-items-baseline">
-            <span class="min-width-140px">Care Plan:</span>
-            <div class="width-300px d-inline-flex align-items-center">
-                @if($patient->has_cm_setup_been_performed)
-                    <div class="text-nowrap text-success">
-                        @if($patient->cm_setup_note_id === $note->id)
-                            <i class="fa fa-check"></i>
-                            <b>Created on this note</b>
-                        @elseif($patient->cmSetupNote)
-                            <i class="fa fa-check"></i>
-                            <b>Created on</b>
-                            <div class="d-inline position-relative on-click-menu">
-                                <span class="text-primary c-pointer">{{friendly_date($patient->cmSetupNote->effective_dateest)}}</span>
-                                <div menu right class="bg-white border">
-                                    <a native target="_blank"
-                                       href="<?= route('patients.view.notes.view.dashboard', ['patient' => $patient, 'note' => $patient->cmSetupNote]) ?>"
-                                       class="px-2 py-1 d-block text-nowrap text-sm">Go to note</a>
-                                </div>
-                            </div>
-                        @else
-                            <i class="fa fa-exclamation-triangle text-warning-mellow"></i>
-                            <b class="text-warning-mellow">Performed, but CM setup note missing!</b> <!-- will never reach this point -->
-                        @endif
-                    </div>
-                    @if($patient->mcp_pro_id === $pro->id || $pro->pro_type === 'ADMIN')
-                        <div moe class="ml-3">
-                            <a href="" show start>Undo</a>
-                            <form url="/api/note/undoMarkCmSetupPerformed" >
-                                <input type="hidden" name="uid" value="{{$note->uid}}">
-                                <p>Mark Comprehensive Care Plan as not created?</p>
-                                <div class="mb-0">
-                                    <button class="btn btn-primary btn-sm" submit>Submit</button>
-                                    <button class="btn btn-default border btn-sm" cancel>Cancel</button>
+        <div class="mb-3">
+            <table class="table-sm table-striped table-bordered w-100 v-top">
+                <tr>
+                    <td>Care Plan:</td>
+                    <td>
+                        <div class="d-inline-flex align-items-center">
+                            @if($patient->has_cm_setup_been_performed)
+                                <div class="text-nowrap text-success">
+                                    @if($patient->cm_setup_note_id === $note->id)
+                                        <i class="fa fa-check"></i>
+                                        <b>Created on this note</b>
+                                    @elseif($patient->cmSetupNote)
+                                        <i class="fa fa-check"></i>
+                                        <b>Created on</b>
+                                        <div class="d-inline position-relative on-click-menu">
+                                            <span class="text-primary c-pointer">{{friendly_date($patient->cmSetupNote->effective_dateest)}}</span>
+                                            <div menu right class="bg-white border">
+                                                <a native target="_blank"
+                                                href="<?= route('patients.view.notes.view.dashboard', ['patient' => $patient, 'note' => $patient->cmSetupNote]) ?>"
+                                                class="px-2 py-1 d-block text-nowrap text-sm">Go to note</a>
+                                            </div>
+                                        </div>
+                                    @else
+                                        <i class="fa fa-exclamation-triangle text-warning-mellow"></i>
+                                        <b class="text-warning-mellow">Performed, but CM setup note missing!</b> <!-- will never reach this point -->
+                                    @endif
                                 </div>
-                            </form>
+                                @if($patient->mcp_pro_id === $pro->id || $pro->pro_type === 'ADMIN')
+                                    <div moe class="ml-3">
+                                        <a href="" show start>Undo</a>
+                                        <form url="/api/note/undoMarkCmSetupPerformed" >
+                                            <input type="hidden" name="uid" value="{{$note->uid}}">
+                                            <p>Mark Comprehensive Care Plan as not created?</p>
+                                            <div class="mb-0">
+                                                <button class="btn btn-primary btn-sm" submit>Submit</button>
+                                                <button class="btn btn-default border btn-sm" cancel>Cancel</button>
+                                            </div>
+                                        </form>
+                                    </div>
+                                @endif
+                            @else
+                                <span class="text-nowrap text-warning-mellow">
+                                    <i class="fa fa-times"></i>
+                                    <b>Not Created</b>
+                                </span>
+                                @if($patient->mcp_pro_id === $pro->id || $pro->pro_type === 'ADMIN')
+                                    <div moe class="ml-3">
+                                        <a href="#" show start>Mark as created</a>
+                                        <form url="/api/note/markCmSetupPerformed" >
+                                            <input type="hidden" name="uid" value="{{$note->uid}}">
+                                            <p>Mark Comprehensive Care Plan as created?</p>
+                                            <div class="mb-0">
+                                                <button class="btn btn-primary btn-sm" submit>Submit</button>
+                                                <button class="btn btn-default border btn-sm" cancel>Cancel</button>
+                                            </div>
+                                        </form>
+                                    </div>
+                                @endif
+                            @endif
                         </div>
-                    @endif
-                @else
-                    <span class="text-nowrap text-warning-mellow">
-                        <i class="fa fa-times"></i>
-                        <b>Not Created</b>
-                    </span>
-                    @if($patient->mcp_pro_id === $pro->id || $pro->pro_type === 'ADMIN')
-                        <div moe class="ml-3">
-                            <a href="#" show start>Mark as created</a>
-                            <form url="/api/note/markCmSetupPerformed" >
-                                <input type="hidden" name="uid" value="{{$note->uid}}">
-                                <p>Mark Comprehensive Care Plan as created?</p>
-                                <div class="mb-0">
-                                    <button class="btn btn-primary btn-sm" submit>Submit</button>
-                                    <button class="btn btn-default border btn-sm" cancel>Cancel</button>
+                        @if($pro->pro_type === 'ADMIN' && $note->was_cm_setup_performed)
+                            <div class="d-flex align-items-baseline">
+                                <div class="d-inline-flex align-items-center flex-grow-1">
+                                    <span class="pr-2">Manager Signature:</span>
+                                    @if($note->cm_setup_manager_signature_status !== 'SIGNED')
+                                        <div moe class="">
+                                            <a start show>Sign</a>
+                                            <form url="/api/note/updateCmSetupManagerSignatureStatus" class="mcp-theme-1">
+                                                <input type="hidden" name="uid" value="{{$note->uid}}">
+                                                <input type="hidden" name="managerSignatureStatus" value="SIGNED">
+                                                <p>Sign Off Care Plan Creation as Manager?</p>
+                                                <div>
+                                                    <button submit class="btn btn-sm btn-success mr-1">Sign</button>
+                                                    <button cancel class="btn btn-sm btn-default border">Cancel</button>
+                                                </div>
+                                            </form>
+                                        </div>
+                                    @else
+                                        <b>SIGNED</b>
+                                        <div moe class="ml-3">
+                                            <a start show>Undo</a>
+                                            <form url="/api/note/updateCmSetupManagerSignatureStatus" class="mcp-theme-1">
+                                                <input type="hidden" name="uid" value="{{$note->uid}}">
+                                                <input type="hidden" name="managerSignatureStatus" value="">
+                                                <p>Undo sign as manager for Care Plan Creation?</p>
+                                                <div>
+                                                    <button submit class="btn btn-sm btn-primary mr-1">Undo</button>
+                                                    <button cancel class="btn btn-sm btn-default border">Cancel</button>
+                                                </div>
+                                            </form>
+                                        </div>
+                                    @endif
                                 </div>
-                            </form>
-                        </div>
-                    @endif
-                @endif
-            </div>
+                            </div>
+                        @endif
+                    </td>
+                </tr>
+            </table>
         </div>
 
-        @if($pro->pro_type === 'ADMIN' && $note->was_cm_setup_performed)
-            <div class="d-flex align-items-baseline mb-3">
-                <span class="min-width-140px"></span>
-                <div class="d-inline-flex align-items-center flex-grow-1">
-                    <span class="pr-2">Manager Signature:</span>
-                    @if($note->cm_setup_manager_signature_status !== 'SIGNED')
-                        <div moe class="">
-                            <a start show>Sign</a>
-                            <form url="/api/note/updateCmSetupManagerSignatureStatus" class="mcp-theme-1">
-                                <input type="hidden" name="uid" value="{{$note->uid}}">
-                                <input type="hidden" name="managerSignatureStatus" value="SIGNED">
-                                <p>Sign Off Care Plan Creation as Manager?</p>
-                                <div>
-                                    <button submit class="btn btn-sm btn-success mr-1">Sign</button>
-                                    <button cancel class="btn btn-sm btn-default border">Cancel</button>
-                                </div>
-                            </form>
-                        </div>
-                    @else
-                        <b>SIGNED</b>
-                        <div moe class="ml-3">
-                            <a start show>Undo</a>
-                            <form url="/api/note/updateCmSetupManagerSignatureStatus" class="mcp-theme-1">
-                                <input type="hidden" name="uid" value="{{$note->uid}}">
-                                <input type="hidden" name="managerSignatureStatus" value="">
-                                <p>Undo sign as manager for Care Plan Creation?</p>
-                                <div>
-                                    <button submit class="btn btn-sm btn-primary mr-1">Undo</button>
-                                    <button cancel class="btn btn-sm btn-default border">Cancel</button>
-                                </div>
-                            </form>
-                        </div>
-                    @endif
-                </div>
-            </div>
-        @endif
+
 
         @if($pro->pro_type === 'ADMIN')
-            <div class="d-flex align-items-baseline mb-3">
-                <span class="min-width-140px">RME Pro:</span>
-                <div class="">
-                    <div class="d-inline-flex align-items-start">
-                        <b>{{ $patient->rme ? $patient->rme->displayName() : '-' }}</b>
-                        <div moe class="ml-2">
-                            <a start show><i class="fa fa-edit"></i></a>
-                            <form url="/api/client/putRmePro" class="mcp-theme-1">
-                                <input type="hidden" name="uid" value="{{$patient->uid}}">
-                                <div class="mb-2">
-                                    <label class="text-secondary text-sm">RME Pro</label>
-                                    <select provider-search data-pro-uid="{{ @$patient->rme->uid }}" name="rmeProUid" class="form-control form-control-sm">
-                                        <option value=""> --select--</option>
-                                    </select>
-                                </div>
-                                <div>
-                                    <button submit class="btn btn-sm btn-primary mr-1">Submit</button>
-                                    <button cancel class="btn btn-sm btn-default border">Cancel</button>
-                                </div>
-                            </form>
-                        </div>
-                        @if($patient->rme)
-                            <div moe class="ml-2">
-                                <a start show><i class="fa fa-trash-alt text-danger on-hover-opaque"></i></a>
-                                <form url="/api/client/removeRmePro" class="mcp-theme-1">
-                                    <input type="hidden" name="uid" value="{{$patient->uid}}">
-                                    <p>Remove RME Pro?</p>
-                                    <div>
-                                        <button submit class="btn btn-sm btn-primary mr-1">Submit</button>
-                                        <button cancel class="btn btn-sm btn-default border">Cancel</button>
+            <div>
+                <table class="table table-sm table-bordered table-striped">
+                    <tr>
+                        <td>RME Pro:</td>
+                        <td>
+                            <div class="">
+                                <div class="d-inline-flex align-items-start">
+                                    <b>{{ $patient->rme ? $patient->rme->displayName() : '-' }}</b>
+                                    <div moe class="ml-2">
+                                        <a start show><i class="fa fa-edit on-hover-opaque"></i></a>
+                                        <form url="/api/client/putRmePro" class="mcp-theme-1">
+                                            <input type="hidden" name="uid" value="{{$patient->uid}}">
+                                            <div class="mb-2">
+                                                <label class="text-secondary text-sm">RME Pro</label>
+                                                <select provider-search data-pro-uid="{{ @$patient->rme->uid }}" name="rmeProUid" class="form-control form-control-sm">
+                                                    <option value=""> --select--</option>
+                                                </select>
+                                            </div>
+                                            <div>
+                                                <button submit class="btn btn-sm btn-primary mr-1">Submit</button>
+                                                <button cancel class="btn btn-sm btn-default border">Cancel</button>
+                                            </div>
+                                        </form>
                                     </div>
-                                </form>
-                            </div>
-                        @endif
-                    </div>
-                </div>
-            </div>
-            <div class="d-flex align-items-baseline mb-3">
-                <span class="min-width-140px">RMM Pro:</span>
-                <div class="">
-                    <div class="d-inline-flex align-items-start">
-                        <b>{{ $patient->rmm ? $patient->rmm->displayName() : '-' }}</b>
-                        <div moe class="ml-2">
-                            <a start show><i class="fa fa-edit"></i></a>
-                            <form url="/api/client/putRmmPro" class="mcp-theme-1">
-                                <input type="hidden" name="uid" value="{{$patient->uid}}">
-                                <div class="mb-2">
-                                    <label class="text-secondary text-sm">RMM Pro</label>
-                                    <select provider-search data-pro-uid="{{ @$patient->rmm->uid }}" name="rmmProUid" class="form-control form-control-sm">
-                                        <option value=""> --select--</option>
-                                    </select>
-                                </div>
-                                <div>
-                                    <button submit class="btn btn-sm btn-primary mr-1">Submit</button>
-                                    <button cancel class="btn btn-sm btn-default border">Cancel</button>
+                                    @if($patient->rme)
+                                        <div moe class="ml-2">
+                                            <a start show><i class="fa fa-trash-alt text-danger on-hover-opaque"></i></a>
+                                            <form url="/api/client/removeRmePro" class="mcp-theme-1">
+                                                <input type="hidden" name="uid" value="{{$patient->uid}}">
+                                                <p>Remove RME Pro?</p>
+                                                <div>
+                                                    <button submit class="btn btn-sm btn-primary mr-1">Submit</button>
+                                                    <button cancel class="btn btn-sm btn-default border">Cancel</button>
+                                                </div>
+                                            </form>
+                                        </div>
+                                    @endif
                                 </div>
-                            </form>
-                        </div>
-                        @if($patient->rmm)
-                            <div moe class="ml-2">
-                                <a start show><i class="fa fa-trash-alt text-danger on-hover-opaque"></i></a>
-                                <form url="/api/client/removeRmmPro" class="mcp-theme-1">
-                                    <input type="hidden" name="uid" value="{{$patient->uid}}">
-                                    <p>Remove RMM Pro?</p>
-                                    <div>
-                                        <button submit class="btn btn-sm btn-primary mr-1">Submit</button>
-                                        <button cancel class="btn btn-sm btn-default border">Cancel</button>
+                            </div>
+                        </td>
+                    </tr>
+                    <tr>
+                        <td>RMM Pro:</td>
+                        <td>
+                            <div class="">
+                                <div class="d-inline-flex align-items-start">
+                                    <b>{{ $patient->rmm ? $patient->rmm->displayName() : '-' }}</b>
+                                    <div moe class="ml-2">
+                                        <a start show><i class="fa fa-edit on-hover-opaque"></i></a>
+                                        <form url="/api/client/putRmmPro" class="mcp-theme-1">
+                                            <input type="hidden" name="uid" value="{{$patient->uid}}">
+                                            <div class="mb-2">
+                                                <label class="text-secondary text-sm">RMM Pro</label>
+                                                <select provider-search data-pro-uid="{{ @$patient->rmm->uid }}" name="rmmProUid" class="form-control form-control-sm">
+                                                    <option value=""> --select--</option>
+                                                </select>
+                                            </div>
+                                            <div>
+                                                <button submit class="btn btn-sm btn-primary mr-1">Submit</button>
+                                                <button cancel class="btn btn-sm btn-default border">Cancel</button>
+                                            </div>
+                                        </form>
                                     </div>
-                                </form>
+                                    @if($patient->rmm)
+                                        <div moe class="ml-2">
+                                            <a start show><i class="fa fa-trash-alt text-danger on-hover-opaque"></i></a>
+                                            <form url="/api/client/removeRmmPro" class="mcp-theme-1">
+                                                <input type="hidden" name="uid" value="{{$patient->uid}}">
+                                                <p>Remove RMM Pro?</p>
+                                                <div>
+                                                    <button submit class="btn btn-sm btn-primary mr-1">Submit</button>
+                                                    <button cancel class="btn btn-sm btn-default border">Cancel</button>
+                                                </div>
+                                            </form>
+                                        </div>
+                                    @endif
+                                </div>
                             </div>
-                        @endif
-                    </div>
-                </div>
+                        </td>
+                    </tr>
+                </table>
             </div>
         @endif
     </div>
@@ -445,7 +480,7 @@
                 <div class="">
                     <div class="d-flex align-items-baseline mb-1">
                         <span class="width-200px pl-3">Arrived:</span>
-                        <span class="ml-3">Yes</span>*
+                        <span class="ml-3">Yes</span>
                     </div>
                     <div class="d-flex align-items-baseline mb-1">
                         <span class="width-200px pl-3">First Measurement:</span>
@@ -494,7 +529,7 @@
                 <div class="">
                     <div class="d-flex align-items-baseline mb-1">
                         <span class="width-200px pl-3">Arrived:</span>
-                        <span class="ml-3">Yes</span>*
+                        <span class="ml-3">Yes</span>
                     </div>
                     <div class="d-flex align-items-baseline mb-1">
                         <span class="width-200px pl-3">First Measurement:</span>

+ 1 - 1
resources/views/app/patient/note/section.blade.php

@@ -47,7 +47,7 @@ if ($latestSectionTS === 0 || $latestSectionTS < $sectionTS) {
         <?php if ($section->sectionTemplate->is_canvas): ?>
             <div moe class="d-none if-edit ml-2">
                 <a start show class="font-weight-normal" title="Update with latest patient data">
-                    <i class="fa fa-sync"></i>
+                    <i class="fa fa-sync on-hover-opaque"></i>
                 </a>
                 <form url="/api/section/updateFromCanvas">
                     <p>Update this section with latest patient data?</p>

+ 2 - 2
resources/views/app/patient/note/segment-slim.blade.php

@@ -54,7 +54,7 @@ $isOmegaHistorySegment = strpos($iName, 'omega_history_') === 0;
                 <a class="ml-3 font-weight-normal refresh-segment c-pointer {{$iName === 'medrisk_vigilence' ? 'on-hover-only' : ''}} screen-only"
                 data-segment-uid="{{$segment->uid}}"
                 title="Update with latest patient data">
-                    <i class="fa fa-sync"></i>
+                    <i class="fa fa-sync on-hover-opaque"></i>
                 </a>
 
             @endif
@@ -67,7 +67,7 @@ $isOmegaHistorySegment = strpos($iName, 'omega_history_') === 0;
                title="{{$segment->display_title}} - Change Log"
                popup-style="medium"
                href="/note-segment-view/{{$patient->uid}}/{{$note->uid}}/{{$segment->uid}}/<?= $segment->segmentTemplate->internal_name ?>/log">
-               <i class="fas fa-history"></i>
+               <i class="fas fa-history on-hover-opaque"></i>
             </a>
         @endif
 

+ 1 - 1
resources/views/app/patient/note/segment.blade.php

@@ -60,7 +60,7 @@
             <a class="ml-3 font-weight-normal refresh-segment text-primary c-pointer {{$iName === 'medrisk_vigilence' ? 'on-hover-only' : ''}} screen-only"
                data-segment-uid="{{$segment->uid}}"
                title="Update with latest patient data">
-                <i class="fa fa-sync"></i>
+                <i class="fa fa-sync on-hover-opaque"></i>
             </a>
 
            

+ 47 - 47
resources/views/app/patient/partials/put-rm-reasons.blade.php

@@ -1,54 +1,54 @@
 <div moe>
-	<a start show><i class="fas fa-edit"></i></a>
+	<a start show><i class="fas fa-edit on-hover-opaque"></i></a>
 	<form url="/api/client/putRmReasons" class="mcp-theme-1">
 		<input type="hidden" name="uid" value="{{$patient->uid}}">
-		<div class="bg-light p-3 mb-2">
-			<div class="mb-2">
-				<label class="text-sm mb-1 text-secondary">RM Reason Icd 1</label>
-				<input type="text" class="form-control form-control-sm" icd-autocomplete-code data-target="input[name=rmReasonIcd1Description]" name="rmReasonIcd1" value="{{ $patient->rm_reason_icd1 }}" />
-			</div>
-			<div class="mb-2">
-				<label class="text-sm mb-1 text-secondary">RM Reason Icd 1 Description</label>
-				<input id="" type="text" class="form-control form-control-sm" icd-autocomplete-description name="rmReasonIcd1Description" value="{{ $patient->rm_reason_icd1description }}">
-			</div>
-		</div>
-
-		<div class="bg-light p-3 mb-2">
-			<div class="mb-2">
-				<label class="text-sm mb-1 text-secondary">RM Reason Icd 2</label>
-				<input type="text" class="form-control form-control-sm" icd-autocomplete-code name="rmReasonIcd2" data-target="input[name=rmReasonIcd2Description]" value="{{ $patient->rm_reason_icd2 }}" />
-			</div>
-			<div class="mb-2">
-				<label class="text-sm mb-1 text-secondary">RM Reason Icd 2 Description</label>
-				<input type="text" class="form-control form-control-sm" icd-autocomplete-description name="rmReasonIcd2Description" value="{{ $patient->rm_reason_icd2description }}">
-			</div>
-		</div>
-
-		<div class="bg-light p-3 mb-2">
-			<div class="mb-2">
-				<label class="text-sm mb-1 text-secondary">RM Reason Icd 3</label>
-				<input type="text" class="form-control form-control-sm" icd-autocomplete-code name="rmReasonIcd3" data-target="input[name=rmReasonIcd3Description]" value="{{ $patient->rm_reason_icd3 }}" />
-			</div>
-			<div class="mb-2">
-				<label class="text-sm mb-1 text-secondary">RM Reason Icd 3 Description</label>
-				<input type="text" class="form-control form-control-sm" icd-autocomplete-description name="rmReasonIcd3Description" value="{{ $patient->rm_reason_icd3description }}">
-			</div>
-		</div>
-		<div class="bg-light p-3 mb-2">
-			<div class="mb-2">
-				<label class="text-sm mb-1 text-secondary">RM Reason Icd 4</label>
-				<input type="text" class="form-control form-control-sm" icd-autocomplete-code name="rmReasonIcd4" data-target="input[name=rmReasonIcd4Description]" value="{{ $patient->rm_reason_icd4 }}" />
-			</div>
-			<div class="mb-2">
-				<label class="text-sm mb-1 text-secondary">RM Reason Icd 4 Description</label>
-				<input type="text" class="form-control form-control-sm" icd-autocomplete-description name="rmReasonIcd4Description" value="{{ $patient->rm_reason_icd4description }}">
-			</div>
+		<div>
+			<table class="table table-sm table-bordered">
+				<thead class="bg-light">
+					<tr>
+						<th class="border-bottom-0">ICD</th>
+						<th class="border-bottom-0">Description</th>
+					</tr>
+				</thead>
+				<tbody>
+					<tr>
+						<td>
+							<input type="text" class="form-control form-control-sm" icd-autocomplete-code data-target="input[name=rmReasonIcd1Description]" name="rmReasonIcd1" value="{{ $patient->rm_reason_icd1 }}" placeholder="ICD 1" />
+						</td>
+						<td>
+							<input id="" type="text" class="form-control form-control-sm" icd-autocomplete-description name="rmReasonIcd1Description" value="{{ $patient->rm_reason_icd1description }}">
+						</td>
+					</tr>
+					<tr>
+						<td>
+							<input type="text" class="form-control form-control-sm" icd-autocomplete-code name="rmReasonIcd2" data-target="input[name=rmReasonIcd2Description]" value="{{ $patient->rm_reason_icd2 }}" placeholder="ICD 2" />
+						</td>
+						<td>
+							<input type="text" class="form-control form-control-sm" icd-autocomplete-description name="rmReasonIcd2Description" value="{{ $patient->rm_reason_icd2description }}">
+						</td>
+					</tr>
+					<tr>
+						<td>
+							<input type="text" class="form-control form-control-sm" icd-autocomplete-code name="rmReasonIcd3" data-target="input[name=rmReasonIcd3Description]" value="{{ $patient->rm_reason_icd3 }}" placeholder="ICD 3" />
+						</td>
+						<td>
+							<input type="text" class="form-control form-control-sm" icd-autocomplete-description name="rmReasonIcd3Description" value="{{ $patient->rm_reason_icd3description }}">
+						</td>
+					</tr>
+					<tr>
+						<td>
+							<input type="text" class="form-control form-control-sm" icd-autocomplete-code name="rmReasonIcd4" data-target="input[name=rmReasonIcd4Description]" value="{{ $patient->rm_reason_icd4 }}" placeholder="ICD 4" />
+						</td>
+						<td>
+							<input type="text" class="form-control form-control-sm" icd-autocomplete-description name="rmReasonIcd4Description" value="{{ $patient->rm_reason_icd4description }}">
+						</td>
+					</tr>
+				</tbody>
+			</table>
 		</div>
-		<div class="bg-light p-3 mb-2">
-			<div class="mb-2">
-				<label class="text-sm mb-1 text-secondary">RM Reason Memo</label>
-				<input type="text" class="form-control form-control-sm" name="rmReasonMemo" value="{{ $patient->rm_reason_memo }}">
-			</div>
+		<div class="mb-2">
+			<label class="font-weight-bold mb-1">RM Reason Memo:</label>
+			<input type="text" class="form-control form-control-sm" name="rmReasonMemo" value="{{ $patient->rm_reason_memo }}">
 		</div>
 		<div>
 			<button submit class="btn btn-sm btn-primary mr-1">Submit</button>

+ 44 - 0
resources/views/app/patient/partials/rm-reasons-display.blade.php

@@ -0,0 +1,44 @@
+<table class="table table-sm table-striped table-bordered mb-0">
+	<tbody>
+		<tr>
+			<td class="text-nowrap">RM Reason Icd 1</td>
+			<td>
+				<div class="d-flex">
+					<span class="font-weight-bold text-sm mr-2" style="min-width: 60px;">{{ $patient->rm_reason_icd1 ? $patient->rm_reason_icd1. ':':'' }}</span>
+					<small class="text-muted text-sm">{{ $patient->rm_reason_icd1description }}</small>
+				</div>
+			</td>
+		</tr>
+		<tr>
+			<td class="text-nowrap">RM Reason Icd 2</td>
+			<td>
+				<div class="d-flex">
+					<span class="font-weight-bold text-sm mr-2" style="min-width: 60px;">{{ $patient->rm_reason_icd2 ? $patient->rm_reason_icd2 . ':':'' }}</span>
+					<small class="text-muted text-sm">{{ $patient->rm_reason_icd2description }}</small>
+				</div>
+			</td>
+		</tr>
+		<tr>
+			<td class="text-nowrap">RM Reason Icd 3</td>
+			<td>
+				<div class="d-flex">
+					<span class="font-weight-bold text-sm mr-2" style="min-width: 60px;">{{ $patient->rm_reason_icd3 ? $patient->rm_reason_icd3 . ':':'' }}</span>
+					<small class="text-muted text-sm">{{ $patient->rm_reason_icd3description }}</small>
+				</div>
+			</td>
+		</tr>
+		<tr>
+			<td class="text-nowrap">RM Reason Icd 4</td>
+			<td>
+				<div class="d-flex">
+					<span class="font-weight-bold text-sm mr-2" style="min-width: 60px;">{{ $patient->rm_reason_icd4 ? $patient->rm_reason_icd4. ':' : '' }}</span>
+					<small class="text-muted text-sm">{{ $patient->rm_reason_icd4description }}</small>
+				</div>
+			</td>
+		</tr>
+		<tr>
+			<td class="text-nowrap">RM Reason Memo</td>
+			<td class="text-muted text-sm">{{ $patient->rm_reason_memo }}</td>
+		</tr>
+	</tbody>
+</table>

+ 4 - 47
resources/views/app/patient/partials/rm-setup.blade.php

@@ -108,51 +108,8 @@
             <span class="mr-2">RM Reasons:</span>
             @include('app.patient.partials.put-rm-reasons')
         </div>
-        <div class="pl-3" style="width: 400px;">
-            <table class="table table-sm table-striped table-bordered">
-                <tbody>
-                    <tr>
-                        <td class="text-nowrap">RM Reason Icd 1</td>
-                        <td>
-                            <div class="d-flex flex-column">
-                                <span class="font-weight-bold">{{ $patient->rm_reason_icd1 }}</span>
-                                <small class="text-muted">{{ $patient->rm_reason_icd1description }}</small>
-                            </div>
-                        </td>
-                    </tr>
-                    <tr>
-                        <td class="text-nowrap">RM Reason Icd 2</td>
-                        <td>
-                        <div class="d-flex flex-column">
-                                <span class="font-weight-bold">{{ $patient->rm_reason_icd2 }}</span>
-                                <small class="text-muted">{{ $patient->rm_reason_icd2description }}</small>
-                            </div>
-                        </td>
-                    </tr>
-                    <tr>
-                        <td class="text-nowrap">RM Reason Icd 3</td>
-                        <td>
-                        <div class="d-flex flex-column">
-                                <span class="font-weight-bold">{{ $patient->rm_reason_icd3 }}</span>
-                                <small class="text-muted">{{ $patient->rm_reason_icd3description }}</small>
-                            </div>
-                        </td>
-                    </tr>
-                    <tr>
-                        <td class="text-nowrap">RM Reason Icd 4</td>
-                        <td>
-                        <div class="d-flex flex-column">
-                                <span class="font-weight-bold">{{ $patient->rm_reason_icd4 }}</span>
-                                <small class="text-muted">{{ $patient->rm_reason_icd4description }}</small>
-                            </div>
-                        </td>
-                    </tr>
-                    <tr>
-                        <td class="text-nowrap">RM Reason Memo</td>
-                        <td>{{ $patient->rm_reason_memo }}</td>
-                    </tr>
-                </tbody>
-            </table>
+        <div class="pl-3" style="max-width: 570px;">
+            @include('app.patient.partials.rm-reasons-display')
         </div>
         {{--<div class="d-flex align-items-baseline mb-3">
             <span class="width-200px">RM Reasons:</span>
@@ -354,7 +311,7 @@
                 <div class="">
                     <div class="d-flex align-items-baseline mb-1">
                         <span class="width-200px pl-3">Arrived:</span>
-                        <span class="ml-3">Yes</span>*
+                        <span class="ml-3">Yes</span>
                     </div>
                     <div class="d-flex align-items-baseline mb-1">
                         <span class="width-200px pl-3">First Measurement:</span>
@@ -403,7 +360,7 @@
                 <div class="">
                     <div class="d-flex align-items-baseline mb-1">
                         <span class="width-200px pl-3">Arrived:</span>
-                        <span class="ml-3">Yes</span>*
+                        <span class="ml-3">Yes</span>
                     </div>
                     <div class="d-flex align-items-baseline mb-1">
                         <span class="width-200px pl-3">First Measurement:</span>

+ 233 - 0
resources/views/app/patient/segment-templates/biopsychosocial_assessment/edit.blade.php

@@ -0,0 +1,233 @@
+<?php
+
+$identificationPoint = App\Models\Point::getorCreateOnlyTopLevelPointOfCategory($note, 'BIOPSYCHOSOCIAL_ASSESSMENT_IDENTIFICATION', $sessionKey, true);
+$historyOfPresentProblemPoint = App\Models\Point::getorCreateOnlyTopLevelPointOfCategory($note, 'BIOPSYCHOSOCIAL_ASSESSMENT_HISTORY_OF_PRESENT_PROBLEM', $sessionKey, true);
+$psychiatricHistoryPriorEpisodesOfSymptomsDiagnosesCoursesOfTreatmentEtcPoint = App\Models\Point::getorCreateOnlyTopLevelPointOfCategory($note, 'BIOPSYCHOSOCIAL_ASSESSMENT_PSYCHIATRIC_HISTORY_PRIOR_EPISODES_OF_SYMPTOMS_DIAGNOSES_COURSES_OF_TREATMENT_ETC', $sessionKey, true);
+$traumaHistoryPoint = App\Models\Point::getorCreateOnlyTopLevelPointOfCategory($note, 'BIOPSYCHOSOCIAL_ASSESSMENT_TRAUMA_HISTORY', $sessionKey, true);
+$familyPsychiatricHistoryPoint = App\Models\Point::getorCreateOnlyTopLevelPointOfCategory($note, 'BIOPSYCHOSOCIAL_ASSESSMENT_FAMILY_PSYCHIATRIC_HISTORY', $sessionKey, true);
+$medicalConditionsAndHistoryPoint = App\Models\Point::getorCreateOnlyTopLevelPointOfCategory($note, 'BIOPSYCHOSOCIAL_ASSESSMENT_MEDICAL_CONDITIONS_AND_HISTORY', $sessionKey, true);
+$substanceUsePoint = App\Models\Point::getorCreateOnlyTopLevelPointOfCategory($note, 'BIOPSYCHOSOCIAL_ASSESSMENT_SUBSTANCE_USE', $sessionKey, true);
+$familyHistoryPoint = App\Models\Point::getorCreateOnlyTopLevelPointOfCategory($note, 'BIOPSYCHOSOCIAL_ASSESSMENT_FAMILY_HISTORY', $sessionKey, true);
+$socialHistoryPoint = App\Models\Point::getorCreateOnlyTopLevelPointOfCategory($note, 'BIOPSYCHOSOCIAL_ASSESSMENT_SOCIAL_HISTORY', $sessionKey, true);
+$spiritualCulturalFactorsPoint = App\Models\Point::getorCreateOnlyTopLevelPointOfCategory($note, 'BIOPSYCHOSOCIAL_ASSESSMENT_SPIRITUAL_CULTURAL_FACTORS', $sessionKey, true);
+$developmentalHistoryPoint = App\Models\Point::getorCreateOnlyTopLevelPointOfCategory($note, 'BIOPSYCHOSOCIAL_ASSESSMENT_DEVELOPMENTAL_HISTORY', $sessionKey, true);
+$educationalVocationalHistoryPoint = App\Models\Point::getorCreateOnlyTopLevelPointOfCategory($note, 'BIOPSYCHOSOCIAL_ASSESSMENT_EDUCATIONAL_VOCATIONAL_HISTORY', $sessionKey, true);
+$legalHistoryPoint = App\Models\Point::getorCreateOnlyTopLevelPointOfCategory($note, 'BIOPSYCHOSOCIAL_ASSESSMENT_LEGAL_HISTORY', $sessionKey, true);
+$snapPoint = App\Models\Point::getorCreateOnlyTopLevelPointOfCategory($note, 'BIOPSYCHOSOCIAL_ASSESSMENT_SNAP', $sessionKey, true);
+$otherImportantInformationPoint = App\Models\Point::getorCreateOnlyTopLevelPointOfCategory($note, 'BIOPSYCHOSOCIAL_ASSESSMENT_OTHER_IMPORTANT_INFORMATION', $sessionKey, true);
+
+
+$identificationContent = [
+	'value' => null,
+];
+if($identificationPoint->lastChildReview && $identificationPoint->lastChildReview->data) {
+    $identificationPoint->lastChildReview->data = json_decode($identificationPoint->lastChildReview->data, true);
+    $identificationContent = $identificationPoint->lastChildReview->data;
+}
+
+$historyOfPresentProblemContent = [
+	'value' => null, 
+];
+if($historyOfPresentProblemPoint->lastChildReview && $historyOfPresentProblemPoint->lastChildReview->data){
+	$historyOfPresentProblemPoint->lastChildReview->data = json_decode($historyOfPresentProblemPoint->lastChildReview->data, true);
+	$historyOfPresentProblemContent = $historyOfPresentProblemPoint->lastChildReview->data;
+}
+
+$psychiatricHistoryPriorEpisodesOfSymptomsDiagnosesCoursesOfTreatmentEtcContent = [
+	'value' => null, 
+];
+if($psychiatricHistoryPriorEpisodesOfSymptomsDiagnosesCoursesOfTreatmentEtcPoint->lastChildReview && $psychiatricHistoryPriorEpisodesOfSymptomsDiagnosesCoursesOfTreatmentEtcPoint->lastChildReview->data){
+	$psychiatricHistoryPriorEpisodesOfSymptomsDiagnosesCoursesOfTreatmentEtcPoint->lastChildReview->data = json_decode($psychiatricHistoryPriorEpisodesOfSymptomsDiagnosesCoursesOfTreatmentEtcPoint->lastChildReview->data, true);
+	$psychiatricHistoryPriorEpisodesOfSymptomsDiagnosesCoursesOfTreatmentEtcContent = $psychiatricHistoryPriorEpisodesOfSymptomsDiagnosesCoursesOfTreatmentEtcPoint->lastChildReview->data;
+}
+
+$traumaHistoryContent = [
+	'value' => null, 
+];
+if($traumaHistoryPoint->lastChildReview && $traumaHistoryPoint->lastChildReview->data){
+	$traumaHistoryPoint->lastChildReview->data = json_decode($traumaHistoryPoint->lastChildReview->data, true);
+	$traumaHistoryContent = $traumaHistoryPoint->lastChildReview->data;
+}
+
+$familyPsychiatricHistoryContent = [
+	'value' => null, 
+];
+if($familyPsychiatricHistoryPoint->lastChildReview && $familyPsychiatricHistoryPoint->lastChildReview->data){
+	$familyPsychiatricHistoryPoint->lastChildReview->data = json_decode($familyPsychiatricHistoryPoint->lastChildReview->data, true);
+	$familyPsychiatricHistoryContent = $familyPsychiatricHistoryPoint->lastChildReview->data;
+}
+
+$medicalConditionsAndHistoryContent = [
+	'value' => null, 
+];
+if($medicalConditionsAndHistoryPoint->lastChildReview && $medicalConditionsAndHistoryPoint->lastChildReview->data){
+	$medicalConditionsAndHistoryPoint->lastChildReview->data = json_decode($medicalConditionsAndHistoryPoint->lastChildReview->data, true);
+	$medicalConditionsAndHistoryContent = $medicalConditionsAndHistoryPoint->lastChildReview->data;
+}
+
+$substanceUseContent = [
+	'value' => null, 
+];
+if($substanceUsePoint->lastChildReview && $substanceUsePoint->lastChildReview->data){
+	$substanceUsePoint->lastChildReview->data = json_decode($substanceUsePoint->lastChildReview->data, true);
+	$substanceUseContent = $substanceUsePoint->lastChildReview->data;
+}
+
+$familyHistoryContent = [
+	'value' => null, 
+];
+if($familyHistoryPoint->lastChildReview && $familyHistoryPoint->lastChildReview->data){
+	$familyHistoryPoint->lastChildReview->data = json_decode($familyHistoryPoint->lastChildReview->data, true);
+	$familyHistoryContent = $familyHistoryPoint->lastChildReview->data;
+}
+
+$socialHistoryContent = [
+	'value' => null, 
+];
+if($socialHistoryPoint->lastChildReview && $socialHistoryPoint->lastChildReview->data){
+	$socialHistoryPoint->lastChildReview->data = json_decode($socialHistoryPoint->lastChildReview->data, true);
+	$socialHistoryContent = $socialHistoryPoint->lastChildReview->data;
+}
+
+$spiritualCulturalFactorsContent = [
+	'value' => null, 
+];
+if($spiritualCulturalFactorsPoint->lastChildReview && $spiritualCulturalFactorsPoint->lastChildReview->data){
+	$spiritualCulturalFactorsPoint->lastChildReview->data = json_decode($spiritualCulturalFactorsPoint->lastChildReview->data, true);
+	$spiritualCulturalFactorsContent = $spiritualCulturalFactorsPoint->lastChildReview->data;
+}
+
+$developmentalHistoryContent = [
+	'value' => null, 
+];
+if($developmentalHistoryPoint->lastChildReview && $developmentalHistoryPoint->lastChildReview->data){
+	$developmentalHistoryPoint->lastChildReview->data = json_decode($developmentalHistoryPoint->lastChildReview->data, true);
+	$developmentalHistoryContent = $developmentalHistoryPoint->lastChildReview->data;
+}
+
+$educationalVocationalHistoryContent = [
+	'value' => null, 
+];
+if($educationalVocationalHistoryPoint->lastChildReview && $educationalVocationalHistoryPoint->lastChildReview->data){
+	$educationalVocationalHistoryPoint->lastChildReview->data = json_decode($educationalVocationalHistoryPoint->lastChildReview->data, true);
+	$educationalVocationalHistoryContent = $educationalVocationalHistoryPoint->lastChildReview->data;
+}
+
+$legalHistoryContent = [
+	'value' => null, 
+];
+if($legalHistoryPoint->lastChildReview && $legalHistoryPoint->lastChildReview->data){
+	$legalHistoryPoint->lastChildReview->data = json_decode($legalHistoryPoint->lastChildReview->data, true);
+	$legalHistoryContent = $legalHistoryPoint->lastChildReview->data;
+}
+
+$snapContent = [
+	'value' => null, 
+];
+if($snapPoint->lastChildReview && $snapPoint->lastChildReview->data){
+	$snapPoint->lastChildReview->data = json_decode($snapPoint->lastChildReview->data, true);
+	$snapContent = $snapPoint->lastChildReview->data;
+}
+
+$otherImportantInformationContent = [
+	'value' => null, 
+];
+if($otherImportantInformationPoint->lastChildReview && $otherImportantInformationPoint->lastChildReview->data){
+	$otherImportantInformationPoint->lastChildReview->data = json_decode($otherImportantInformationPoint->lastChildReview->data, true);
+	$otherImportantInformationContent = $otherImportantInformationPoint->lastChildReview->data;
+}
+
+
+$contents = [
+	'identification' => $identificationContent,
+	'history_of_present_problem' => $historyOfPresentProblemContent,
+	'psychiatric_history_prior_episodes_of_symptoms_diagnoses_courses_of_treatment_etc' => $psychiatricHistoryPriorEpisodesOfSymptomsDiagnosesCoursesOfTreatmentEtcContent,
+	'trauma_history' => $traumaHistoryContent,
+	'family_psychiatric_history' => $familyPsychiatricHistoryContent,
+	'medical_conditions_and_history' => $medicalConditionsAndHistoryContent,
+	'substance_use' => $substanceUseContent,
+	'family_history' => $familyHistoryContent,
+	'social_history' => $socialHistoryContent,
+	'spiritual_cultural_factors' => $spiritualCulturalFactorsContent,
+	'developmental_history' => $developmentalHistoryContent,
+	'educational_vocational_history' => $educationalVocationalHistoryContent,
+	'legal_history' => $legalHistoryContent,
+	'snap' => $snapContent,
+	'other_important_information' => $otherImportantInformationContent,
+];
+
+$points = [
+	'identification' => $identificationPoint,
+	'history_of_present_problem' => $historyOfPresentProblemPoint,
+	'psychiatric_history_prior_episodes_of_symptoms_diagnoses_courses_of_treatment_etc' => $psychiatricHistoryPriorEpisodesOfSymptomsDiagnosesCoursesOfTreatmentEtcPoint,
+	'trauma_history' => $traumaHistoryPoint,
+	'family_psychiatric_history' => $familyPsychiatricHistoryPoint,
+	'medical_conditions_and_history' => $medicalConditionsAndHistoryPoint,
+	'substance_use' => $substanceUsePoint,
+	'family_history' => $familyHistoryPoint,
+	'social_history' => $socialHistoryPoint,
+	'spiritual_cultural_factors' => $spiritualCulturalFactorsPoint,
+	'developmental_history' => $developmentalHistoryPoint,
+	'educational_vocational_history' => $educationalVocationalHistoryPoint,
+	'legal_history' => $legalHistoryPoint,
+	'snap' => $snapPoint,
+	'other_important_information' => $otherImportantInformationPoint,
+];
+
+$placeholders = [
+	'identification' => 'age (71 at time of intake), ethnicity, religion, marital status, referral status, etc.',
+	'history_of_present_problem' => 'symptoms, onset, duration, frequency, etc.',
+	'psychiatric_history_prior_episodes_of_symptoms_diagnoses_courses_of_treatment_etc' => 'prior episodes of symptoms, diagnoses, courses of treatment, etc.',
+	'trauma_history' => 'nature of trauma, when occurred, persons involved, etc.',
+	'family_psychiatric_history' => 'history of mental illness in family, diagnoses, etc.',
+	'medical_conditions_and_history' => 'current and past medical conditions, treatments, allergies, etc.',
+	'substance_use' => 'history of substances used, including alcohol, tobacco, and prescription drugs other than prescribed, present substance use, etc.',
+	'family_history' => 'family of origin, relationship with parents, siblings, significant others, etc.',
+	'social_history' => 'significant relationships, social support, nature/quality of relationships, current community resources, etc.',
+	'spiritual_cultural_factors' => 'important spiritual practices and communities, cultural influences, etc.',
+	'developmental_history' => 'developmental milestones, delays, etc.',
+	'educational_vocational_history' => 'level of education, current/past employment, hobbies, leisure activities, etc.',
+	'legal_history' => 'arrest/summons history, sentencing, DUI occurrences, incarceration, civil litigation, family court matters, etc.',
+	'snap' => 'strengths, needs, abilities, preferences, etc.',
+	'other_important_information' => 'other important information relevant to treatment',
+];
+
+$labels = [
+	'identification' => 'Identification', 
+	'history_of_present_problem' => 'History of Present Problem', 
+	'psychiatric_history_prior_episodes_of_symptoms_diagnoses_courses_of_treatment_etc' => 'Psychiatric History', 
+	'trauma_history' => 'Trauma History', 
+	'family_psychiatric_history' => 'Family Psychiatric History', 
+	'medical_conditions_and_history' => 'Medical Conditions & History', 
+	'substance_use' => 'Substance Use', 
+	'family_history' => 'Family History', 
+	'social_history' => 'Social History', 
+	'spiritual_cultural_factors' => 'Spiritual/Cultural Factors', 
+	'developmental_history' => 'Developmental History', 
+	'educational_vocational_history' => 'Educational/Vocational History', 
+	'legal_history' => 'Legal History', 
+	'snap' => 'SNAP', 
+	'other_important_information' => 'Other Important Information', 
+];
+?>
+<div class="p-3">
+	@foreach($contents as $field => $content)
+		<div visit-moe close-on-save close-on-cancel class="d-block" id="biopsychosocial_assessment-{{$field}}-{{$note->id}}">
+			<form show url="/api/visitPoint/upsertChildReview" class="mcp-theme-1 frm-upsert-review-psych-intake-current-mental-status">
+				<input type="hidden" name="uid" value="{{$points[$field]->uid}}">
+				<input type="hidden" name="noteUid" value="<?= $note->uid ?>">
+				<input type="hidden" name="segmentUid" value="<?= $segment->uid ?>">
+				<input type="hidden" name="data" value="{{json_encode($content)}}">
+
+				<div class="row align-items-center mb-1">
+					<div class="col-md-4">
+						<label class="control-label mb-0" style="font-size:13px;">{{$labels[$field]}}:</label>
+					</div>
+					<div class="col-md-8">
+						<input type="text" name="value" class="form-control input-sm" placeholder="{{$placeholders[$field]}}" value="{{$content['value']}}" data-name="value">
+					</div>
+				</div>
+			</form> 
+		</div>
+	@endforeach  
+</div>

+ 222 - 0
resources/views/app/patient/segment-templates/biopsychosocial_assessment/summary.blade.php

@@ -0,0 +1,222 @@
+<?php
+
+$identificationPoint = App\Models\Point::getorCreateOnlyTopLevelPointOfCategory($note, 'BIOPSYCHOSOCIAL_ASSESSMENT_IDENTIFICATION', $sessionKey, true);
+$historyOfPresentProblemPoint = App\Models\Point::getorCreateOnlyTopLevelPointOfCategory($note, 'BIOPSYCHOSOCIAL_ASSESSMENT_HISTORY_OF_PRESENT_PROBLEM', $sessionKey, true);
+$psychiatricHistoryPriorEpisodesOfSymptomsDiagnosesCoursesOfTreatmentEtcPoint = App\Models\Point::getorCreateOnlyTopLevelPointOfCategory($note, 'BIOPSYCHOSOCIAL_ASSESSMENT_PSYCHIATRIC_HISTORY_PRIOR_EPISODES_OF_SYMPTOMS_DIAGNOSES_COURSES_OF_TREATMENT_ETC', $sessionKey, true);
+$traumaHistoryPoint = App\Models\Point::getorCreateOnlyTopLevelPointOfCategory($note, 'BIOPSYCHOSOCIAL_ASSESSMENT_TRAUMA_HISTORY', $sessionKey, true);
+$familyPsychiatricHistoryPoint = App\Models\Point::getorCreateOnlyTopLevelPointOfCategory($note, 'BIOPSYCHOSOCIAL_ASSESSMENT_FAMILY_PSYCHIATRIC_HISTORY', $sessionKey, true);
+$medicalConditionsAndHistoryPoint = App\Models\Point::getorCreateOnlyTopLevelPointOfCategory($note, 'BIOPSYCHOSOCIAL_ASSESSMENT_MEDICAL_CONDITIONS_AND_HISTORY', $sessionKey, true);
+$substanceUsePoint = App\Models\Point::getorCreateOnlyTopLevelPointOfCategory($note, 'BIOPSYCHOSOCIAL_ASSESSMENT_SUBSTANCE_USE', $sessionKey, true);
+$familyHistoryPoint = App\Models\Point::getorCreateOnlyTopLevelPointOfCategory($note, 'BIOPSYCHOSOCIAL_ASSESSMENT_FAMILY_HISTORY', $sessionKey, true);
+$socialHistoryPoint = App\Models\Point::getorCreateOnlyTopLevelPointOfCategory($note, 'BIOPSYCHOSOCIAL_ASSESSMENT_SOCIAL_HISTORY', $sessionKey, true);
+$spiritualCulturalFactorsPoint = App\Models\Point::getorCreateOnlyTopLevelPointOfCategory($note, 'BIOPSYCHOSOCIAL_ASSESSMENT_SPIRITUAL_CULTURAL_FACTORS', $sessionKey, true);
+$developmentalHistoryPoint = App\Models\Point::getorCreateOnlyTopLevelPointOfCategory($note, 'BIOPSYCHOSOCIAL_ASSESSMENT_DEVELOPMENTAL_HISTORY', $sessionKey, true);
+$educationalVocationalHistoryPoint = App\Models\Point::getorCreateOnlyTopLevelPointOfCategory($note, 'BIOPSYCHOSOCIAL_ASSESSMENT_EDUCATIONAL_VOCATIONAL_HISTORY', $sessionKey, true);
+$legalHistoryPoint = App\Models\Point::getorCreateOnlyTopLevelPointOfCategory($note, 'BIOPSYCHOSOCIAL_ASSESSMENT_LEGAL_HISTORY', $sessionKey, true);
+$snapPoint = App\Models\Point::getorCreateOnlyTopLevelPointOfCategory($note, 'BIOPSYCHOSOCIAL_ASSESSMENT_SNAP', $sessionKey, true);
+$otherImportantInformationPoint = App\Models\Point::getorCreateOnlyTopLevelPointOfCategory($note, 'BIOPSYCHOSOCIAL_ASSESSMENT_OTHER_IMPORTANT_INFORMATION', $sessionKey, true);
+
+
+$identificationContent = [
+	'value' => null,
+];
+if($identificationPoint->lastChildReview && $identificationPoint->lastChildReview->data) {
+    $identificationPoint->lastChildReview->data = json_decode($identificationPoint->lastChildReview->data, true);
+    $identificationContent = $identificationPoint->lastChildReview->data;
+}
+
+$historyOfPresentProblemContent = [
+	'value' => null, 
+];
+if($historyOfPresentProblemPoint->lastChildReview && $historyOfPresentProblemPoint->lastChildReview->data){
+	$historyOfPresentProblemPoint->lastChildReview->data = json_decode($historyOfPresentProblemPoint->lastChildReview->data, true);
+	$historyOfPresentProblemContent = $historyOfPresentProblemPoint->lastChildReview->data;
+}
+
+$psychiatricHistoryPriorEpisodesOfSymptomsDiagnosesCoursesOfTreatmentEtcContent = [
+	'value' => null, 
+];
+if($psychiatricHistoryPriorEpisodesOfSymptomsDiagnosesCoursesOfTreatmentEtcPoint->lastChildReview && $psychiatricHistoryPriorEpisodesOfSymptomsDiagnosesCoursesOfTreatmentEtcPoint->lastChildReview->data){
+	$psychiatricHistoryPriorEpisodesOfSymptomsDiagnosesCoursesOfTreatmentEtcPoint->lastChildReview->data = json_decode($psychiatricHistoryPriorEpisodesOfSymptomsDiagnosesCoursesOfTreatmentEtcPoint->lastChildReview->data, true);
+	$psychiatricHistoryPriorEpisodesOfSymptomsDiagnosesCoursesOfTreatmentEtcContent = $psychiatricHistoryPriorEpisodesOfSymptomsDiagnosesCoursesOfTreatmentEtcPoint->lastChildReview->data;
+}
+
+$traumaHistoryContent = [
+	'value' => null, 
+];
+if($traumaHistoryPoint->lastChildReview && $traumaHistoryPoint->lastChildReview->data){
+	$traumaHistoryPoint->lastChildReview->data = json_decode($traumaHistoryPoint->lastChildReview->data, true);
+	$traumaHistoryContent = $traumaHistoryPoint->lastChildReview->data;
+}
+
+$familyPsychiatricHistoryContent = [
+	'value' => null, 
+];
+if($familyPsychiatricHistoryPoint->lastChildReview && $familyPsychiatricHistoryPoint->lastChildReview->data){
+	$familyPsychiatricHistoryPoint->lastChildReview->data = json_decode($familyPsychiatricHistoryPoint->lastChildReview->data, true);
+	$familyPsychiatricHistoryContent = $familyPsychiatricHistoryPoint->lastChildReview->data;
+}
+
+$medicalConditionsAndHistoryContent = [
+	'value' => null, 
+];
+if($medicalConditionsAndHistoryPoint->lastChildReview && $medicalConditionsAndHistoryPoint->lastChildReview->data){
+	$medicalConditionsAndHistoryPoint->lastChildReview->data = json_decode($medicalConditionsAndHistoryPoint->lastChildReview->data, true);
+	$medicalConditionsAndHistoryContent = $medicalConditionsAndHistoryPoint->lastChildReview->data;
+}
+
+$substanceUseContent = [
+	'value' => null, 
+];
+if($substanceUsePoint->lastChildReview && $substanceUsePoint->lastChildReview->data){
+	$substanceUsePoint->lastChildReview->data = json_decode($substanceUsePoint->lastChildReview->data, true);
+	$substanceUseContent = $substanceUsePoint->lastChildReview->data;
+}
+
+$familyHistoryContent = [
+	'value' => null, 
+];
+if($familyHistoryPoint->lastChildReview && $familyHistoryPoint->lastChildReview->data){
+	$familyHistoryPoint->lastChildReview->data = json_decode($familyHistoryPoint->lastChildReview->data, true);
+	$familyHistoryContent = $familyHistoryPoint->lastChildReview->data;
+}
+
+$socialHistoryContent = [
+	'value' => null, 
+];
+if($socialHistoryPoint->lastChildReview && $socialHistoryPoint->lastChildReview->data){
+	$socialHistoryPoint->lastChildReview->data = json_decode($socialHistoryPoint->lastChildReview->data, true);
+	$socialHistoryContent = $socialHistoryPoint->lastChildReview->data;
+}
+
+$spiritualCulturalFactorsContent = [
+	'value' => null, 
+];
+if($spiritualCulturalFactorsPoint->lastChildReview && $spiritualCulturalFactorsPoint->lastChildReview->data){
+	$spiritualCulturalFactorsPoint->lastChildReview->data = json_decode($spiritualCulturalFactorsPoint->lastChildReview->data, true);
+	$spiritualCulturalFactorsContent = $spiritualCulturalFactorsPoint->lastChildReview->data;
+}
+
+$developmentalHistoryContent = [
+	'value' => null, 
+];
+if($developmentalHistoryPoint->lastChildReview && $developmentalHistoryPoint->lastChildReview->data){
+	$developmentalHistoryPoint->lastChildReview->data = json_decode($developmentalHistoryPoint->lastChildReview->data, true);
+	$developmentalHistoryContent = $developmentalHistoryPoint->lastChildReview->data;
+}
+
+$educationalVocationalHistoryContent = [
+	'value' => null, 
+];
+if($educationalVocationalHistoryPoint->lastChildReview && $educationalVocationalHistoryPoint->lastChildReview->data){
+	$educationalVocationalHistoryPoint->lastChildReview->data = json_decode($educationalVocationalHistoryPoint->lastChildReview->data, true);
+	$educationalVocationalHistoryContent = $educationalVocationalHistoryPoint->lastChildReview->data;
+}
+
+$legalHistoryContent = [
+	'value' => null, 
+];
+if($legalHistoryPoint->lastChildReview && $legalHistoryPoint->lastChildReview->data){
+	$legalHistoryPoint->lastChildReview->data = json_decode($legalHistoryPoint->lastChildReview->data, true);
+	$legalHistoryContent = $legalHistoryPoint->lastChildReview->data;
+}
+
+$snapContent = [
+	'value' => null, 
+];
+if($snapPoint->lastChildReview && $snapPoint->lastChildReview->data){
+	$snapPoint->lastChildReview->data = json_decode($snapPoint->lastChildReview->data, true);
+	$snapContent = $snapPoint->lastChildReview->data;
+}
+
+$otherImportantInformationContent = [
+	'value' => null, 
+];
+if($otherImportantInformationPoint->lastChildReview && $otherImportantInformationPoint->lastChildReview->data){
+	$otherImportantInformationPoint->lastChildReview->data = json_decode($otherImportantInformationPoint->lastChildReview->data, true);
+	$otherImportantInformationContent = $otherImportantInformationPoint->lastChildReview->data;
+}
+
+
+$contents = [
+	'identification' => $identificationContent,
+	'history_of_present_problem' => $historyOfPresentProblemContent,
+	'psychiatric_history_prior_episodes_of_symptoms_diagnoses_courses_of_treatment_etc' => $psychiatricHistoryPriorEpisodesOfSymptomsDiagnosesCoursesOfTreatmentEtcContent,
+	'trauma_history' => $traumaHistoryContent,
+	'family_psychiatric_history' => $familyPsychiatricHistoryContent,
+	'medical_conditions_and_history' => $medicalConditionsAndHistoryContent,
+	'substance_use' => $substanceUseContent,
+	'family_history' => $familyHistoryContent,
+	'social_history' => $socialHistoryContent,
+	'spiritual_cultural_factors' => $spiritualCulturalFactorsContent,
+	'developmental_history' => $developmentalHistoryContent,
+	'educational_vocational_history' => $educationalVocationalHistoryContent,
+	'legal_history' => $legalHistoryContent,
+	'snap' => $snapContent,
+	'other_important_information' => $otherImportantInformationContent,
+];
+
+$points = [
+	'identification' => $identificationPoint,
+	'history_of_present_problem' => $historyOfPresentProblemPoint,
+	'psychiatric_history_prior_episodes_of_symptoms_diagnoses_courses_of_treatment_etc' => $psychiatricHistoryPriorEpisodesOfSymptomsDiagnosesCoursesOfTreatmentEtcPoint,
+	'trauma_history' => $traumaHistoryPoint,
+	'family_psychiatric_history' => $familyPsychiatricHistoryPoint,
+	'medical_conditions_and_history' => $medicalConditionsAndHistoryPoint,
+	'substance_use' => $substanceUsePoint,
+	'family_history' => $familyHistoryPoint,
+	'social_history' => $socialHistoryPoint,
+	'spiritual_cultural_factors' => $spiritualCulturalFactorsPoint,
+	'developmental_history' => $developmentalHistoryPoint,
+	'educational_vocational_history' => $educationalVocationalHistoryPoint,
+	'legal_history' => $legalHistoryPoint,
+	'snap' => $snapPoint,
+	'other_important_information' => $otherImportantInformationPoint,
+];
+
+$placeholders = [
+	'identification' => 'age (71 at time of intake), ethnicity, religion, marital status, referral status, etc.',
+	'history_of_present_problem' => 'symptoms, onset, duration, frequency, etc.',
+	'psychiatric_history_prior_episodes_of_symptoms_diagnoses_courses_of_treatment_etc' => 'prior episodes of symptoms, diagnoses, courses of treatment, etc.',
+	'trauma_history' => 'nature of trauma, when occurred, persons involved, etc.',
+	'family_psychiatric_history' => 'history of mental illness in family, diagnoses, etc.',
+	'medical_conditions_and_history' => 'current and past medical conditions, treatments, allergies, etc.',
+	'substance_use' => 'history of substances used, including alcohol, tobacco, and prescription drugs other than prescribed, present substance use, etc.',
+	'family_history' => 'family of origin, relationship with parents, siblings, significant others, etc.',
+	'social_history' => 'significant relationships, social support, nature/quality of relationships, current community resources, etc.',
+	'spiritual_cultural_factors' => 'important spiritual practices and communities, cultural influences, etc.',
+	'developmental_history' => 'developmental milestones, delays, etc.',
+	'educational_vocational_history' => 'level of education, current/past employment, hobbies, leisure activities, etc.',
+	'legal_history' => 'arrest/summons history, sentencing, DUI occurrences, incarceration, civil litigation, family court matters, etc.',
+	'snap' => 'strengths, needs, abilities, preferences, etc.',
+	'other_important_information' => 'other important information relevant to treatment',
+];
+
+$labels = [
+	'identification' => 'Identification', 
+	'history_of_present_problem' => 'History of Present Problem', 
+	'psychiatric_history_prior_episodes_of_symptoms_diagnoses_courses_of_treatment_etc' => 'Psychiatric History', 
+	'trauma_history' => 'Trauma History', 
+	'family_psychiatric_history' => 'Family Psychiatric History', 
+	'medical_conditions_and_history' => 'Medical Conditions & History', 
+	'substance_use' => 'Substance Use', 
+	'family_history' => 'Family History', 
+	'social_history' => 'Social History', 
+	'spiritual_cultural_factors' => 'Spiritual/Cultural Factors', 
+	'developmental_history' => 'Developmental History', 
+	'educational_vocational_history' => 'Educational/Vocational History', 
+	'legal_history' => 'Legal History', 
+	'snap' => 'SNAP', 
+	'other_important_information' => 'Other Important Information', 
+];
+?>
+<div class="events-none form-read-mode">
+	<table class="table table-sm table-bordered table-striped">
+	@foreach($contents as $field => $content)
+		<tr>
+			<td>{{$labels[$field]}}:</td>
+			<td>{{$content['value']}}</td>
+		</tr>
+	@endforeach  
+	</table>	
+</div>

+ 370 - 0
resources/views/app/patient/segment-templates/psych_intake_current_mental-status/edit.blade.php

@@ -0,0 +1,370 @@
+<?php
+
+$keyToInputMap = [
+
+	'generalAppearance' => [
+		'Appropriate',
+		'Disheveled',
+		'Emaciated',
+		'Obese',
+		'Poor Hygiene',
+		'Not Assessed'
+	],
+
+	'dressInput' => [
+		'Appropriate',
+		'Eccentric',
+		'Seductive',
+		'Bizarre',
+		'Not Assessed'
+	],
+
+	'motorActivity' => [
+		'Unremarkable',
+		'Agitation',
+		'Retardation',
+		'Posturing',
+		'Repetitive actions',
+		'Tics',
+		'Tremor',
+		'Unusual Gait',
+		'Not Assessed'
+	],
+
+	'insight' => [
+		'Excellent',
+		'Good',
+		'Fair',
+		'Poor',
+		'Nil',
+		'Not Assessed'
+	],
+
+	'judgment' => [
+		'Excellent',
+		'Good',
+		'Fair',
+		'Poor',
+		'Nil',
+		'Not Assessed'
+	],
+
+	'affect' => [
+		'Congruent',
+		'Incongruent',
+		'Appropriate',
+		'Inappropriate',
+		'Reactive',
+		'Constricted',
+		'Blunted',
+		'Flat',
+		'Not Assessed'
+	],
+
+	'mood' => [
+		'Euthymic',
+		'Dysphoric',
+		'Depressed',
+		'Euphoric',
+		'Grandiose',
+		'Anxious',
+		'Labile',
+		'Irritable',
+		'Angry',
+		'Not Assessed'
+	],
+
+	'orientation' => [
+		'X3: Oriented to Person, Place, and Time',
+		'X2: Oriented to Person, Place; Impaired to Time',
+		'X2: Oriented to Person, Time; Impaired to Place',
+		'X2: Oriented to Time, Place; Impaired to Person',
+		'X1: Oriented to Person; Impaired to Place, Time',
+		'X1: Oriented to Place; Impaired to Person, Time',
+		'X1: Oriented to Time; Impaired to Person, Place',
+		'X0: Impaired to Person, Place, and Time',
+		'Not Assessed'
+	],
+
+	'memory' =>[
+		'Intact',
+		'Poor Remote',
+		'Poor Recent',
+		'Not Assessed'
+	],
+
+	'attentionConcentration' => [
+		'Good',
+		'Distractible',
+		'Variable',
+		'Not Assessed',
+    ],
+
+	'thoughtContent' => [
+		'Appropriate',
+		'Preoccupied',
+		'Obsessions',
+		'Delusions: Persecutory',
+		'Delusions: Bizarre',
+		'Delusions: Grandeur',
+		'Delusions: Guilt',
+		'Delusions: Somatic',
+		'Delusions: Ideas of Reference',
+		'Delusions: Thought Broadcasting',
+		'Delusions: Thought Control',
+		'Not Assessed'
+	],
+
+	'perception' => [
+		'Unremarkable',
+		'Auditory Hallucinations',
+		'Visual Hallucinations',
+		'Olfactory Hallucinations',
+		'Tactile Hallucinations',
+		'Gustatory Hallucinations',
+		'Not Assessed'
+	],
+
+	'thoughtProcess' => [
+		'Unremarkable',
+		'Blocking',
+		'Circumstantial',
+		'Flight of Ideas',
+		'Loose Associations',
+		'Perseveration',
+		'Tangential',
+		'Not Assessed'
+	],
+
+	'interviewBehavior' => [
+		'Appropriate',
+		'Aggressive',
+		'Angry',
+		'Apathetic',
+		'Argumentative',
+		'Child-like',
+		'Demanding',
+		'Drastic',
+		'Evasive',
+		'Hostile',
+		'Irritable',
+		'Passive',
+		'Manipulative',
+		'Withdrawn',
+		'Uncooperative',
+		'Not Assessed'
+	],
+
+	'speech' =>[
+		'Normal',
+		'Hesitant',
+		'Pressured',
+		'Slurred',
+		'Soft',
+		'Stuttering',
+		'Mute',
+		'Verbose',
+		'Not Assessed'
+	],
+
+	'functionalStatus' => [
+		'Intact',
+		'Mildly Impaired',
+		'Moderately Impaired',
+		'Severely Impaired',
+		'Variably Impaired',
+		'Not Assessed'
+	]
+
+];
+
+$keyToLabelMap = [
+	'orientation' => 'Orientation',
+	'generalAppearance' => 'General Appearance',
+	'dressInput' => 'Dress',
+	'motorActivity' => 'Motor Activity',
+	'interviewBehavior' => 'Interview Behavior',
+	'speech' => 'Speech',
+	'mood' => 'Mood',
+	'affect' => 'Affect',
+	'insight' => 'Insight',
+	'judgment' => 'Judgment/Impulse Control',
+	'memory' => 'Memory',
+	'attentionConcentration' => 'Attention/Concentration',
+	'thoughtProcess' => 'Thought Process',
+	'thoughtContent' => 'Thought Content',
+	'perception' => 'Perception',
+	'functionalStatus' => 'Functional Status'
+];
+
+$allNormal = [
+	'Orientation' => 'X3: Oriented to Person, Place, and Time',
+	'Insight' => 'Excellent',
+	'General Appearance' => 'Appropriate',
+	'Judgment/Impulse Control' => 'Excellent',
+	'Dress' => 'Appropriate',
+	'Memory' => 'Intact',
+	'Motor Activity' => 'Unremarkable',
+	'Attention/Concentration' => 'Good',
+	'Interview Behavior' => 'Appropriate',       
+	'Thought Process' => 'Unremarkable',
+	'Speech' => 'Normal',
+	'Thought Content' => 'Appropriate',
+	'Mood' => 'Euthymic',
+	'Perception' => 'Unremarkable',
+	'Affect' => 'Congruent',
+	'Functional Status' => 'Intact'
+];
+
+$displayColumns = [
+	'left' => ['orientation', 'generalAppearance', 'dressInput', 'motorActivity', 'interviewBehavior', 'speech', 'mood', 'affect'],
+	'right' => ['insight', 'judgement', 'memory', 'attentionConcentration', 'thoughtProcess', 'thoughtContent', 'perception', 'functionalStatus']
+];
+
+$point = App\Models\Point::getOrCreateOnlyTopLevelPointOfCategory($note, 'PSYCH_INTAKE_CURRENT_MENTAL_STATUS', $sessionKey, true);
+$contentData = [
+    'orientation' => null,
+	'generalAppearance' => null,
+	'dressInput' => null,
+	'motorActivity' => null,
+	'interviewBehavior' => null,
+	'speech' => null,
+	'mood' => null,
+	'affect' => null,
+	'insight' => null,
+	'judgment' => null,
+	'memory' => null,
+	'attentionConcentration' => null,
+	'thoughtProcess' => null,
+	'thoughtContent' => null,
+	'perception' => null,
+	'functionalStatus' => null,
+];
+if ($point->lastChildReview && $point->lastChildReview->data) {
+    $point->lastChildReview->data = json_decode($point->lastChildReview->data, true);
+    $contentData = $point->lastChildReview->data;
+}
+$submitFormUrl = "/api/visitPoint/upsertChildReview";
+?>
+
+<div visit-moe close-on-save close-on-cancel class="d-block p-3" id="psych-intake-current-mental-status-{{$note->id}}">
+    <form id="pychIntakeForm" show url="{{ $submitFormUrl }}" class="mcp-theme-1 frm-upsert-review-typical-day-ls">
+        <input type="hidden" name="uid" value="<?= $point->uid ?>">
+        <input type="hidden" name="noteUid" value="<?= $note->uid ?>">
+        <input type="hidden" name="segmentUid" value="<?= $segment->uid ?>">
+        <input type="hidden" name="data" value="{{json_encode($contentData)}}">
+
+        <div class="mb-2 d-flex align-items-center justify-content-between">
+			<p class="mb-0 font-weight-bold">Psych Intake Current Mental Status</p>
+			<div>
+				<a class="mr-2 font-weight-bold c-pointer" all-normal><i class="fas fa-thumbs-up"></i> All Normal</a>
+				<a class="font-weight-bold c-pointer" all-not-assessed><i class="fas fa-times-circle"></i> All Not assessed</a>
+			</div>
+		</div>
+
+        <div>
+            <div class="row">
+                
+                <div class="col-md-6">
+                    @foreach($keyToInputMap as  $field => $options)
+                        @if(in_array($field, $displayColumns['left']))
+							<div class="row align-items-center mb-1">
+								<div class="col-md-4">
+									<label class="control-label mb-0">{{$keyToLabelMap[$field]}}:</label>
+								</div>
+								<div class="col-md-8">
+									<input type="text" list="{{$field}}s" data-name="{{$field}}" name="{{$field}}" id="{{$field}}" class="form-control" value="{{ @$contentData[$field] }}">
+									<datalist id="{{$field}}s">
+										@foreach($options as $option)
+											<option value="{{$option}}">{{$option}}</option>
+										@endforeach
+									</datalist>
+									
+								</div>
+							</div>
+                        @endif
+                    @endforeach
+                </div>
+                    
+                <div class="col-md-6">
+                    @foreach($keyToInputMap as  $field => $options)
+                        @if(in_array($field, $displayColumns['right']))
+						<div class="row align-items-center mb-1">
+							<div class="col-md-4">
+								<label class="control-label mb-0">{{$keyToLabelMap[$field]}}:</label>
+							</div>
+							<div class="col-md-8">
+								<input type="text" list="{{$field}}s" data-name="{{$field}}" name="{{$field}}" id="{{$field}}" class="form-control" value="{{ @$contentData[$field] }}">
+								<datalist id="{{$field}}s">
+									@foreach($options as $option)
+                                        <option value="{{$option}}">{{$option}}</option>
+                                    @endforeach
+								</datalist>
+							</div>
+						</div>
+                        @endif
+                    @endforeach
+                </div>
+            </div>   
+        </div>    
+        <div>
+            <button submit class="btn btn-sm btn-primary mr-2"><i class="fa fa-save"></i></button>
+            <div class="d-inline-flex align-self-stretch align-items-center">
+                <span class="autosave-indicator saving text-sm text-secondary">Saving changes &hellip;</span>
+                <span class="autosave-indicator saved text-sm text-secondary">
+                    <i class="fa fa-check"></i>
+                    Saved
+                </span>
+            </div>
+        </div>
+    </form>   
+</div>
+<script>
+    (function($){
+		var pychIntakeComponent = {
+			form: null,
+			keyLabelMap: <?= json_encode($keyToLabelMap) ?>,
+			allNormal:<?= json_encode($allNormal) ?>,
+			NotAssessedValue: "Not Assessed",
+
+			initOnSetAllNormal: function(){
+				var self = this;
+				
+				$('[all-normal]').click(function(){
+					self.resetFieldsToAllNormal();
+					return;
+				});
+				$('[all-not-assessed]').click(function(){
+					self.resetFieldsToAllNormal(true);
+					return;
+				});
+			},
+			resetFieldsToAllNormal: function(setAsNotAssessed){
+				var self = this;
+				
+				var formData = {};
+				var inputs = self.form.find('[data-name]');
+				$.each(inputs, function(i, input){
+					var key = $(input).data('name');
+					var ref = self.keyLabelMap[key];
+					var defaultValue = self.allNormal[ref];
+					if(setAsNotAssessed){
+						defaultValue = self.NotAssessedValue;
+					}
+					$(input).val(defaultValue);
+					formData[key] = defaultValue;
+				});
+				self.submitForm(formData);
+			},
+			submitForm: function(data){
+				this.form.find('input[name=data]').val(JSON.stringify(data));
+                $.post('{{ $submitFormUrl }}', this.form.serializeArray(), function(response) {}, 'json');
+			},
+			init: function(){
+				this.form = $('#pychIntakeForm');
+				this.initOnSetAllNormal();
+			}
+		};
+		pychIntakeComponent.init();
+	})(jQuery);
+</script>

+ 265 - 0
resources/views/app/patient/segment-templates/psych_intake_current_mental-status/summary.blade.php

@@ -0,0 +1,265 @@
+<?php
+
+$keyToInputMap = [
+
+	'generalAppearance' => [
+		'Appropriate',
+		'Disheveled',
+		'Emaciated',
+		'Obese',
+		'Poor Hygiene',
+		'Not Assessed'
+	],
+
+	'dressInput' => [
+		'Appropriate',
+		'Eccentric',
+		'Seductive',
+		'Bizarre',
+		'Not Assessed'
+	],
+
+	'motorActivity' => [
+		'Unremarkable',
+		'Agitation',
+		'Retardation',
+		'Posturing',
+		'Repetitive actions',
+		'Tics',
+		'Tremor',
+		'Unusual Gait',
+		'Not Assessed'
+	],
+
+	'insight' => [
+		'Excellent',
+		'Good',
+		'Fair',
+		'Poor',
+		'Nil',
+		'Not Assessed'
+	],
+
+	'judgment' => [
+		'Excellent',
+		'Good',
+		'Fair',
+		'Poor',
+		'Nil',
+		'Not Assessed'
+	],
+
+	'affect' => [
+		'Congruent',
+		'Incongruent',
+		'Appropriate',
+		'Inappropriate',
+		'Reactive',
+		'Constricted',
+		'Blunted',
+		'Flat',
+		'Not Assessed'
+	],
+
+	'mood' => [
+		'Euthymic',
+		'Dysphoric',
+		'Depressed',
+		'Euphoric',
+		'Grandiose',
+		'Anxious',
+		'Labile',
+		'Irritable',
+		'Angry',
+		'Not Assessed'
+	],
+
+	'orientation' => [
+		'X3: Oriented to Person, Place, and Time',
+		'X2: Oriented to Person, Place; Impaired to Time',
+		'X2: Oriented to Person, Time; Impaired to Place',
+		'X2: Oriented to Time, Place; Impaired to Person',
+		'X1: Oriented to Person; Impaired to Place, Time',
+		'X1: Oriented to Place; Impaired to Person, Time',
+		'X1: Oriented to Time; Impaired to Person, Place',
+		'X0: Impaired to Person, Place, and Time',
+		'Not Assessed'
+	],
+
+	'memory' =>[
+		'Intact',
+		'Poor Remote',
+		'Poor Recent',
+		'Not Assessed'
+	],
+
+	'attentionConcentration' => [
+		'Good',
+		'Distractible',
+		'Variable',
+		'Not Assessed',
+    ],
+
+	'thoughtContent' => [
+		'Appropriate',
+		'Preoccupied',
+		'Obsessions',
+		'Delusions: Persecutory',
+		'Delusions: Bizarre',
+		'Delusions: Grandeur',
+		'Delusions: Guilt',
+		'Delusions: Somatic',
+		'Delusions: Ideas of Reference',
+		'Delusions: Thought Broadcasting',
+		'Delusions: Thought Control',
+		'Not Assessed'
+	],
+
+	'perception' => [
+		'Unremarkable',
+		'Auditory Hallucinations',
+		'Visual Hallucinations',
+		'Olfactory Hallucinations',
+		'Tactile Hallucinations',
+		'Gustatory Hallucinations',
+		'Not Assessed'
+	],
+
+	'thoughtProcess' => [
+		'Unremarkable',
+		'Blocking',
+		'Circumstantial',
+		'Flight of Ideas',
+		'Loose Associations',
+		'Perseveration',
+		'Tangential',
+		'Not Assessed'
+	],
+
+	'interviewBehavior' => [
+		'Appropriate',
+		'Aggressive',
+		'Angry',
+		'Apathetic',
+		'Argumentative',
+		'Child-like',
+		'Demanding',
+		'Drastic',
+		'Evasive',
+		'Hostile',
+		'Irritable',
+		'Passive',
+		'Manipulative',
+		'Withdrawn',
+		'Uncooperative',
+		'Not Assessed'
+	],
+
+	'speech' =>[
+		'Normal',
+		'Hesitant',
+		'Pressured',
+		'Slurred',
+		'Soft',
+		'Stuttering',
+		'Mute',
+		'Verbose',
+		'Not Assessed'
+	],
+
+	'functionalStatus' => [
+		'Intact',
+		'Mildly Impaired',
+		'Moderately Impaired',
+		'Severely Impaired',
+		'Variably Impaired',
+		'Not Assessed'
+	]
+
+];
+
+$keyToLabelMap = [
+	'orientation' => 'Orientation',
+	'generalAppearance' => 'General Appearance',
+	'dressInput' => 'Dress',
+	'motorActivity' => 'Motor Activity',
+	'interviewBehavior' => 'Interview Behavior',
+	'speech' => 'Speech',
+	'mood' => 'Mood',
+	'affect' => 'Affect',
+	'insight' => 'Insight',
+	'judgment' => 'Judgment/Impulse Control',
+	'memory' => 'Memory',
+	'attentionConcentration' => 'Attention/Concentration',
+	'thoughtProcess' => 'Thought Process',
+	'thoughtContent' => 'Thought Content',
+	'perception' => 'Perception',
+	'functionalStatus' => 'Functional Status'
+];
+
+$displayColumns = [
+	'left' => ['orientation', 'generalAppearance', 'dressInput', 'motorActivity', 'interviewBehavior', 'speech', 'mood', 'affect'],
+	'right' => ['insight', 'judgement', 'memory', 'attentionConcentration', 'thoughtProcess', 'thoughtContent', 'perception', 'functionalStatus']
+];
+
+if(!@$sessionKey) {
+    $sessionKey = request()->cookie('sessionKey');
+}
+$point = App\Models\Point::getOrCreateOnlyTopLevelPointOfCategory($note, 'PSYCH_INTAKE_CURRENT_MENTAL_STATUS', $sessionKey, true);
+$contentData = [
+    'orientation' => null,
+	'generalAppearance' => null,
+	'dressInput' => null,
+	'motorActivity' => null,
+	'interviewBehavior' => null,
+	'speech' => null,
+	'mood' => null,
+	'affect' => null,
+	'insight' => null,
+	'judgment' => null,
+	'memory' => null,
+	'attentionConcentration' => null,
+	'thoughtProcess' => null,
+	'thoughtContent' => null,
+	'perception' => null,
+	'functionalStatus' => null,
+];
+if ($point->lastChildReview && $point->lastChildReview->data) {
+    $point->lastChildReview->data = json_decode($point->lastChildReview->data, true);
+    $contentData = $point->lastChildReview->data;
+}
+?>
+<div class="events-none form-read-mode">
+    <div>
+        <div class="row">
+            
+            <div class="col-md-6">
+				<table class="table table-sm table-striped table-bordered">
+					@foreach($keyToInputMap as  $field => $options)
+						@if(in_array($field, $displayColumns['left']))
+							<tr>
+								<td><b>{{$keyToLabelMap[$field]}}</b></td>
+								<td>{{ @$contentData[$field] ?? '-' }}</td>
+							</tr>
+						@endif
+					@endforeach
+				</table>
+                
+            </div>
+                
+            <div class="col-md-6">
+				<table class="table table-sm table-striped table-bordered">
+					@foreach($keyToInputMap as  $field => $options)
+						@if(in_array($field, $displayColumns['right']))
+							<tr>
+								<td><b>{{$keyToLabelMap[$field]}}</b></td>
+								<td>{{ @$contentData[$field] ?? '-' }}</td>
+							</tr>
+						@endif
+					@endforeach
+				</table>
+            </div>
+        </div>   
+    </div>    
+    
+</div>

+ 27 - 0
resources/views/app/patient/segment-templates/sigma_allergies/active-linear-summary.blade.php

@@ -0,0 +1,27 @@
+<?php
+
+use App\Models\Point;
+
+/** @var \App\Models\Client $patient */
+
+$points = Point::getPointsOfCategory($patient, 'ALLERGY');
+$tracker = Point::getGlobalSingletonOfCategory($patient, 'NO_KNOWN_TRACKER');
+?>
+
+<?php if($tracker && @($tracker->data->no_known_drug_allergies)): ?>
+	<div class="text-secondary mb-2"><span>No known drug allergies</span></div>
+<?php endif; ?>
+<?php if($tracker && @($tracker->data->no_known_allergies_of_any_type)): ?>
+	<div class="text-secondary mb-2"><span>No known allergies of any type</span></div>
+<?php endif; ?>
+<?php if(!$tracker || !@($tracker->data->no_known_allergies_of_any_type)): ?>
+	<?php if (!count($points)): ?>
+		<div class="text-secondary">-</div>
+	<?php else: ?>
+		<div class="d-flex align-items-baseline flex-wrap">
+			<?php $j = 0; foreach ($points as $point): $j++; ?>
+				<span class="mr-2 text-nowrap">• <?= !!@($point->data->name) ? @($point->data->name) : '-' ?></span>
+			<?php endforeach; ?>
+		</div>
+	<?php endif; ?>
+<?php endif; ?>

+ 0 - 0
resources/views/app/patient/segment-templates/sigma_allergies/edit.blade.php


+ 70 - 0
resources/views/app/patient/segment-templates/sigma_allergies/summary.blade.php

@@ -0,0 +1,70 @@
+<?php
+
+use App\Models\Point;
+
+/** @var \App\Models\Client $patient */
+
+$points = Point::getIntakePointsOfCategory($patient, 'ALLERGY', $note);
+$tracker = Point::getGlobalSingletonOfCategory($patient, 'NO_KNOWN_TRACKER');
+$numRelevant = 0;
+$plural = 'Allergies';
+?>
+
+<?php if($tracker && @($tracker->data->no_known_drug_allergies)): ?>
+    <div class="text-secondary mb-2"><span>-</span></div>
+<?php endif; ?>
+<?php if($tracker && @($tracker->data->no_known_allergies_of_any_type)): ?>
+    <div class="text-secondary mb-2"><span>-</span></div>
+<?php endif; ?>
+
+<?php if(!$tracker || !@($tracker->data->no_known_allergies_of_any_type)): ?>
+<?php if (!count($points)): ?>
+    <div class="text-secondary">-</div>
+<?php else: ?>
+<table class="table table-bordered table-xs table-cage mb-0">
+    <?php $j = 0; foreach ($points as $point): $j++; ?>
+	<?php $rel = $point->relevanceToNote($note); ?>
+        <tr>
+            <td class="width-40px pl-0 pr-2 {{ $rel ? ' text-info':'' }}">
+                @if($rel)
+                    <?php $numRelevant++; ?>
+                    {{ $j }}.*
+                @else
+                    {{ $j }}.
+                @endif
+            </td>
+            <td class="px-2 width-300px">
+                <div class=" <?= $point->is_removed ? 'strike-through' : '' ?>">
+                    <?= !!@($point->data->name) ? @($point->data->name) : '-' ?>
+                    
+                </div>
+		    </td>
+            <td class="width-300px">
+                <div class="d-flex align-items-baseline pl-2">
+                    <?php $review = $point->childReviewAddedInNote($note); ?>
+                    <?php if(!!$review && @$review->data->value): ?>
+                        <span class="pr-2">{!! $review->data->value !!}</span>
+                    <?php endif; ?>
+                    <span class="text-nowrap">
+                        <?php if ($point->is_removed): ?>
+                            @if($point->removal_reason_category === 'DURING_VISIT')
+                                <span class="text-sm text-secondary">Removed during visit</span>
+                            @elseif($point->removal_reason_category === 'ON_INTAKE')
+                                <span class="text-sm text-secondary">Removed on intake</span>
+                            @endif
+                        <?php elseif ($point->added_in_note_id === $note->id): ?>
+                            <?php if ($point->addition_reason_category === 'DURING_VISIT'): ?>
+                                <span class="text-sm text-success">* Added during visit</span>
+                            <?php else: ?>
+                                <span class="text-sm text-info">* Added on intake</span>
+                            <?php endif;?>
+                        <?php endif; ?>
+                    </span>
+                </div>
+            </td>
+            <td></td>
+        </tr>
+    <?php endforeach; ?>
+</table>
+<?php endif; ?>
+<?php endif; ?>

+ 4 - 0
resources/views/app/patient/segment-templates/sigma_assessment_free_text/edit.blade.php

@@ -0,0 +1,4 @@
+<?php
+$category = 'ASSESSMENT_FREE_TEXT';
+$endPoint = 'upsertNoteSingleton';
+include resource_path('views/app/patient/segment-templates/_simple_text_segment/edit.php');

+ 3 - 0
resources/views/app/patient/segment-templates/sigma_assessment_free_text/summary.blade.php

@@ -0,0 +1,3 @@
+<?php
+$category = 'ASSESSMENT_FREE_TEXT';
+include resource_path('views/app/patient/segment-templates/_simple_text_segment/summary.php');

+ 0 - 0
resources/views/app/patient/segment-templates/sigma_assessment_system/edit.blade.php


+ 59 - 0
resources/views/app/patient/segment-templates/sigma_assessment_system/summary.blade.php

@@ -0,0 +1,59 @@
+<?php
+$points = \App\Models\Point
+    ::where('client_id', $patient->id)
+    ->where('is_removed_due_to_entry_error', false)
+    ->where(function ($query1) use ($note) {
+        $query1
+            ->where(function ($query2) use ($note) {
+                $query2->where('is_removed', false)
+                    ->where('addition_reason_category', 'DURING_VISIT')
+                    ->where('added_in_note_id', $note->id);
+            })
+            ->orWhereRaw("(SELECT count(id) from note_point WHERE is_active IS TRUE AND note_id = {$note->id} AND point_id = point.id) > 0");
+    })
+    ->orderBy('created_at')
+    ->get();
+
+$problems = [];
+$allergies = [];
+
+foreach ($points as $point) {
+    if ($point->data) {
+        $point->data = json_decode($point->data);
+    }
+    // if($point->category === 'ALLERGY' && @$point->data->name) $allergies[] = $point->data->name;
+    if($point->category === 'PROBLEM' && @$point->data->name) $problems[] = $point->data->name . (@$point->data->icd ? ' (' . $point->data->icd . ')' : '');
+}
+?>
+
+{{--@if($allergies && count($allergies))
+    <div class="d-flex mb-1">
+        <a class="mr-2 min-width-110px "
+           open-in-stag-popup
+           href="/allergies-center/{{$note->client->uid}}/{{$note->uid}}"
+           mc-initer="allergies-center-{{$note->id}}"
+           title="Allergies Center"
+           popup-style="overflow-visible">
+            Allergies
+        </a>
+        <div class="flex-grow-1 text-dark">
+            {{implode(", ", $allergies)}}
+        </div>
+    </div>
+@endif--}}
+
+@if($problems && count($problems))
+    <div class="d-flex mb-1">
+        <a class="mr-2 min-width-110px "
+           open-in-stag-popup
+           href="/problems-center/{{$note->client->uid}}/{{$note->uid}}"
+           mc-initer="problems-center-{{$note->id}}"
+           title="Problems Center"
+           popup-style="overflow-visible">
+            Problems
+        </a>
+        <div class="flex-grow-1 text-dark">
+            {{implode(", ", $problems)}}
+        </div>
+    </div>
+@endif

+ 0 - 0
resources/views/app/patient/segment-templates/sigma_care_team/edit.blade.php


+ 64 - 0
resources/views/app/patient/segment-templates/sigma_care_team/summary.blade.php

@@ -0,0 +1,64 @@
+<?php
+
+use App\Models\Point;
+
+/** @var \App\Models\Client $patient */
+
+$points = Point::getIntakePointsOfCategory($patient, 'CARE_TEAM_MEMBER', $note);
+$numRelevant = 0;
+$plural = 'Care team members';
+?>
+
+<?php if (!count($points)): ?>
+    <div class="text-secondary">-</div>
+<?php else: ?>
+    <table class="table table-bordered table-xs table-cage mb-0">
+    <?php $j = 0; foreach ($points as $point): $j++; ?>
+        <?php $rel = $point->relevanceToNote($note); ?>
+        <tr>
+            <td class="width-40px pl-0 pr-2 {{ $rel ? ' text-info':'' }}">
+                @if($rel)
+                    <?php $numRelevant++; ?>
+                    {{ $j }}.*
+                @else
+                    {{ $j }}.
+                @endif
+            </td>
+            <td class="px-2 width-300px">
+                <div class="<?= $point->is_removed ? 'strike-through' : '' ?>">
+                    <?= !!@($point->data->name) ? @($point->data->name) : '-' ?>
+                    <?= !!@($point->data->specialty) ? '/&nbsp;' . @($point->data->specialty) . '' : '' ?>
+                    <?= !!@($point->data->organization) ? '/&nbsp;' . @($point->data->organization) . '' : '' ?><br>
+                    <?= !!@($point->data->phone) ? 'Ph: ' . @($point->data->phone) . '' : '' ?>
+                    <?= !!@($point->data->fax) ? '&nbsp;/&nbsp;Fax: ' . @($point->data->fax) . '<br>' : '' ?>
+                    <?= !!@($point->data->date) ? '&nbsp;/&nbsp;Date: ' . @($point->data->date) : '' ?>
+                </div>
+            </td>
+            <td class="width-300px">
+                <div class="d-flex align-items-baseline pl-2">
+                    <?php $review = $point->childReviewAddedInNote($note); ?>
+                    <?php if(!!$review && @$review->data->value): ?>
+                    <span class="pr-2">{!! $review->data->value !!}</span>
+                    <?php endif; ?>
+                    <span class="text-nowrap">
+                        <?php if ($point->is_removed): ?>
+                        @if($point->removal_reason_category === 'DURING_VISIT')
+                            <span class="text-sm text-secondary">Removed during visit</span>
+                        @elseif($point->removal_reason_category === 'ON_INTAKE')
+                            <span class="text-sm text-secondary">Removed on intake</span>
+                        @endif
+                        <?php elseif ($point->added_in_note_id === $note->id): ?>
+                        <?php if ($point->addition_reason_category === 'DURING_VISIT'): ?>
+                                <span class="text-sm text-success">* Added during visit</span>
+                            <?php else: ?>
+                                <span class="text-sm text-info">* Added on intake</span>
+                            <?php endif;?>
+                        <?php endif; ?>
+                    </span>
+                </div>
+            </td>
+            <td></td>
+        </tr>
+    <?php endforeach; ?>
+    </table>
+<?php endif; ?>

+ 64 - 0
resources/views/app/patient/segment-templates/sigma_cc/edit.blade.php

@@ -0,0 +1,64 @@
+<?php
+$category = 'CHIEF_COMPLAINT';
+$endPoint = 'upsertNoteSingleton';
+
+use App\Models\Point;
+
+$point = Point::where('added_in_note_id', $segment->note->id)->where('category', $category)->orderBy('id', 'DESC')->first();
+$parsed = null;
+if ($point && !!@$point->data) {
+    $parsed = json_decode($point->data);
+}
+
+if(!$parsed || !@$parsed->free_text) {
+    $problemPoints = Point::getPointsOfCategory($patient, 'PROBLEM');
+    $problemNames = [];
+    foreach ($problemPoints as $problemPoint) {
+        if($problemPoint->relevanceToNote($note)) {
+            $problemNames[] = $problemPoint->data->name;
+        }
+    }
+    $problems = '';
+    for($i = 0; $i < count($problemNames); $i++) {
+        if($i > 0) {
+            if($i === count($problemNames) - 1) {
+                $problems .= " and ";
+            }
+            else {
+                $problems .= ", ";
+            }
+        }
+        $problems .= $problemNames[$i];
+    }
+    $defaultCC = "Patient {$patient->name_first} {$patient->name_last} " .
+        "is a {$patient->age_in_years} year old" .
+        ($patient->sex ? ($patient->sex === 'F' ? ' female' : ($patient->sex === 'M' ? ' male' : ' ' . $patient->sex)) : '') .
+        ($problems ? " with a history of {$problems}" : "") .
+        ($note->new_or_fu_or_na === 'NEW' ? ' presenting for establishing care' : ' presenting for follow-up') .
+        ".";
+    $parsed = json_decode(json_encode([
+        "free_text" => $defaultCC
+    ]));
+}
+?>
+<div visit-moe close-on-save close-on-cancel class="d-block">
+    <form show url="/api/visitPoint/<?= $endPoint ?>" class="mcp-theme-1">
+        <input type="hidden" name="segmentUid" value="<?= $segment->uid ?>">
+        <input type="hidden" name="category" value="<?= $category ?>">
+        <input type="hidden" name="data">
+        <div note-rte
+             class="form-group mb-2 border-left border-right rte-holder"
+             data-field-name="free_text"
+        ><?= $parsed && @$parsed->free_text ? $parsed->free_text : '' ?></div>
+        <div class="m-2">
+            <button submit class="btn btn-sm btn-primary mr-2"><i class="fa fa-save"></i></button>
+            <div class="d-inline-flex align-self-stretch align-items-center">
+                <span class="autosave-indicator saving text-sm text-secondary">Saving changes &hellip;</span>
+                <span class="autosave-indicator saved text-sm text-secondary">
+                    <i class="fa fa-check"></i>
+                    Saved
+                </span>
+            </div>
+        </div>
+    </form>
+</div>

+ 55 - 0
resources/views/app/patient/segment-templates/sigma_cc/summary.blade.php

@@ -0,0 +1,55 @@
+<?php
+$category = 'CHIEF_COMPLAINT';
+
+use App\Models\Point;
+
+$point = Point::where('added_in_note_id', $segment->note->id)->where('category', $category)->orderBy('id', 'DESC')->first();
+$parsed = null;
+if ($point && !!@$point->data) {
+    $parsed = json_decode($point->data);
+}
+
+if(!$parsed || !@$parsed->free_text) {
+    
+    list($problemPoints, $counts) = Point::getPointsOfCategoryExtended($patient, 'PROBLEM', $note);
+    $problemNames = [];
+    foreach ($problemPoints as $problemPoint) {
+        if($problemPoint->relevanceToNote($note)) {
+            $problemNames[] = $problemPoint->data->name;
+        }
+    }
+    $problems = '';
+    for($i = 0; $i < count($problemNames); $i++) {
+        if($i > 0) {
+            if($i === count($problemNames) - 1) {
+                $problems .= " and ";
+            }
+            else {
+                $problems .= ", ";
+            }
+        }
+        $problems .= $problemNames[$i];
+    }
+    $defaultCC = "Patient {$patient->name_first} {$patient->name_last} " .
+        "is a {$patient->age_in_years} year old" .
+        ($patient->sex ? ($patient->sex === 'F' ? ' female' : ($patient->sex === 'M' ? ' male' : ' ' . $patient->sex)) : '') .
+        ($problems ? " with a history of {$problems}" : "") .
+        ($note->new_or_fu_or_na === 'NEW' ? ' presenting for establishing care' : ' presenting for follow-up') .
+        ".";
+    $parsed = json_decode(json_encode([
+        "free_text" => $defaultCC
+    ]));
+    
+}
+?>
+<div>
+    <?php
+    if (!!$parsed && @$parsed->free_text) {
+        echo $parsed->free_text;
+    }
+    else {
+        echo "-";
+    }
+    ?>
+</div>
+

+ 0 - 0
resources/views/app/patient/segment-templates/sigma_goals/edit.blade.php


+ 59 - 0
resources/views/app/patient/segment-templates/sigma_goals/summary.blade.php

@@ -0,0 +1,59 @@
+<?php
+
+use App\Models\Point;
+
+/** @var \App\Models\Client $patient */
+
+$points = Point::getIntakePointsOfCategory($patient, 'GOAL', $note);
+$numRelevant = 0;
+$plural = 'Goals';
+?>
+
+<?php if (!count($points)): ?>
+    <div class="text-secondary">-</div>
+<?php else: ?>
+    <table class="table table-bordered table-xs table-cage mb-0">
+    <?php $j = 0; foreach ($points as $point): $j++; ?>
+        <?php $rel = $point->relevanceToNote($note); ?>
+        <tr>
+            <td class="width-40px pl-0 pr-2 {{ $rel ? ' text-info':'' }}">
+                @if($rel)
+                    <?php $numRelevant++; ?>
+                    {{ $j }}.*
+                @else
+                    {{ $j }}.
+                @endif
+            </td>
+            <td class="px-2 width-300px">
+                <div class="<?= $point->is_removed ? 'strike-through' : '' ?>">
+                    <?= !!@($point->data->goal) ? @($point->data->goal) : '-' ?>
+                </div>
+            </td>
+            <td class="width-300px">
+                <div class="d-flex align-items-baseline pl-2">
+                    <?php $review = $point->childReviewAddedInNote($note); ?>
+                    <?php if(!!$review && @$review->data->value): ?>
+                    <span class="pr-2">{!! $review->data->value !!}</span>
+                    <?php endif; ?>
+                    <span class="text-nowrap">
+                        <?php if ($point->is_removed): ?>
+                        @if($point->removal_reason_category === 'DURING_VISIT')
+                            <span class="text-sm text-secondary">Removed during visit</span>
+                        @elseif($point->removal_reason_category === 'ON_INTAKE')
+                            <span class="text-sm text-secondary">Removed on intake</span>
+                        @endif
+                        <?php elseif ($point->added_in_note_id === $note->id): ?>
+                        <?php if ($point->addition_reason_category === 'DURING_VISIT'): ?>
+                                <span class="text-sm text-success">* Added during visit</span>
+                            <?php else: ?>
+                                <span class="text-sm text-info">* Added on intake</span>
+                            <?php endif;?>
+                        <?php endif; ?>
+                    </span>
+                </div>
+            </td>
+            <td></td>
+        </tr>
+    <?php endforeach; ?>
+    </table>
+<?php endif; ?>

+ 426 - 0
resources/views/app/patient/segment-templates/sigma_history_family/edit.blade.php

@@ -0,0 +1,426 @@
+<?php
+
+use App\Models\Client;
+use App\Models\Point;
+use App\Models\Note;
+/** @var Client $patient */
+/** @var Note $note */
+
+if(!@$segment) $segment = null;
+
+if(!@$sessionKey) {
+    $sessionKey = request()->cookie('sessionKey');
+}
+
+$point = Point::getOrCreateOnlyTopLevelPointOfCategory($note, 'FAMILY_HISTORY', $sessionKey, true);
+
+$contentData = $parsed = false;
+
+if ($point->lastChildReview && $point->lastChildReview->data) {
+    $point->lastChildReview->data = json_decode($point->lastChildReview->data, true);
+    $contentData = $parsed = $point->lastChildReview->data;
+}
+
+if(!$contentData) {
+    $contentData = [
+        "count" => 1,
+        "unknown" => false,
+        "items" => [
+            [
+                "relationship" => '',
+                "status" => '',
+                "general_no_health_concern" => null,
+                "general_arthritis" => null,
+                "general_asthma" => null,
+                "general_bleeding_disorder" => null,
+                "general_cad_lt_age_55" => null,
+                "general_copd" => null,
+                "general_diabetes" => null,
+                "general_heart_attack" => null,
+                "general_heart_disease" => null,
+                "general_high_cholesterol" => null,
+                "general_hypertension" => null,
+                "general_mental_illness" => null,
+                "general_osteoporosis" => null,
+                "general_stroke" => null,
+                "cancer_breast_ca" => null,
+                "cancer_colon_ca" => null,
+                "cancer_other_ca" => null,
+                "cancer_ovarian_ca" => null,
+                "cancer_uterine_ca" => null,
+                "comments" => '',
+            ]
+        ]
+    ];
+}
+
+?>
+
+<hr class="hide-outside-popup mt-3 mb-0">
+<div class="p-3 mcp-theme-1">
+    <div {{!!$segment ? 'visit-moe' : 'moe'}} close-on-save close-on-cancel class="d-block">
+        <form show url="/api/visitPoint/upsertChildReview" class="mcp-theme-1"
+                    {{!$segment ? 'hook=onHxPopupClosure' : ''}}>
+            @if(!!@$segment)
+                <input type="hidden" name="segmentUid" value="<?= $segment->uid ?>">
+            @else
+                <input type="hidden" name="segmentUid" value="<?= $note->coreSegment->uid ?>">
+            @endif
+            <input type="hidden" name="uid" value="<?= $point->uid ?>">
+            <input type="hidden" name="noteUid" value="<?= $note->uid ?>">
+            <input type="hidden" name="data">
+
+            <div id="edit-univ_history_family-container">
+
+                <div class="border border-secondary rounded mb-2 p-2">
+                    <label class="my-0 d-flex align-items-center">
+                        <input type="checkbox" class="my-0 mr-2" v-model="unknown" name="unknown">
+                        <span>Family history is unknown/unavailable</span>
+                    </label>
+                </div>
+
+                <div v-if="!unknown" v-for="(item, index) in items" class="note-section-item-row">
+                    <hr v-if="index > 0" class="row">
+                    <div class="row mb-3">
+                        <div class="col-md-3">
+                            <label class="text-secondary text-sm mb-1 d-block">Relationship</label>
+                            <select class="form-control form-control-sm min-width-unset" v-model="item.relationship" required>
+                                <option value="">-- select --</option>
+                                <option value="Mother">Mother</option>
+                                <option value="Father">Father</option>
+                                <option value="Sister (First)">Sister (First)</option>
+                                <option value="Sister (Second)">Sister (Second)</option>
+                                <option value="Sister (Third)">Sister (Third)</option>
+                                <option value="Sister (Fourth)">Sister (Fourth)</option>
+                                <option value="Brother (First)">Brother (First)</option>
+                                <option value="Brother (Second)">Brother (Second)</option>
+                                <option value="Brother (Third)">Brother (Third)</option>
+                                <option value="Brother (Fourth)">Brother (Fourth)</option>
+                                <option value="Daughter (First)">Daughter (First)</option>
+                                <option value="Daughter (Second)">Daughter (Second)</option>
+                                <option value="Daughter (Third)">Daughter (Third)</option>
+                                <option value="Daughter (Fourth)">Daughter (Fourth)</option>
+                                <option value="Son (First)">Son (First)</option>
+                                <option value="Son (Second)">Son (Second)</option>
+                                <option value="Son (Third)">Son (Third)</option>
+                                <option value="Son (Fourth)">Son (Fourth)</option>
+                                <option value="Half-sister">Half-sister</option>
+                                <option value="Half-brother">Half-brother</option>
+                                <option value="Maternal Aunt">Maternal Aunt</option>
+                                <option value="Paternal Aunt">Paternal Aunt</option>
+                                <option value="Maternal Uncle">Maternal Uncle</option>
+                                <option value="Paternal Uncle">Paternal Uncle</option>
+                                <option value="Niece">Niece</option>
+                                <option value="Nephew">Nephew</option>
+                                <option value="Maternal Cousin">Maternal Cousin</option>
+                                <option value="Paternal Cousin">Paternal Cousin</option>
+                                <option value="Maternal Grandmother">Maternal Grandmother</option>
+                                <option value="Maternal Grandfather">Maternal Grandfather</option>
+                                <option value="Paternal Grandmother">Paternal Grandmother</option>
+                                <option value="Paternal Grandfather">Paternal Grandfather</option>
+                                <option value="Granddaughter">Granddaughter</option>
+                                <option value="Grandson">Grandson</option>
+                            </select>
+                        </div>
+                        <div class="col-md-6">
+                            <label class="text-secondary text-sm mb-1 d-block">Health Status</label>
+                            <label class="my-0 mr-3 d-inline-flex align-items-center">
+                                <input type="radio" :name="'item_' + index + '_status'" v-model="item.status" value="Alive" class="mr-1">
+                                Alive
+                            </label>
+                            <label class="my-0 mr-3 d-inline-flex align-items-center">
+                                <input type="radio" :name="'item_' + index + '_status'" v-model="item.status" value="Deceased" class="mr-1">
+                                Deceased
+                            </label>
+                            <label class="my-0 mr-3 d-inline-flex align-items-center">
+                                <input type="radio" :name="'item_' + index + '_status'" v-model="item.status" value="Unknown" class="mr-1">
+                                Unknown
+                            </label>
+                        </div>
+                        <div class="col-md-2">
+                            <label class="text-secondary text-sm mb-1 d-block">&nbsp;</label>
+                            <div moe relative v-if="items.length > 1">
+                                <a href="#" start show><i class="fa fa-trash-alt text-danger on-hover-opaque"></i></a>
+                                <div url="/nop" right>
+                                    <p>Are you sure?</p>
+                                    <div class="">
+                                        <a class="btn btn-sm btn-danger text-white" v-on:click.prevent="removeItem(index)">Yes</a>
+                                        <button type="button" class="btn btn-sm btn-default border" cancel>No</button>
+                                    </div>
+                                </div>
+                            </div>
+                        </div>
+                    </div>
+                    <div class="row mb-1 font-weight-bold">
+                        <div class="col-8">
+                            General
+                        </div>
+                        <div class="col-4">
+                            Cancer
+                        </div>
+                    </div>
+                    <div class="row mb-1 font-weight-bold">
+                        <div class="col-4">
+                            <div class="rspace">+</div>
+                            <div class="rspace">-</div>
+                        </div>
+                        <div class="col-4">
+                            <div class="rspace">+</div>
+                            <div class="rspace">-</div>
+                        </div>
+                        <div class="col-4">
+                            <div class="rspace">+</div>
+                            <div class="rspace">-</div>
+                        </div>
+                    </div>
+                    <div class="row mb-3">
+                        <div class="col-4">
+                            <div class="d-flex align-items-center">
+                                <div class="rspace"><input type="radio" value="yes" :name="'item_' + index + '_general_no_health_concern'" v-model="item.general_no_health_concern"></div>
+                                <div class="rspace"><input type="radio" value="no" :name="'item_' + index + '_general_no_health_concern'" v-model="item.general_no_health_concern"></div>
+                                <span class="ml-2">No Health Concern</span>
+                                <a href="#" v-show="item.general_no_health_concern" v-on:click.prevent="clearValue(item, 'general_no_health_concern')"><i class="text-danger on-hover-opaque fa fa-trash-alt ml-1"></i></a>
+                            </div>
+                            <div class="d-flex align-items-center">
+                                <div class="rspace"><input type="radio" value="yes" :name="'item_' + index + '_general_arthritis'" v-model="item.general_arthritis"></div>
+                                <div class="rspace"><input type="radio" value="no" :name="'item_' + index + '_general_arthritis'" v-model="item.general_arthritis"></div>
+                                <span class="ml-2">Arthritis</span>
+                                <a href="#" v-show="item.general_arthritis" v-on:click.prevent="clearValue(item, 'general_arthritis')"><i class="text-danger on-hover-opaque fa fa-trash-alt ml-1"></i></a>
+                            </div>
+                            <div class="d-flex align-items-center">
+                                <div class="rspace"><input type="radio" value="yes" :name="'item_' + index + '_general_asthma'" v-model="item.general_asthma"></div>
+                                <div class="rspace"><input type="radio" value="no" :name="'item_' + index + '_general_asthma'" v-model="item.general_asthma"></div>
+                                <span class="ml-2">Asthma</span>
+                                <a href="#" v-show="item.general_asthma" v-on:click.prevent="clearValue(item, 'general_asthma')"><i class="text-danger on-hover-opaque fa fa-trash-alt ml-1"></i></a>
+                            </div>
+                            <div class="d-flex align-items-center">
+                                <div class="rspace"><input type="radio" value="yes" :name="'item_' + index + '_general_bleeding_disorder'" v-model="item.general_bleeding_disorder"></div>
+                                <div class="rspace"><input type="radio" value="no" :name="'item_' + index + '_general_bleeding_disorder'" v-model="item.general_bleeding_disorder"></div>
+                                <span class="ml-2">Bleeding Disorder</span>
+                                <a href="#" v-show="item.general_bleeding_disorder" v-on:click.prevent="clearValue(item, 'general_bleeding_disorder')"><i class="text-danger on-hover-opaque fa fa-trash-alt ml-1"></i></a>
+                            </div>
+                            <div class="d-flex align-items-center">
+                                <div class="rspace"><input type="radio" value="yes" :name="'item_' + index + '_general_cad_lt_age_55'" v-model="item.general_cad_lt_age_55"></div>
+                                <div class="rspace"><input type="radio" value="no" :name="'item_' + index + '_general_cad_lt_age_55'" v-model="item.general_cad_lt_age_55"></div>
+                                <span class="ml-2">CAD < age 55</span>
+                                <a href="#" v-show="item.general_cad_lt_age_55" v-on:click.prevent="clearValue(item, 'general_cad_lt_age_55')"><i class="text-danger on-hover-opaque fa fa-trash-alt ml-1"></i></a>
+                            </div>
+                            <div class="d-flex align-items-center">
+                                <div class="rspace"><input type="radio" value="yes" :name="'item_' + index + '_general_copd'" v-model="item.general_copd"></div>
+                                <div class="rspace"><input type="radio" value="no" :name="'item_' + index + '_general_copd'" v-model="item.general_copd"></div>
+                                <span class="ml-2">COPD</span>
+                                <a href="#" v-show="item.general_copd" v-on:click.prevent="clearValue(item, 'general_copd')"><i class="text-danger on-hover-opaque fa fa-trash-alt ml-1"></i></a>
+                            </div>
+                            <div class="d-flex align-items-center">
+                                <div class="rspace"><input type="radio" value="yes" :name="'item_' + index + '_general_diabetes'" v-model="item.general_diabetes"></div>
+                                <div class="rspace"><input type="radio" value="no" :name="'item_' + index + '_general_diabetes'" v-model="item.general_diabetes"></div>
+                                <span class="ml-2">Diabetes</span>
+                                <a href="#" v-show="item.general_diabetes" v-on:click.prevent="clearValue(item, 'general_diabetes')"><i class="text-danger on-hover-opaque fa fa-trash-alt ml-1"></i></a>
+                            </div>
+                        </div>
+                        <div class="col-4">
+                            <div class="d-flex align-items-center">
+                                <div class="rspace"><input type="radio" value="yes" :name="'item_' + index + '_general_heart_attack'" v-model="item.general_heart_attack"></div>
+                                <div class="rspace"><input type="radio" value="no" :name="'item_' + index + '_general_heart_attack'" v-model="item.general_heart_attack"></div>
+                                <span class="ml-2">Heart Attack</span>
+                                <a href="#" v-show="item.general_heart_attack" v-on:click.prevent="clearValue(item, 'general_heart_attack')"><i class="text-danger on-hover-opaque fa fa-trash-alt ml-1"></i></a>
+                            </div>
+                            <div class="d-flex align-items-center">
+                                <div class="rspace"><input type="radio" value="yes" :name="'item_' + index + '_general_heart_disease'" v-model="item.general_heart_disease"></div>
+                                <div class="rspace"><input type="radio" value="no" :name="'item_' + index + '_general_heart_disease'" v-model="item.general_heart_disease"></div>
+                                <span class="ml-2">Heart Disease</span>
+                                <a href="#" v-show="item.general_heart_disease" v-on:click.prevent="clearValue(item, 'general_heart_disease')"><i class="text-danger on-hover-opaque fa fa-trash-alt ml-1"></i></a>
+                            </div>
+                            <div class="d-flex align-items-center">
+                                <div class="rspace"><input type="radio" value="yes" :name="'item_' + index + '_general_high_cholesterol'" v-model="item.general_high_cholesterol"></div>
+                                <div class="rspace"><input type="radio" value="no" :name="'item_' + index + '_general_high_cholesterol'" v-model="item.general_high_cholesterol"></div>
+                                <span class="ml-2">High Cholesterol</span>
+                                <a href="#" v-show="item.general_high_cholesterol" v-on:click.prevent="clearValue(item, 'general_high_cholesterol')"><i class="text-danger on-hover-opaque fa fa-trash-alt ml-1"></i></a>
+                            </div>
+                            <div class="d-flex align-items-center">
+                                <div class="rspace"><input type="radio" value="yes" :name="'item_' + index + '_general_hypertension'" v-model="item.general_hypertension"></div>
+                                <div class="rspace"><input type="radio" value="no" :name="'item_' + index + '_general_hypertension'" v-model="item.general_hypertension"></div>
+                                <span class="ml-2">Hypertension</span>
+                                <a href="#" v-show="item.general_hypertension" v-on:click.prevent="clearValue(item, 'general_hypertension')"><i class="text-danger on-hover-opaque fa fa-trash-alt ml-1"></i></a>
+                            </div>
+                            <div class="d-flex align-items-center">
+                                <div class="rspace"><input type="radio" value="yes" :name="'item_' + index + '_general_mental_illness'" v-model="item.general_mental_illness"></div>
+                                <div class="rspace"><input type="radio" value="no" :name="'item_' + index + '_general_mental_illness'" v-model="item.general_mental_illness"></div>
+                                <span class="ml-2">Mental Illness</span>
+                                <a href="#" v-show="item.general_mental_illness" v-on:click.prevent="clearValue(item, 'general_mental_illness')"><i class="text-danger on-hover-opaque fa fa-trash-alt ml-1"></i></a>
+                            </div>
+                            <div class="d-flex align-items-center">
+                                <div class="rspace"><input type="radio" value="yes" :name="'item_' + index + '_general_osteoporosis'" v-model="item.general_osteoporosis"></div>
+                                <div class="rspace"><input type="radio" value="no" :name="'item_' + index + '_general_osteoporosis'" v-model="item.general_osteoporosis"></div>
+                                <span class="ml-2">Osteoporosis</span>
+                                <a href="#" v-show="item.general_osteoporosis" v-on:click.prevent="clearValue(item, 'general_osteoporosis')"><i class="text-danger on-hover-opaque fa fa-trash-alt ml-1"></i></a>
+                            </div>
+                            <div class="d-flex align-items-center">
+                                <div class="rspace"><input type="radio" value="yes" :name="'item_' + index + '_general_stroke'" v-model="item.general_stroke"></div>
+                                <div class="rspace"><input type="radio" value="no" :name="'item_' + index + '_general_stroke'" v-model="item.general_stroke"></div>
+                                <span class="ml-2">Stroke</span>
+                                <a href="#" v-show="item.general_stroke" v-on:click.prevent="clearValue(item, 'general_stroke')"><i class="text-danger on-hover-opaque fa fa-trash-alt ml-1"></i></a>
+                            </div>
+                        </div>
+                        <div class="col-4">
+                            <div class="d-flex align-items-center">
+                                <div class="rspace"><input type="radio" value="yes" :name="'item_' + index + '_cancer_breast_ca'" v-model="item.cancer_breast_ca"></div>
+                                <div class="rspace"><input type="radio" value="no" :name="'item_' + index + '_cancer_breast_ca'" v-model="item.cancer_breast_ca"></div>
+                                <span class="ml-2">Breast CA</span>
+                                <a href="#" v-show="item.cancer_breast_ca" v-on:click.prevent="clearValue(item, 'cancer_breast_ca')"><i class="text-danger on-hover-opaque fa fa-trash-alt ml-1"></i></a>
+                            </div>
+                            <div class="d-flex align-items-center">
+                                <div class="rspace"><input type="radio" value="yes" :name="'item_' + index + '_cancer_colon_ca'" v-model="item.cancer_colon_ca"></div>
+                                <div class="rspace"><input type="radio" value="no" :name="'item_' + index + '_cancer_colon_ca'" v-model="item.cancer_colon_ca"></div>
+                                <span class="ml-2">Colon CA</span>
+                                <a href="#" v-show="item.cancer_colon_ca" v-on:click.prevent="clearValue(item, 'cancer_colon_ca')"><i class="text-danger on-hover-opaque fa fa-trash-alt ml-1"></i></a>
+                            </div>
+                            <div class="d-flex align-items-center">
+                                <div class="rspace"><input type="radio" value="yes" :name="'item_' + index + '_cancer_other_ca'" v-model="item.cancer_other_ca"></div>
+                                <div class="rspace"><input type="radio" value="no" :name="'item_' + index + '_cancer_other_ca'" v-model="item.cancer_other_ca"></div>
+                                <span class="ml-2">Other CA</span>
+                                <a href="#" v-show="item.cancer_other_ca" v-on:click.prevent="clearValue(item, 'cancer_other_ca')"><i class="text-danger on-hover-opaque fa fa-trash-alt ml-1"></i></a>
+                            </div>
+                            <div class="d-flex align-items-center">
+                                <div class="rspace"><input type="radio" value="yes" :name="'item_' + index + '_cancer_ovarian_ca'" v-model="item.cancer_ovarian_ca"></div>
+                                <div class="rspace"><input type="radio" value="no" :name="'item_' + index + '_cancer_ovarian_ca'" v-model="item.cancer_ovarian_ca"></div>
+                                <span class="ml-2">Ovarian CA</span>
+                                <a href="#" v-show="item.cancer_ovarian_ca" v-on:click.prevent="clearValue(item, 'cancer_ovarian_ca')"><i class="text-danger on-hover-opaque fa fa-trash-alt ml-1"></i></a>
+                            </div>
+                            <div class="d-flex align-items-center">
+                                <div class="rspace"><input type="radio" value="yes" :name="'item_' + index + '_cancer_uterine_ca'" v-model="item.cancer_uterine_ca"></div>
+                                <div class="rspace"><input type="radio" value="no" :name="'item_' + index + '_cancer_uterine_ca'" v-model="item.cancer_uterine_ca"></div>
+                                <span class="ml-2">Uterine CA</span>
+                                <a href="#" v-show="item.cancer_uterine_ca" v-on:click.prevent="clearValue(item, 'cancer_uterine_ca')"><i class="text-danger on-hover-opaque fa fa-trash-alt ml-1"></i></a>
+                            </div>
+                        </div>
+                    </div>
+
+                    <div class="row mb-2">
+                        <div class="col-md-12">
+                        <textarea class="form-control form-control-sm" type="text" v-model="item.comments" :model-index="index" placeholder="Additional details (optional)">
+                        </textarea>
+                        </div>
+                    </div>
+
+                </div>
+
+                <div class="form-group my-2">
+                    <button v-if="!unknown" class="btn btn-sm btn-default text-primary border border-primary mr-2"
+                            v-on:click.prevent="addItem()"
+                    >Add Family Member</button>
+                </div>
+
+            </div>
+
+            @if(!!$segment)
+                <div>
+                    <button onclick="return saveVisitForm(this, false, true)" type="button" class="btn btn-sm btn-primary mr-2"><i class="fa fa-save"></i></button>
+                    <div class="d-inline-flex align-self-stretch align-items-center">
+                        <span class="autosave-indicator saving text-sm text-secondary">Saving changes &hellip;</span>
+                        <span class="autosave-indicator saved text-sm text-secondary">
+                            <i class="fa fa-check"></i>
+                            Saved
+                        </span>
+                    </div>
+                </div>
+            @else
+                <div>
+                    <button submit type="button" class="btn btn-sm btn-primary mr-2">Submit</button>
+                    <button cancel type="button" class="btn btn-sm btn-default border" {!! @$closeOnSave ? 'onmousedown="return closeStagPopup()"' : '' !!}>Close</button>
+                </div>
+            @endif
+
+        </form>
+    </div>
+</div>
+<script>
+    (function() {
+
+        window.segmentInitializers.<?= !!@$segment ? $segment->segmentTemplate->internal_name : $segmentInternalName ?> = function() {
+
+            new Vue({
+                el: '#edit-univ_history_family-container',
+                data: {
+                    count: {{ $contentData['count'] }},
+                    unknown: {{ $contentData['unknown'] ? 'true' : 'false' }},
+                    items: <?= json_encode($contentData['items']) ?>
+                },
+                watch: {
+                    $data: {
+                        handler: function(val, oldVal) {
+                            let parent = $('#edit-univ_history_family-container').closest('form');
+                            parent.find('[name="data"]').val(JSON.stringify(this.$data));
+                        },
+                        deep: true
+                    }
+                },
+                methods: {
+
+                    clearValue: function(_item, _key) {
+                        _item[_key] = null;
+                        Vue.nextTick(function() {
+                            $('#edit-univ_history_family-container').find('textarea').first().trigger('input');
+                        });
+                    },
+
+                    addItem: function() {
+                        this.items.push({
+                            relationship: '',
+                            status: '',
+
+                            general_no_health_concern: null,
+                            general_arthritis: null,
+                            general_asthma: null,
+                            general_bleeding_disorder: null,
+                            general_cad_lt_age_55: null,
+                            general_copd: null,
+                            general_diabetes: null,
+                            general_heart_attack: null,
+                            general_heart_disease: null,
+                            general_high_cholesterol: null,
+                            general_hypertension: null,
+                            general_mental_illness: null,
+                            general_osteoporosis: null,
+                            general_stroke: null,
+
+                            cancer_breast_ca: null,
+                            cancer_colon_ca: null,
+                            cancer_other_ca: null,
+                            cancer_ovarian_ca: null,
+                            cancer_uterine_ca: null,
+
+                            comments: '',
+                        });
+                        this.count = this.items.length;
+
+                        // trigger autosave!
+                        Vue.nextTick(() => {
+                            let parent = $('#edit-univ_history_family-container').closest('form');
+                            parent.find('[name="unknown"]').trigger('change');
+                            $('#edit-univ_history_family-container').find('[moe][initialized]').removeAttr('initialized');
+                            initMoes();
+                        });
+                    },
+                    removeItem: function(_index) {
+                        this.items.splice(_index, 1);
+                        this.count = this.items.length;
+
+                        // trigger autosave!
+                        Vue.nextTick(() => {
+                            let parent = $('#edit-univ_history_family-container').closest('form');
+                            parent.find('[name="unknown"]').trigger('change');
+                            hideMoeFormMask();
+                        });
+                    }
+                },
+                mounted: function() {
+                    $('#edit-univ_history_family-container').find('[moe][initialized]').removeAttr('initialized');
+                    initMoes();
+                }
+            });
+
+        };
+
+    }).call(window);
+</script>

+ 92 - 0
resources/views/app/patient/segment-templates/sigma_history_family/log.blade.php

@@ -0,0 +1,92 @@
+<?php
+
+use App\Models\Client;
+use App\Models\Point;
+use App\Models\Note;
+/** @var Client $patient */
+/** @var Note $note */
+
+$labels = [
+    'general_no_health_concern' => 'No health concern',
+    'general_arthritis' => 'Arthritis',
+    'general_asthma' => 'Asthma',
+    'general_bleeding_disorder' => 'Bleeding disorder',
+    'general_cad_lt_age_55' => 'CAD &gt; age 55',
+    'general_copd' => 'COPD',
+    'general_diabetes' => 'Diabetes',
+    'general_heart_attack' => 'Heart attack',
+    'general_heart_disease' => 'Heart disease',
+    'general_high_cholesterol' => 'High cholesterol',
+    'general_hypertension' => 'Hypertension',
+    'general_mental_illness' => 'Mental illness',
+    'general_osteoporosis' => 'Osteoporosis',
+    'general_stroke' => 'Stroke',
+    'cancer_breast_ca' => 'Breast cancer',
+    'cancer_colon_ca' => 'Colon cancer',
+    'cancer_other_ca' => 'Other cancer',
+    'cancer_ovarian_ca' => 'Ovarian cancer',
+    'cancer_uterine_ca' => 'Uterine cancer',
+];
+
+$point = Point::getOnlyTopLevelPointOfCategory($note, 'FAMILY_HISTORY', true);
+
+if($point) {
+    ?> <div class="popup-content-container px-3"> <?php
+    foreach ($point->childReviews as $childReview) {
+        $contentData = $parsed = false;
+        if ($childReview->data) {
+            $childReview->data = json_decode($childReview->data, true);
+            $contentData = $parsed = $childReview->data;
+
+            if($contentData && !$contentData['unknown'] && !!$contentData['count']) {
+                ?>
+                <div class="mb-1 font-weight-bold">{{$childReview->creatorPro->displayName()}} - {{friendly_date($childReview->note->effective_dateest)}}</div>
+                <div class="pl-3 bg-light border p-3 mb-3">
+                <?php
+                for ($i = 0; $i < $contentData['count']; $i++) {
+                    ?>
+                    <div class="<?= $i > 0 ? 'mt-2' : '' ?>">
+                        <div class="">
+                            <b><?= isset($contentData['items'][$i]['relationship']) ? $contentData['items'][$i]['relationship'] : '--' ?></b>
+                            <?php if(isset($contentData['items'][$i]['status']) && !empty($contentData['items'][$i]['status'])): ?>
+                            <span class="ml-1 text-secondary">(<?= $contentData['items'][$i]['status'] ?>)</span>
+                            <?php endif; ?>
+                        </div>
+                        <div class="ml-3">
+                            <?php
+                            $positives = [];
+                            $negatives = [];
+                            foreach ($labels as $k => $v) {
+                                if(isset($contentData['items'][$i][$k])) {
+                                    if(strtolower($contentData['items'][$i][$k]) === 'yes') {
+                                        $positives[] = $v;
+                                    }
+                                    else {
+                                        $negatives[] = $v;
+                                    }
+                                }
+                            }
+                            ?>
+                            @if(count($positives))
+                                <div class="pt-1"><b>Positive for</b>: {!!  implode(', ', $positives) !!}</div>
+                            @endif
+                            @if(count($negatives))
+                                <div class="pt-1"><b>Negative for</b>: {!!  implode(', ', $negatives) !!}</div>
+                            @endif
+                        </div>
+                        <?php if(isset($contentData['items'][$i]['comments']) && !empty($contentData['items'][$i]['comments'])): ?>
+                        <div class="ml-3 pt-1 client-rs-contents">
+                            <b>Comments: </b><?= $contentData['items'][$i]['comments'] ?>
+                        </div>
+                        <?php endif; ?>
+                    </div>
+                    <?php
+                }
+                ?>
+                </div>
+                <?php
+            }
+        }
+    }
+    ?> </div> <?php
+}

+ 100 - 0
resources/views/app/patient/segment-templates/sigma_history_family/summary.blade.php

@@ -0,0 +1,100 @@
+<?php
+
+use App\Models\Client;
+use App\Models\Point;
+use App\Models\Note;
+/** @var Client $patient */
+/** @var Note $note */
+
+if(!@$note) {
+    $note = $patient->coreNote;
+}
+if(!@$sessionKey) {
+    $sessionKey = request()->cookie('sessionKey');
+}
+
+$point = Point::getOrCreateOnlyTopLevelPointOfCategory($note, 'FAMILY_HISTORY', $sessionKey, true);
+
+$contentData = $parsed = false;
+
+$rel = !!$point->relevanceToNote($note);
+
+if ($point->lastChildReview && $point->lastChildReview->data && ($rel || $point->lastChildReview->added_in_note_id === $note->id)) {
+    $point->lastChildReview->data = json_decode($point->lastChildReview->data, true);
+    $contentData = $parsed = $point->lastChildReview->data;
+}
+
+$labels = [
+    'general_no_health_concern' => 'No health concern',
+    'general_arthritis' => 'Arthritis',
+    'general_asthma' => 'Asthma',
+    'general_bleeding_disorder' => 'Bleeding disorder',
+    'general_cad_lt_age_55' => 'CAD &gt; age 55',
+    'general_copd' => 'COPD',
+    'general_diabetes' => 'Diabetes',
+    'general_heart_attack' => 'Heart attack',
+    'general_heart_disease' => 'Heart disease',
+    'general_high_cholesterol' => 'High cholesterol',
+    'general_hypertension' => 'Hypertension',
+    'general_mental_illness' => 'Mental illness',
+    'general_osteoporosis' => 'Osteoporosis',
+    'general_stroke' => 'Stroke',
+    'cancer_breast_ca' => 'Breast cancer',
+    'cancer_colon_ca' => 'Colon cancer',
+    'cancer_other_ca' => 'Other cancer',
+    'cancer_ovarian_ca' => 'Ovarian cancer',
+    'cancer_uterine_ca' => 'Uterine cancer',
+];
+
+if($contentData && !@$contentData['unknown'] && !!$contentData['count']) {
+    for ($i = 0; $i < $contentData['count']; $i++) {
+?>
+<div class="<?= $i > 0 ? 'mt-2' : '' ?>">
+    <div class="">
+        <b><?= isset($contentData['items'][$i]['relationship']) ? $contentData['items'][$i]['relationship'] : '--' ?></b>
+        <?php if(isset($contentData['items'][$i]['status']) && !empty($contentData['items'][$i]['status'])): ?>
+        <span class="ml-1 text-secondary">(<?= $contentData['items'][$i]['status'] ?>)</span>
+        <?php endif; ?>
+    </div>
+    <div class="ml-3">
+        <?php
+        $positives = [];
+        $negatives = [];
+        foreach ($labels as $k => $v) {
+            if(isset($contentData['items'][$i][$k])) {
+                if(strtolower($contentData['items'][$i][$k]) === 'yes') {
+                    $positives[] = $v;
+                }
+                else {
+                    $negatives[] = $v;
+                }
+            }
+        }
+        ?>
+        @if(count($positives))
+            <div class=""><b>Positive for</b>: {!!  implode(', ', $positives) !!}</div>
+        @endif
+        @if(count($negatives))
+            <div class=""><b>Negative for</b>: {!!  implode(', ', $negatives) !!}</div>
+        @endif
+    </div>
+    <?php if(isset($contentData['items'][$i]['comments']) && !empty($contentData['items'][$i]['comments'])): ?>
+    <div class="ml-3 pt-1 client-rs-contents">
+        <b>Comments: </b><?= $contentData['items'][$i]['comments'] ?>
+    </div>
+    <?php endif; ?>
+</div>
+<?php
+    }
+}
+else if(@$contentData['unknown']) {
+    ?>
+    <div class="text-secondary">Family history is unknown/unavailable</div>
+    <?php
+}
+else {
+?>
+<div class="text-secondary">-</div>
+<?php
+}
+?>

+ 281 - 0
resources/views/app/patient/segment-templates/sigma_history_past_medical/edit.blade.php

@@ -0,0 +1,281 @@
+<?php
+
+use App\Models\Client;
+use App\Models\Point;
+use App\Models\Note;
+/** @var Client $patient */
+/** @var Note $note */
+/** @var Segment $segment */
+
+if(!@$segment) $segment = null;
+
+if(!@$sessionKey) {
+    $sessionKey = request()->cookie('sessionKey');
+}
+
+$fields = [
+    [
+        "Head" => ["Trauma"],
+        "Eyes" => ["Blindness", "Cataracts", "Glaucoma", "Wears glasses/contacts"],
+        "Ears" => ["Hearing aids"],
+        "Nose/Sinuses" => ["Allergic Rhinitis", "Sinus infections"],
+        "Mouth/Throat/Teeth" => ["Dentures"],
+        "Cardiovascular" => ["Aneurysm", "Angina", "DVT", "Dysrhythmia", "HTN", "Murmur", "Myocardial infarction", "Other heart disease"],
+    ],
+    [
+        "Respiratory" => ["Asthma", "Bronchitis", "COPD - Bronchitis/Emphysema", "Pleuritis", "Pneumonia"],
+        "Gastrointestinal" => ["Cirrhosis", "GERD", "Gallbladder disease", "Heartburn", "Hemorrhoids", "Hepatitis", "Hiatal hernia", "Jaundice", "Ulcer"],
+        "Genitourinary" => ["Hernia", "Incontinence", "Nephrolithiasis", "Other kidney disease", "STDs", "UTI(s)"],
+    ],
+    [
+        "Musculoskeletal" => ["Arthritis", "Gout", "M/S injury"],
+        "Skin" => ["Dermatitis", "Mole(s)", "Other skin condition(s)", "Psoriasis"],
+        "Neurological" => ["Epilepsy", "Seizures", "Severe headaches, migraines", "Stroke", "TIA"],
+        "Psychiatric" => ["Bipolar disorder", "Depression", "Hallucinations, delusions", "Suicidal ideation", "Suicide attempts"],
+    ],
+    [
+        "Endocrine" => ["Goiter", "Hyperlipidemia", "Hypothyroidism", "Thyroid disease", "Thyroiditis", "Type I DM", "Type II DM"],
+        "Heme/Onc" => ["Anemia", "Cancer"],
+        "Infectious" => ["HIV", "STDs", "Tuberculosis (dz)", "Tuberculosis (exposure)"],
+    ]
+];
+
+$customFields = $pro->canvasCustomItems('pmhx');
+/*$customFields = array_map(function($_item) {
+    return $_item['label'];
+}, $customFields->toArray());*/
+
+if(!$customFields) $customFields = [];
+
+$point = Point::getOrCreateOnlyTopLevelPointOfCategory($note, 'PAST_MEDICAL_HISTORY', $sessionKey, true);
+
+$contentData = $parsed = false;
+
+if ($point->lastChildReview && $point->lastChildReview->data) {
+    $point->lastChildReview->data = json_decode($point->lastChildReview->data, true);
+    $contentData = $parsed = $point->lastChildReview->data;
+}
+
+if(!$contentData) {
+    $contentData = [
+        "bloodType" => "",
+        "bloodRH" => "",
+        "common" => [],
+        "custom" => [],
+        "comments" => "",
+    ];
+}
+
+for ($i = 0; $i < count($fields); $i++) {
+    foreach($fields[$i] as $head => $values) {
+        for($k = 0; $k < count($values); $k++) {
+            $fName = $head . '_' . sanitize_field_name($values[$k]);
+            if(!isset($contentData["common"][$fName])) $contentData["common"][$fName] = null;
+        }
+    }
+}
+?>
+<hr class="hide-outside-popup mt-3 mb-0">
+<div class="p-3 mcp-theme-1">
+    <div {{!!$segment ? 'visit-moe' : 'moe'}} close-on-save close-on-cancel class="d-block">
+        <form show url="/api/visitPoint/upsertChildReview" class="mcp-theme-1"
+                {{!$segment ? 'hook=onHxPopupClosure' : ''}}>
+            @if(!!@$segment)
+                <input type="hidden" name="segmentUid" value="<?= $segment->uid ?>">
+            @else
+                <input type="hidden" name="segmentUid" value="<?= $note->coreSegment->uid ?>">
+            @endif
+            <input type="hidden" name="uid" value="<?= $point->uid ?>">
+            <input type="hidden" name="noteUid" value="<?= $note->uid ?>">
+            <input type="hidden" name="data">
+
+            <div id="edit-univ_history_past_medical-container">
+                <div class="d-flex align-items-center mb-2">
+                    <div class="width-100px mr-3">
+                        <label class="text-secondary mb-1">Blood Type</label>
+                        <select class="form-control form-control-sm width-100px" v-model="bloodType">
+                            <option value=""> -- select -- </option>
+                            <option value="A">A</option>
+                            <option value="AB">AB</option>
+                            <option value="B">B</option>
+                            <option value="O">O</option>
+                        </select>
+                    </div>
+                    <div class="width-100px mr-3">
+                        <label class="text-secondary mb-1">RH</label>
+                        <select class="form-control form-control-sm width-100px" v-model="bloodRH">
+                            <option value=""> -- select -- </option>
+                            <option value="+ve">+ve</option>
+                            <option value="-ve">-ve</option>
+                        </select>
+                    </div>
+                </div>
+                <div class="d-flex align-items-start flex-wrap custom-items-container">
+                    @for ($i = 0; $i < count($fields); $i++)
+                        <div class="w-25">
+                            @foreach($fields[$i] as $head => $values)
+                                <div class="font-weight-bold mb-2">{{ $head }}</div>
+                                <div class="mb-3">
+                                    @for($k = 0; $k < count($values); $k++)
+                                        <?php $fName = $head . '_' . sanitize_field_name($values[$k]); ?>
+                                        <label class="d-flex align-items-start mb-1">
+                                            <input type="checkbox" name="{{ $fName }}" class="mx-0 mt-1"
+                                                   v-model="common['{{$fName}}']">
+                                            <div class="ml-2">
+                                                <div>
+                                                    <span class="mr-2 common-item">{{ $values[$k] }}</span>
+                                                    <div moe relative no-mask v-show="common['{{$fName}}']" >
+                                                        <a href="#" start show>
+                                                            <i class="fa-comment" :class="common['{{$fName}}__comments'] ? 'fas' : 'far'"></i>
+                                                        </a>
+                                                        <div url="/nop">
+                                                            <div class="mb-2">
+                                                                <textarea class="form-control form-control-sm ns-custom-comment min-width-200px"
+                                                                          v-model="common['{{$fName}}__comments']"></textarea>
+                                                            </div>
+                                                            <div class="">
+                                                                <button type="button" class="btn btn-sm btn-primary" cancel>Close
+                                                                </button>
+                                                            </div>
+                                                        </div>
+                                                    </div>
+                                                    <a v-show="common['{{$fName}}']"
+                                                       class="ml-1"
+                                                       open-in-stag-popup
+                                                       mc-initer="problems-center-{{$note->id}}"
+                                                       title="Problems Center"
+                                                       popup-style="wide overflow-visible"
+                                                       href="/problems-center/{{$patient->uid}}/{{$note->uid}}?dx={{urlencode($values[$k])}}">
+                                                        <i class="fa fa-plus-circle on-hover-opaque"></i>
+                                                    </a>
+                                                </div>
+                                                <span v-show="common['{{$fName}}'] && common['{{$fName}}__comments']"
+                                                      v-html="common['{{$fName}}__comments']"
+                                                      class="text-sm text-secondary">
+                                                </span>
+                                            </div>
+                                        </label>
+                                    @endfor
+                                </div>
+                            @endforeach
+                        </div>
+                    @endfor
+                </div>
+                <div class="row border-top pt-3">
+                    <div class="col-12">
+                        @include('app.patient.segment-templates._custom_items.edit')
+                    </div>
+                </div>
+                <hr class="m-neg-4">
+                <div class="mb-2">
+                    <textarea class="form-control form-control-sm" v-model="comments">{!! $parsed && @$parsed->content ? @$parsed->content : '' !!}</textarea>
+                </div>
+            </div>
+
+            @if(!!$segment)
+                <div>
+                    <button submit class="btn btn-sm btn-primary mr-2"><i class="fa fa-save"></i></button>
+                    <div class="d-inline-flex align-self-stretch align-items-center">
+                        <span class="autosave-indicator saving text-sm text-secondary">Saving changes &hellip;</span>
+                        <span class="autosave-indicator saved text-sm text-secondary">
+                        <i class="fa fa-check"></i>
+                        Saved
+                    </span>
+                    </div>
+                </div>
+            @else
+                <div>
+                    <button submit class="btn btn-sm btn-primary mr-2">Submit</button>
+                    <button cancel class="btn btn-sm btn-default border" {!! @$closeOnSave ? 'onmousedown="return closeStagPopup()"' : '' !!}>Close</button>
+                </div>
+            @endif
+
+        </form>
+    </div>
+</div>
+<script>
+    (function() {
+
+        window.segmentInitializers.<?= !!@$segment ? $segment->segmentTemplate->internal_name : $segmentInternalName ?> = function() {
+
+            let model = <?= $contentData ? json_encode($contentData) : '{}' ?>;
+            model.newCustomItemLabel = '';
+            let myCustomFields = <?= json_encode($customFields) ?>;
+            if(!model.customFields) {
+                model.customFields = [];
+            }
+            for (let i = 0; i < myCustomFields.length; i++) {
+                let foundAt = -1;
+                for (let j = 0; j < model.customFields.length; j++) {
+                    if(model.customFields[j].label === myCustomFields[i].label) {
+                        foundAt = j;
+                        break;
+                    }
+                }
+                if(foundAt === -1) {
+                    model.customFields.push({
+                        label: myCustomFields[i].label,
+                        value: '',
+                        comments: '',
+                        uid: myCustomFields[i].uid
+                    })
+                }
+                else {
+                    model.customFields[foundAt].uid = myCustomFields[i].uid;
+                }
+            }
+
+            // if not own AND not active - remove from model.customFields
+            for (let i = model.customFields.length - 1; i >= 0 ; i--) {
+                let foundAt = -1;
+                for (let j = 0; j < myCustomFields.length; j++) {
+                    if(model.customFields[i].label === myCustomFields[j].label) {
+                        foundAt = j;
+                        break;
+                    }
+                }
+                if(foundAt === -1) {
+                    if(!!model.customFields[i].value) {
+                        model.customFields[i].other = true;
+                    }
+                    else {
+                        model.customFields.splice(i, 1);
+                    }
+                }
+            }
+
+            // sort by label
+            model.customFields.sort(function (a, b) {
+                return a.label.localeCompare(b.label);
+            });
+
+            model.itemKey = 'pmhx';
+
+            new Vue({
+                el: '#edit-univ_history_past_medical-container',
+                delimiters: ["@{{","}}"],
+                data: model,
+                mounted: function() {
+                    $('#edit-univ_history_past_medical-container [moe][initialized]').removeAttr('initialized');
+                    initMoes();
+                },
+                watch: {
+                    $data: {
+                        handler: function(val, oldVal) {
+                            let parent = $('#edit-univ_history_past_medical-container').closest('form');
+                            parent.find('[name="data"]').val(JSON.stringify(this.$data));
+                        },
+                        deep: true
+                    }
+                },
+                methods: {
+                    @include('app.patient.segment-templates._custom_items.script')
+                }
+            });
+
+            window.segmentInitializers.<?= !!@$segment ? $segment->segmentTemplate->internal_name : $segmentInternalName ?> = function() {};
+
+        };
+
+    }).call(window);
+</script>

+ 130 - 0
resources/views/app/patient/segment-templates/sigma_history_past_medical/summary.blade.php

@@ -0,0 +1,130 @@
+<?php
+
+use App\Models\Client;
+use App\Models\Point;
+use App\Models\Note;
+/** @var Client $patient */
+/** @var Note $note */
+
+if(!@$note) {
+    $note = $patient->coreNote;
+}
+
+$fields = [
+    [
+        "Head" => ["Trauma"],
+        "Eyes" => ["Blindness", "Cataracts", "Glaucoma", "Wears glasses/contacts"],
+        "Ears" => ["Hearing aids"],
+        "Nose/Sinuses" => ["Allergic Rhinitis", "Sinus infections"],
+        "Mouth/Throat/Teeth" => ["Dentures"],
+        "Cardiovascular" => ["Aneurysm", "Angina", "DVT", "Dysrhythmia", "HTN", "Murmur", "Myocardial infarction", "Other heart disease"],
+    ],
+    [
+        "Respiratory" => ["Asthma", "Bronchitis", "COPD - Bronchitis/Emphysema", "Pleuritis", "Pneumonia"],
+        "Gastrointestinal" => ["Cirrhosis", "GERD", "Gallbladder disease", "Heartburn", "Hemorrhoids", "Hepatitis", "Hiatal hernia", "Jaundice", "Ulcer"],
+        "Genitourinary" => ["Hernia", "Incontinence", "Nephrolithiasis", "Other kidney disease", "STDs", "UTI(s)"],
+    ],
+    [
+        "Musculoskeletal" => ["Arthritis", "Gout", "M/S injury"],
+        "Skin" => ["Dermatitis", "Mole(s)", "Other skin condition(s)", "Psoriasis"],
+        "Neurological" => ["Epilepsy", "Seizures", "Severe headaches, migraines", "Stroke", "TIA"],
+        "Psychiatric" => ["Bipolar disorder", "Depression", "Hallucinations, delusions", "Suicidal ideation", "Suicide attempts"],
+    ],
+    [
+        "Endocrine" => ["Goiter", "Hyperlipidemia", "Hypothyroidism", "Thyroid disease", "Thyroiditis", "Type I DM", "Type II DM"],
+        "Heme/Onc" => ["Anemia", "Cancer"],
+        "Infectious" => ["HIV", "STDs", "Tuberculosis (dz)", "Tuberculosis (exposure)"],
+    ]
+];
+
+$contentData = [
+    "bloodType" => "",
+    "bloodRH" => "",
+    "common" => [],
+    "customFields" => [],
+    "comments" => "",
+];
+$isempty = false;
+
+if(!@$sessionKey) {
+    $sessionKey = request()->cookie('sessionKey');
+}
+
+$point = Point::getOrCreateOnlyTopLevelPointOfCategory($note, 'PAST_MEDICAL_HISTORY', $sessionKey, true);
+
+$contentData = $parsed = false;
+
+$rel = !!$point->relevanceToNote($note);
+
+if ($point->lastChildReview && $point->lastChildReview->data && ($rel || $point->lastChildReview->added_in_note_id === $note->id)) {
+    $point->lastChildReview->data = json_decode($point->lastChildReview->data, true);
+    $contentData = $parsed = $point->lastChildReview->data;
+}
+
+if ($contentData) {
+
+    $blood = [];
+    if(isset($contentData['bloodType'])) {
+        $blood[] = $contentData['bloodType'];
+    }
+    if(isset($contentData['bloodRH'])) {
+        $blood[] = $contentData['bloodRH'];
+    }
+    $blood = implode(" ", $blood);
+    if(!empty(trim($blood))) { ?>
+        <div class="mb-2">
+            <div>Blood Type &amp; RH: <b><?= $blood ?></b></div>
+        </div>
+    <?php }
+
+    for ($i = 0; $i < count($fields); $i++):
+        foreach($fields[$i] as $head => $values):
+            for($k = 0; $k < count($values); $k++):
+                $fName = $head . '_' . sanitize_field_name($values[$k]);
+                if(@$contentData['common'][$fName]): ?>
+                    <div>
+                        <?= ucwords($head) ?>
+                        <i class="fa fa-arrow-right text-sm text-secondary"></i>
+                        <span class="font-weight-bold"><?= $values[$k] ?></span>
+                        <?php if(@$contentData['common'][$fName . '__comments']): ?>
+                            <span class="text-sm ml-1 text-secondary">(<?= $contentData['common'][$fName . '__comments'] ?>)</span>
+                        <?php endif; ?>
+                    </div>
+                <?php
+                endif;
+            endfor;
+        endforeach;
+    endfor;
+
+    // custom fields
+
+    if(isset($contentData['customFields']) && count($contentData['customFields'])):
+        ?> <div class=""> <?php
+        for ($i = 0; $i < count($contentData['customFields']); $i++):
+            $item = $contentData['customFields'][$i];
+            if($item['value']): ?>
+                <div>
+                    Custom
+                    <i class="fa fa-arrow-right text-sm text-secondary"></i>
+                    <span class="font-weight-bold"><?= $item['label'] ?></span>
+                    <?php if($item['comments']): ?>
+                        <span class="text-sm ml-1 text-secondary">(<?= $item['comments'] ?>)</span>
+                    <?php endif; ?>
+                </div>
+            <?php
+            endif;
+        endfor;
+        ?> </div> <?php
+    endif;
+
+    if(isset($contentData['comments']) && !empty(trim($contentData['comments']))) { ?>
+        <div class="mt-2 mb-1">
+            <b>Comments: </b><?= $contentData['comments'] ?>
+        </div>
+    <?php }
+
+} else {
+    echo '<div class="text-secondary">-</div>';
+}
+?>
+

+ 239 - 0
resources/views/app/patient/segment-templates/sigma_history_social/edit.blade.php

@@ -0,0 +1,239 @@
+<?php
+
+use App\Models\Client;
+use App\Models\Point;
+use App\Models\Note;
+/** @var Client $patient */
+/** @var Note $note */
+/** @var Segment $segment */
+
+if(!@$segment) $segment = null;
+
+if(!@$sessionKey) {
+    $sessionKey = request()->cookie('sessionKey');
+}
+
+$fields = [
+    [
+        "Tobacco" => ["Current every day smoker", "Current some day smoker", "Former smoker", "Heavy tobacco smoker", "Light tobacco smoker", "Never smoker", "Smoker, current status unknown", "Unknown if ever smoked "],
+    ],
+    [
+        "Alcohol" => ["Do not drink", "Drink daily", "Frequently drink", "Hx of Alcoholism", "Occasional drink"],
+        "Drug Abuse" => ["IVDU", "Illicit drug use", "No illicit drug use"],
+    ],
+    [
+        "Cardiovascular" => ["Eat healthy meals", "Regular exercise", "Take daily aspirin"],
+        "Safety" => ["Household Smoke detector", "Keep Firearms in home", "Wear seatbelts"],
+    ],
+    [
+        "Sexual Activity" => ["Exposure to STI", "Homosexual encounters", "Not sexually active", "Safe sex practices", "Sexually active"],
+        "Birth Gender" => ["Male", "Female", "Undifferentiated"],
+    ]
+];
+
+$customFields = $pro->canvasCustomItems('sochx');
+/*$customFields = array_map(function($_item) {
+    return $_item['label'];
+}, $customFields->toArray());*/
+
+if(!$customFields) $customFields = [];
+
+$point = Point::getOrCreateOnlyTopLevelPointOfCategory($note, 'SOCIAL_HISTORY', $sessionKey, true);
+
+$contentData = $parsed = false;
+
+if ($point->lastChildReview && $point->lastChildReview->data) {
+    $point->lastChildReview->data = json_decode($point->lastChildReview->data, true);
+    $contentData = $parsed = $point->lastChildReview->data;
+}
+
+if(!$contentData) {
+    $contentData = [
+        "common" => [],
+        "custom" => [],
+        "comments" => "",
+    ];
+}
+
+for ($i = 0; $i < count($fields); $i++) {
+    foreach($fields[$i] as $head => $values) {
+        for($k = 0; $k < count($values); $k++) {
+            $fName = $head . '_' . sanitize_field_name($values[$k]);
+            if(!isset($contentData["common"][$fName])) $contentData["common"][$fName] = null;
+        }
+    }
+}
+?>
+<hr class="hide-outside-popup mt-3 mb-0">
+<div class="p-3 mcp-theme-1">
+    <div {{!!$segment ? 'visit-moe' : 'moe'}} close-on-save close-on-cancel class="d-block">
+        <form show url="/api/visitPoint/upsertChildReview" class="mcp-theme-1"
+                {{!$segment ? 'hook=onHxPopupClosure' : ''}}>
+            @if(!!@$segment)
+                <input type="hidden" name="segmentUid" value="<?= $segment->uid ?>">
+            @else
+                <input type="hidden" name="segmentUid" value="<?= $note->coreSegment->uid ?>">
+            @endif
+            <input type="hidden" name="uid" value="<?= $point->uid ?>">
+            <input type="hidden" name="noteUid" value="<?= $note->uid ?>">
+            <input type="hidden" name="data">
+
+            <div id="edit-univ_history_social-container">
+                <div class="d-flex align-items-start flex-wrap custom-items-container">
+                    @for ($i = 0; $i < count($fields); $i++)
+                        <div class="w-25">
+                            @foreach($fields[$i] as $head => $values)
+                                <div class="font-weight-bold mb-2">{{ $head }}</div>
+                                <div class="mb-3">
+                                    @for($k = 0; $k < count($values); $k++)
+                                        <?php $fName = $head . '_' . sanitize_field_name($values[$k]); ?>
+                                        <label class="d-flex align-items-start mb-1">
+                                            <input type="checkbox" name="{{ $fName }}" class="mx-0 mt-1"
+                                                   v-model="common['{{$fName}}']">
+                                            <div class="ml-2">
+                                                <div>
+                                                    <span class="mr-2 common-item">{{ $values[$k] }}</span>
+                                                    <div moe relative no-mask v-show="common['{{$fName}}']" >
+                                                        <a href="#" start show>
+                                                            <i class="fa-comment" :class="common['{{$fName}}__comments'] ? 'fas' : 'far'"></i>
+                                                        </a>
+                                                        <div url="/nop" right>
+                                                            <div class="mb-2">
+                                                                <textarea class="form-control form-control-sm ns-custom-comment min-width-200px"
+                                                                          v-model="common['{{$fName}}__comments']"></textarea>
+                                                            </div>
+                                                            <div class="">
+                                                                <button type="button" class="btn btn-sm btn-primary" cancel>Close
+                                                                </button>
+                                                            </div>
+                                                        </div>
+                                                    </div>
+                                                </div>
+                                                <span v-show="common['{{$fName}}'] && common['{{$fName}}__comments']"
+                                                      v-html="common['{{$fName}}__comments']"
+                                                      class="text-sm text-secondary">
+                                                </span>
+                                            </div>
+                                        </label>
+                                    @endfor
+                                </div>
+                            @endforeach
+                        </div>
+                    @endfor
+                </div>
+                <div class="row border-top pt-3">
+                    <div class="col-12">
+                        @include('app.patient.segment-templates._custom_items.edit')
+                    </div>
+                </div>
+                <hr class="m-neg-4">
+                <div class="mb-2">
+                    <textarea class="form-control form-control-sm" v-model="comments">{!! $parsed && @$parsed->content ? @$parsed->content : '' !!}</textarea>
+                </div>
+            </div>
+
+            @if(!!$segment)
+                <div>
+                    <button submit class="btn btn-sm btn-primary mr-2"><i class="fa fa-save"></i></button>
+                    <div class="d-inline-flex align-self-stretch align-items-center">
+                        <span class="autosave-indicator saving text-sm text-secondary">Saving changes &hellip;</span>
+                        <span class="autosave-indicator saved text-sm text-secondary">
+                            <i class="fa fa-check"></i>
+                            Saved
+                        </span>
+                    </div>
+                </div>
+            @else
+                <div>
+                    <button submit class="btn btn-sm btn-primary mr-2">Submit</button>
+                    <button cancel class="btn btn-sm btn-default border" {!! @$closeOnSave ? 'onmousedown="return closeStagPopup()"' : '' !!}>Close</button>
+                </div>
+            @endif
+
+        </form>
+    </div>
+</div>
+<script>
+    (function() {
+
+        window.segmentInitializers.<?= !!@$segment ? $segment->segmentTemplate->internal_name : $segmentInternalName ?> = function() {
+
+            let model = <?= $contentData ? json_encode($contentData) : '{}' ?>;
+            model.newCustomItemLabel = '';
+            let myCustomFields = <?= json_encode($customFields) ?>;
+            if(!model.customFields) {
+                model.customFields = [];
+            }
+            for (let i = 0; i < myCustomFields.length; i++) {
+                let foundAt = -1;
+                for (let j = 0; j < model.customFields.length; j++) {
+                    if(model.customFields[j].label === myCustomFields[i].label) {
+                        foundAt = j;
+                        break;
+                    }
+                }
+                if(foundAt === -1) {
+                    model.customFields.push({
+                        label: myCustomFields[i].label,
+                        value: '',
+                        comments: '',
+                        uid: myCustomFields[i].uid
+                    })
+                }
+                else {
+                    model.customFields[foundAt].uid = myCustomFields[i].uid;
+                }
+            }
+
+            // if not own AND not active - remove from model.customFields
+            for (let i = model.customFields.length - 1; i >= 0 ; i--) {
+                let foundAt = -1;
+                for (let j = 0; j < myCustomFields.length; j++) {
+                    if(model.customFields[i].label === myCustomFields[j].label) {
+                        foundAt = j;
+                        break;
+                    }
+                }
+                if(foundAt === -1) {
+                    if(!!model.customFields[i].value) {
+                        model.customFields[i].other = true;
+                    }
+                    else {
+                        model.customFields.splice(i, 1);
+                    }
+                }
+            }
+
+            // sort by label
+            model.customFields.sort(function (a, b) {
+                return a.label.localeCompare(b.label);
+            });
+
+            model.itemKey = 'sochx';
+
+            new Vue({
+                el: '#edit-univ_history_social-container',
+                delimiters: ["@{{","}}"],
+                data: model,
+                mounted: function() {
+                    $('#edit-univ_history_social-container [moe][initialized]').removeAttr('initialized');
+                    initMoes();
+                },
+                watch: {
+                    $data: {
+                        handler: function(val, oldVal) {
+                            let parent = $('#edit-univ_history_social-container').closest('form');
+                            parent.find('[name="data"]').val(JSON.stringify(this.$data));
+                        },
+                        deep: true
+                    }
+                },
+                methods: {
+                    @include('app.patient.segment-templates._custom_items.script')
+                }
+            });
+
+        };
+
+    }).call(window);
+</script>

+ 89 - 0
resources/views/app/patient/segment-templates/sigma_history_social/log.blade.php

@@ -0,0 +1,89 @@
+<?php
+
+use App\Models\Client;
+use App\Models\Point;
+use App\Models\Note;
+/** @var Client $patient */
+/** @var Note $note */
+
+$fields = [
+    [
+        "Tobacco" => ["Current every day smoker", "Current some day smoker", "Former smoker", "Heavy tobacco smoker", "Light tobacco smoker", "Never smoker", "Smoker, current status unknown", "Unknown if ever smoked "],
+    ],
+    [
+        "Alcohol" => ["Do not drink", "Drink daily", "Frequently drink", "Hx of Alcoholism", "Occasional drink"],
+        "Drug Abuse" => ["IVDU", "Illicit drug use", "No illicit drug use"],
+    ],
+    [
+        "Cardiovascular" => ["Eat healthy meals", "Regular exercise", "Take daily aspirin"],
+        "Safety" => ["Household Smoke detector", "Keep Firearms in home", "Wear seatbelts"],
+    ],
+    [
+        "Sexual Activity" => ["Exposure to STI", "Homosexual encounters", "Not sexually active", "Safe sex practices", "Sexually active"],
+        "Birth Gender" => ["Male", "Female", "Undifferentiated"],
+    ]
+];
+
+$point = Point::getOnlyTopLevelPointOfCategory($note, 'SOCIAL_HISTORY', true);
+
+if($point) {
+    ?> <div class="popup-content-container px-3"> <?php
+    foreach ($point->childReviews as $childReview) {
+        $contentData = $parsed = false;
+        if ($childReview->data) {
+            $childReview->data = json_decode($childReview->data, true);
+            $contentData = $parsed = $childReview->data;
+            ?>
+            <div class="mb-1 font-weight-bold">{{$childReview->creatorPro->displayName()}} - {{friendly_date($childReview->note->effective_dateest)}}</div>
+            <div class="pl-3 bg-light border p-3 mb-3">
+            <?php
+
+            for ($i = 0; $i < count($fields); $i++):
+            foreach($fields[$i] as $head => $values):
+            for($k = 0; $k < count($values); $k++):
+            $fName = $head . '_' . sanitize_field_name($values[$k]);
+            if(@$contentData['common'][$fName]): ?>
+            <div>
+                <?= ucwords($head) ?>
+                <i class="fa fa-arrow-right text-sm text-secondary"></i>
+                <span class="font-weight-bold"><?= $values[$k] ?></span>
+                <?php if(@$contentData['common'][$fName . '__comments']): ?>
+                <span class="text-sm ml-1 text-secondary">(<?= $contentData['common'][$fName . '__comments'] ?>)</span>
+                <?php endif; ?>
+            </div>
+            <?php
+            endif;
+            endfor;
+            endforeach;
+            endfor;
+
+            // custom fields
+
+            if(isset($contentData['customFields']) && count($contentData['customFields'])):
+            ?> <div class=""> <?php
+                for ($i = 0; $i < count($contentData['customFields']); $i++):
+                $item = $contentData['customFields'][$i];
+                if($item['value']): ?>
+                <div>
+                    Custom
+                    <i class="fa fa-arrow-right text-sm text-secondary"></i>
+                    <span class="font-weight-bold"><?= $item['label'] ?></span>
+                    <?php if($item['comments']): ?>
+                    <span class="text-sm ml-1 text-secondary">(<?= $item['comments'] ?>)</span>
+                    <?php endif; ?>
+                </div>
+                <?php
+                endif;
+                endfor;
+                ?> </div> <?php
+            endif;
+
+            if(isset($contentData['comments']) && !empty(trim($contentData['comments']))) { ?>
+            <div class="mt-2 mb-1">
+                <b>Comments: </b><?= $contentData['comments'] ?>
+            </div>
+            <?php }
+        }
+    }
+    ?> </div> <?php
+}

+ 94 - 0
resources/views/app/patient/segment-templates/sigma_history_social/summary.blade.php

@@ -0,0 +1,94 @@
+<?php
+
+use App\Models\Client;
+use App\Models\Point;
+use App\Models\Note;
+/** @var Client $patient */
+/** @var Note $note */
+/** @var Segment $segment */
+
+$fields = [
+    [
+        "Tobacco" => ["Current every day smoker", "Current some day smoker", "Former smoker", "Heavy tobacco smoker", "Light tobacco smoker", "Never smoker", "Smoker, current status unknown", "Unknown if ever smoked "],
+    ],
+    [
+        "Alcohol" => ["Do not drink", "Drink daily", "Frequently drink", "Hx of Alcoholism", "Occasional drink"],
+        "Drug Abuse" => ["IVDU", "Illicit drug use", "No illicit drug use"],
+    ],
+    [
+        "Cardiovascular" => ["Eat healthy meals", "Regular exercise", "Take daily aspirin"],
+        "Safety" => ["Household Smoke detector", "Keep Firearms in home", "Wear seatbelts"],
+    ],
+    [
+        "Sexual Activity" => ["Exposure to STI", "Homosexual encounters", "Not sexually active", "Safe sex practices", "Sexually active"],
+        "Birth Gender" => ["Male", "Female", "Undifferentiated"],
+    ]
+];
+
+if(!@$note) {
+    $note = $patient->coreNote;
+}
+if(!@$sessionKey) {
+    $sessionKey = request()->cookie('sessionKey');
+}
+
+$point = Point::getOrCreateOnlyTopLevelPointOfCategory($note, 'SOCIAL_HISTORY', $sessionKey, true);
+
+$contentData = $parsed = false;
+
+$rel = !!$point->relevanceToNote($note);
+
+if ($point->lastChildReview && $point->lastChildReview->data && ($rel || $point->lastChildReview->added_in_note_id === $note->id)) {
+    $point->lastChildReview->data = json_decode($point->lastChildReview->data, true);
+    $contentData = $parsed = $point->lastChildReview->data;
+
+    for ($i = 0; $i < count($fields); $i++):
+        foreach($fields[$i] as $head => $values):
+            for($k = 0; $k < count($values); $k++):
+                $fName = $head . '_' . sanitize_field_name($values[$k]);
+                if(@$contentData['common'][$fName]): ?>
+                    <div>
+                        <?= ucwords($head) ?>
+                        <i class="fa fa-arrow-right text-sm text-secondary"></i>
+                        <span class="font-weight-bold"><?= $values[$k] ?></span>
+                        <?php if(@$contentData['common'][$fName . '__comments']): ?>
+                            <span class="text-sm ml-1 text-secondary">(<?= $contentData['common'][$fName . '__comments'] ?>)</span>
+                        <?php endif; ?>
+                    </div>
+                <?php
+                endif;
+            endfor;
+        endforeach;
+    endfor;
+
+    // custom fields
+
+    if(isset($contentData['customFields']) && count($contentData['customFields'])):
+        ?> <div class=""> <?php
+        for ($i = 0; $i < count($contentData['customFields']); $i++):
+            $item = $contentData['customFields'][$i];
+            if($item['value']): ?>
+                <div>
+                    Custom
+                    <i class="fa fa-arrow-right text-sm text-secondary"></i>
+                    <span class="font-weight-bold"><?= $item['label'] ?></span>
+                    <?php if($item['comments']): ?>
+                        <span class="text-sm ml-1 text-secondary">(<?= $item['comments'] ?>)</span>
+                    <?php endif; ?>
+                </div>
+            <?php
+            endif;
+        endfor;
+        ?> </div> <?php
+    endif;
+
+    if(isset($contentData['comments']) && !empty(trim($contentData['comments']))) { ?>
+        <div class="mt-2 mb-1">
+            <b>Comments: </b><?= $contentData['comments'] ?>
+        </div>
+    <?php }
+}
+else {
+    echo '<span class="text-secondary">-</span>';
+}
+?>

+ 239 - 0
resources/views/app/patient/segment-templates/sigma_history_surgical/edit.blade.php

@@ -0,0 +1,239 @@
+<?php
+
+use App\Models\Client;
+use App\Models\Point;
+use App\Models\Note;
+/** @var Client $patient */
+/** @var Note $note */
+/** @var Segment $segment */
+
+if(!@$segment) $segment = null;
+
+if(!@$sessionKey) {
+    $sessionKey = request()->cookie('sessionKey');
+}
+
+$fields = [
+    [
+        "" => ["Aneurysm repair", "Appendectomy", "Back surgery", "Bariatric surgery/gastric bypass", "Bilateral tubal ligation", "Breast resection/mastectomy", "CABG", "Carotid endarterectomy/stent", "Carpal tunnel release surgery",]
+    ],
+    [
+        "" => ["Cataract/lens surgery", "Cesarean section", "Cholecystectomy/bile duct surgery", "Dilation and curettage", "Hemorrhoid surgery", "Hip arthroplasty", "Hip replacement", "Hysterectomy", "Inguinal hernia repair",]
+    ],
+    [
+        "" => ["Knee arthroplasty", "LASIK", "Laminectomy", "Nasal surgery", "PTCA/PCI", "Pacemaker/defibrillator", "Prostate surgery", "Prostatectomy", "Rotator cuff surgery",]
+    ],
+    [
+        "" => ["Sinus surgery", "Skin cancer excision", "Spinal fusion", "TAH-BSO", "TURP", "Tonsillectomy/Adenoidectomy", "Vasectomy",]
+    ]
+];
+
+$customFields = $pro->canvasCustomItems('pshx');
+/*$customFields = array_map(function($_item) {
+    return $_item['label'];
+}, $customFields->toArray());*/
+
+if(!$customFields) $customFields = [];
+
+$point = Point::getOrCreateOnlyTopLevelPointOfCategory($note, 'SURGICAL_HISTORY', $sessionKey, true);
+
+$contentData = $parsed = false;
+
+if ($point->lastChildReview && $point->lastChildReview->data) {
+    $point->lastChildReview->data = json_decode($point->lastChildReview->data, true);
+    $contentData = $parsed = $point->lastChildReview->data;
+}
+
+if(!$contentData) {
+    $contentData = [
+        "common" => [],
+        "custom" => [],
+        "comments" => "",
+    ];
+}
+
+for ($i = 0; $i < count($fields); $i++) {
+    foreach($fields[$i] as $head => $values) {
+        for($k = 0; $k < count($values); $k++) {
+            $fName = $head . '_' . sanitize_field_name($values[$k]);
+            if(!isset($contentData["common"][$fName])) $contentData["common"][$fName] = null;
+        }
+    }
+}
+?>
+<hr class="hide-outside-popup mt-3 mb-0">
+<div class="p-3 mcp-theme-1">
+    <div {{!!$segment ? 'visit-moe' : 'moe'}} close-on-save close-on-cancel class="d-block">
+        <form show url="/api/visitPoint/upsertChildReview" class="mcp-theme-1"
+                {{!$segment ? 'hook=onHxPopupClosure' : ''}}>
+            @if(!!@$segment)
+                <input type="hidden" name="segmentUid" value="<?= $segment->uid ?>">
+            @else
+                <input type="hidden" name="segmentUid" value="<?= $note->coreSegment->uid ?>">
+            @endif
+            <input type="hidden" name="uid" value="<?= $point->uid ?>">
+            <input type="hidden" name="noteUid" value="<?= $note->uid ?>">
+            <input type="hidden" name="data">
+
+            <div id="edit-univ_history_surgical-container">
+                <div class="d-flex align-items-center mb-2">
+                    <span class="font-weight-bold">Common Surgeries</span>
+                </div>
+                <div class="d-flex align-items-start flex-wrap custom-items-container">
+                    @for ($i = 0; $i < count($fields); $i++)
+                        <div class="w-25">
+                            @foreach($fields[$i] as $head => $values)
+                                <div class="font-weight-bold mb-2">{{ $head }}</div>
+                                <div class="mb-3">
+                                    @for($k = 0; $k < count($values); $k++)
+                                        <?php $fName = $head . '_' . sanitize_field_name($values[$k]); ?>
+                                        <label class="d-flex align-items-start mb-1">
+                                            <input type="checkbox" name="{{ $fName }}" class="mx-0 mt-1"
+                                                   v-model="common['{{$fName}}']">
+                                            <div class="ml-2">
+                                                <div>
+                                                    <span class="mr-2 common-item">{{ $values[$k] }}</span>
+                                                    <div moe relative no-mask v-show="common['{{$fName}}']" >
+                                                        <a href="#" start show>
+                                                            <i class="fa-comment" :class="common['{{$fName}}__comments'] ? 'fas' : 'far'"></i>
+                                                        </a>
+                                                        <div url="/nop" right>
+                                                            <div class="mb-2">
+                                                                <textarea class="form-control form-control-sm ns-custom-comment min-width-200px"
+                                                                          v-model="common['{{$fName}}__comments']"></textarea>
+                                                            </div>
+                                                            <div class="">
+                                                                <button type="button" class="btn btn-sm btn-primary" cancel>Close
+                                                                </button>
+                                                            </div>
+                                                        </div>
+                                                    </div>
+                                                </div>
+                                                <span v-show="common['{{$fName}}'] && common['{{$fName}}__comments']"
+                                                      v-html="common['{{$fName}}__comments']"
+                                                      class="text-sm text-secondary">
+                                                </span>
+                                            </div>
+                                        </label>
+                                    @endfor
+                                </div>
+                            @endforeach
+                        </div>
+                    @endfor
+                </div>
+                <div class="row border-top pt-3">
+                    <div class="col-12">
+                        @include('app.patient.segment-templates._custom_items.edit')
+                    </div>
+                </div>
+                <hr class="m-neg-4">
+                <div class="mb-2">
+                    <textarea class="form-control form-control-sm" v-model="comments">{!! $parsed && @$parsed->content ? @$parsed->content : '' !!}</textarea>
+                </div>
+            </div>
+
+            @if(!!$segment)
+                <div>
+                    <button submit class="btn btn-sm btn-primary mr-2"><i class="fa fa-save"></i></button>
+                    <div class="d-inline-flex align-self-stretch align-items-center">
+                        <span class="autosave-indicator saving text-sm text-secondary">Saving changes &hellip;</span>
+                        <span class="autosave-indicator saved text-sm text-secondary">
+                            <i class="fa fa-check"></i>
+                            Saved
+                        </span>
+                    </div>
+                </div>
+            @else
+                <div>
+                    <button submit class="btn btn-sm btn-primary mr-2">Submit</button>
+                    <button cancel class="btn btn-sm btn-default border" {!! @$closeOnSave ? 'onmousedown="return closeStagPopup()"' : '' !!}>Close</button>
+                </div>
+            @endif
+
+        </form>
+    </div>
+</div>
+<script>
+    (function() {
+
+        window.segmentInitializers.<?= !!@$segment ? $segment->segmentTemplate->internal_name : $segmentInternalName ?> = function() {
+
+            let model = <?= $contentData ? json_encode($contentData) : '{}' ?>;
+            model.newCustomItemLabel = '';
+            let myCustomFields = <?= json_encode($customFields) ?>;
+            if(!model.customFields) {
+                model.customFields = [];
+            }
+            for (let i = 0; i < myCustomFields.length; i++) {
+                let foundAt = -1;
+                for (let j = 0; j < model.customFields.length; j++) {
+                    if(model.customFields[j].label === myCustomFields[i].label) {
+                        foundAt = j;
+                        break;
+                    }
+                }
+                if(foundAt === -1) {
+                    model.customFields.push({
+                        label: myCustomFields[i].label,
+                        value: '',
+                        comments: '',
+                        uid: myCustomFields[i].uid
+                    })
+                }
+                else {
+                    model.customFields[foundAt].uid = myCustomFields[i].uid;
+                }
+            }
+
+            // if not own AND not active - remove from model.customFields
+            for (let i = model.customFields.length - 1; i >= 0 ; i--) {
+                let foundAt = -1;
+                for (let j = 0; j < myCustomFields.length; j++) {
+                    if(model.customFields[i].label === myCustomFields[j].label) {
+                        foundAt = j;
+                        break;
+                    }
+                }
+                if(foundAt === -1) {
+                    if(!!model.customFields[i].value) {
+                        model.customFields[i].other = true;
+                    }
+                    else {
+                        model.customFields.splice(i, 1);
+                    }
+                }
+            }
+
+            // sort by label
+            model.customFields.sort(function (a, b) {
+                return a.label.localeCompare(b.label);
+            });
+
+            model.itemKey = 'pshx';
+
+            new Vue({
+                el: '#edit-univ_history_surgical-container',
+                delimiters: ["@{{","}}"],
+                data: model,
+                mounted: function() {
+                    $('#edit-univ_history_surgical-container [moe][initialized]').removeAttr('initialized');
+                    initMoes();
+                },
+                watch: {
+                    $data: {
+                        handler: function(val, oldVal) {
+                            let parent = $('#edit-univ_history_surgical-container').closest('form');
+                            parent.find('[name="data"]').val(JSON.stringify(this.$data));
+                        },
+                        deep: true
+                    }
+                },
+                methods: {
+                    @include('app.patient.segment-templates._custom_items.script')
+                }
+            });
+
+        };
+
+    }).call(window);
+</script>

+ 88 - 0
resources/views/app/patient/segment-templates/sigma_history_surgical/log.blade.php

@@ -0,0 +1,88 @@
+<?php
+
+use App\Models\Client;
+use App\Models\Point;
+use App\Models\Note;
+/** @var Client $patient */
+/** @var Note $note */
+
+$fields = [
+    [
+        "" => ["Aneurysm repair", "Appendectomy", "Back surgery", "Bariatric surgery/gastric bypass", "Bilateral tubal ligation", "Breast resection/mastectomy", "CABG", "Carotid endarterectomy/stent", "Carpal tunnel release surgery",]
+    ],
+    [
+        "" => ["Cataract/lens surgery", "Cesarean section", "Cholecystectomy/bile duct surgery", "Dilation and curettage", "Hemorrhoid surgery", "Hip arthroplasty", "Hip replacement", "Hysterectomy", "Inguinal hernia repair",]
+    ],
+    [
+        "" => ["Knee arthroplasty", "LASIK", "Laminectomy", "Nasal surgery", "PTCA/PCI", "Pacemaker/defibrillator", "Prostate surgery", "Prostatectomy", "Rotator cuff surgery",]
+    ],
+    [
+        "" => ["Sinus surgery", "Skin cancer excision", "Spinal fusion", "TAH-BSO", "TURP", "Tonsillectomy/Adenoidectomy", "Vasectomy",]
+    ]
+];
+
+
+$point = Point::getOnlyTopLevelPointOfCategory($note, 'SURGICAL_HISTORY', true);
+
+if($point) {
+    ?> <div class="popup-content-container px-3"> <?php
+    foreach ($point->childReviews as $childReview) {
+        $contentData = $parsed = false;
+        if ($childReview->data) {
+            $childReview->data = json_decode($childReview->data, true);
+            $contentData = $parsed = $childReview->data;
+
+            ?>
+            <div class="mb-1 font-weight-bold">{{$childReview->creatorPro->displayName()}} - {{friendly_date($childReview->note->effective_dateest)}}</div>
+            <div class="pl-3 bg-light border p-3 mb-3">
+            <?php
+
+            for ($i = 0; $i < count($fields); $i++):
+            foreach($fields[$i] as $head => $values):
+            for($k = 0; $k < count($values); $k++):
+            $fName = $head . '_' . sanitize_field_name($values[$k]);
+            if(@$contentData['common'][$fName]): ?>
+            <div>
+                <!--Common
+                <i class="fa fa-arrow-right text-sm text-secondary"></i>-->
+                <span class="font-weight-bold"><?= $values[$k] ?></span>
+                <?php if(@$contentData['common'][$fName . '__comments']): ?>
+                <span class="text-sm ml-1 text-secondary">(<?= $contentData['common'][$fName . '__comments'] ?>)</span>
+                <?php endif; ?>
+            </div>
+            <?php
+            endif;
+            endfor;
+            endforeach;
+            endfor;
+
+            // custom fields
+
+            if(isset($contentData['customFields']) && count($contentData['customFields'])):
+            ?> <div class=""> <?php
+                for ($i = 0; $i < count($contentData['customFields']); $i++):
+                $item = $contentData['customFields'][$i];
+                if($item['value']): ?>
+                <div>
+                    <!--Custom
+                    <i class="fa fa-arrow-right text-sm text-secondary"></i>-->
+                    <span class="font-weight-bold"><?= $item['label'] ?></span>
+                    <?php if($item['comments']): ?>
+                    <span class="text-sm ml-1 text-secondary">(<?= $item['comments'] ?>)</span>
+                    <?php endif; ?>
+                </div>
+                <?php
+                endif;
+                endfor;
+                ?> </div> <?php
+            endif;
+
+            if(isset($contentData['comments']) && !empty(trim($contentData['comments']))) { ?>
+            <div class="mt-2 mb-1">
+                <b>Comments: </b><?= $contentData['comments'] ?>
+            </div>
+            <?php }
+        }
+    }
+    ?> </div> <?php
+}

+ 91 - 0
resources/views/app/patient/segment-templates/sigma_history_surgical/summary.blade.php

@@ -0,0 +1,91 @@
+<?php
+
+use App\Models\Client;
+use App\Models\Point;
+use App\Models\Note;
+/** @var Client $patient */
+/** @var Note $note */
+/** @var Segment $segment */
+
+if(!@$note) {
+    $note = $patient->coreNote;
+}
+if(!@$sessionKey) {
+    $sessionKey = request()->cookie('sessionKey');
+}
+
+$fields = [
+    [
+        "" => ["Aneurysm repair", "Appendectomy", "Back surgery", "Bariatric surgery/gastric bypass", "Bilateral tubal ligation", "Breast resection/mastectomy", "CABG", "Carotid endarterectomy/stent", "Carpal tunnel release surgery",]
+    ],
+    [
+        "" => ["Cataract/lens surgery", "Cesarean section", "Cholecystectomy/bile duct surgery", "Dilation and curettage", "Hemorrhoid surgery", "Hip arthroplasty", "Hip replacement", "Hysterectomy", "Inguinal hernia repair",]
+    ],
+    [
+        "" => ["Knee arthroplasty", "LASIK", "Laminectomy", "Nasal surgery", "PTCA/PCI", "Pacemaker/defibrillator", "Prostate surgery", "Prostatectomy", "Rotator cuff surgery",]
+    ],
+    [
+        "" => ["Sinus surgery", "Skin cancer excision", "Spinal fusion", "TAH-BSO", "TURP", "Tonsillectomy/Adenoidectomy", "Vasectomy",]
+    ]
+];
+
+$point = Point::getOrCreateOnlyTopLevelPointOfCategory($note, 'SURGICAL_HISTORY', $sessionKey, true);
+
+$contentData = $parsed = false;
+
+$rel = !!$point->relevanceToNote($note);
+
+if ($point->lastChildReview && $point->lastChildReview->data && ($rel || $point->lastChildReview->added_in_note_id === $note->id)) {
+    $point->lastChildReview->data = json_decode($point->lastChildReview->data, true);
+    $contentData = $parsed = $point->lastChildReview->data;
+
+    for ($i = 0; $i < count($fields); $i++):
+        foreach($fields[$i] as $head => $values):
+            for($k = 0; $k < count($values); $k++):
+                $fName = $head . '_' . sanitize_field_name($values[$k]);
+                if(@$contentData['common'][$fName]): ?>
+                    <div>
+                        <!--Common
+                        <i class="fa fa-arrow-right text-sm text-secondary"></i>-->
+                        <span class="font-weight-bold"><?= $values[$k] ?></span>
+                        <?php if(@$contentData['common'][$fName . '__comments']): ?>
+                            <span class="text-sm ml-1 text-secondary">(<?= $contentData['common'][$fName . '__comments'] ?>)</span>
+                        <?php endif; ?>
+                    </div>
+                <?php
+                endif;
+            endfor;
+        endforeach;
+    endfor;
+
+    // custom fields
+
+    if(isset($contentData['customFields']) && count($contentData['customFields'])):
+        ?> <div class=""> <?php
+        for ($i = 0; $i < count($contentData['customFields']); $i++):
+            $item = $contentData['customFields'][$i];
+            if($item['value']): ?>
+                <div>
+                    <!--Custom
+                    <i class="fa fa-arrow-right text-sm text-secondary"></i>-->
+                    <span class="font-weight-bold"><?= $item['label'] ?></span>
+                    <?php if($item['comments']): ?>
+                        <span class="text-sm ml-1 text-secondary">(<?= $item['comments'] ?>)</span>
+                    <?php endif; ?>
+                </div>
+            <?php
+            endif;
+        endfor;
+        ?> </div> <?php
+    endif;
+
+    if(isset($contentData['comments']) && !empty(trim($contentData['comments']))) { ?>
+        <div class="mt-2 mb-1">
+            <b>Comments: </b><?= $contentData['comments'] ?>
+        </div>
+    <?php }
+}
+else {
+    echo '<span class="text-secondary">-</span>';
+}
+?>

+ 50 - 0
resources/views/app/patient/segment-templates/sigma_informed_consent/edit.blade.php

@@ -0,0 +1,50 @@
+<?php
+
+use App\Models\Point;
+
+$category = 'INFORMED_CONSENT';
+$endPoint = 'upsertNoteSingleton';
+
+$point = Point::where('added_in_note_id', $note->id)->where('category', $category)->orderBy('id', 'DESC')->first();
+$contentData = [
+    "informed_consent" => false
+];
+if (!!@$point->data) {
+    $contentData = json_decode($point->data, true);
+}
+?>
+<div visit-moe close-on-save close-on-cancel class="d-block pb-2">
+    <form show url="/api/visitPoint/<?= $endPoint ?>" class="mcp-theme-1">
+        <input type="hidden" name="segmentUid" value="<?= $segment->uid ?>">
+        <input type="hidden" name="category" value="<?= $category ?>">
+        <input type="hidden" name="data" value="{{json_encode($contentData)}}">
+
+        <label class="d-flex align-items-baseline">
+            <div class="mr-2 align-self-stretch" style="padding-top: 2px;">
+                <input type="checkbox" data-name="informed_consent" {{@($contentData["informed_consent"] ? 'checked' : '')}}>
+            </div>
+            <div>
+                <div>This is a {{$note->method}} visit that was performed on {{friendly_date($note->effective_dateest)}}. Verbal consent to participate was obtained.</div>
+                <div>This visit occurred during the Coronavirus (COVID-19) Public Health Emergency.</div>
+                <div>I discussed with the patient the nature of our visit, that:</div>
+                <div class="ml-3">- I would evaluate the patient and recommend diagnostics and treatments based on my assessment.</div>
+                <div class="ml-3">- Our sessions are not being recorded, and that personal health information is protected.</div>
+                <div class="ml-3">- Our team would provide follow-up care in person if/when the patient needs it.</div>
+                <div class="ml-3">- No physical exam was performed due to the remote nature of this evaluation.</div>
+            </div>
+        </label>
+
+        <div class="pt-2">
+            <button submit class="btn btn-sm btn-primary mr-2"><i class="fa fa-save"></i></button>
+            <div class="d-inline-flex align-self-stretch align-items-center">
+                <span class="autosave-indicator saving text-sm text-secondary">Saving changes &hellip;</span>
+                <span class="autosave-indicator saved text-sm text-secondary">
+                    <i class="fa fa-check"></i>
+                    Saved
+                </span>
+            </div>
+        </div>
+    </form>
+</div>
+
+

+ 38 - 0
resources/views/app/patient/segment-templates/sigma_informed_consent/summary.blade.php

@@ -0,0 +1,38 @@
+<?php
+
+use App\Models\Point;
+
+$category = 'INFORMED_CONSENT';
+$endPoint = 'upsertNoteSingleton';
+
+$point = Point::where('added_in_note_id', $note->id)->where('category', $category)->orderBy('id', 'DESC')->first();
+$contentData = [
+    "informed_consent" => false
+];
+if (!!@$point->data) {
+    $contentData = json_decode($point->data, true);
+}
+?>
+
+<div class="d-flex align-items-baseline">
+    @if(!@($contentData["informed_consent"]))
+        <div class="align-self-stretch min-width-30px text-left">
+            <i class="fa fa-exclamation-triangle"></i>
+        </div>
+    @endif
+    <div class="flex-grow-1">
+    @if(@($contentData["informed_consent"]))
+        <div>
+            <div>This is a {{$note->method}} visit that was performed on {{friendly_date($note->effective_dateest)}}. Verbal consent to participate was obtained.</div>
+            <div>This visit occurred during the Coronavirus (COVID-19) Public Health Emergency.</div>
+            <div>I discussed with the patient the nature of our visit, that:</div>
+            <div class="ml-3">- I would evaluate the patient and recommend diagnostics and treatments based on my assessment.</div>
+            <div class="ml-3">- Our sessions are not being recorded, and that personal health information is protected.</div>
+            <div class="ml-3">- Our team would provide follow-up care in person if/when the patient needs it.</div>
+            <div class="ml-3">- No physical exam was performed due to the remote nature of this evaluation.</div>
+        </div>
+    @else
+        <div>Please click here to document informed consent.</div>
+    @endif
+    </div>
+</div>

+ 24 - 0
resources/views/app/patient/segment-templates/sigma_medications/active-linear-summary.blade.php

@@ -0,0 +1,24 @@
+<?php
+
+use App\Models\Point;
+
+/** @var \App\Models\Client $patient */
+
+$points = Point::getPointsOfCategory($patient, 'MEDICATION');
+$tracker = Point::getGlobalSingletonOfCategory($patient, 'NO_KNOWN_TRACKER');
+?>
+
+<?php if($tracker && @($tracker->data->no_known_medications)): ?>
+    <div class="text-secondary"><span>No active medications</span></div>
+<?php endif; ?>
+<?php if(!$tracker || !@($tracker->data->no_known_medications)): ?>
+	<?php if (!count($points)): ?>
+		<div class="text-secondary">-</div>
+	<?php else: ?>
+		<div class="d-flex align-items-baseline flex-wrap">
+			<?php $j = 0; foreach ($points as $point): $j++; ?>
+				<span class="mr-2 text-nowrap">• <?= !!@($point->data->name) ? @($point->data->name) : '-' ?></span>
+			<?php endforeach; ?>
+		</div>
+	<?php endif; ?>
+<?php endif; ?>

+ 0 - 0
resources/views/app/patient/segment-templates/sigma_medications/edit.blade.php


+ 65 - 0
resources/views/app/patient/segment-templates/sigma_medications/summary.blade.php

@@ -0,0 +1,65 @@
+<?php
+
+use App\Models\Point;
+
+/** @var \App\Models\Client $patient */
+
+$points = Point::getIntakePointsOfCategory($patient, 'MEDICATION', $note);
+$tracker = Point::getGlobalSingletonOfCategory($patient, 'NO_KNOWN_TRACKER');
+$numRelevant = 0;
+$plural = 'Medications';
+?>
+
+<?php if($tracker && @($tracker->data->no_known_medications)): ?>
+    <div class="text-secondary"><span>-</span></div>
+<?php endif; ?>
+<?php if(!$tracker || !@($tracker->data->no_known_medications)): ?>
+<?php if (!count($points)): ?>
+    <div class="text-secondary">-</div>
+<?php else: ?>
+	<table class="table table-bordered table-xs table-cage mb-0">
+    <?php $j = 0; foreach ($points as $point): $j++; ?>
+        <?php $rel = $point->relevanceToNote($note); ?>
+	<tr>
+		<td class="width-40px pl-0 pr-2 {{ $rel ? ' text-info':'' }}">
+			@if($rel)
+				<?php $numRelevant++; ?>
+				{{ $j }}.*
+			@else
+				{{ $j }}.
+			@endif
+		</td>
+		<td class="px-2 width-300px">
+			<div class=" <?= $point->is_removed ? 'strike-through' : '' ?>">
+				<?= !!@($point->data->name) ? @($point->data->name) : '-' ?>
+			</div>
+		</td>
+		<td class="width-300px">
+			<div class="d-flex align-items-baseline pl-2">
+				<?php $review = $point->childReviewAddedInNote($note); ?>
+				<?php if(!!$review && @$review->data->value): ?>
+					<span class="pr-2">{!! $review->data->value !!}</span>
+				<?php endif; ?>
+				<span class="text-nowrap">
+					<?php if ($point->is_removed): ?>
+				@if($point->removal_reason_category === 'DURING_VISIT')
+					<span class="text-sm text-secondary">Removed during visit</span>
+				@elseif($point->removal_reason_category === 'ON_INTAKE')
+					<span class="text-sm text-secondary">Removed on intake</span>
+				@endif
+				<?php elseif ($point->added_in_note_id === $note->id): ?>
+				<?php if ($point->addition_reason_category === 'DURING_VISIT'): ?>
+					<span class="text-sm text-success">* Addeded during visit</span>
+				<?php else: ?>
+					<span class="text-sm text-info">* Added on intake</span>
+				<?php endif;?>
+				<?php endif; ?>
+				</span>
+			</div>
+		</td>
+		<td></td>
+	</tr>
+    <?php endforeach; ?>
+	</table>
+<?php endif; ?>
+<?php endif; ?>

+ 4 - 0
resources/views/app/patient/segment-templates/sigma_objective_free_text/edit.blade.php

@@ -0,0 +1,4 @@
+<?php
+$category = 'OBJECTIVE_FREE_TEXT';
+$endPoint = 'upsertNoteSingleton';
+include resource_path('views/app/patient/segment-templates/_simple_text_segment/edit.php');

+ 3 - 0
resources/views/app/patient/segment-templates/sigma_objective_free_text/summary.blade.php

@@ -0,0 +1,3 @@
+<?php
+$category = 'OBJECTIVE_FREE_TEXT';
+include resource_path('views/app/patient/segment-templates/_simple_text_segment/summary.php');

+ 114 - 0
resources/views/app/patient/segment-templates/sigma_objective_system/edit.blade.php

@@ -0,0 +1,114 @@
+<?php
+
+use App\Models\Point;
+
+$category = 'OBJECTIVE_SYSTEM';
+$endPoint = 'upsertNoteSingleton';
+
+$point = Point::where('added_in_note_id', $note->id)->where('category', $category)->orderBy('id', 'DESC')->first();
+$contentData = [
+    "reviewed_relevant_labs" => null,
+    "lab_findings" => null,
+    "reviewed_relevant_rpm_data" => null,
+    "rpm_findings" => null,
+    "rpm_data_unavailable" => null
+];
+if (!!@$point->data) {
+    $contentData = json_decode($point->data, true);
+}
+?>
+<div visit-moe close-on-save close-on-cancel class="d-block px-2 py-1">
+    <form show url="/api/visitPoint/<?= $endPoint ?>" class="mcp-theme-1">
+        <input type="hidden" name="segmentUid" value="<?= $segment->uid ?>">
+        <input type="hidden" name="category" value="<?= $category ?>">
+        <input type="hidden" name="data" value="{{json_encode($contentData)}}">
+
+        <label class="d-flex align-items-center mb-2">
+            <input type="checkbox" data-name="reviewed_relevant_labs" {{@$contentData["reviewed_relevant_labs"] ? 'checked' : ''}} class="mr-2">
+            <span>Reviewed relevant labs.</span>
+        </label>
+
+        <div class="mb-2 align-items-baseline {{ @$contentData["reviewed_relevant_labs"] ? 'd-flex' : 'd-none' }}" if-reviewed-labs>
+            <span class="text-dark mr-2 text-nowrap">Lab Findings:</span>
+            <input type="text" class="form-control form-control-sm flex-grow-1" data-name="lab_findings" value="{{@$contentData["lab_findings"]}}">
+        </div>
+
+        <label class="d-flex align-items-center mb-2">
+            <input type="checkbox" data-name="reviewed_relevant_rpm_data" {{@$contentData["reviewed_relevant_rpm_data"] ? 'checked' : ''}} class="mr-2">
+            <span>Reviewed relevant remote measurements.</span>
+            <?php
+            // resolve care month from the effective date of this note
+            $cmStartDate = date('Y-m-01', strtotime($note->effective_dateest));
+            $careMonth = \App\Models\CareMonth::where('client_id', $note->client->id)->where('start_date', $cmStartDate)->first();
+            ?>
+            @if($careMonth)
+                <a href="/patients/view/{{ $note->client->uid }}/care-months/view/{{$careMonth->uid}}"
+                   class="text-nowrap ml-3"
+                   native target="_blank"
+                   open-in-stag-popup
+                   popup-style="tall overflow-visible"
+                   mc-initer="care-month-dashboard-{{$note->client->uid}}"
+                   title="Current Care Month RPM Data"
+                >Current Care Month RPM Data</a>
+            @endif
+        </label>
+
+        <div class="mb-2 align-items-baseline {{ @$contentData["reviewed_relevant_rpm_data"] ? 'd-flex' : 'd-none' }}" if-reviewed-rpm>
+            <span class="text-dark mr-2 text-nowrap">RPM Findings:</span>
+            <input type="text" class="form-control form-control-sm flex-grow-1" data-name="rpm_findings" value="{{@$contentData["rpm_findings"]}}">
+        </div>
+
+        <label class="d-flex align-items-center mb-2">
+            <input type="checkbox" data-name="rpm_data_unavailable" {{@$contentData["rpm_data_unavailable"] ? 'checked' : ''}} class="mr-2">
+            <span>Remote monitoring data not available.</span>
+        </label>
+
+        <div class="pt-2">
+            <button submit class="btn btn-sm btn-primary mr-2"><i class="fa fa-save"></i></button>
+            <div class="d-inline-flex align-self-stretch align-items-center">
+                <span class="autosave-indicator saving text-sm text-secondary">Saving changes &hellip;</span>
+                <span class="autosave-indicator saved text-sm text-secondary">
+                    <i class="fa fa-check"></i>
+                    Saved
+                </span>
+            </div>
+        </div>
+    </form>
+</div>
+
+<script>
+    (function() {
+        window.segmentInitializers.<?= !!@$segment ? $segment->segmentTemplate->internal_name : $segmentInternalName ?> = function () {
+            let parentSegment = $('[data-segment-template-name="<?= $segment->segmentTemplate->internal_name ?>"] ');
+            parentSegment.find('[data-name="reviewed_relevant_labs"]')
+                .off('change')
+                .on('change', function() {
+                    if(this.checked) {
+                        parentSegment.find('[if-reviewed-labs]').removeClass('d-none').addClass('d-flex');
+                    }
+                    else {
+                        parentSegment.find('[if-reviewed-labs]').removeClass('d-flex').addClass('d-none');
+                    }
+                });
+            parentSegment.find('[data-name="reviewed_relevant_rpm_data"]')
+                .off('change')
+                .on('change', function() {
+                    if(this.checked) {
+                        parentSegment.find('[data-name="rpm_data_unavailable"]').prop('checked', false);
+                        parentSegment.find('[if-reviewed-rpm]').removeClass('d-none').addClass('d-flex');
+                    }
+                    else {
+                        parentSegment.find('[if-reviewed-rpm]').removeClass('d-flex').addClass('d-none');
+                    }
+                });
+            parentSegment.find('[data-name="rpm_data_unavailable"]')
+                .off('change')
+                .on('change', function() {
+                    if(this.checked) {
+                        parentSegment.find('[data-name="reviewed_relevant_rpm_data"]').prop('checked', false);
+                        parentSegment.find('[if-reviewed-rpm]').removeClass('d-flex').addClass('d-none');
+                    }
+                });
+        };
+    }).call(window);
+</script>

+ 37 - 0
resources/views/app/patient/segment-templates/sigma_objective_system/summary.blade.php

@@ -0,0 +1,37 @@
+<?php
+
+use App\Models\Point;
+
+$category = 'OBJECTIVE_SYSTEM';
+$endPoint = 'upsertNoteSingleton';
+
+$point = Point::where('added_in_note_id', $note->id)->where('category', $category)->orderBy('id', 'DESC')->first();
+$contentData = [
+    "reviewed_relevant_labs" => null,
+    "lab_findings" => null,
+    "reviewed_relevant_rpm_data" => null,
+    "rpm_findings" => null,
+    "rpm_data_unavailable" => null
+];
+if (!!@$point->data) {
+    $contentData = json_decode($point->data, true);
+}
+
+$output = [];
+if(@$contentData["reviewed_relevant_labs"]) {
+    $output[] = "Reviewed relevant labs.";
+    if(@$contentData["lab_findings"]) {
+        $output[] = "Findings: {$contentData["lab_findings"]}.";
+    }
+}
+if(@$contentData["rpm_data_unavailable"]) {
+    $output[] = "Remote monitoring data not available.";
+}
+elseif(@$contentData["reviewed_relevant_rpm_data"]) {
+    $output[] = "Reviewed relevant remote measurements.";
+    if(@$contentData["rpm_findings"]) {
+        $output[] = "Findings: {$contentData["rpm_findings"]}.";
+    }
+}
+?>
+{{ count($output) ? implode(' ', $output) : '-' }}

+ 0 - 0
resources/views/app/patient/segment-templates/sigma_plan_allergies/edit.blade.php


+ 80 - 0
resources/views/app/patient/segment-templates/sigma_plan_allergies/summary.blade.php

@@ -0,0 +1,80 @@
+<?php
+
+use App\Models\Point;
+
+/** @var \App\Models\Client $patient */
+
+$points = Point::getPlanPointsOfCategory($patient, 'ALLERGY', $note);
+$tracker = Point::getGlobalSingletonOfCategory($patient, 'NO_KNOWN_TRACKER');
+$numRelevant = 0;
+$numVisible = 0;
+$plural = 'Allergies';
+?>
+
+<?php if($tracker && @($tracker->data->no_known_drug_allergies)): ?>
+    <div class="text-secondary mb-2"><span>-</span></div>
+<?php endif; ?>
+<?php if($tracker && @($tracker->data->no_known_allergies_of_any_type)): ?>
+    <div class="text-secondary mb-2"><span>-</span></div>
+<?php endif; ?>
+
+<?php if(!$tracker || !@($tracker->data->no_known_allergies_of_any_type)): ?>
+<?php if (!count($points)): ?>
+    <div class="text-secondary">-</div>
+<?php else: ?>
+    <table class="table table-bordered table-xs table-cage mb-0">
+    <?php $j = 0; foreach ($points as $point): $j++; ?>
+        <?php if($point->is_removed && $point->is_removed_due_to_entry_error) continue; ?>
+        <?php $rel = $point->relevanceToNote($note); ?>
+        <?php $plan = $point->lastChildPlan; ?>
+        <?php if($plan && @($plan->data)) $plan->data = json_decode($plan->data); ?>
+        <?php $numVisible++; ?>
+        <tr>
+            <td class="width-40px pl-0 pr-2 {{ $rel ? 'font-weight-bold text-info':'' }}">
+                @if($rel)
+                    <?php $numRelevant++; ?>
+                    {{ $j }}.*
+                @else
+                    {{ $j }}.
+                @endif
+            </td>
+            <td class="px-2 width-300px">
+                <div class="<?= $point->is_removed ? 'strike-through' : '' ?>">
+                    <b><?= !!@($point->data->name) ? @($point->data->name) : '-' ?></b>
+                </div>
+            </td>
+            <td class="px-2 width-300px">
+                <div>
+                    <?php if(!!$plan): ?>
+                        <div class="pl-3 mt-1 d-flex align-items-baseline">
+                            <span>{!! $plan->data->value !!}</span>
+                        </div>
+                    <?php endif; ?>
+                </div>
+                <div class="d-flex align-items-baseline">
+                    <?php if ($point->is_removed): ?>
+                        @if($point->removal_reason_category === 'DURING_VISIT')
+                            <span class="ml-2 text-sm text-secondary">Removed during visit</span>
+                        @elseif($point->removal_reason_category === 'ON_INTAKE')
+                            <span class="ml-2 text-sm text-secondary">Removed on intake</span>
+                        @endif
+                    <?php elseif ($point->added_in_note_id === $note->id): ?>
+                        <?php if ($point->addition_reason_category === 'DURING_VISIT'): ?>
+                            <span class="ml-2 text-sm text-success">* Added during visit</span>
+                        <?php else: ?>
+                            <span class="ml-2 text-sm text-info">* Added on intake</span>
+                        <?php endif;?>
+                    <?php endif; ?>
+                </div>
+            </td>
+            <td></td>
+        </tr>
+    <?php endforeach; ?>
+    </table>
+    @if(!$numVisible)
+        <div class="d-flex align-items-baseline mr-1">
+            <span class="text-secondary">-</span>
+        </div>
+    @endif
+<?php endif; ?>
+<?php endif; ?>

+ 0 - 0
resources/views/app/patient/segment-templates/sigma_plan_care_team/edit.blade.php


+ 75 - 0
resources/views/app/patient/segment-templates/sigma_plan_care_team/summary.blade.php

@@ -0,0 +1,75 @@
+<?php
+
+use App\Models\Point;
+
+/** @var \App\Models\Client $patient */
+
+$points = Point::getPlanPointsOfCategory($patient, 'CARE_TEAM_MEMBER', $note);
+$numRelevant = 0;
+$numVisible = 0;
+$plural = 'Care team members';
+?>
+
+<?php if (!count($points)): ?>
+    <div class="text-secondary">-</div>
+<?php else: ?>
+    <table class="table table-bordered table-xs table-cage mb-0">
+    <?php $j = 0; foreach ($points as $point): $j++; ?>
+        <?php if($point->is_removed && $point->is_removed_due_to_entry_error) continue; ?>
+        <?php $rel = $point->relevanceToNote($note); ?>
+        <?php $plan = $point->lastChildPlan; ?>
+        <?php if($plan && @($plan->data)) $plan->data = json_decode($plan->data); ?>
+        <?php $numVisible++; ?>
+        <tr>
+            <td class="width-40px pl-0 pr-2 {{ $rel ? 'font-weight-bold text-info':'' }}">
+                @if($rel)
+                    <?php $numRelevant++; ?>
+                    {{ $j }}.*
+                @else
+                    {{ $j }}.
+                @endif
+            </td>
+            <td class="px-2 width-300px">
+                <div class="<?= $point->is_removed ? 'strike-through' : '' ?>">
+                    <b><?= !!@($point->data->name) ? @($point->data->name) : '-' ?></b>
+                    <?= !!@($point->data->specialty) ? '/&nbsp;' . @($point->data->specialty) . '' : '' ?>
+                    <?= !!@($point->data->organization) ? '/&nbsp;' . @($point->data->organization) . '' : '' ?><br>
+                    <?= !!@($point->data->phone) ? 'Ph: ' . @($point->data->phone) . '' : '' ?>
+                    <?= !!@($point->data->fax) ? '&nbsp;/&nbsp;Fax: ' . @($point->data->fax) . '<br>' : '' ?>
+                    <?= !!@($point->data->date) ? '&nbsp;/&nbsp;Date: ' . @($point->data->date) : '' ?>
+                </div>
+            </td>
+            <td class="px-2 width-300px">
+                <div class="pl-3">
+                    <?php if(!!$plan): ?>
+                        <div class="mt-1 d-flex align-items-baseline">
+                            <span>{!! $plan->data->value !!}</span>
+                        </div>
+                    <?php endif; ?>
+                </div>
+                <div class="pl-3 d-flex align-items-baseline">
+                    <?php if ($point->is_removed): ?>
+                        @if($point->removal_reason_category === 'DURING_VISIT')
+                            <span class="mt-1 text-sm text-secondary">Removed during visit</span>
+                        @elseif($point->removal_reason_category === 'ON_INTAKE')
+                            <span class="mt-1 text-sm text-secondary">Removed on intake</span>
+                        @endif
+                    <?php elseif ($point->added_in_note_id === $note->id): ?>
+                        <?php if ($point->addition_reason_category === 'DURING_VISIT'): ?>
+                            <span class="mt-1 text-sm text-success">* Added during visit</span>
+                        <?php else: ?>
+                            <span class="mt-1 text-sm text-info">* Added on intake</span>
+                        <?php endif;?>
+                    <?php endif; ?>
+                </div>
+            </td>
+            <td></td>
+        </tr>
+    <?php endforeach; ?>
+    </table>
+    @if(!$numVisible)
+        <div class="d-flex align-items-baseline mr-1">
+            <span class="text-secondary">-</span>
+        </div>
+    @endif
+<?php endif; ?>

+ 4 - 0
resources/views/app/patient/segment-templates/sigma_plan_free_text/edit.blade.php

@@ -0,0 +1,4 @@
+<?php
+$category = 'PLAN_FREE_TEXT';
+$endPoint = 'upsertNoteSingleton';
+include resource_path('views/app/patient/segment-templates/_simple_text_segment/edit.php');

+ 3 - 0
resources/views/app/patient/segment-templates/sigma_plan_free_text/summary.blade.php

@@ -0,0 +1,3 @@
+<?php
+$category = 'PLAN_FREE_TEXT';
+include resource_path('views/app/patient/segment-templates/_simple_text_segment/summary.php');

+ 0 - 0
resources/views/app/patient/segment-templates/sigma_plan_goals/edit.blade.php


+ 70 - 0
resources/views/app/patient/segment-templates/sigma_plan_goals/summary.blade.php

@@ -0,0 +1,70 @@
+<?php
+
+use App\Models\Point;
+
+/** @var \App\Models\Client $patient */
+
+$points = Point::getPlanPointsOfCategory($patient, 'GOAL', $note);
+$numRelevant = 0;
+$numVisible = 0;
+$plural = 'Goals';
+?>
+
+<?php if (!count($points)): ?>
+    <div class="text-secondary">-</div>
+<?php else: ?>
+    <table class="table table-bordered table-xs table-cage mb-0">
+    <?php $j = 0; foreach ($points as $point): $j++; ?>
+        <?php if($point->is_removed && $point->is_removed_due_to_entry_error) continue; ?>
+        <?php $rel = $point->relevanceToNote($note); ?>
+        <?php $plan = $point->lastChildPlan; ?>
+        <?php if($plan && @($plan->data)) $plan->data = json_decode($plan->data); ?>
+        <?php $numVisible++; ?>
+        <tr>
+            <td class="width-40px pl-0 pr-2 {{ $rel ? 'font-weight-bold text-info':'' }}">
+                @if($rel)
+                    <?php $numRelevant++; ?>
+                    {{ $j }}.*
+                @else
+                    {{ $j }}.
+                @endif
+            </td>
+            <td class="px-2 width-300px">
+                <div class="<?= $point->is_removed ? 'strike-through' : '' ?>">
+                    <b><?= !!@($point->data->goal) ? @($point->data->goal) : '-' ?></b>
+                </div>
+            </td>
+            <td class="px-2 width-300px">
+                <div>
+                    <?php if(!!$plan): ?>
+                        <div class="pl-3 mt-1 d-flex align-items-baseline">
+                            <span>{!! $plan->data->value !!}</span>
+                        </div>
+                    <?php endif; ?>
+                </div>
+                <div class="d-flex align-items-baseline">
+                    <?php if ($point->is_removed): ?>
+                        @if($point->removal_reason_category === 'DURING_VISIT')
+                            <span class="ml-2 text-sm text-secondary">Removed during visit</span>
+                        @elseif($point->removal_reason_category === 'ON_INTAKE')
+                            <span class="ml-2 text-sm text-secondary">Removed on intake</span>
+                        @endif
+                    <?php elseif ($point->added_in_note_id === $note->id): ?>
+                        <?php if ($point->addition_reason_category === 'DURING_VISIT'): ?>
+                            <span class="ml-2 text-sm text-success">* Prescribed during visit</span>
+                        <?php else: ?>
+                            <span class="ml-2 text-sm text-info">* Added on intake</span>
+                        <?php endif;?>
+                    <?php endif; ?>
+                </div>
+            </td>
+            <td></td>
+        </tr>
+    <?php endforeach; ?>
+    </table>
+    @if(!$numVisible)
+        <div class="d-flex align-items-baseline mr-1">
+            <span class="text-secondary">-</span>
+        </div>
+    @endif
+<?php endif; ?>

+ 0 - 0
resources/views/app/patient/segment-templates/sigma_plan_medications/edit.blade.php


+ 76 - 0
resources/views/app/patient/segment-templates/sigma_plan_medications/summary.blade.php

@@ -0,0 +1,76 @@
+<?php
+
+use App\Models\Point;
+
+/** @var \App\Models\Client $patient */
+
+$points = Point::getPlanPointsOfCategory($patient, 'MEDICATION', $note);
+$tracker = Point::getGlobalSingletonOfCategory($patient, 'NO_KNOWN_TRACKER');
+$numRelevant = 0;
+$numVisible = 0;
+$plural = 'Medications';
+?>
+
+<?php if($tracker && @($tracker->data->no_known_medications)): ?>
+    <div class="text-secondary"><span>-</span></div>
+<?php endif; ?>
+<?php if(!$tracker || !@($tracker->data->no_known_medications)): ?>
+<?php if (!count($points)): ?>
+    <div class="text-secondary">-</div>
+<?php else: ?>
+    <table class="table table-bordered table-xs table-cage mb-0">
+        <?php $j = 0; foreach ($points as $point): $j++; ?>
+        <?php if($point->is_removed && $point->is_removed_due_to_entry_error) continue; ?>
+        <?php $rel = $point->relevanceToNote($note); ?>
+        <?php $plan = $point->lastChildPlan; ?>
+        <?php if($plan && @($plan->data)) $plan->data = json_decode($plan->data); ?>
+        <?php $numVisible++; ?>
+        <tr>
+            <td class="width-40px pl-0 pr-2 {{ $rel ? 'font-weight-bold text-info':'' }}">
+                @if($rel)
+                    <?php $numRelevant++; ?>
+                    {{ $j }}.*
+                @else
+                    {{ $j }}.
+                @endif
+            </td>
+            <td class="px-2 width-300px">
+                <div class="font-weight-bold <?= $point->is_removed ? 'strike-through' : '' ?>">
+                    <?= !!@($point->data->name) ? @($point->data->name) : '-' ?>
+                </div>
+            </td>
+            <td class="px-2 width-300px">
+                <div>
+                    <?php if(!!$plan): ?>
+                    <div class="pl-3 mt-1 d-flex align-items-baseline">
+                        <span>{!! $plan->data->value !!}</span>
+                    </div>
+                    <?php endif; ?>
+                </div>
+                <div class="d-flex align-items-baseline">                
+                    <?php if ($point->is_removed): ?>
+                        @if($point->removal_reason_category === 'DURING_VISIT')
+                            <span class="ml-2 text-sm text-secondary">Removed during visit</span>
+                        @elseif($point->removal_reason_category === 'ON_INTAKE')
+                            <span class="ml-2 text-sm text-secondary">Removed on intake</span>
+                        @endif
+                    <?php elseif ($point->added_in_note_id === $note->id): ?>
+                        <?php if ($point->addition_reason_category === 'DURING_VISIT'): ?>
+                            <span class="ml-2 text-sm text-success">* Prescribed during visit</span>
+                        <?php else: ?>
+                            <span class="ml-2 text-sm text-info">* Added on intake</span>
+                        <?php endif;?>
+                    <?php endif; ?>
+                </div>
+            </td>
+            <td></td>
+        </tr>
+    <?php endforeach; ?>
+    </table>
+    @if(!$numVisible)
+        <div class="d-flex align-items-baseline mr-1">
+            <span class="text-secondary">-</span>
+        </div>
+    @endif
+<?php endif; ?>
+<?php endif; ?>

+ 0 - 0
resources/views/app/patient/segment-templates/sigma_plan_problems/edit.blade.php


+ 71 - 0
resources/views/app/patient/segment-templates/sigma_plan_problems/summary.blade.php

@@ -0,0 +1,71 @@
+<?php
+
+use App\Models\Point;
+
+/** @var \App\Models\Client $patient */
+
+$points = Point::getPlanPointsOfCategory($patient, 'PROBLEM', $note);
+$numRelevant = 0;
+$numVisible = 0;
+$plural = 'Problems';
+?>
+<?php if (!count($points)): ?>
+    <div class="text-secondary">-</div>
+<?php else: ?>
+    <table class="table table-bordered table-xs table-cage mb-0">
+    <?php $j = 0; foreach ($points as $point): $j++; ?>
+        <?php if($point->is_removed && $point->is_removed_due_to_entry_error) continue; ?>
+        <?php $rel = $point->relevanceToNote($note); ?>
+        <?php $plan = $point->lastChildPlan; ?>
+        <?php if($plan && @($plan->data)) $plan->data = json_decode($plan->data); ?>
+        <?php if(!$rel && $point->addition_reason_category != 'DURING_VISIT' /* && @VJ PLAN_NOT_UPDATED_ON_THIS_NOTE */ ) continue; ?>
+	<?php $numVisible++; ?>
+        <tr>
+            <td class="width-40px pl-0 pr-2 {{ $rel ? 'font-weight-bold text-info':'' }}">
+                @if($rel)
+                    <?php $numRelevant++; ?>
+                    {{ $j }}.*
+                @else
+                    {{ $j }}.
+                @endif
+            </td>
+            <td class="px-2 width-300px">
+                <div class="<?= $point->is_removed ? 'strike-through' : '' ?>">
+                    <b><?= !!@($point->data->name) ? @($point->data->name) : '-' ?></b>
+                </div>
+            </td>
+            <td class="px-2 width-300px">
+                <div>
+                    <?php if(!!$plan): ?>
+                        <div class="pl-3 mt-1 d-flex align-items-baseline">
+                            <span>{!! $plan->data->value !!}</span>
+                        </div>
+                    <?php endif; ?>
+                </div>
+                <div class="d-flex align-items-baseline">
+                    <?php if ($point->is_removed): ?>
+                        @if($point->removal_reason_category === 'DURING_VISIT')
+                            <span class="ml-2 text-sm text-secondary">Removed during visit</span>
+                        @elseif($point->removal_reason_category === 'ON_INTAKE')
+                            <span class="ml-2 text-sm text-secondary">Removed on intake</span>
+                        @endif
+                    <?php elseif ($point->added_in_note_id === $note->id): ?>
+                        <?php if ($point->addition_reason_category === 'DURING_VISIT'): ?>
+                            <span class="ml-2 text-sm text-success">* Added during visit</span>
+                        <?php else: ?>
+                            <span class="ml-2 text-sm text-info">* Added on intakee</span>
+                        <?php endif;?>
+                    <?php endif; ?>
+                </div>
+            </td>
+            <td></td>
+        </tr>
+    <?php endforeach; ?>
+    </table>
+    @if(!$numVisible)
+        <div class="d-flex align-items-baseline mr-1">
+            <span class="text-secondary">-</span>
+        </div>
+    @endif
+<?php endif; ?>
+

+ 0 - 0
resources/views/app/patient/segment-templates/sigma_plan_system/edit.blade.php


+ 74 - 0
resources/views/app/patient/segment-templates/sigma_plan_system/summary.blade.php

@@ -0,0 +1,74 @@
+<?php
+
+use App\Models\Point;
+
+/** @var \App\Models\Client $patient */
+/** @var \App\Models\Note $note */
+
+?>
+<div class="system_segment">
+<?php
+
+$allPoints = Point::getPlanPoints($patient, $note);
+
+// allergies/meds/problems/goals/careteam
+$topLevelPointToRendererMap = [
+    'ALLERGY' => 'allergy',
+    'MEDICATION' => 'medication',
+    'PROBLEM' => 'problem',
+    'GOAL' => 'goal',
+    'CARE_TEAM_MEMBER' => 'care_team_member'
+];
+
+$pointMap = [];
+
+foreach($allPoints as $point){
+    if(!isset($topLevelPointToRendererMap[$point->category])) continue;
+    $renderer = $topLevelPointToRendererMap[$point->category];
+    if(!isset($pointMap[$renderer])) $pointMap[$renderer] = [];
+    $pointMap[$renderer][] = $point;
+}
+
+foreach ($pointMap as $renderer => $points) {
+?>
+@include('app.patient.module-specific-summary-renderers.' . $renderer . '.plan', compact('points'))
+<?php
+}
+
+// rest of it
+$topLevelPointToRendererMap = [
+    'HIGH_SUGAR_BEVERAGES' => 'nutrition',
+    'WATER_INTAKE' => 'nutrition',
+    'FAST_FOOD' => 'nutrition',
+    'SNACKS' => 'nutrition',
+    'VEGETABLES' => 'nutrition',
+    'PORTION_SIZES' => 'nutrition',
+    'DAILY_INTAKE_CARBOHYDRATES' => 'nutrition',
+    'DAILY_INTAKE_CALORIES' => 'nutrition',
+    'AEROBIC_ACTIVITY' => 'exercise',
+    'STRENGTH_TRAINING' => 'exercise',
+    'NEAT,' => 'exercise',
+    'SELF_MONITORING' => 'behavior',
+    'FOOD_TRIGGERS' => 'behavior',
+    'CRAVINGS' => 'behavior',
+    'SLEEP_HABITS' => 'behavior',
+    'WEIGHT_LOSS_INTAKE' => 'weight_loss_intake',
+];
+
+$pointMap = [];
+
+foreach($allPoints as $point){
+    if(!isset($topLevelPointToRendererMap[$point->category])) continue;
+    $renderer = $topLevelPointToRendererMap[$point->category];
+    if(!isset($pointMap[$renderer])) $pointMap[$renderer] = [];
+    $pointMap[$renderer][] = $point;
+}
+
+foreach ($pointMap as $renderer => $points) {
+?>
+@include('app.patient.module-specific-summary-renderers.' . $renderer . '.plan', compact('points'))
+<?php
+}
+?>
+</div>
+

+ 0 - 0
resources/views/app/patient/segment-templates/sigma_problems/edit.blade.php


+ 60 - 0
resources/views/app/patient/segment-templates/sigma_problems/summary.blade.php

@@ -0,0 +1,60 @@
+<?php
+
+use App\Models\Point;
+
+/** @var \App\Models\Client $patient */
+
+$points = Point::getIntakePointsOfCategory($patient, 'PROBLEM', $note);
+$numRelevant = 0;
+$plural = 'Problems';
+?>
+
+<?php if (!count($points)): ?>
+    <div class="text-secondary">-</div>
+<?php else: ?>
+    <table class="table table-bordered table-xs table-cage mb-0">
+    <?php $j = 0; foreach ($points as $point): $j++; ?>
+        <?php $rel = $point->relevanceToNote($note); ?>
+       <tr>
+            <td class="width-40px pl-0 pr-2 {{ $rel ? ' text-info':'' }}">
+                @if($rel)
+                    <?php $numRelevant++; ?>
+                    {{ $j }}.*
+                @else
+                    {{ $j }}.
+                @endif
+            </td>
+            <td class="px-2 width-300px">
+                <div class=" <?= $point->is_removed ? 'strike-through' : '' ?>">
+                    <?= !!@($point->data->name) ? @($point->data->name) : '-' ?>
+                </div>
+            </td>
+           <td class="width-300px">
+               <div class="d-flex align-items-baseline pl-2">
+                   <?php $review = $point->childReviewAddedInNote($note); ?>
+                   <?php if(!!$review && @$review->data->value): ?>
+                   <span class="pr-2">{!! $review->data->value !!}</span>
+                   <?php endif; ?>
+                   <span class="text-nowrap">
+                       <?php if ($point->is_removed): ?>
+                       @if($point->removal_reason_category === 'DURING_VISIT')
+                           <span class="text-sm text-secondary">Removed during visit</span>
+                       @elseif($point->removal_reason_category === 'ON_INTAKE')
+                           <span class="text-sm text-secondary">Removed on intake</span>
+                       @endif
+                       <?php elseif ($point->added_in_note_id === $note->id): ?>
+                       <?php if ($point->addition_reason_category === 'DURING_VISIT'): ?>
+                                <span class="text-sm text-success">* Added during visit</span>
+                            <?php else: ?>
+                                <span class="text-sm text-info">* Added on intake</span>
+                            <?php endif;?>
+                       <?php endif; ?>
+                    </span>
+               </div>
+           </td>
+           <td></td>
+        </tr>
+    <?php endforeach; ?>
+    </table>
+<?php endif; ?>
+

+ 416 - 0
resources/views/app/patient/segment-templates/sigma_ros/edit.blade.php

@@ -0,0 +1,416 @@
+<?php
+
+use App\Models\Client;
+use App\Models\Point;
+use App\Models\Note;
+use App\Models\Segment;
+/** @var Client $patient */
+/** @var Note $note */
+/** @var Segment $segment */
+
+if(!@$segment) $segment = null;
+
+$fields = [
+    [
+        "Constitutional" => [
+            "Fatigue",
+            "Fever",
+            "Weight gain",
+            "Weight loss"],
+
+        "Eyes" => [
+            "Blurry vision",
+            "Double vision",
+            "Dry eyes",
+            "Floaters",
+            "Halos",
+            "Headache",
+            "Irritation",
+            "Loss of peripheral vision",
+            "Pain",
+            "Pinpoint pupils",
+            "Teary",
+            "Visual changes"],
+
+        "ENMT" => [
+            "Altered sense of smell",
+            "Dental caries",
+            "Dentures",
+            "Dizziness",
+            "Dry mouth",
+            "Ear pain/pressure",
+            "Hearing loss",
+            "Mouth pain",
+            "Nasal congestion",
+            "Neck pain/stiffness",
+            "Post nasal drainage",
+            "Sinus pain / pressure",
+            "Sore throat",
+            "Teeth missing",
+            "Tinnitus",
+            "Trouble swallowing"],
+        "Allergy / Immune" => [
+            "Congestion",
+            "Difficulty healing",
+            "Frequent infections",
+            "Headache",
+            "Hives",
+            "Itching",
+            "Running nose",
+            "Sneezing",
+            "Watery eyes"],
+
+        "Cardiovascular" => [
+            "Chest pain / pressure at rest",
+            "Chest pain / pressure with excursion",
+            "Cold hands / feet",
+            "Dizziness",
+            "Exercise intolerance",
+            "Fainting",
+            "Feeling faint",
+            "Left arm pain",
+            "Light headed",
+            "Lower leg cramps",
+            "Muscle weakness",
+            "Palpitations",
+            "Shortness of breath",
+            "Sweating",
+            "Swelling"],
+
+    ],
+    [
+        "Respiratory" => [
+            "Cough – dry",
+            "Cough – wet",
+            "Coughing up blood",
+            "Pain with breathing",
+            "Productive cough",
+            "Shortness of breath at rest",
+            "Shortness of breath on excursion",
+            "Wheezing"],
+
+        "Gastrointestinal" => [
+            "Abdominal pain",
+            "Constipation",
+            "Coughing up blood",
+            "Diarrhea",
+            "Difficulty swallowing",
+            "Fecal incontinence",
+            "Heartburn",
+            "Loose stool",
+            "Nausea",
+            "Painful swallowing",
+            "Rectal pain",
+            "Stool – black tarry",
+            "Stool – bloody"],
+
+        "Genitourinary" => [
+            "Blood in urine",
+            "Discharge",
+            "Foley",
+            "Incontinence",
+            "Lesions",
+            "Sexual dysfunction",
+            "Tenderness",
+            "Urinary retention",
+            "Urination - frequent",
+            "Urination - painful",
+            "Urination wakes you up at night"],
+
+        "Musculoskeletal" => [
+            "Decreased range of motion",
+            "Fracture",
+            "Gait - unstable",
+            "Joint instability",
+            "Joint pain",
+            "Joint stiffness",
+            "Joint swelling",
+            "Muscle pain",
+            "Muscle weakness",
+            "Sprain"],
+
+        "Skin" => [
+            "Bruises",
+            "Color changes",
+            "Dry skin",
+            "Goosebumps",
+            "Itchy",
+            "IVDU marks",
+            "Lesions",
+            "Nodules",
+            "Rash",
+            "Scars",
+            "Swelling",
+            "Track marks",
+            "Ulcer",
+            "Wound"],
+    ],
+    [
+        "Neurological" => [
+            "Coordination problem",
+            "Dizziness",
+            "Double vision",
+            "Fainting",
+            "Head trauma",
+            "Headache",
+            "Imbalance",
+            "Muscle twitching",
+            "Numbness",
+            "Problems walking",
+            "Restlessness",
+            "Seizures",
+            "Speech disturbance",
+            "TBI",
+            "Tingling",
+            "Tinnitus",
+            "Tremor",
+            "Vertigo",
+            "Weakness"],
+
+        "Endocrine" => [
+            "Change in hair growth",
+            "Cold intolerance",
+            "Diabetes",
+            "Excessive hunger",
+            "Excessive thirst",
+            "Excessive urination",
+            "Exhausted",
+            "Goiter",
+            "Heat intolerance",
+            "Hot and cold flashes",
+            "Sleeplessness",
+            "Weight gain",
+            "Weight loss"],
+
+        "Lymphatic" => [
+            "Anemia",
+            "Bleeding tendency",
+            "Bruises",
+            "Lymph node pain enlargement",
+            "Pain",
+            "Swelling",
+            "Transfusions"],
+    ]
+];
+
+// only for ros - since ros edit markup is loaded via AJAX GET from the UI
+if(!@$sessionKey) {
+    $sessionKey = request()->cookie('sessionKey');
+}
+
+$point = Point::getOrCreateOnlyTopLevelPointOfCategory($note, 'ROS', $sessionKey, true);
+
+$contentData = $parsed = false;
+
+if ($point->lastChildReview && $point->lastChildReview->data) {
+    $point->lastChildReview->data = json_decode($point->lastChildReview->data, true);
+    $contentData = $parsed = $point->lastChildReview->data;
+}
+
+if(!$contentData) {
+    $contentData = [
+        "declaration" => false,
+        "common" => [],
+        "comments" => "",
+    ];
+}
+
+for ($i = 0; $i < count($fields); $i++) {
+    foreach($fields[$i] as $head => $values) {
+        for($k = 0; $k < count($values); $k++) {
+            $fName = $head . '_' . sanitize_field_name($values[$k]);
+            if(!isset($contentData["common"][$fName])) $contentData["common"][$fName] = null;
+        }
+    }
+}
+?>
+<hr class="hide-outside-popup mt-3 mb-0">
+<div class="p-3 mcp-theme-1">
+    <div {{!!$segment ? 'visit-moe' : 'moe'}} close-on-save close-on-cancel class="d-block">
+        <form show url="/api/visitPoint/upsertChildReview" class="mcp-theme-1"
+                {{!$segment ? 'hook=onHxPopupClosure' : ''}}>
+            @if(!!@$segment)
+                <input type="hidden" name="segmentUid" value="<?= $segment->uid ?>">
+            @endif
+            <input type="hidden" name="uid" value="<?= $point->uid ?>">
+            <input type="hidden" name="noteUid" value="<?= $note->uid ?>">
+            <input type="hidden" name="data" value='{!! json_encode($contentData) !!}'>
+
+            <div id="edit-ros-container">
+                <label class="d-flex align-items-center mb-3">
+                    <input type="checkbox" class="my-0 mr-2" v-model="declaration">
+                    <span>Except for the systems documented in the HPI or detailed below, all other systems were reviewed and negative.</span>
+                </label>
+                <div class="d-flex align-items-start flex-wrap custom-items-container">
+                    @for ($i = 0; $i < count($fields); $i++)
+                        <div class="w-33">
+                            @foreach($fields[$i] as $head => $values)
+                                <div class="font-weight-bold mb-2">{{ $head }}</div>
+                                <div class="d-flex flex-nowrap align-items-center mb-1">
+                                    <span class="rspace"><i class="fa fa-plus-circle text-success on-hover-opaque"></i></span>
+                                    <span class="rspace ros-minus-all c-pointer" data-category="{{$head}}"><i class="fa fa-minus-circle text-danger on-hover-opaque"></i></span>
+                                </div>
+                                <div class="mb-3 ros-category" data-category="{{$head}}">
+                                    @for($k = 0; $k < count($values); $k++)
+                                        <?php $fName = $head . '_' . sanitize_field_name($values[$k]); ?>
+                                        <div class="d-flex align-items-stretch mb-1">
+                                            <div class="d-inline-flex flex-nowrap align-items-center">
+                                                <span class="rspace">
+                                                    <input type="radio" name="{{ $fName }}" class="m-0 c-pointer"
+                                                           v-model="common['{{$fName}}']" value="+">
+                                                </span>
+                                                <span class="rspace">
+                                                    <input type="radio" name="{{ $fName }}" class="m-0 c-pointer"
+                                                           v-model="common['{{$fName}}']" value="-">
+                                                </span>
+                                            </div>
+                                            <div class="ml-2">
+                                                <div>
+                                                    <span class="mr-2 common-item">{{ $values[$k] }}</span>
+                                                    <div moe relative no-mask v-show="common['{{$fName}}']" >
+                                                        <a href="#" start show>
+                                                            <i class="fa-comment" :class="common['{{$fName}}__comments'] ? 'fas' : 'far'"></i>
+                                                        </a>
+                                                        <div url="/nop" right>
+                                                            <div class="mb-2">
+                                                                <textarea class="form-control form-control-sm ns-custom-comment min-width-200px"
+                                                                          v-model="common['{{$fName}}__comments']"></textarea>
+                                                            </div>
+                                                            <div class="">
+                                                                <button type="button" class="btn btn-sm btn-primary" cancel>Close
+                                                                </button>
+                                                            </div>
+                                                        </div>
+                                                    </div>
+                                                    <a href="#" v-show="common['{{$fName}}']" v-on:click.prevent="clearValue('{{$fName}}')">
+                                                        <i class="text-danger on-hover-opaque fa fa-trash-alt ml-1"></i>
+                                                    </a>
+                                                </div>
+                                                <span v-show="common['{{$fName}}'] && common['{{$fName}}__comments']"
+                                                      v-html="common['{{$fName}}__comments']"
+                                                      class="text-sm text-secondary">
+                                                </span>
+                                            </div>
+                                        </div>
+                                    @endfor
+                                </div>
+                            @endforeach
+                        </div>
+                    @endfor
+                </div>
+                <hr class="m-neg-4 mt-0">
+                <div class="mb-2">
+                    <textarea class="form-control form-control-sm" v-model="comments">{!! $parsed && @$parsed->content ? @$parsed->content : '' !!}</textarea>
+                </div>
+                <div class="mt-3">
+                    <div class="d-inline-flex align-self-stretch align-items-center">
+                        <span class="autosave-indicator saving text-sm text-secondary">Saving changes &hellip;</span>
+                        <span class="autosave-indicator saved text-sm text-secondary">
+                        <i class="fa fa-check"></i>
+                        Saved
+                    </span>
+                    </div>
+                </div>
+            </div>
+
+        </form>
+    </div>
+</div>
+<script>
+    (function() {
+
+        const debounce = (func, wait) => {
+            let timeout;
+            return function executedFunction(...args) {
+                const later = () => {
+                    clearTimeout(timeout);
+                    func(...args);
+                };
+                clearTimeout(timeout);
+                timeout = setTimeout(later, wait);
+            };
+        };
+
+        let debouncedROSSaver = debounce(function(_trigger) {
+            $(_trigger).closest('.stag-popup').find('.autosave-indicator').removeClass('show');
+            $(_trigger).closest('.stag-popup').find('.autosave-indicator.saving').addClass('show');
+            saveVisitForm(_trigger, true, false, () => {
+                $(_trigger).closest('.stag-popup').find('.autosave-indicator').removeClass('show');
+                $(_trigger).closest('.stag-popup').find('.autosave-indicator.saved').addClass('show');
+            });
+        }, 500);
+
+        function initROS() {
+
+            let model = <?= $contentData ? json_encode($contentData) : '{}' ?>;
+
+            model.itemKey = 'pmhx';
+
+            new Vue({
+                el: '#edit-ros-container',
+                delimiters: ["@{{","}}"],
+                data: model,
+                mounted: function() {
+                    $('#edit-ros-container [moe][initialized]').removeAttr('initialized');
+                    initMoes();
+
+                    // custom buttons on title bar
+                    $('.button-container').remove();
+                    let buttonContainer = $('<div/>').addClass('button-container ml-4 mr-auto');
+                    let titleElem = $('#edit-ros-container').closest('.stag-popup').find('.stag-popup-title>span');
+                    titleElem.next().removeClass('ml-auto');
+                    titleElem.parent().addClass('align-items-center');
+
+                    // add button for "Edit Mode"
+                    $('<div class="d-inline-flex align-self-stretch align-items-center">' +
+                        '<span class="autosave-indicator saving text-sm text-secondary">Saving changes &hellip;</span>' +
+                        '<span class="autosave-indicator saved text-sm text-secondary">' +
+                        '<i class="fa fa-check"></i>' +
+                        ' Saved' +
+                        '</span>' +
+                        '</div>').appendTo(buttonContainer);
+
+                    buttonContainer.insertAfter(titleElem);
+
+                    $('#edit-ros-container')
+                        .off('click.ros-minus-all')
+                        .on('click.ros-minus-all', '.ros-minus-all[data-category]', function() {
+                            let category = $(this).attr('data-category');
+                            $('.ros-category[data-category="' + category + '"]').find('input[type="radio"][value="-"]').click();
+                            return false;
+                        });
+                },
+                watch: {
+                    $data: {
+                        handler: function(val, oldVal) {
+                            let parent = $('#edit-ros-container').closest('form');
+                            parent.find('[name="data"]').val(JSON.stringify(this.$data));
+                            debouncedROSSaver($('#edit-ros-container')[0]);
+                        },
+                        deep: true
+                    }
+                },
+                methods: {
+                    clearValue: function(_key) {
+                        this.common[_key] = null;
+                        Vue.nextTick(function() {
+                            $('#edit-ros-container').find('textarea').first().trigger('input');
+                        });
+                    },
+                    saveROS: function() {
+                        saveVisitForm($('#edit-ros-container')[0], false, true);
+                    }
+                }
+            });
+
+            // if in popup (omega template), add provision to toggle relevance
+            @include('app.patient.segment-templates._common_actions.toggle-relevance', ['container' => '#edit-ros-container', 'segmentName' => 'omega_ros'])
+
+        }
+
+        window.segmentInitializers.omega_ros = initROS;
+
+        addMCInitializer('init-ros-{{$note->id}}', initROS, '#edit-ros-container');
+
+    }).call(window);
+</script>

+ 261 - 0
resources/views/app/patient/segment-templates/sigma_ros/log.blade.php

@@ -0,0 +1,261 @@
+<?php
+
+use App\Models\Client;
+use App\Models\Point;
+use App\Models\Note;
+/** @var Client $patient */
+/** @var Note $note */
+
+$fields = [
+    [
+        "Constitutional" => [
+            "Fatigue",
+            "Fever",
+            "Weight gain",
+            "Weight loss"],
+
+        "Eyes" => [
+            "Blurry vision",
+            "Double vision",
+            "Dry eyes",
+            "Floaters",
+            "Halos",
+            "Headache",
+            "Irritation",
+            "Loss of peripheral vision",
+            "Pain",
+            "Pinpoint pupils",
+            "Teary",
+            "Visual changes"],
+
+        "ENMT" => [
+            "Altered sense of smell",
+            "Dental caries",
+            "Dentures",
+            "Dizziness",
+            "Dry mouth",
+            "Ear pain/pressure",
+            "Hearing loss",
+            "Mouth pain",
+            "Nasal congestion",
+            "Neck pain/stiffness",
+            "Post nasal drainage",
+            "Sinus pain / pressure",
+            "Sore throat",
+            "Teeth missing",
+            "Tinnitus",
+            "Trouble swallowing"],
+        "Allergy / Immune" => [
+            "Congestion",
+            "Difficulty healing",
+            "Frequent infections",
+            "Headache",
+            "Hives",
+            "Itching",
+            "Running nose",
+            "Sneezing",
+            "Watery eyes"]
+    ],
+    [
+        "Cardiovascular" => [
+            "Chest pain / pressure at rest",
+            "Chest pain / pressure with excursion",
+            "Cold hands / feet",
+            "Dizziness",
+            "Exercise intolerance",
+            "Fainting",
+            "Feeling faint",
+            "Left arm pain",
+            "Light headed",
+            "Lower leg cramps",
+            "Muscle weakness",
+            "Palpitations",
+            "Shortness of breath",
+            "Sweating",
+            "Swelling"],
+
+        "Respiratory" => [
+            "Cough – dry",
+            "Cough – wet",
+            "Coughing up blood",
+            "Pain with breathing",
+            "Productive cough",
+            "Shortness of breath at rest",
+            "Shortness of breath on excursion",
+            "Wheezing"],
+
+        "Gastrointestinal" => [
+            "Abdominal pain",
+            "Constipation",
+            "Coughing up blood",
+            "Diarrhea",
+            "Difficulty swallowing",
+            "Fecal incontinence",
+            "Heartburn",
+            "Loose stool",
+            "Nausea",
+            "Painful swallowing",
+            "Rectal pain",
+            "Stool – black tarry",
+            "Stool – bloody"],
+    ],
+    [
+        "Genitourinary" => [
+            "Blood in urine",
+            "Discharge",
+            "Foley",
+            "Incontinence",
+            "Lesions",
+            "Sexual dysfunction",
+            "Tenderness",
+            "Urinary retention",
+            "Urination - frequent",
+            "Urination - painful",
+            "Urination wakes you up at night"],
+
+        "Musculoskeletal" => [
+            "Decreased range of motion",
+            "Fracture",
+            "Gait - unstable",
+            "Joint instability",
+            "Joint pain",
+            "Joint stiffness",
+            "Joint swelling",
+            "Muscle pain",
+            "Muscle weakness",
+            "Sprain"],
+
+        "Skin" => [
+            "Bruises",
+            "Color changes",
+            "Dry skin",
+            "Goosebumps",
+            "Itchy",
+            "IVDU marks",
+            "Lesions",
+            "Nodules",
+            "Rash",
+            "Scars",
+            "Swelling",
+            "Track marks",
+            "Ulcer",
+            "Wound"],
+
+    ],
+    [
+        "Neurological" => [
+            "Coordination problem",
+            "Dizziness",
+            "Double vision",
+            "Fainting",
+            "Head trauma",
+            "Headache",
+            "Imbalance",
+            "Muscle twitching",
+            "Numbness",
+            "Problems walking",
+            "Restlessness",
+            "Seizures",
+            "Speech disturbance",
+            "TBI",
+            "Tingling",
+            "Tinnitus",
+            "Tremor",
+            "Vertigo",
+            "Weakness"],
+
+        "Endocrine" => [
+            "Change in hair growth",
+            "Cold intolerance",
+            "Diabetes",
+            "Excessive hunger",
+            "Excessive thirst",
+            "Excessive urination",
+            "Exhausted",
+            "Goiter",
+            "Heat intolerance",
+            "Hot and cold flashes",
+            "Sleeplessness",
+            "Weight gain",
+            "Weight loss"],
+
+        "Lymphatic" => [
+            "Anemia",
+            "Bleeding tendency",
+            "Bruises",
+            "Lymph node pain enlargement",
+            "Pain",
+            "Swelling",
+            "Transfusions"],
+    ]
+];
+
+$point = Point::getOnlyTopLevelPointOfCategory($note, 'ROS', true);
+
+if($point) {
+    ?> <div class="popup-content-container px-3"> <?php
+    foreach ($point->childReviews as $childReview) {
+        $contentData = $parsed = false;
+        if ($childReview->data) {
+            $childReview->data = json_decode($childReview->data, true);
+            $contentData = $parsed = $childReview->data;
+
+            ?>
+            <div class="mb-1 font-weight-bold">{{$childReview->creatorPro->displayName()}} - {{friendly_date($childReview->note->effective_dateest)}}</div>
+            <div class="pl-3 bg-light border p-3 mb-3">
+            <?php
+
+            if(!!@$contentData['declaration']) {
+                echo '<div class="mb-2">';
+                echo '<i class="fa fa-check"></i>&nbsp;';
+                echo "Except for the systems documented in the HPI or detailed below, all other systems were reviewed and negative.";
+                echo '</div>';
+            }
+
+            // group by "head" and separate fields with values
+            $grouped = [];
+            for ($i = 0; $i < count($fields); $i++) {
+                foreach ($fields[$i] as $head => $values) {
+                    for ($k = 0; $k < count($values); $k++) {
+                        $fName = $head . '_' . sanitize_field_name($values[$k]);
+                        if (@$contentData['common'][$fName]) {
+                            if(!isset($grouped[$head])) $grouped[$head] = [];
+                            $grouped[$head][] = [
+                                "label" => $values[$k],
+                                "value" => @$contentData['common'][$fName],
+                                "comments" => @$contentData['common'][$fName . '__comments']
+                            ];
+                        }
+                    }
+                }
+            }
+
+            $display = [];
+            foreach($grouped as $head => $items) {
+                $combined = [];
+                for ($i = 0; $i < count($items); $i++) {
+                    $combined[] = $items[$i]['label'] . ' (' . $items[$i]['value'] . ')' .
+                        (@$items[$i]['comments'] ? '<span class="text-secondary font-italic text-sm">&nbsp;' . @$items[$i]['comments'] . '</span>' : '');
+                }
+                $display[$head] = implode(' • ', $combined);
+            }
+
+            foreach($display as $head => $line) {
+            ?>
+            <div class="mb-2">
+                <span class="font-weight-bold mr-1">{{$head}}:</span>
+                <span class="">{!! $line !!}</span>
+            </div>
+            <?php
+            }
+            if(isset($contentData['comments']) && !empty(trim($contentData['comments']))) {
+            ?>
+                <div class="mt-2 mb-1">
+                    <b>Comments: </b><?= $contentData['comments'] ?>
+                </div>
+            <?php
+            }
+        }
+    }
+    ?> </div> <?php
+}

+ 254 - 0
resources/views/app/patient/segment-templates/sigma_ros/summary.blade.php

@@ -0,0 +1,254 @@
+<?php
+
+use App\Models\Client;
+use App\Models\Point;
+use App\Models\Note;
+/** @var Client $patient */
+/** @var Note $note */
+
+$fields = [
+    [
+        "Constitutional" => [
+            "Fatigue",
+            "Fever",
+            "Weight gain",
+            "Weight loss"],
+
+        "Eyes" => [
+            "Blurry vision",
+            "Double vision",
+            "Dry eyes",
+            "Floaters",
+            "Halos",
+            "Headache",
+            "Irritation",
+            "Loss of peripheral vision",
+            "Pain",
+            "Pinpoint pupils",
+            "Teary",
+            "Visual changes"],
+
+        "ENMT" => [
+            "Altered sense of smell",
+            "Dental caries",
+            "Dentures",
+            "Dizziness",
+            "Dry mouth",
+            "Ear pain/pressure",
+            "Hearing loss",
+            "Mouth pain",
+            "Nasal congestion",
+            "Neck pain/stiffness",
+            "Post nasal drainage",
+            "Sinus pain / pressure",
+            "Sore throat",
+            "Teeth missing",
+            "Tinnitus",
+            "Trouble swallowing"],
+        "Allergy / Immune" => [
+            "Congestion",
+            "Difficulty healing",
+            "Frequent infections",
+            "Headache",
+            "Hives",
+            "Itching",
+            "Running nose",
+            "Sneezing",
+            "Watery eyes"]
+    ],
+    [
+        "Cardiovascular" => [
+            "Chest pain / pressure at rest",
+            "Chest pain / pressure with excursion",
+            "Cold hands / feet",
+            "Dizziness",
+            "Exercise intolerance",
+            "Fainting",
+            "Feeling faint",
+            "Left arm pain",
+            "Light headed",
+            "Lower leg cramps",
+            "Muscle weakness",
+            "Palpitations",
+            "Shortness of breath",
+            "Sweating",
+            "Swelling"],
+
+        "Respiratory" => [
+            "Cough – dry",
+            "Cough – wet",
+            "Coughing up blood",
+            "Pain with breathing",
+            "Productive cough",
+            "Shortness of breath at rest",
+            "Shortness of breath on excursion",
+            "Wheezing"],
+
+        "Gastrointestinal" => [
+            "Abdominal pain",
+            "Constipation",
+            "Coughing up blood",
+            "Diarrhea",
+            "Difficulty swallowing",
+            "Fecal incontinence",
+            "Heartburn",
+            "Loose stool",
+            "Nausea",
+            "Painful swallowing",
+            "Rectal pain",
+            "Stool – black tarry",
+            "Stool – bloody"],
+    ],
+    [
+        "Genitourinary" => [
+            "Blood in urine",
+            "Discharge",
+            "Foley",
+            "Incontinence",
+            "Lesions",
+            "Sexual dysfunction",
+            "Tenderness",
+            "Urinary retention",
+            "Urination - frequent",
+            "Urination - painful",
+            "Urination wakes you up at night"],
+
+        "Musculoskeletal" => [
+            "Decreased range of motion",
+            "Fracture",
+            "Gait - unstable",
+            "Joint instability",
+            "Joint pain",
+            "Joint stiffness",
+            "Joint swelling",
+            "Muscle pain",
+            "Muscle weakness",
+            "Sprain"],
+
+        "Skin" => [
+            "Bruises",
+            "Color changes",
+            "Dry skin",
+            "Goosebumps",
+            "Itchy",
+            "IVDU marks",
+            "Lesions",
+            "Nodules",
+            "Rash",
+            "Scars",
+            "Swelling",
+            "Track marks",
+            "Ulcer",
+            "Wound"],
+
+    ],
+    [
+        "Neurological" => [
+            "Coordination problem",
+            "Dizziness",
+            "Double vision",
+            "Fainting",
+            "Head trauma",
+            "Headache",
+            "Imbalance",
+            "Muscle twitching",
+            "Numbness",
+            "Problems walking",
+            "Restlessness",
+            "Seizures",
+            "Speech disturbance",
+            "TBI",
+            "Tingling",
+            "Tinnitus",
+            "Tremor",
+            "Vertigo",
+            "Weakness"],
+
+        "Endocrine" => [
+            "Change in hair growth",
+            "Cold intolerance",
+            "Diabetes",
+            "Excessive hunger",
+            "Excessive thirst",
+            "Excessive urination",
+            "Exhausted",
+            "Goiter",
+            "Heat intolerance",
+            "Hot and cold flashes",
+            "Sleeplessness",
+            "Weight gain",
+            "Weight loss"],
+
+        "Lymphatic" => [
+            "Anemia",
+            "Bleeding tendency",
+            "Bruises",
+            "Lymph node pain enlargement",
+            "Pain",
+            "Swelling",
+            "Transfusions"],
+    ]
+];
+
+$point = Point::getOrCreateOnlyTopLevelPointOfCategory($note, 'ROS', $sessionKey, true);
+
+$rel = !!$point->relevanceToNote($note);
+
+if ($point->lastChildReview && $point->lastChildReview->data && ($rel || $point->lastChildReview->added_in_note_id === $note->id)) {
+    $point->lastChildReview->data = json_decode($point->lastChildReview->data, true);
+    $contentData = $point->lastChildReview->data;
+
+    if(!!@$contentData['declaration']) {
+        echo '<div class="mb-1">';
+        echo '<i class="fa fa-check"></i>&nbsp;';
+        echo "Except for the systems documented in the HPI or detailed below, all other systems were reviewed and negative.";
+        echo '</div>';
+    }
+
+    // group by "head" and separate fields with values
+    $grouped = [];
+    for ($i = 0; $i < count($fields); $i++) {
+        foreach ($fields[$i] as $head => $values) {
+            for ($k = 0; $k < count($values); $k++) {
+                $fName = $head . '_' . sanitize_field_name($values[$k]);
+                if (@$contentData['common'][$fName]) {
+                    if(!isset($grouped[$head])) $grouped[$head] = [];
+                    $grouped[$head][] = [
+                        "label" => $values[$k],
+                        "value" => @$contentData['common'][$fName],
+                        "comments" => @$contentData['common'][$fName . '__comments']
+                    ];
+                }
+            }
+        }
+    }
+
+    $display = [];
+    foreach($grouped as $head => $items) {
+        $combined = [];
+        for ($i = 0; $i < count($items); $i++) {
+            $combined[] = $items[$i]['label'] . ' (' . $items[$i]['value'] . ')' .
+                (@$items[$i]['comments'] ? '<span class="text-secondary font-italic text-sm">&nbsp;' . @$items[$i]['comments'] . '</span>' : '');
+        }
+        $display[$head] = implode(' • ', $combined);
+    }
+
+    foreach($display as $head => $line) {
+        ?>
+        <div class="">
+            <span class="font-weight-bold mr-1">{{$head}}:</span>
+            <span class="">{!! $line !!}</span>
+        </div>
+        <?php
+    }
+    ?>
+    @if(isset($contentData['comments']) && !empty(trim($contentData['comments'])))
+        <div class="mt-2">
+            <b>Comments: </b><?= $contentData['comments'] ?>
+        </div>
+    @endif
+    <?php
+} else {
+    echo '<div class="text-secondary">-</div>';
+}
+?>

+ 4 - 0
resources/views/app/patient/segment-templates/sigma_subjective_free_text/edit.blade.php

@@ -0,0 +1,4 @@
+<?php
+$category = 'SUBJECTIVE_GENERAL';
+$endPoint = 'upsertNoteSingleton';
+include resource_path('views/app/patient/segment-templates/_simple_text_segment/edit.php');

+ 3 - 0
resources/views/app/patient/segment-templates/sigma_subjective_free_text/summary.blade.php

@@ -0,0 +1,3 @@
+<?php
+$category = 'SUBJECTIVE_GENERAL';
+include resource_path('views/app/patient/segment-templates/_simple_text_segment/summary.php');

+ 0 - 0
resources/views/app/patient/segment-templates/sigma_subjective_system/edit.blade.php


+ 156 - 0
resources/views/app/patient/segment-templates/sigma_subjective_system/summary.blade.php

@@ -0,0 +1,156 @@
+<?php
+
+use App\Models\Point;
+
+/** @var \App\Models\Client $patient */
+/** @var \App\Models\Note $note */
+
+$wizardLinks = [
+    [
+        "name" => 'Nutrition Rx',
+        "title" => '<img src=\'/img/nutrition-rx.png\'/> Nutrition Rx',
+        "href" => "/nutrition-center/{$note->client->uid}/{$note->uid}",
+        "initer" => "nutrition-center-{$note->id}"
+    ],
+    [
+        "name" => 'Exercise Rx',
+        "title" => '<img src=\'/img/exercise-rx.png\'/> Exercise Rx',
+        "href" => "/exercise-center/{$note->client->uid}/{$note->uid}",
+        "initer" => "exercise-center-{$note->id}"
+    ],
+    [
+        "name" => 'Behavior Rx',
+        "title" => '<img src=\'/img/behavior-rx.png\'/> Behavior Rx',
+        "href" => "/behavior-center/{$note->client->uid}/{$note->uid}",
+        "initer" => "behavior-center-{$note->id}"
+    ],
+];
+
+?>
+
+<div class="mb-2 hide-if-note-signed">
+    @foreach($wizardLinks as $link)
+        @if(@$link['name'])
+            <a href="{{$link['href']}}"
+               open-in-stag-popup
+               popup-style="overflow-visible {{@$link['style']}}"
+               title="{!! @$link['title'] ?: $link['name'] !!}"
+               mc-initer="{{ @$link['initer']  }}"
+               class="mr-2 d-inline-block text-nowrap font-underline">{!! $link['name'] !!}</a>
+        @endif
+    @endforeach
+</div>
+
+<div class="system_segment">
+<?php
+/*
+$inPoints = Point::getPointsOfCategory($patient, 'ALLERGY');
+if(count($inPoints)) {
+?>
+    @include('app.patient.module-specific-summary-renderers.allergy.subjective', ['points' => $inPoints])
+<?php
+}
+
+$inPoints = Point::getPointsOfCategory($patient, 'MEDICATION');
+if(count($inPoints)) {
+?>
+    @include('app.patient.module-specific-summary-renderers.medication.subjective', ['points' => $inPoints])
+<?php
+}
+
+$inPoints = Point::getIntakePointsWithChildReview($patient, $note);
+
+// allergies/meds/problems/goals/careteam
+$topLevelPointToRendererMap = [
+    'PROBLEM' => 'problem',
+    'GOAL' => 'goal',
+    'CARE_TEAM_MEMBER' => 'care_team_member'
+];
+
+$pointMap = [];
+
+foreach($inPoints as $point){
+    if(!isset($topLevelPointToRendererMap[$point->category])) continue;
+    $renderer = $topLevelPointToRendererMap[$point->category];
+    if(!isset($pointMap[$renderer])) $pointMap[$renderer] = [];
+    $pointMap[$renderer][] = $point;
+}
+
+foreach ($pointMap as $renderer => $points) {
+?>
+@include('app.patient.module-specific-summary-renderers.' . $renderer . '.subjective', compact('points'))
+<?php
+}
+
+// history, ros
+$topLevelPointToRendererMap = [
+    'PAST_MEDICAL_HISTORY' => 'past_medical_history',
+    'FAMILY_HISTORY' => 'history_family',
+    'SOCIAL_HISTORY' => 'history_social',
+    'SURGICAL_HISTORY' => 'history_surgical',
+    'ROS' => 'ros',
+];
+
+$pointMap = [];
+
+foreach($inPoints as $point){
+    if(!isset($topLevelPointToRendererMap[$point->category])) continue;
+    $renderer = $topLevelPointToRendererMap[$point->category];
+    if(!isset($pointMap[$renderer])) $pointMap[$renderer] = [];
+    $pointMap[$renderer][] = $point;
+}
+
+foreach ($pointMap as $renderer => $points) {
+?>
+@include('app.patient.module-specific-summary-renderers.' . $renderer . '.subjective', compact('points'))
+<?php
+}
+*/
+
+$inPoints = Point::getIntakePointsWithChildReview($patient, $note);
+
+$topLevelPointToRendererMap = [
+    'HIGH_SUGAR_BEVERAGES' => 'nutrition',
+    'WATER_INTAKE' => 'nutrition',
+    'FAST_FOOD' => 'nutrition',
+    'SNACKS' => 'nutrition',
+    'VEGETABLES' => 'nutrition',
+    'PORTION_SIZES' => 'nutrition',
+    'DAILY_INTAKE_CARBOHYDRATES' => 'nutrition',
+    'DAILY_INTAKE_CALORIES' => 'nutrition',
+    'AEROBIC_ACTIVITY' => 'exercise',
+    'STRENGTH_TRAINING' => 'exercise',
+    'NEAT' => 'exercise',
+    'SELF_MONITORING' => 'behavior',
+    'FOOD_TRIGGERS' => 'behavior',
+    'CRAVINGS' => 'behavior',
+    'SLEEP_HABITS' => 'behavior',
+
+    // lifestyle
+    'LIFESTYLE_GENERAL' => 'lifestyle_general',
+    'LIFESTYLE_NUTRITION' => 'lifestyle_nutrition',
+    'LIFESTYLE_PHYSICAL_ACTIVITY' => 'lifestyle_physical_activity',
+    'LIFESTYLE_SLEEP' => 'lifestyle_sleep',
+    'LIFESTYLE_SOCIAL_RELATIONSHIPS' => 'lifestyle_social_relationships',
+    'LIFESTYLE_STRESS' => 'lifestyle_stress',
+    'LIFESTYLE_SUBSTANCE_USE' => 'lifestyle_substance_use',
+    'WEIGHT_LOSS_INTAKE' => 'weight_loss_intake',
+];
+
+$pointMap = [];
+
+foreach($inPoints as $point){
+    if(!isset($topLevelPointToRendererMap[$point->category])) continue;
+    $renderer = $topLevelPointToRendererMap[$point->category];
+    if(!isset($pointMap[$renderer])) $pointMap[$renderer] = [];
+    $pointMap[$renderer][] = $point;
+}
+
+foreach ($pointMap as $renderer => $points) {
+?>
+    @include('app.patient.module-specific-summary-renderers.' . $renderer . '.subjective', compact('points'))
+<?php
+}
+?>
+</div>
+

+ 288 - 0
resources/views/app/patient/segment-templates/sigma_typical_day_lifestyle/edit.blade.php

@@ -0,0 +1,288 @@
+<?php
+$point = App\Models\Point::getOrCreateOnlyTopLevelPointOfCategory($note, 'TYPICAL_DAY_LIFESTYLE', $sessionKey, true);
+$contentData = [
+    "lines" => [
+        [
+            "S" => '',
+            "I" => '',
+            "P" => '',
+        ]
+    ],
+    "estimated_daily_calories" => [
+        "S" => '',
+        "P" => '',
+    ],
+    "estimated_daily_protein_grams" => [
+        "S" => '',
+        "P" => '',
+    ],
+    "estimated_daily_vegetable_servings" => [
+        "S" => '',
+        "P" => '',
+    ],
+    "estimated_daily_hours_of_sleep" => [
+        "S" => '',
+        "P" => '',
+    ]
+];
+if ($point->lastChildReview && $point->lastChildReview->data) {
+    $point->lastChildReview->data = json_decode($point->lastChildReview->data, true);
+    $contentData = $point->lastChildReview->data;
+}
+?>
+
+<div visit-moe no-auto-save close-on-save close-on-cancel class="d-block p-3" id="typical_day_lifestyle-{{$note->id}}">
+    <form show url="/api/visitPoint/upsertChildReview" class="mcp-theme-1 frm-upsert-review-typical-day-ls">
+        <input type="hidden" name="uid" value="<?= $point->uid ?>">
+        <input type="hidden" name="noteUid" value="<?= $note->uid ?>">
+        <input type="hidden" name="segmentUid" value="<?= $segment->uid ?>">
+        <input type="hidden" name="data" value="{{json_encode($contentData)}}">
+
+        <p class="mb-2 font-weight-bold">Typical Day</p>
+
+        <table class="table table-sm table-bordered mb-2 stag-sheet allow-row-addition mb-3" lines>
+            <thead class="bg-light">
+            <tr>
+                <th class="border-bottom-0 text-secondary width-30px"></th>
+                <th class="border-bottom-0 text-secondary">Subjective</th>
+                <th class="border-bottom-0 text-secondary width-100px">Impression</th>
+                <th class="border-bottom-0 text-secondary w-50">Plan</th>
+            </tr>
+            </thead>
+            <tbody>
+                @foreach(@$contentData["lines"] as $line)
+                    <tr>
+                        <td class="align-middle text-center bg-light"><a href="#" class="delete-line"><i class="fa fa-trash-alt on-hover-opaque text-danger"></i></a></td>
+                        <td><textarea rows="1" key="S">{{@$line['S']}}</textarea></td>
+                        <td><textarea rows="1" key="I">{{@$line['I']}}</textarea></td>
+                        <td><textarea rows="1" key="P">{{@$line['P']}}</textarea></td>
+                    </tr>
+                @endforeach
+            </tbody>
+        </table>
+
+        <p class="mb-2 font-weight-bold">Daily Aggregates</p>
+
+        <table class="table table-sm table-bordered mb-2 stag-sheet" aggregates>
+            <thead class="bg-light">
+            <tr>
+                <th class="border-bottom-0 text-secondary width-200px">Subject</th>
+                <th class="border-bottom-0 text-secondary">Current</th>
+                <th class="border-bottom-0 text-secondary w-50">Target</th>
+            </tr>
+            </thead>
+            <tbody>
+                <tr>
+                    <td class="pl-1 align-middle bg-light">Est. Daily Calories</td>
+                    <td><textarea rows="1" key="estimated_daily_calories->S">{{@$contentData["estimated_daily_calories"]["S"]}}</textarea></td>
+                    <td><textarea rows="1" key="estimated_daily_calories->P">{{@$contentData["estimated_daily_calories"]["P"]}}</textarea></td>
+                </tr>
+                <tr>
+                    <td class="pl-1 align-middle bg-light">Est. Daily Protein Grams</td>
+                    <td><textarea rows="1" key="estimated_daily_protein_grams->S">{{@$contentData["estimated_daily_protein_grams"]["S"]}}</textarea></td>
+                    <td><textarea rows="1" key="estimated_daily_protein_grams->P">{{@$contentData["estimated_daily_protein_grams"]["P"]}}</textarea></td>
+                </tr>
+                <tr>
+                    <td class="pl-1 align-middle bg-light">Est. Daily Vegetable Servings</td>
+                    <td><textarea rows="1" key="estimated_daily_vegetable_servings->S">{{@$contentData["estimated_daily_vegetable_servings"]["S"]}}</textarea></td>
+                    <td><textarea rows="1" key="estimated_daily_vegetable_servings->P">{{@$contentData["estimated_daily_vegetable_servings"]["P"]}}</textarea></td>
+                </tr>
+                <tr>
+                    <td class="pl-1 align-middle bg-light">Est. Daily Hours Of Sleep</td>
+                    <td><textarea rows="1" key="estimated_daily_hours_of_sleep->S">{{@$contentData["estimated_daily_hours_of_sleep"]["S"]}}</textarea></td>
+                    <td><textarea rows="1" key="estimated_daily_hours_of_sleep->P">{{@$contentData["estimated_daily_hours_of_sleep"]["P"]}}</textarea></td>
+                </tr>
+            </tbody>
+        </table>
+
+        <div class="pt-2">
+            <button submit class="btn btn-sm btn-primary mr-2"><i class="fa fa-save"></i></button>
+            <div class="d-inline-flex align-self-stretch align-items-center">
+                <span class="autosave-indicator saving text-sm text-secondary">Saving changes &hellip;</span>
+                <span class="autosave-indicator saved text-sm text-secondary">
+                    <i class="fa fa-check"></i>
+                    Saved
+                </span>
+            </div>
+        </div>
+    </form>
+</div>
+<script>
+    (function() {
+        function init() {
+            let parentSegment = $('[data-segment-template-name="typical_day_lifestyle"] ');
+
+            function getRowBefore(_tr) {
+                return _tr.prev();
+            }
+
+            function moveToPrevRowInput(_td) {
+                let tr = getRowBefore(_td.closest('tr'));
+                tr.find('td:eq(' + _td.index() + ') textarea').first().focus();
+            }
+
+            function getRowAfter(_tr) {
+                return _tr.next();
+            }
+
+            function getOrCreateRowAfter(_tr) {
+                let tr = getRowAfter(_tr);
+                if(!tr.length) {
+                    tr = newRow().insertAfter(_tr);
+                }
+                return tr;
+            }
+
+            function createRowAfter(_tr) {
+                return newRow().insertAfter(_tr);
+            }
+
+            function newRow() {
+                return $('<tr><td class="align-middle text-center bg-light"><a href="#" class="delete-line"><i class="fa fa-trash-alt on-hover-opaque text-danger"></i></a></td>' +
+                    '<td><textarea rows="1" key="S"></textarea></td>' +
+                    '<td><textarea rows="1" key="I"></textarea></td>' +
+                    '<td><textarea rows="1" key="P"></textarea></td></tr>');
+            }
+
+            function createAndMoveToNextRowInput(_td) {
+                let tr = createRowAfter(_td.closest('tr'));
+                tr.find('td:eq(' + _td.index() + ') textarea').first().focus();
+            }
+
+            function moveToNextRowInput(_td, _forceCreate = false) {
+                let tr = _forceCreate ? getOrCreateRowAfter(_td.closest('tr')) : getRowAfter(_td.closest('tr'));
+                if(tr.length) {
+                    tr.find('td:eq(' + _td.index() + ') textarea').first().focus();
+                }
+            }
+
+            function moveToPrevInput(_td) {
+                _td.prev().find('textarea').first().focus();
+            }
+
+            function moveToNextInput(_td) {
+                _td.next().find('textarea').first().focus();
+            }
+
+            function generateData(_parentSegment) {
+                let data = {};
+                let lines = [];
+                _parentSegment.find('.stag-sheet[lines] tbody tr').each(function() {
+                    let line = {};
+                    $(this).find('textarea').each(function() {
+                        line[$(this).attr('key')] = this.value;
+                    });
+                    lines.push(line);
+                });
+                data.lines = lines;
+                data.estimated_daily_calories = {
+                    S: _parentSegment.find('.stag-sheet[aggregates] textarea[key="estimated_daily_calories->S"]').val(),
+                    P: _parentSegment.find('.stag-sheet[aggregates] textarea[key="estimated_daily_calories->P"]').val()
+                };
+                data.estimated_daily_protein_grams = {
+                    S: _parentSegment.find('.stag-sheet[aggregates] textarea[key="estimated_daily_protein_grams->S"]').val(),
+                    P: _parentSegment.find('.stag-sheet[aggregates] textarea[key="estimated_daily_protein_grams->P"]').val()
+                };
+                data.estimated_daily_vegetable_servings = {
+                    S: _parentSegment.find('.stag-sheet[aggregates] textarea[key="estimated_daily_vegetable_servings->S"]').val(),
+                    P: _parentSegment.find('.stag-sheet[aggregates] textarea[key="estimated_daily_vegetable_servings->P"]').val()
+                };
+                data.estimated_daily_hours_of_sleep = {
+                    S: _parentSegment.find('.stag-sheet[aggregates] textarea[key="estimated_daily_hours_of_sleep->S"]').val(),
+                    P: _parentSegment.find('.stag-sheet[aggregates] textarea[key="estimated_daily_hours_of_sleep->P"]').val()
+                };
+                return JSON.stringify(data);
+            }
+
+            function autoSave() {
+                parentSegment.find('[name="data"]').val(generateData(parentSegment));
+                parentSegment.find('[name="data"]').trigger('save-trigger');
+            }
+
+            function autoGrowTextarea(_textarea) {
+                _textarea.style.minHeight = "100%";
+                _textarea.style.height = "calc(1.5em + .5rem + 2px)";
+                _textarea.style.height = (_textarea.scrollHeight)+"px";
+            }
+
+            parentSegment
+                .off('keydown', '.stag-sheet textarea')
+                .on('keydown', '.stag-sheet textarea', function(_e) {
+                    switch (_e.which) {
+                        case 13: // ENTER: If shift NOT pressed, move to next row same column
+                            if (!_e.shiftKey) {
+                                if($(this).closest('.stag-sheet').is('.allow-row-addition')) {
+                                    createAndMoveToNextRowInput($(this).closest('td'), );
+                                }
+                                else {
+                                    moveToNextRowInput($(this).closest('td'), false);
+                                }
+                                return false;
+                            }
+                            break;
+                        case 38: // UP: If caret already at 0, move up to prev row same column
+                            if (this.selectionStart === this.selectionEnd && this.selectionStart === 0) {
+                                moveToPrevRowInput($(this).closest('td'));
+                                return false;
+                            }
+                            break;
+                        case 40: // DOWN: If caret already at end, move down to next row same column
+                            if (this.selectionStart === this.selectionEnd && this.selectionStart === this.value.length) {
+                                moveToNextRowInput($(this).closest('td'));
+                                return false;
+                            }
+                            break;
+                        case 37: // LEFT: If caret already at 0, move left to prev column
+                            if (this.selectionStart === this.selectionEnd && this.selectionStart === 0) {
+                                moveToPrevInput($(this).closest('td'));
+                                return false;
+                            }
+                            break;
+                        case 39: // DOWN: If caret already at end, move right to next column
+                            if (this.selectionStart === this.selectionEnd && this.selectionStart === this.value.length) {
+                                moveToNextInput($(this).closest('td'));
+                                return false;
+                            }
+                            break;
+                        case 8: // BACKSPACE: If caret already at 0, move left to prev column
+                            break;
+                    }
+
+                });
+
+            parentSegment
+                .off('input paste cut change', '.stag-sheet textarea')
+                .on('input paste cut change', '.stag-sheet textarea', function() {
+                    autoSave();
+                });
+
+            parentSegment
+                .off('click.delete-line', '.stag-sheet .delete-line')
+                .on('click.delete-line', '.stag-sheet .delete-line', function() {
+                    let tr = $(this).closest('tr');
+                    let isFirst = (tr.index() === 0);
+                    if(isFirst) {
+                        newRow().insertAfter(tr);
+                    }
+                    tr.remove();
+                    autoSave();
+                    return false;
+                });
+
+            parentSegment.find('.stag-sheet textarea').each(function() {
+                autoGrowTextarea(this);
+            });
+
+            parentSegment
+                .off('edit-mode-activated')
+                .on('edit-mode-activated', function() {
+                    parentSegment.find('.stag-sheet textarea').each(function() {
+                        autoGrowTextarea(this);
+                    });
+                });
+
+        }
+        window.segmentInitializers.typical_day_lifestyle = init;
+        addMCInitializer('typical_day_lifestyle-{{$note->id}}', init, '#typical_day_lifestyle-{{$note->id}}');
+    }).call(window);
+</script>

+ 73 - 0
resources/views/app/patient/segment-templates/sigma_typical_day_lifestyle/log.blade.php

@@ -0,0 +1,73 @@
+<?php
+
+use App\Models\Point;
+
+$point = Point::getOnlyTopLevelPointOfCategory($note, 'TYPICAL_DAY_LIFESTYLE', true);
+
+if($point) {
+    ?> <div class="popup-content-container px-3"> <?php
+    foreach ($point->childReviews as $childReview) {
+        $contentData = $parsed = false;
+        if ($childReview->data) {
+            $childReview->data = json_decode($childReview->data, true);
+            $contentData = $parsed = $childReview->data;
+            ?>
+            <div class="mb-1 font-weight-bold">{{$childReview->creatorPro->displayName()}} - {{friendly_date($childReview->note->effective_dateest)}}</div>
+            <div class="pl-3 bg-light border p-3 mb-3">
+                <p class="mb-2 font-weight-bold">Typical Day</p>
+                @if(@$contentData["lines"] && count($contentData["lines"]))
+                    <table class="table table-sm table-bordered mb-3">
+                        <thead class="bg-light">
+                        <tr>
+                            <th class="border-bottom-0 text-secondary">Subjective</th>
+                            <th class="border-bottom-0 text-secondary w-50">Impression & Plan</th>
+                        </tr>
+                        </thead>
+                        <tbody>
+                        @foreach(@$contentData["lines"] as $line)
+                            <tr>
+                                <td><pre class="m-0">{{$line['S']}}</pre></td>
+                                <td><pre class="m-0">{{$line['P']}}</pre></td>
+                            </tr>
+                        @endforeach
+                        </tbody>
+                    </table>
+                @endif
+                <p class="mb-2 font-weight-bold">Daily Aggregates</p>
+                <table class="table table-sm table-bordered mb-2">
+                    <thead class="bg-light">
+                    <tr>
+                        <th class="border-bottom-0 text-secondary width-200px">Subject</th>
+                        <th class="border-bottom-0 text-secondary">Current</th>
+                        <th class="border-bottom-0 text-secondary w-50">Target</th>
+                    </tr>
+                    </thead>
+                    <tbody>
+                    <tr>
+                        <td class="pl-1 align-middle bg-light">Est. Daily Calories</td>
+                        <td><pre class="m-0">{{@$contentData["estimated_daily_calories"]["S"]}}</pre></td>
+                        <td><pre class="m-0">{{@$contentData["estimated_daily_calories"]["P"]}}</pre></td>
+                    </tr>
+                    <tr>
+                        <td class="pl-1 align-middle bg-light">Est. Daily Protein Grams</td>
+                        <td><pre class="m-0">{{@$contentData["estimated_daily_protein_grams"]["S"]}}</pre></td>
+                        <td><pre class="m-0">{{@$contentData["estimated_daily_protein_grams"]["P"]}}</pre></td>
+                    </tr>
+                    <tr>
+                        <td class="pl-1 align-middle bg-light">Est. Daily Vegetable Servings</td>
+                        <td><pre class="m-0">{{@$contentData["estimated_daily_vegetable_servings"]["S"]}}</pre></td>
+                        <td><pre class="m-0">{{@$contentData["estimated_daily_vegetable_servings"]["P"]}}</pre></td>
+                    </tr>
+                    <tr>
+                        <td class="pl-1 align-middle bg-light">Est. Daily Hours Of Sleep</td>
+                        <td><pre class="m-0">{{@$contentData["estimated_daily_hours_of_sleep"]["S"]}}</pre></td>
+                        <td><pre class="m-0">{{@$contentData["estimated_daily_hours_of_sleep"]["P"]}}</pre></td>
+                    </tr>
+                    </tbody>
+                </table>
+            </div> <?php
+        }
+    }
+    ?> </div> <?php
+}
+?>

+ 98 - 0
resources/views/app/patient/segment-templates/sigma_typical_day_lifestyle/summary.blade.php

@@ -0,0 +1,98 @@
+<?php
+if(!@$sessionKey) {
+    $sessionKey = request()->cookie('sessionKey');
+}
+$point = App\Models\Point::getOrCreateOnlyTopLevelPointOfCategory($note, 'TYPICAL_DAY_LIFESTYLE', $sessionKey, true);
+$contentData = [
+    "lines" => [
+        [
+            "S" => '',
+            "I" => '',
+            "P" => '',
+        ]
+    ],
+    "estimated_daily_calories" => [
+        "S" => '',
+        "P" => '',
+    ],
+    "estimated_daily_protein_grams" => [
+        "S" => '',
+        "P" => '',
+    ],
+    "estimated_daily_vegetable_servings" => [
+        "S" => '',
+        "P" => '',
+    ],
+    "estimated_daily_hours_of_sleep" => [
+        "S" => '',
+        "P" => '',
+    ]
+];
+if ($point->lastChildReview && $point->lastChildReview->data) {
+    $point->lastChildReview->data = json_decode($point->lastChildReview->data, true);
+    $contentData = $point->lastChildReview->data;
+}
+?>
+<div class="events-none form-read-mode">
+    <p class="mb-2 font-weight-bold">Typical Day</p>
+
+    @if(@$contentData["lines"] && count($contentData["lines"]))
+        <table class="table table-sm table-bordered mb-3">
+            <thead class="bg-light">
+            <tr>
+                <th class="border-bottom-0 text-secondary">Subjective</th>
+                <th class="border-bottom-0 text-secondary w-50">Impression & Plan</th>
+            </tr>
+            </thead>
+            <tbody>
+            @foreach(@$contentData["lines"] as $line)
+                <tr>
+                    <td><pre class="m-0">{{$line['S']}}&nbsp;</pre></td>
+                    <td>
+                        <div class="d-flex align-items-baseline">
+                            @if(@$line['I'])
+                                <b class="mr-2">{{$line['I']}}</b>
+                            @endif
+                            <pre class="m-0">{{$line['P']}}&nbsp;</pre>
+                        </div>
+                    </td>
+                </tr>
+            @endforeach
+            </tbody>
+        </table>
+    @endif
+
+    <p class="mb-2 font-weight-bold">Daily Aggregates</p>
+
+    <table class="table table-sm table-bordered mb-2">
+        <thead class="bg-light">
+        <tr>
+            <th class="border-bottom-0 text-secondary width-200px">Subject</th>
+            <th class="border-bottom-0 text-secondary">Current</th>
+            <th class="border-bottom-0 text-secondary w-50">Target</th>
+        </tr>
+        </thead>
+        <tbody>
+        <tr>
+            <td class="pl-1 align-middle bg-light">Est. Daily Calories</td>
+            <td><pre class="m-0">{{@$contentData["estimated_daily_calories"]["S"]}}</pre></td>
+            <td><pre class="m-0">{{@$contentData["estimated_daily_calories"]["P"]}}</pre></td>
+        </tr>
+        <tr>
+            <td class="pl-1 align-middle bg-light">Est. Daily Protein Grams</td>
+            <td><pre class="m-0">{{@$contentData["estimated_daily_protein_grams"]["S"]}}</pre></td>
+            <td><pre class="m-0">{{@$contentData["estimated_daily_protein_grams"]["P"]}}</pre></td>
+        </tr>
+        <tr>
+            <td class="pl-1 align-middle bg-light">Est. Daily Vegetable Servings</td>
+            <td><pre class="m-0">{{@$contentData["estimated_daily_vegetable_servings"]["S"]}}</pre></td>
+            <td><pre class="m-0">{{@$contentData["estimated_daily_vegetable_servings"]["P"]}}</pre></td>
+        </tr>
+        <tr>
+            <td class="pl-1 align-middle bg-light">Est. Daily Hours Of Sleep</td>
+            <td><pre class="m-0">{{@$contentData["estimated_daily_hours_of_sleep"]["S"]}}</pre></td>
+            <td><pre class="m-0">{{@$contentData["estimated_daily_hours_of_sleep"]["P"]}}</pre></td>
+        </tr>
+        </tbody>
+    </table>
+</div>

+ 327 - 0
resources/views/app/patient/segment-templates/sigma_vitals/edit.blade.php

@@ -0,0 +1,327 @@
+<?php
+if(!@$sessionKey) {
+    $sessionKey = request()->cookie('sessionKey');
+}
+$point = App\Models\Point::getOrCreateOnlyTopLevelPointOfCategory($note, 'VITALS', $sessionKey, true);
+$vitalLabels = [
+    "heightInInches" => "Ht. (in.)",
+    "weightPounds" => "Wt. (lbs.)",
+    "bmi" => "BMI (kg/m²)",
+    "temperatureF" => "Temp. (F)",
+    "systolicBP" => "SBP",
+    "diastolicBP" => "DBP",
+    "pulseRatePerMinute" => "Pulse",
+    "respirationRatePerMinute" => "Resp.",
+    "pulseOx" => "Pulse Ox.",
+    "smokingStatus" => "Smoking Status",
+];
+$contentData = null;
+if ($point->lastChildReview && $point->lastChildReview->note->id === $note->id && $point->lastChildReview->data) {
+    $point->lastChildReview->data = json_decode($point->lastChildReview->data, true);
+    $contentData = $point->lastChildReview->data;
+}
+
+if(!$contentData) {
+    $contentData = [
+        "date" => $note->effective_dateest,
+        "heightInInches" => '',
+        "weightPounds" => '',
+        "bmi" => '',
+        "temperatureF" => '',
+        "systolicBP" => '',
+        "diastolicBP" => '',
+        "pulseRatePerMinute" => '',
+        "respirationRatePerMinute" => '',
+        "pulseOx" => '',
+        "smokingStatus" => '',
+    ];
+}else {
+    if(!isset($contentData['date'])) $contentData['date'] = $note->effective_dateest;
+    foreach ($vitalLabels as $k => $v) {
+        if (!isset($contentData[$k]) || is_array($contentData[$k])) {
+            $contentData[$k] = '';
+        }
+    }
+}
+
+$previousVitals = [];
+
+$previousVitals = \App\Models\Point::where('parent_point_id', $point->id)
+    ->where('category', 'REVIEW')
+    ->where('added_in_note_id', '!=', $note->id)
+    ->orderBy('id', 'DESC')
+    ->limit(4)
+    ->get();
+
+// convert to new format
+$previousData = [];
+$previousDataAssoc = [];
+foreach ($previousVitals as $p) {
+    if (!!@$p->data) {
+        $parsedP = json_decode($p->data, true);
+        $newFormat = [];
+        foreach ($vitalLabels as $k => $v) {
+            if (isset($parsedP[$k]) && is_array($parsedP[$k]) && isset($parsedP[$k]['value'])) {
+                $newFormat[$k] = $parsedP[$k]['value'];
+            }
+            else if(isset($parsedP[$k]) && !is_array($parsedP[$k])) {
+                $newFormat[$k] = $parsedP[$k];
+            }
+            else {
+                $newFormat[$k] = '';
+            }
+        }
+        $newFormat['date'] = $p->note->effective_dateest; // unfriendly_date($p->created_at);
+        $previousData[] = $newFormat;
+        $previousDataAssoc[$newFormat['date']] = $newFormat; // for easy iter to cols
+    }
+}
+
+$copyTriggerAdded = [];
+
+if(!@$segment) {
+    $segment = $note->coreSegment;
+}
+
+?>
+<div visit-moe close-on-save close-on-cancel class="d-block">
+    <form show url="/api/visitPoint/upsertChildReview" class="mcp-theme-1">
+        <input type="hidden" name="uid" value="<?= $point->uid ?>">
+        <input type="hidden" name="noteUid" value="<?= $note->uid ?>">
+        <input type="hidden" name="segmentUid" value="<?= $segment->uid ?>">
+        <input type="hidden" name="category" value="VITALS">
+        <input type="hidden" name="data" value="{{json_encode($contentData)}}">
+
+        <table class="table table-sm table-bordered mb-2 table-edit-sheet">
+            <thead>
+            <tr class="bg-light">
+                <th class="px-2 text-secondary border-bottom-0 width-150px">Vital</th>
+                <th class="px-2 text-secondary border-bottom-0 w-25">{{friendly_date($contentData['date'])}}</th>
+                @if(!$previousData || !count($previousData))
+                    <th class="px-2 text-secondary border-bottom-0">Previous</th>
+                @else
+                    @foreach($previousData as $pDay)
+                        <th class="px-2 text-secondary border-bottom-0 on-hover-opaque position-relative">
+                            {{friendly_date($pDay['date'])}}
+                        </th>
+                    @endforeach
+                @endif
+            </tr>
+            </thead>
+            <tbody>
+                @foreach($vitalLabels as $k => $v)
+                    @if($k !== 'diastolicBP')
+                    <tr>
+                        <td>
+                            <input type="text" tabindex="-1"
+                                   class="form-control form-control-sm events-none border-0"
+                                   value="{{ $k === 'systolicBP' ? 'Blood Pressure' : ($k === 'heightInInches' ? 'Height' : $v) }}" readonly>
+                        </td>
+                        <td class="position-relative">
+                            @if($k === "bmi")
+                                <div class="d-flex align-items-stretch">
+                                    <input type="text" readonly bmi
+                                           class="form-control form-control-sm vitals-title border-bottom-0 border-top-0 border-left-0 border-right width-70px"
+                                           data-name="bmi" value="{{$contentData['bmi']}}">
+                                    <div class="flex-grow-1 py-1 m-0 px-2 font-weight-bold bg-light" bmi-category>
+                                        @if(isset($contentData['bmi']) && $contentData['bmi'] != "" )
+                                            <?php $bmi = $contentData['bmi']; ?>
+                                            @if($bmi < 18.5)
+                                                <span class="text-sm text-warning-mellow">Underweight</span>
+                                            @endif
+                                            @if($bmi >= 18.5 && $bmi < 25)
+                                                <span class="text-sm text-success">Healthy Weight</span>
+                                            @endif
+                                            @if($bmi >= 25 && $bmi < 30)
+                                                <span class="text-sm text-warning-mellow">Overweight</span>
+                                            @endif
+                                            @if($bmi >= 30)
+                                                <span class="text-sm text-warning-mellow">Obese</span>
+                                            @endif
+                                        @endif
+                                    </div>
+                                </div>
+                            @elseif($k === "smokingStatus")
+                                <input type="text"
+                                       class="form-control form-control-sm border-0"
+                                       data-name="smokingStatus"
+                                       placeholder="{{$v}}"
+                                       data-option-list="smokingStatus" value="{{$contentData['smokingStatus']}}">
+                                <div id="smoking-status-options" class="data-option-list">
+                                    <div>Current every day smoker</div>
+                                    <div>Former some day smoker</div>
+                                    <div>Former smoker</div>
+                                    <div>Never smoker</div>
+                                    <div>Smoker, current status unknown</div>
+                                    <div>Unknown if ever smoked</div>
+                                    <div>Heavy tobacco smoker</div>
+                                    <div>Light tobacco smoker</div>
+                                </div>
+                            @elseif($k === 'systolicBP')
+                                <div class="d-flex align-items-center bg-white">
+                                    <input type="text" class="form-control form-control-sm min-width-unset w-auto-input width-70px border-0 edit"
+                                           data-name="systolicBP" systolicBP
+                                           value="{{$contentData['systolicBP']}}" placeholder="Systolic">
+                                    <span class="px-2 text-secondary bg-white">/</span>
+                                    <input type="text" class="form-control form-control-sm min-width-unset w-auto-input width-70px border-0 edit"
+                                           data-name="diastolicBP" diastolicBP
+                                           value="{{$contentData['diastolicBP']}}" placeholder="Diastolic">
+                                </div>
+                            @elseif($k === 'heightInInches')
+                                <div class="d-flex align-items-center bg-white">
+                                    <input type="text" class="form-control form-control-sm min-width-unset w-auto-input width-30px border-0 edit"
+                                           heightFeetInput
+                                           value="{{feetFromInches($contentData['heightInInches']) ?: ''}}">
+                                    <span class="pl-1 pr-2 text-secondary bg-white">ft.</span>
+                                    <input type="text" class="form-control form-control-sm min-width-unset w-auto-input width-30px border-0 edit pr-0"
+                                           heightInchesInput
+                                           value="{{inchesAfterFeetFromInches($contentData['heightInInches']) ?: ''}}">
+                                    <span class="pl-1 text-secondary bg-white">in.</span>
+                                    <input type="hidden" data-name="heightInInches" value="{{$contentData['heightInInches']}}">
+                                </div>
+                            @else
+                                <input type="text"
+                                       class="form-control form-control-sm border-0" data-name="{{$k}}" {{$k}}
+                                       value="{{$contentData[$k]}}"
+                                       placeholder="{{$v}}"
+                                       @if($k == 'heightInInches' || $k == 'weightPounds') refresh-bmi @endif>
+                            @endif
+                        </td>
+                        @if(!$previousData || !count($previousData))
+                            <td class="bg-light"></td>
+                        @else
+                            @foreach($previousData as $pDay)
+                                <td class="bg-light {{!isset($copyTriggerAdded[$k]) ? 'px-2' : 'px-2'}} py-1 text-secondary position-relative">
+                                    <span data-type="{{$k}}">
+                                    @if($k === 'systolicBP')
+                                        {{ @$previousDataAssoc[$pDay['date']]['systolicBP'] ?: '-' }}/{{ @$previousDataAssoc[$pDay['date']]['diastolicBP'] ?: '-' }}
+                                    @elseif($k === 'heightInInches')
+                                        {{$previousDataAssoc[$pDay['date']][$k] ? toFeetAndInches($previousDataAssoc[$pDay['date']][$k]) : '-' }}
+                                    @elseif($k === 'bmi')
+                                        {{$previousDataAssoc[$pDay['date']][$k] ?: '-' }}
+                                        <?php
+                                        $prevBMI = $previousDataAssoc[$pDay['date']][$k] ? +($previousDataAssoc[$pDay['date']][$k]) : false;
+                                        ?>
+                                        @if($prevBMI < 18.5)
+                                            <span class="text-sm text-warning-mellow ml-1">Underweight</span>
+                                        @endif
+                                        @if($prevBMI >= 18.5 && $prevBMI < 25)
+                                            <span class="text-sm text-success ml-1">Healthy Weight</span>
+                                        @endif
+                                        @if($prevBMI >= 25 && $prevBMI < 30)
+                                            <span class="text-sm text-warning-mellow ml-1">Overweight</span>
+                                        @endif
+                                        @if($prevBMI >= 30)
+                                            <span class="text-sm text-warning-mellow ml-1">Obese</span>
+                                        @endif
+                                    @else
+                                        {{$previousDataAssoc[$pDay['date']][$k] ?: '-' }}
+                                    @endif
+                                    </span>
+                                    @if(!isset($copyTriggerAdded[$k]) && $k !== "bmi")
+                                        <a href="#" title="Copy to this note" class="vitals-copy-trigger"><i class="fa fa-chevron-circle-left font-size-14"></i></a>
+                                    @endif
+                                </td>
+                                <?php $copyTriggerAdded[$k] = true ?>
+                            @endforeach
+                        @endif
+                    </tr>
+                    @endif
+                @endforeach
+            </tbody>
+        </table>
+        <div>
+            <button submit class="btn btn-sm btn-primary mr-2"><i class="fa fa-save"></i></button>
+            <div class="d-inline-flex align-self-stretch align-items-center">
+                <span class="autosave-indicator saving text-sm text-secondary">Saving changes &hellip;</span>
+                <span class="autosave-indicator saved text-sm text-secondary">
+                    <i class="fa fa-check"></i>
+                    Saved
+                </span>
+            </div>
+        </div>
+    </form>
+</div>
+<script>
+    window.segmentInitializers.omega_vitals = function () {
+        let parentSegment = $('[data-segment-template-name="omega_vitals"] ');
+
+        function __refreshBMI() {
+            var height = parseInt(parentSegment.find('[data-name="heightInInches"]').val());
+            var weight = parseInt(parentSegment.find('[data-name="weightPounds"]').val());
+            var bmi = '', bmiCategory = '';
+            if(!isNaN(height) && !isNaN(weight)) {
+                bmi = Math.round((weight / (height * height)) * 703.06957964);
+                if(bmi < 18.5) {
+                    bmiCategory = '<span class="text-sm text-warning-mellow">Underweight</span>';
+                }
+                else if(bmi >= 18.5 && bmi < 25) {
+                    bmiCategory = '<span class="text-sm text-success">Healthy Weight</span>';
+                }
+                else if(bmi >= 25 && bmi < 30) {
+                    bmiCategory = '<span class="text-sm text-warning-mellow">Overweight</span>';
+                }
+                else if(bmi >= 30) {
+                    bmiCategory = '<span class="text-sm text-warning-mellow">Obese</span>';
+                }
+            }
+            parentSegment.find('[bmi]').val(bmi);
+            parentSegment.find('[bmi-category]').empty().append(bmiCategory);
+        }
+
+        parentSegment.find('[refresh-bmi]').off('change input');
+        parentSegment.find('[refresh-bmi]').on('change input', __refreshBMI);
+
+        parentSegment.find('[heightFeetInput], [heightInchesInput]').off('change input paste');
+        parentSegment.find('[heightFeetInput], [heightInchesInput]').on('change input paste', function () {
+            let inches = 0;
+            let ft = +(parentSegment.find('[heightFeetInput]').val()),
+                inc = +(parentSegment.find('[heightInchesInput]').val());
+            inches = Math.round(ft * 12 + inc);
+            parentSegment.find('[data-name="heightInInches"]').val(inches);
+            __refreshBMI();
+        });
+
+        parentSegment.find('.vitals-copy-trigger').off('click.copy-vital');
+        parentSegment.find('.vitals-copy-trigger').on('click.copy-vital', function () {
+            let td = $(this).closest('td'), value = $.trim(td.text());
+            let type = td.find('>span').first().attr('data-type');
+            if(!type) return false;
+            switch (type) {
+                case 'heightInInches':
+                    if(value.indexOf('ft.') !== -1 && value.indexOf('in.') !== -1) {
+                        value = value.replace('in.', '');
+                        value = value.replace('ft.', '|');
+                        value = value.replace('/\s/gi', '');
+                        let parts = value.split('|');
+                        if (parts.length >= 1 && parts[0] !== '-') {
+                            td.prev().find('input:eq(0)').val(parts[0]).trigger('change');
+                        }
+                        if (parts.length >= 2 && parts[1] !== '-') {
+                            td.prev().find('input:eq(1)').val(parts[1]).trigger('change');
+                        }
+                    }
+                    break;
+                case 'systolicBP':
+                    if(value.indexOf('/') !== -1) {
+                        let parts = value.split('/');
+                        if (parts.length >= 1 && parts[0] !== '-') {
+                            td.prev().find('input:eq(0)').val(parts[0]).trigger('change');
+                        }
+                        if (parts.length >= 2 && parts[1] !== '-') {
+                            td.prev().find('input:eq(1)').val(parts[1]).trigger('change');
+                        }
+                    }
+                    break;
+                default:
+                    if(value && value !== '-') {
+                        td.prev().find('input').val(value).trigger('change');
+                    }
+                    break;
+            }
+
+            return false;
+        });
+
+    };
+</script>

+ 101 - 0
resources/views/app/patient/segment-templates/sigma_vitals/summary.blade.php

@@ -0,0 +1,101 @@
+<?php
+if(!@$sessionKey) {
+    $sessionKey = request()->cookie('sessionKey');
+}
+$point = App\Models\Point::getOrCreateOnlyTopLevelPointOfCategory($note, 'VITALS', $sessionKey, true);
+$vitalLabels = [
+    "heightInInches" => "Ht. (in.)",
+    "weightPounds" => "Wt. (lbs.)",
+    "bmi" => "BMI (kg/m²)",
+    "temperatureF" => "Temp. (F)",
+    "systolicBP" => "SBP",
+    "diastolicBP" => "DBP",
+    "pulseRatePerMinute" => "Pulse",
+    "respirationRatePerMinute" => "Resp.",
+    "pulseOx" => "Pulse Ox.",
+    "smokingStatus" => "Smoking Status",
+];
+$contentData = null;
+if ($point->lastChildReview && $point->lastChildReview->note->id === $note->id && $point->lastChildReview->data) {
+    $point->lastChildReview->data = json_decode($point->lastChildReview->data, true);
+    $contentData = $point->lastChildReview->data;
+}
+
+if(!$contentData) {
+    $contentData = [
+        "date" => $note->effective_dateest,
+        "heightInInches" => '',
+        "weightPounds" => '',
+        "bmi" => '',
+        "temperatureF" => '',
+        "systolicBP" => '',
+        "diastolicBP" => '',
+        "pulseRatePerMinute" => '',
+        "respirationRatePerMinute" => '',
+        "pulseOx" => '',
+        "smokingStatus" => '',
+    ];
+}else {
+    if(!isset($contentData['date'])) $contentData['date'] = $note->effective_dateest;
+    foreach ($vitalLabels as $k => $v) {
+        if (!isset($contentData[$k]) || is_array($contentData[$k])) {
+            $contentData[$k] = '';
+        }
+    }
+}
+?>
+
+{{--<div class="mb-2">Effective Date: <b>{{friendly_date($contentData['date'])}}</b></div>--}}
+<div class="d-flex flex-wrap">
+@foreach ($vitalLabels as $k => $v)
+    @if($k !== 'diastolicBP')
+        <div class="d-inline-flex vital-item align-items-center mr-3 mb-1">
+            <span class="content-html text-nowrap">
+                <?php $vital = @$contentData[$k]; ?>
+                @if($k === 'systolicBP')
+                    <span>BP:</span>
+                    <b>{{ @$contentData['systolicBP'] ?: '-' }}/{{ @$contentData['diastolicBP'] ?: '-' }}</b>
+                @elseif($k === 'diastolicBP')
+                    <!--ignore-->
+                @elseif($k === 'heightInInches')
+                    <span>Ht:</span>
+                    <b>{{ !empty($vital) ? toFeetAndInches($vital, "'", '"') : '-' }}</b>
+                @elseif($k === 'weightPounds')
+                    <span>Wt:</span>
+                    <b>{{ !empty($vital) ? $vital : '-' }}</b>
+                @elseif($k === 'bmi')
+                    <span>BMI:</span>
+                    <b>{{ !empty($vital) ? $vital : '-' }}</b>
+                @elseif($k === 'temperatureF')
+                    <span>Temp:</span>
+                    <b>{{ !empty($vital) ? $vital : '-' }}</b>
+                @elseif($k === 'smokingStatus')
+                    <span>Smoking:</span>
+                    <b>{{ !empty($vital) ? $vital : '-' }}</b>
+                @else
+                    <span>{{$v}}:</span>
+                    <b>{{ !empty($vital) ? $vital : '-' }}</b>
+                @endif
+                @if($k === 'bmi' && !empty($vital))
+                    <?php $bmi = floatval($vital); ?>
+                    <span class="ml-1 py-1 m-0">
+                         @if($bmi < 18.5)
+                            <span class="text-warning-mellow">(Underweight)</span>
+                         @endif
+                        @if($bmi >= 18.5 && $bmi < 25)
+                            <span class="text-success">(Healthy Weight)</span>
+                        @endif
+                        @if($bmi >= 25 && $bmi < 30)
+                            <span class="text-warning-mellow">(Overweight)</span>
+                        @endif
+                        @if($bmi >= 30)
+                            <span class="text-warning-mellow">(Obese)</span>
+                        @endif
+                    </span>
+                @endif
+            </span>
+        </div>
+        @if(in_array($k, ['bmi', 'temperatureF', 'respirationRatePerMinute']))<br>@endif
+    @endif
+@endforeach
+</div>

+ 1 - 1
resources/views/app/practice-management/process-notes.blade.php

@@ -20,7 +20,7 @@
                 <b class="">{{$modeLabel}} ({{$counts["mode-" . $mode]}})</b>&nbsp;&nbsp;<i class="fa fa-arrow-right"></i>&nbsp;&nbsp;Pick Up Next Available Note
             </button>
                 <a href="/practice-management/process-notes?mode={{$mode}}" class="btn btn-warning px-4 ml-3" style="display: none; color: black;" id="btn-pick-refresh">
-			<b class="">CLICK TO REFRESH DATA! {{$modeLabel}} ({{$counts["mode-" . $mode]}})</b>&nbsp;&nbsp;<i class="fa fa-sync"></i>&nbsp;&nbsp;
+			<b class="">CLICK TO REFRESH DATA! {{$modeLabel}} ({{$counts["mode-" . $mode]}})</b>&nbsp;&nbsp;<i class="fa fa-sync on-hover-opaque"></i>&nbsp;&nbsp;
 		</a>
         </div>
 

+ 1 - 1
resources/views/layouts/confirm-hours-of-availability-notification.blade.php

@@ -38,7 +38,7 @@
 		</div>
 		@else
 		<div>
-			<span>Hours of Availability last confirmed on <b><i class="fas fa-history"></i> {{ friendly_date_time($pro->hours_of_availability_confirmed_at) }}</b></span>
+			<span>Hours of Availability last confirmed on <b><i class="fas fa-history on-hover-opaque"></i> {{ friendly_date_time($pro->hours_of_availability_confirmed_at) }}</b></span>
 		</div>
 
 		<div>

+ 1 - 1
resources/views/layouts/no-mc-template.blade.php

@@ -147,7 +147,7 @@
             <div class="current-work mr-2">
                 @include('app/current-work')
             </div>
-            <a href="#" class="mr-2 text-white small" onclick="return fastReload()"><i class="fa fa-sync"></i></a>
+            <a href="#" class="mr-2 text-white small" onclick="return fastReload()"><i class="fa fa-sync on-hover-opaque"></i></a>
             <div class="d-inline-flex pr-2 mcp-theme-1 position-relative">
                 <input id="patient-search" type="search" class="form-control form-control-sm outline-0" autocomplete="off" placeholder="Search Patients">
                 <div class="patient-search-results suggestions-outer position-absolute d-none">

+ 2 - 6
resources/views/layouts/patient-header.blade.php

@@ -77,15 +77,11 @@ $addressParts .= implode(", ", $addressPart2);
       <div class="d-flex border-left pl-2 ml-2">
         <div class="mr-1">Cell. BP: <b>{{$patient->hasBPDevice()?'Yes':'No'}}</b>
           @if($patient->most_recent_cellular_bp_sbp_mm_hg && $patient->most_recent_cellular_bp_dbp_mm_hg)
-          (<b>{{$patient->most_recent_cellular_bp_sbp_mm_hg ?: '-'}}/{{$patient->most_recent_cellular_bp_dbp_mm_hg ?: '-'}}</b>@if($patient->most_recent_cellular_bp_measurement_at),{{friendly_date_short($patient->most_recent_cellular_bp_measurement_at)}} @endif)
-          @endif
+          (<b>{{$patient->most_recent_cellular_bp_sbp_mm_hg ?: '-'}}/{{$patient->most_recent_cellular_bp_dbp_mm_hg ?: '-'}}</b>@if($patient->most_recent_cellular_bp_measurement_at), {{friendly_date_short($patient->most_recent_cellular_bp_measurement_at)}}@endif)@endif
         </div>
         <div class="mr-2">Wt.: <b>{{$patient->hasWeightScaleDevice()?'Yes':'No'}}</b>
           @if($patient->most_recent_cellular_weight_value)
-          (
-            <b>{{round($patient->most_recent_cellular_weight_value, 1)}}</b>@if($patient->most_recent_cellular_weight_measurement_at),{{friendly_date_short($patient->most_recent_cellular_weight_measurement_at)}}
-            @endif
-          )
+          (<b>{{round($patient->most_recent_cellular_weight_value, 1)}}</b>@if($patient->most_recent_cellular_weight_measurement_at), {{friendly_date_short($patient->most_recent_cellular_weight_measurement_at)}}@endif)
           @endif
         </div>
         

+ 1 - 1
resources/views/layouts/template-no-mc.blade.php

@@ -136,7 +136,7 @@
             <div class="current-work mr-2">
                 @include('app/current-work')
             </div>
-            <a href="#" class="mr-2 text-white small" onclick="return fastReload()"><i class="fa fa-sync"></i></a>
+            <a href="#" class="mr-2 text-white small" onclick="return fastReload()"><i class="fa fa-sync on-hover-opaque"></i></a>
             <div class="d-inline-flex pr-2 mcp-theme-1 position-relative">
                 <input id="patient-search" type="search" class="form-control form-control-sm outline-0" autocomplete="off" placeholder="Search Patients">
                 <div class="suggestions-outer position-absolute d-none">

+ 1 - 1
resources/views/layouts/template.blade.php

@@ -232,7 +232,7 @@
             <div class="current-work mr-2">
                 @include('app/current-work')
             </div> --}}
-            <a href="#" class="mr-2 text-white small" onclick="return fastReload()"><i class="fa fa-sync"></i></a>
+            <a href="#" class="mr-2 text-white small" onclick="return fastReload()"><i class="fa fa-sync on-hover-opaque"></i></a>
             <div class="d-inline-flex pr-2 mcp-theme-1 position-relative">
                 <input id="patient-search" type="search" class="form-control form-control-sm outline-0" autocomplete="off" placeholder="Search Patients">
                 <div class="patient-search-results suggestions-outer position-absolute d-none">