Skip to content

Instantly share code, notes, and snippets.

@raulriera
Created July 7, 2010 20:23
Show Gist options
  • Save raulriera/467219 to your computer and use it in GitHub Desktop.
Save raulriera/467219 to your computer and use it in GitHub Desktop.
<!--- Verify that the treatmentplan creates successfully --->
<cfif treatmentplan.save()>
<!--- Loop through all the patient's teeth --->
<cfloop collection="#params.as_values_treatmentplandetail.treatment#" item="tooth">
<!--- Loop through all the treatment plans selected --->
<cfloop list="#params.as_values_treatmentplandetail.treatment[tooth]#" index="treatmentId">
<!--- Find the selected treatment (HUGE DB IMPACT) --->
<cfset treatment = model("Treatment").findByKey(treatmentId)>
<!--- Insert a new treatment detail in the plan --->
<cfset treatmentplan.createTreatmentPlanDetail(toothId=tooth, treatment=treatment.name, price=treatment.price)>
</cfloop>
</cfloop>
<cfset flashInsert(success="The treatment plan was created successfully.")>
<cfset redirectTo(route="treatmentPlan", patientId=params.patientId, key=treatmentplan.id)>
<!--- Otherwise --->
<cfelse>
<cfset flashInsert(error="There was an error creating the treatment plan.")>
<cfset renderPage(action="new")>
</cfif>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment