Skip to content

Commit

Permalink
Database connection Screning and other fields
Browse files Browse the repository at this point in the history
  • Loading branch information
SushantTamu committed Oct 27, 2023
1 parent 7f94c08 commit 50dedde
Show file tree
Hide file tree
Showing 22 changed files with 2,191 additions and 36 deletions.
70 changes: 70 additions & 0 deletions app/controllers/child_level_details_controller.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,70 @@
class ChildLevelDetailsController < ApplicationController
before_action :set_child_level_detail, only: %i[ show edit update destroy ]

# GET /child_level_details or /child_level_details.json
def index
@child_level_details = ChildLevelDetail.all
end

# GET /child_level_details/1 or /child_level_details/1.json
def show
end

# GET /child_level_details/new
def new
@child_level_detail = ChildLevelDetail.new
end

# GET /child_level_details/1/edit
def edit
end

# POST /child_level_details or /child_level_details.json
def create
@child_level_detail = ChildLevelDetail.new(child_level_detail_params)

respond_to do |format|
if @child_level_detail.save
format.html { redirect_to child_level_detail_url(@child_level_detail), notice: "Child level detail was successfully created." }
format.json { render :show, status: :created, location: @child_level_detail }
else
format.html { render :new, status: :unprocessable_entity }
format.json { render json: @child_level_detail.errors, status: :unprocessable_entity }
end
end
end

# PATCH/PUT /child_level_details/1 or /child_level_details/1.json
def update
respond_to do |format|
if @child_level_detail.update(child_level_detail_params)
format.html { redirect_to child_level_detail_url(@child_level_detail), notice: "Child level detail was successfully updated." }
format.json { render :show, status: :ok, location: @child_level_detail }
else
format.html { render :edit, status: :unprocessable_entity }
format.json { render json: @child_level_detail.errors, status: :unprocessable_entity }
end
end
end

# DELETE /child_level_details/1 or /child_level_details/1.json
def destroy
@child_level_detail.destroy!

respond_to do |format|
format.html { redirect_to child_level_details_url, notice: "Child level detail was successfully destroyed." }
format.json { head :no_content }
end
end

private
# Use callbacks to share common setup or constraints between actions.
def set_child_level_detail
@child_level_detail = ChildLevelDetail.find(params[:id])
end

# Only allow a list of trusted parameters through.
def child_level_detail_params
params.require(:child_level_detail).permit(:PID, :TeethScreening, :TeethPreventative, :TeethFollowup, :PrescriberName, :ScreenDate, :ScreenComment, :UntreatedCavities, :CarriesExperience, :Sealants, :ReferralS, :ProviderName, :ProviderDate, :PreventComment, :FirstSealedNum, :SecondSealedNum, :OtherPermNum, :PrimarySealed, :FluorideVarnish, :EvaluatorsName, :EvaluatorDate, :EvaluatorComment, :RetainedSealant, :ReferredDT, :ReferredUDT, :SealantsRecd, :SealnatsNeeded, :Experienced, :UntreatedDecayFollow, :Services, :ORHealthStatus)
end
end
2 changes: 2 additions & 0 deletions app/helpers/child_level_details_helper.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
module ChildLevelDetailsHelper
end
2 changes: 2 additions & 0 deletions app/models/child_level_detail.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
class ChildLevelDetail < ApplicationRecord
end
88 changes: 58 additions & 30 deletions app/views/child_details/screening.html.erb
Original file line number Diff line number Diff line change
Expand Up @@ -348,54 +348,56 @@
FollowUp Form
</button>
<br/>
<%= form_with model: @child_level_detail, url: child_level_details_path, local: true, id: 'unique-form-id' do |form| %>

<div class="form-container" id="preventativeFormContainer" style="display: none;">
<form>
<div class="form-group">
<label for="prescriberName">Sealant Prescriber’s Signature</label>
<input type="text" id="prescriberName">
<input type="text" id="prescriberName" name="child_level_detail[PrescriberName]">
</div>
<div class="form-group">
<label for="date">Date</label>
<input type="date" id="date" name="date">
<input type="date" id="date" name="child_level_detail[ScreenDate]">
</div>
<div class="form-group">
<label for="comment">Comment</label>
<textarea id="comment" name="comment" rows="2" cols="20"></textarea>
<textarea id="comment" name="child_level_detail[ScreenComment]" rows="2" cols="20"></textarea>
</div>
<div class="form-group">
<label for="providerName">Provider's Name</label>
<input type="text" id="providerName">
<input type="text" id="providerName" name="child_level_detail[ProviderName]">
</div>
<div class="form-group">
<label for="date">Date</label>
<input type="date" id="date" name="date">
<input type="date" id="date" name="child_level_detail[ProviderDate]">
</div>
<div class="form-group">
<label for="comment">Comment</label>
<textarea id="comment" name="comment" rows="2" cols="20"></textarea>
<textarea id="comment" rows="2" cols="20" name="child_level_detail[PreventComment]"></textarea>
</div>
<div class="form-section">
<h3>Data for SEALS</h3>
</div>
<div class="form-group">
<label for="num1stMolarsSealed">Number of 1st molars sealed</label>
<input type="text" id="num1stMolarsSealed">
<input type="text" id="num1stMolarsSealed" name="child_level_detail[FirstSealedNum]">
</div>
<div class="form-group">
<label for="num2ndMolarsSealed">Number of 2nd molars sealed</label>
<input type="text" id="num2ndMolarsSealed">
<input type="text" id="num2ndMolarsSealed" name="child_level_detail[SecondSealedNum]">
</div>
<div class="form-group">
<label for="numOtherSealed">Number of other permanent sealed</label>
<input type="text" id="numOtherSealed">
<input type="text" id="numOtherSealed"name="child_level_detail[OtherPermNum]" >
</div>
<div class="form-group">
<label for="numPrimaryTeethSealed">Number of primary teeth sealed</label>
<input type="text" id="numPrimaryTeethSealed">
<input type="text" id="numPrimaryTeethSealed" name="child_level_detail[PrimarySealed]">
</div>
<div class="form-group">
<label for="fluorideVarnish">Fluoride varnish provided</label>
<select name="fluorideVarnish" id="fluorideVarnish">
<select name="child_level_detail[FluorideVarnish]" id="fluorideVarnish">
<option value="">--Please select an option--</option>
<option value="Yes">Yes</option>
<option value="No">No</option>
Expand All @@ -405,22 +407,23 @@
</div>

<br/>

<div class="form-container" id="followUpFormContainer" style="display: none;">
<form>
<div class="form-group">
<label for="Evaluator's Name">Evaluator's Name</label>
<input type="text" id="1st-molars">
<input type="text" id="evaName" name="child_level_detail[EvaluatorsName]">
</div>
<br/>
<div class="form-group">
<label for="date">Date</label>
<label for="blank"></label>
<input type="date" id="date" name="date"><br>
<input type="date" id="date" name="date" name="child_level_detail[EvaluatorDate]"><br>
</div>
<br/>
<div class="form-group">
<label for="Comment">Comment</label>
<textarea id="comment" name="comment" rows="2" cols="20"></textarea><br>
<textarea id="comment" rows="2" cols="20" name="child_level_detail[EvaluatorComment]"></textarea><br>
</div>
<br/>
<br/>
Expand All @@ -429,17 +432,17 @@
</div>
<div class="form-group">
<label for="Number of teeth with retained sealant">Number of teeth with a retained sealant (0-8):</label>
<input type="text" id="Number_of_teeth_with_a_retained_sealant">
<input type="text" id="Number_of_teeth_with_a_retained_sealant" name="child_level_detail[RetainedSealant]">
</div>
<br/>

<div class="form-group">
<label for="Referred for Dental Treatment">Referred for Dental Treatment?</label>
<label for="Yes"> </label>
<label for="Yes">Yes</label>
<input type="radio" name="Referred for Dental Treatment" value="yes" id="Referred_for_Dental_Treatment_Yes">
<input type="radio" name="child_level_detail[ReferredDT]" value="yes" id="Referred_for_Dental_Treatment_Yes">
<label for="No">No</label>
<input type="radio" name="Referred for Dental Treatment" value="no" id="Referred_for_Dental_Treatment_No">
<input type="radio" name="child_level_detail[ReferredDT]" value="no" id="Referred_for_Dental_Treatment_No">
</div>

<br/>
Expand All @@ -448,48 +451,48 @@
<label for="Referred for urgent Dental Treatment">Referred for urgent Dental Treatment?</label>
<label for="blank"> </label>
<label for="Yes">Yes</label>
<input type="radio" name="Referred for urgent Dental Treatment" value="yes" id="Referred_for_urgent_Dental_Treatment_Yes">
<input type="radio" name="child_level_detail[ReferredUDT]" value="yes" id="Referred_for_urgent_Dental_Treatment_Yes">
<label for="No">No</label>
<input type="radio" name="Referred for urgent Dental Treatment" value="no" id="Referred_for_urgent_Dental_Treatment_No">
<input type="radio" name="child_level_detail[ReferredUDT]" value="no" id="Referred_for_urgent_Dental_Treatment_No">
</div>
<br/>

<div class="form-group">
<label for="Total Number of Sealants received">Total Number of Sealants received:</label>
<input type="text" id="Total_Sealants_received">
<input type="text" id="Total_Sealants_received" name="child_level_detail[SealantsRecd]">
</div>
<br/>

<div class="form-group">
<label for="Total Number of Sealants needed">Total Number of Sealants needed:</label>
<input type="text" id="Total_Sealants_needed ">
<input type="text" id="Total_Sealants_needed" name="child_level_detail[SealnatsNeeded]">
</div>
<br/>

<div class="form-group">
<label for="Did the patients have caries experience">Did the patients have caries experience?</label>
<label for="blank"> </label>
<label for="Yes">Yes</label>
<input type="radio" name="Did the patients have caries experience" value="yes" id="Did_the_patients_have_caries_experience_Yes">
<input type="radio" name="child_level_detail[Experienced]" value="yes" id="Did_the_patients_have_caries_experience_Yes">
<label for="No">No</label>
<input type="radio" name="Did the patients have caries experience" value="no" id="Did_the_patients_have_caries_experience_No">
</div>
<input type="radio" name="child_level_detail[Experienced]" value="no" id="Did_the_patients_have_caries_experience_No">
</div>
<br/>

<div class="form-group">
<label for="Did the patient have untreated decay">Did the patient have untreated decay?</label>
<label for="blank"> </label>
<label for="Yes">Yes</label>
<input type="radio" name="Did the patient have untreated decay" value="yes" id="Did_the_patient_have_untreated_decay_Yes">
<input type="radio" name="child_level_detail[UntreatedDecayFollow]" value="yes" id="Did_the_patient_have_untreated_decay_Yes">
<label for="No">No</label>
<input type="radio" name="Did the patient have untreated decay" value="no" id="Did_the_patient_have_untreated_decay_No">
<input type="radio" name="child_level_detail[UntreatedDecayFollow]" value="no" id="Did_the_patient_have_untreated_decay_No">
</div>
<br/>

<div class="form-group">
<label for="Services the patient received">Services the patient received</label>
<label for="blank"> </label>
<select name="Services the patient received" >
<select name="child_level_detail[Services]" >
<option value="">--Please select an option--</option>
<option value="Sealants">Sealants</option>
<option value="Fluoride_Varnish">Fluoride Varnish</option>
Expand All @@ -499,13 +502,18 @@
</div>
<br/>
<label for="Overall Oral Health Status">Overall Oral Health Status:</label><br>
<textarea id="Overall_Oral_Health_Status" name="comment" rows="4" cols="50"></textarea><br>
<textarea id="Overall_Oral_Health_Status" name="child_level_detail[ORHealthStatus]" rows="4" cols="50"></textarea><br>
<br/>
<input type="submit" value="Submit">
</form>
</div>
<br/>


<input type="submit" value="Submit" id="submitButton">
<% end %>
</body>

<script>

document.addEventListener("DOMContentLoaded", function() {
Expand Down Expand Up @@ -621,7 +629,7 @@
// Find the selected option for the specific popup
radioOptions.forEach(option => {
if (option.checked) {
selectedOptions[popupId] = option.value; // Save the selected option to the object
selectedOptions[Id] = option.value; // Save the selected option to the object
cell.textContent = selectedOptions[popupId]; // Set the cell text to the selected option
}
});
Expand Down Expand Up @@ -702,6 +710,26 @@
sealantPresentElement.textContent = SealantPresentCount;
}

//to set hidden screening field
document.addEventListener("submit", function(event) {
event.preventDefault();
console.log("inside");

// Check if the submit button with the specified ID was clicked
if (event.submitter && event.submitter.id === "submitButton") {
var form = event.target;

// Your code to handle the specific form
// For example, you can access form fields and submit the form


var TeethScreeningStr = JSON.stringify(selectedOptions);
var TeethScreeningInput = form.querySelector('[name="child_level_detail[TeethScreening]"]');
TeethScreeningInput.value = TeethScreeningStr;

form.submit();
}
});
</script>
</body>

</html>
Loading

0 comments on commit 50dedde

Please sign in to comment.